diff --git a/pom.xml b/pom.xml
index fe2abaa9..b7a88a85 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
2.7.7
1.3.2
1.0.0
- 1.3.0
+ 1.4.0
1.01
0.4
2.1.0.BUILD-SNAPSHOT
diff --git a/src/main/java/org/springframework/data/gemfire/eviction/EvictionAttributesFactoryBean.java b/src/main/java/org/springframework/data/gemfire/eviction/EvictionAttributesFactoryBean.java
index 798c30a5..3a5a6180 100644
--- a/src/main/java/org/springframework/data/gemfire/eviction/EvictionAttributesFactoryBean.java
+++ b/src/main/java/org/springframework/data/gemfire/eviction/EvictionAttributesFactoryBean.java
@@ -20,8 +20,6 @@ package org.springframework.data.gemfire.eviction;
import org.apache.geode.cache.EvictionAction;
import org.apache.geode.cache.EvictionAttributes;
import org.apache.geode.cache.util.ObjectSizer;
-import org.apache.geode.internal.cache.lru.LRUCapacityController;
-import org.apache.geode.internal.cache.lru.MemLRUCapacityController;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
@@ -38,10 +36,9 @@ import org.springframework.beans.factory.InitializingBean;
@SuppressWarnings("unused")
public class EvictionAttributesFactoryBean implements FactoryBean, InitializingBean {
- // TODO remove this reference to the GemFire internal class when the Gem team fixes the EvictionAttributes bug!!!
- protected static final int DEFAULT_LRU_MAXIMUM_ENTRIES = LRUCapacityController.DEFAULT_MAXIMUM_ENTRIES;
+ protected static final int DEFAULT_LRU_MAXIMUM_ENTRIES = EvictionAttributes.DEFAULT_ENTRIES_MAXIMUM;
- protected static final int DEFAULT_MEMORY_MAXIMUM_SIZE = MemLRUCapacityController.DEFAULT_MAXIMUM_MEGABYTES;
+ protected static final int DEFAULT_MEMORY_MAXIMUM_SIZE = EvictionAttributes.DEFAULT_MEMORY_MAXIMUM;
private EvictionAction action = null;
diff --git a/src/test/java/org/springframework/data/gemfire/GemfireTemplateUnitTests.java b/src/test/java/org/springframework/data/gemfire/GemfireTemplateUnitTests.java
index 45bae640..0639a02c 100644
--- a/src/test/java/org/springframework/data/gemfire/GemfireTemplateUnitTests.java
+++ b/src/test/java/org/springframework/data/gemfire/GemfireTemplateUnitTests.java
@@ -17,8 +17,6 @@
package org.springframework.data.gemfire;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.nullValue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
@@ -45,9 +43,7 @@ import org.apache.geode.cache.query.Query;
import org.apache.geode.cache.query.QueryService;
import org.apache.geode.cache.query.SelectResults;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
@@ -73,9 +69,6 @@ import org.springframework.data.gemfire.test.support.AbstractUnitAndIntegrationT
@RunWith(MockitoJUnitRunner.class)
public class GemfireTemplateUnitTests extends AbstractUnitAndIntegrationTestsWithMockSupport {
- @Rule
- public ExpectedException exception = ExpectedException.none();
-
private GemfireTemplate template;
@Mock
@@ -108,13 +101,19 @@ public class GemfireTemplateUnitTests extends AbstractUnitAndIntegrationTestsWit
assertThat(localTemplate.isExposeNativeRegion()).isFalse();
}
- @Test
+ @Test(expected = IllegalArgumentException.class)
public void constructWithNullRegionThrowsIllegalArgumentException() {
- exception.expect(IllegalArgumentException.class);
- exception.expectCause(is(nullValue(Throwable.class)));
- exception.expectMessage("Region is required");
- new GemfireTemplate(null);
+ try {
+ new GemfireTemplate(null);
+ }
+ catch (IllegalArgumentException expected) {
+
+ assertThat(expected).hasMessage("Region is required");
+ assertThat(expected).hasNoCause();
+
+ throw expected;
+ }
}
@Test
@@ -167,28 +166,32 @@ public class GemfireTemplateUnitTests extends AbstractUnitAndIntegrationTestsWit
@Test
public void findIsSuccessful() throws Exception {
+
Object[] expectedParams = { "arg" };
+
String expectedQuery = "SELECT * FROM /Example";
SelectResults mockSelectResults = mock(SelectResults.class);
- when(mockQuery.execute(any(Object[].class))).thenReturn(mockSelectResults);
+ when(mockQuery.execute(any(Object.class))).thenReturn(mockSelectResults);
assertThat(template.find(expectedQuery, expectedParams)).isEqualTo(mockSelectResults);
verify(mockRegion, atLeastOnce()).getRegionService();
verify(mockRegionService, times(1)).getQueryService();
verify(mockQueryService, times(1)).newQuery(eq(expectedQuery));
- verify(mockQuery, times(1)).execute(eq(expectedParams));
+ verify(mockQuery, times(1)).execute(eq("arg"));
verifyZeroInteractions(mockSelectResults);
}
@Test(expected = InvalidDataAccessApiUsageException.class)
public void findWithSingleResultQueryThrowsInvalidDataAccessApiUsageException() throws Exception {
+
Object[] expectedParams = { "arg" };
+
String expectedQuery = "SELECT 1 FROM /Example";
- when(mockQuery.execute(any(Object[].class))).thenReturn(1);
+ when(mockQuery.execute(any(Object.class))).thenReturn(1);
try {
template.find(expectedQuery, expectedParams);
@@ -197,18 +200,20 @@ public class GemfireTemplateUnitTests extends AbstractUnitAndIntegrationTestsWit
verify(mockRegion, atLeastOnce()).getRegionService();
verify(mockRegionService, times(1)).getQueryService();
verify(mockQueryService, times(1)).newQuery(eq(expectedQuery));
- verify(mockQuery, times(1)).execute(eq(expectedParams));
+ verify(mockQuery, times(1)).execute(eq("arg"));
}
}
@Test
public void findUniqueReturnsSelectResultsIsSuccessful() throws Exception {
+
Object[] expectedParams = { "arg" };
+
String expectedQuery = "SELECT 1 FROM /Example";
SelectResults mockSelectResults = mock(SelectResults.class);
- when(mockQuery.execute(eq(expectedParams))).thenReturn(mockSelectResults);
+ when(mockQuery.execute(any(Object.class))).thenReturn(mockSelectResults);
when(mockSelectResults.asList()).thenReturn(Collections.singletonList(1));
assertThat((Object) template.findUnique(expectedQuery, expectedParams)).isEqualTo(1);
@@ -216,33 +221,37 @@ public class GemfireTemplateUnitTests extends AbstractUnitAndIntegrationTestsWit
verify(mockRegion, atLeastOnce()).getRegionService();
verify(mockRegionService, times(1)).getQueryService();
verify(mockQueryService, times(1)).newQuery(eq(expectedQuery));
- verify(mockQuery, times(1)).execute(eq(expectedParams));
+ verify(mockQuery, times(1)).execute(eq("arg"));
verify(mockSelectResults, times(1)).asList();
}
@Test
public void findUniqueReturnsObjectIsSuccessful() throws Exception {
+
Object[] expectedParams = { "arg" };
+
String expectedQuery = "SELECT 1 FROM /Example";
- when(mockQuery.execute(eq(expectedParams))).thenReturn("test");
+ when(mockQuery.execute(any(Object.class))).thenReturn("test");
assertThat((Object) template.findUnique(expectedQuery, expectedParams)).isEqualTo("test");
verify(mockRegion, atLeastOnce()).getRegionService();
verify(mockRegionService, times(1)).getQueryService();
verify(mockQueryService, times(1)).newQuery(eq(expectedQuery));
- verify(mockQuery, times(1)).execute(eq(expectedParams));
+ verify(mockQuery, times(1)).execute(eq("arg"));
}
@Test(expected = InvalidDataAccessApiUsageException.class)
public void findUniqueWithMultiResultQueryThrowsInvalidDataAccessApiUsageException() throws Exception {
+
Object[] expectedParams = { "arg" };
+
String expectedQuery = "SELECT 1 FROM /Example";
SelectResults mockSelectResults = mock(SelectResults.class);
- when(mockQuery.execute(eq(expectedParams))).thenReturn(mockSelectResults);
+ when(mockQuery.execute(any(Object.class))).thenReturn(mockSelectResults);
when(mockSelectResults.asList()).thenReturn(Arrays.asList(1, 2));
try {
@@ -252,7 +261,7 @@ public class GemfireTemplateUnitTests extends AbstractUnitAndIntegrationTestsWit
verify(mockRegion, atLeastOnce()).getRegionService();
verify(mockRegionService, times(1)).getQueryService();
verify(mockQueryService, times(1)).newQuery(eq(expectedQuery));
- verify(mockQuery, times(1)).execute(eq(expectedParams));
+ verify(mockQuery, times(1)).execute(eq("arg"));
verify(mockSelectResults, times(1)).asList();
}
}
diff --git a/src/test/java/org/springframework/data/gemfire/config/xml/RegionEvictionAttributesNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/xml/RegionEvictionAttributesNamespaceTest.java
index 88b737d6..e8c51b50 100644
--- a/src/test/java/org/springframework/data/gemfire/config/xml/RegionEvictionAttributesNamespaceTest.java
+++ b/src/test/java/org/springframework/data/gemfire/config/xml/RegionEvictionAttributesNamespaceTest.java
@@ -24,8 +24,8 @@ import javax.annotation.Resource;
import org.apache.geode.cache.DataPolicy;
import org.apache.geode.cache.EvictionAction;
import org.apache.geode.cache.EvictionAlgorithm;
+import org.apache.geode.cache.EvictionAttributes;
import org.apache.geode.cache.Region;
-import org.apache.geode.internal.cache.lru.LRUCapacityController;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
@@ -84,7 +84,7 @@ public class RegionEvictionAttributesNamespaceTest {
assertEquals(EvictionAction.LOCAL_DESTROY, two.getAttributes().getEvictionAttributes().getAction());
assertEquals(EvictionAlgorithm.LRU_ENTRY, two.getAttributes().getEvictionAttributes().getAlgorithm());
- assertEquals(LRUCapacityController.DEFAULT_MAXIMUM_ENTRIES,
+ assertEquals(EvictionAttributes.DEFAULT_ENTRIES_MAXIMUM,
two.getAttributes().getEvictionAttributes().getMaximum());
}
diff --git a/src/test/java/org/springframework/data/gemfire/fork/LocatorProcess.java b/src/test/java/org/springframework/data/gemfire/fork/LocatorProcess.java
index 632cfa47..d2d2bb4a 100644
--- a/src/test/java/org/springframework/data/gemfire/fork/LocatorProcess.java
+++ b/src/test/java/org/springframework/data/gemfire/fork/LocatorProcess.java
@@ -90,8 +90,8 @@ public class LocatorProcess {
distributedSystemProperties.setProperty(DistributionConfig.LOG_LEVEL_NAME,
System.getProperty("spring.data.gemfire.log-level", GEMFIRE_LOG_LEVEL));
- return InternalLocator.startLocator(locatorPort, null, null, null, null, null, distributedSystemProperties,
- true, true, hostnameForClients, loadClusterConfigurationFromDirectory);
+ return InternalLocator.startLocator(locatorPort, null, null, null, null,
+ true, distributedSystemProperties, hostnameForClients);
}
@SuppressWarnings("unused")