diff --git a/pom.xml b/pom.xml index a4492742..692899a9 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ 2.7.7 1.3.2 1.0.0 - 1.5.0 + 1.6.0 1.01 0.4 2.1.0.BUILD-SNAPSHOT diff --git a/src/test/java/org/springframework/data/gemfire/LookupRegionMutationIntegrationTest.java b/src/test/java/org/springframework/data/gemfire/LookupRegionMutationIntegrationTest.java index 9a58b940..a8790c04 100644 --- a/src/test/java/org/springframework/data/gemfire/LookupRegionMutationIntegrationTest.java +++ b/src/test/java/org/springframework/data/gemfire/LookupRegionMutationIntegrationTest.java @@ -155,13 +155,8 @@ public class LookupRegionMutationIntegrationTest { assertCacheListeners(example.getAttributes().getCacheListeners(), Arrays.asList("A", "B")); assertGemFireComponent(example.getAttributes().getCacheLoader(), "C"); assertGemFireComponent(example.getAttributes().getCacheWriter(), "D"); - // TODO: re-instate the original assertion after Apache Geode fixes bug GEODE-5039! - /* assertEvictionAttributes(example.getAttributes().getEvictionAttributes(), EvictionAction.OVERFLOW_TO_DISK, EvictionAlgorithm.LRU_ENTRY, 1000); - */ - assertEvictionAttributes(example.getAttributes().getEvictionAttributes(), EvictionAction.OVERFLOW_TO_DISK, - EvictionAlgorithm.LRU_ENTRY, 500); assertExpirationAttributes(example.getAttributes().getRegionTimeToLive(), "Region TTL", 120, ExpirationAction.LOCAL_DESTROY); assertExpirationAttributes(example.getAttributes().getRegionIdleTimeout(), "Region TTI", diff --git a/src/test/java/org/springframework/data/gemfire/test/StubCache.java b/src/test/java/org/springframework/data/gemfire/test/StubCache.java index a9ca379c..5c626257 100644 --- a/src/test/java/org/springframework/data/gemfire/test/StubCache.java +++ b/src/test/java/org/springframework/data/gemfire/test/StubCache.java @@ -62,13 +62,11 @@ import org.apache.geode.i18n.LogWriterI18n; import org.apache.geode.pdx.PdxInstance; import org.apache.geode.pdx.PdxInstanceFactory; import org.apache.geode.pdx.PdxSerializer; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; @SuppressWarnings({ "deprecation", "unused" }) public class StubCache implements Cache, ClientCache { - private static final AtomicReference queryServiceReference = new AtomicReference(null); + private static final AtomicReference queryServiceReference = new AtomicReference<>(null); protected static final String NOT_IMPLEMENTED = "Not Implemented"; @@ -112,7 +110,7 @@ public class StubCache implements Cache, ClientCache { private String name; public StubCache(){ - rootRegions = new HashMap(); + rootRegions = new HashMap<>(); resourceManager = new StubResourceManager(); } @@ -276,7 +274,8 @@ public class StubCache implements Cache, ClientCache { @SuppressWarnings({ "rawtypes", "unchecked" }) @Override public Map> listRegionAttributes() { - Map> attributes = new HashMap>(); + + Map> attributes = new HashMap<>(); for (Entry entry: allRegions().entrySet()) { attributes.put(entry.getKey(), entry.getValue().getAttributes()); @@ -378,7 +377,8 @@ public class StubCache implements Cache, ClientCache { */ @Override public Set> rootRegions() { - Set> rootRegions = new HashSet>(); + + Set> rootRegions = new HashSet<>(); for (String key: allRegions().keySet()) { if (!key.contains(Region.SEPARATOR)) { @@ -689,14 +689,10 @@ public class StubCache implements Cache, ClientCache { } DistributedSystem mockDistributedSystem() { + DistributedSystem mockDistributedSystem = mock(DistributedSystem.class); - when(mockDistributedSystem.getName()).thenAnswer(new Answer() { - @Override - public String answer(InvocationOnMock invocation) throws Throwable { - return getName(); - } - }); + when(mockDistributedSystem.getName()).thenAnswer(invocation -> getName()); when(mockDistributedSystem.getProperties()).thenReturn(this.properties); @@ -718,69 +714,63 @@ public class StubCache implements Cache, ClientCache { return new StubCacheServer(); } - QueryService mockQueryService() throws RegionNotFoundException, IndexInvalidException, IndexNameConflictException, IndexExistsException, UnsupportedOperationException { + QueryService mockQueryService() throws RegionNotFoundException, IndexInvalidException, IndexNameConflictException, + IndexExistsException, UnsupportedOperationException { + QueryService queryService = mock(QueryService.class); - when(queryService.getIndexes()).thenReturn(new ArrayList()); + when(queryService.getIndexes()).thenReturn(new ArrayList<>()); - when(queryService.createIndex(anyString(), anyString(),anyString())).thenAnswer(new Answer() { - @Override - public Index answer(InvocationOnMock invocation) throws Throwable { - String indexName = (String) invocation.getArguments()[0]; - String indexedExpression = (String) invocation.getArguments()[1]; - String fromClause = (String) invocation.getArguments()[2]; - return mockIndex(indexName, org.apache.geode.cache.query.IndexType.FUNCTIONAL, indexedExpression, - fromClause, null); - } + when(queryService.createIndex(anyString(), anyString(),anyString())).thenAnswer(invocation -> { + + String indexName = (String) invocation.getArguments()[0]; + String indexedExpression = (String) invocation.getArguments()[1]; + String fromClause = (String) invocation.getArguments()[2]; + + return mockIndex(indexName, org.apache.geode.cache.query.IndexType.FUNCTIONAL, indexedExpression, + fromClause, null); }); - when(queryService.createIndex(anyString(), anyString(),anyString(),anyString())).thenAnswer(new Answer() { - @Override - public Index answer(InvocationOnMock invocation) throws Throwable { - String indexName = (String) invocation.getArguments()[0]; - String indexedExpression = (String) invocation.getArguments()[1]; - String fromClause = (String) invocation.getArguments()[2]; - String imports = (String) invocation.getArguments()[3]; - return mockIndex(indexName, org.apache.geode.cache.query.IndexType.FUNCTIONAL, indexedExpression, - fromClause, imports); - } + when(queryService.createIndex(anyString(), anyString(),anyString(),anyString())).thenAnswer(invocation -> { + + String indexName = (String) invocation.getArguments()[0]; + String indexedExpression = (String) invocation.getArguments()[1]; + String fromClause = (String) invocation.getArguments()[2]; + String imports = (String) invocation.getArguments()[3]; + + return mockIndex(indexName, org.apache.geode.cache.query.IndexType.FUNCTIONAL, indexedExpression, + fromClause, imports); }); - when(queryService.createKeyIndex(anyString(), anyString(),anyString())).thenAnswer(new Answer() { - @Override - public Index answer(InvocationOnMock invocation) throws Throwable { - String indexName = (String) invocation.getArguments()[0]; - String indexedExpression = (String) invocation.getArguments()[1]; - String fromClause = (String) invocation.getArguments()[2]; + when(queryService.createKeyIndex(anyString(), anyString(),anyString())).thenAnswer(invocation -> { - return mockIndex(indexName, org.apache.geode.cache.query.IndexType.PRIMARY_KEY, indexedExpression, - fromClause, null); - } + String indexName = (String) invocation.getArguments()[0]; + String indexedExpression = (String) invocation.getArguments()[1]; + String fromClause = (String) invocation.getArguments()[2]; + + return mockIndex(indexName, org.apache.geode.cache.query.IndexType.PRIMARY_KEY, indexedExpression, + fromClause, null); }); - when(queryService.createHashIndex(anyString(), anyString(),anyString())).thenAnswer(new Answer() { - @Override - public Index answer(InvocationOnMock invocation) throws Throwable { - String indexName = (String) invocation.getArguments()[0]; - String indexedExpression = (String) invocation.getArguments()[1]; - String fromClause = (String) invocation.getArguments()[2]; + when(queryService.createHashIndex(anyString(), anyString(),anyString())).thenAnswer(invocation -> { - return mockIndex(indexName, org.apache.geode.cache.query.IndexType.HASH, indexedExpression, - fromClause, null); - } + String indexName = (String) invocation.getArguments()[0]; + String indexedExpression = (String) invocation.getArguments()[1]; + String fromClause = (String) invocation.getArguments()[2]; + + return mockIndex(indexName, org.apache.geode.cache.query.IndexType.HASH, indexedExpression, + fromClause, null); }); - when(queryService.createHashIndex(anyString(), anyString(),anyString(),anyString())).thenAnswer(new Answer() { - @Override - public Index answer(InvocationOnMock invocation) throws Throwable { - String indexName = (String) invocation.getArguments()[0]; - String indexedExpression = (String) invocation.getArguments()[1]; - String fromClause = (String) invocation.getArguments()[2]; - String imports = (String) invocation.getArguments()[3]; + when(queryService.createHashIndex(anyString(), anyString(),anyString(),anyString())).thenAnswer(invocation -> { - return mockIndex(indexName, org.apache.geode.cache.query.IndexType.HASH, indexedExpression, - fromClause, imports); - } + String indexName = (String) invocation.getArguments()[0]; + String indexedExpression = (String) invocation.getArguments()[1]; + String fromClause = (String) invocation.getArguments()[2]; + String imports = (String) invocation.getArguments()[3]; + + return mockIndex(indexName, org.apache.geode.cache.query.IndexType.HASH, indexedExpression, + fromClause, imports); }); return queryService; @@ -872,4 +862,7 @@ public class StubCache implements Cache, ClientCache { return getQueryService(); } + @Override + public void registerPdxMetaData(Object objectToSerializeAndRegister) { } + }