diff --git a/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/integration/SpringApplicationContextIntegrationTestsSupport.java b/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/integration/SpringApplicationContextIntegrationTestsSupport.java index 7a96afb..32f5385 100644 --- a/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/integration/SpringApplicationContextIntegrationTestsSupport.java +++ b/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/integration/SpringApplicationContextIntegrationTestsSupport.java @@ -13,7 +13,6 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ - package org.springframework.data.gemfire.tests.integration; import java.util.Optional; @@ -46,7 +45,9 @@ public abstract class SpringApplicationContextIntegrationTestsSupport extends In @After public void closeApplicationContext() { - Optional.ofNullable(this.applicationContext).ifPresent(ConfigurableApplicationContext::close); + + Optional.ofNullable(this.applicationContext) + .ifPresent(ConfigurableApplicationContext::close); } protected ConfigurableApplicationContext newApplicationContext(Class... annotatedClasses) { diff --git a/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/mock/GemFireMockObjectsSupport.java b/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/mock/GemFireMockObjectsSupport.java index 1e5a622..4313e62 100644 --- a/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/mock/GemFireMockObjectsSupport.java +++ b/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/mock/GemFireMockObjectsSupport.java @@ -13,7 +13,6 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ - package org.springframework.data.gemfire.tests.mock; import static org.assertj.core.api.Assertions.assertThat; @@ -66,9 +65,6 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.Function; import java.util.stream.Collectors; -import org.mockito.ArgumentMatchers; -import org.mockito.stubbing.Answer; - import org.apache.geode.cache.AttributesMutator; import org.apache.geode.cache.Cache; import org.apache.geode.cache.CacheFactory; @@ -133,6 +129,8 @@ import org.apache.geode.distributed.DistributedMember; import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.pdx.PdxSerializer; import org.apache.lucene.analysis.Analyzer; +import org.mockito.ArgumentMatchers; +import org.mockito.stubbing.Answer; import org.springframework.beans.factory.DisposableBean; import org.springframework.data.gemfire.IndexType; import org.springframework.data.gemfire.server.SubscriptionEvictionPolicy; @@ -150,24 +148,30 @@ import org.springframework.util.StringUtils; * * @author John Blum * @see java.io.File + * @see java.net.InetAddress * @see java.net.InetSocketAddress * @see java.util.Properties * @see java.util.UUID * @see org.apache.geode.cache.AttributesMutator * @see org.apache.geode.cache.Cache * @see org.apache.geode.cache.CacheFactory + * @see org.apache.geode.cache.CacheListener + * @see org.apache.geode.cache.CacheLoader + * @see org.apache.geode.cache.CacheWriter * @see org.apache.geode.cache.CustomExpiry * @see org.apache.geode.cache.DiskStore * @see org.apache.geode.cache.DiskStoreFactory - * @see org.apache.geode.cache.GemFireCache * @see org.apache.geode.cache.EvictionAttributes * @see org.apache.geode.cache.EvictionAttributesMutator * @see org.apache.geode.cache.ExpirationAttributes + * @see org.apache.geode.cache.GemFireCache * @see org.apache.geode.cache.PartitionAttributes * @see org.apache.geode.cache.Region * @see org.apache.geode.cache.RegionAttributes * @see org.apache.geode.cache.RegionFactory * @see org.apache.geode.cache.RegionService + * @see org.apache.geode.cache.Scope + * @see org.apache.geode.cache.asyncqueue.AsyncEventListener * @see org.apache.geode.cache.asyncqueue.AsyncEventQueue * @see org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory * @see org.apache.geode.cache.client.ClientCache @@ -176,6 +180,7 @@ import org.springframework.util.StringUtils; * @see org.apache.geode.cache.client.Pool * @see org.apache.geode.cache.client.PoolFactory * @see org.apache.geode.cache.control.ResourceManager + * @see org.apache.geode.cache.execute.RegionFunctionContext * @see org.apache.geode.cache.lucene.LuceneIndex * @see org.apache.geode.cache.lucene.LuceneIndexFactory * @see org.apache.geode.cache.lucene.LuceneQuery @@ -192,10 +197,15 @@ import org.springframework.util.StringUtils; * @see org.apache.geode.cache.query.QueryStatistics * @see org.apache.geode.cache.server.CacheServer * @see org.apache.geode.cache.server.ClientSubscriptionConfig + * @see org.apache.geode.cache.server.ServerLoadProbe + * @see org.apache.geode.cache.wan.GatewayEventFilter + * @see org.apache.geode.cache.wan.GatewayEventSubstitutionFilter * @see org.apache.geode.cache.wan.GatewayReceiver * @see org.apache.geode.cache.wan.GatewayReceiverFactory * @see org.apache.geode.cache.wan.GatewaySender * @see org.apache.geode.cache.wan.GatewaySenderFactory + * @see org.apache.geode.cache.wan.GatewayTransportFilter + * @see org.apache.geode.compression.Compressor * @see org.apache.geode.distributed.DistributedMember * @see org.apache.geode.distributed.DistributedSystem * @see org.apache.geode.pdx.PdxSerializer @@ -271,7 +281,9 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport { * @param gemfireObject {@link Object GemFire object} to cache. */ private static void cacheGemFireObject(Object gemfireObject) { - Optional.ofNullable(gemfireObject).ifPresent(cachedGemFireObjects::add); + + Optional.ofNullable(gemfireObject). + ifPresent(cachedGemFireObjects::add); } /** @@ -478,7 +490,8 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport { @SuppressWarnings("unchecked") private static Region rememberMockedRegion(Region mockRegion) { - String mockRegionPath = Optional.ofNullable(mockRegion).map(Region::getFullPath) + String mockRegionPath = Optional.ofNullable(mockRegion) + .map(Region::getFullPath) .orElseThrow(() -> newIllegalArgumentException("Region is required")); if (regions.putIfAbsent(mockRegionPath, (Region) mockRegion) != null) { @@ -500,7 +513,9 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport { */ @SuppressWarnings("unchecked") private static Optional resolveMockedGemFireCache(boolean useSingletonCache) { - return Optional.ofNullable((T) singletonCache.get()).filter(it -> useSingletonCache); + + return Optional.ofNullable((T) singletonCache.get()) + .filter(it -> useSingletonCache); } /** @@ -516,8 +531,9 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport { @SuppressWarnings("unchecked") private static RegionAttributes resolveRegionAttributes(String regionAttributesId) { - return (RegionAttributes) Optional.ofNullable(regionAttributes.get(regionAttributesId)).orElseThrow(() -> - newIllegalStateException("RegionAttributes with ID [%s] cannot be found", regionAttributesId)); + return (RegionAttributes) Optional.ofNullable(regionAttributes.get(regionAttributesId)) + .orElseThrow(() -> newIllegalStateException("RegionAttributes with ID [%s] cannot be found", + regionAttributesId)); } /** @@ -534,7 +550,9 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport { return Optional.ofNullable(regionName) .map(String::trim) .map(it -> { + int lastIndexOfRegionSeparator = it.lastIndexOf(Region.SEPARATOR); + return lastIndexOfRegionSeparator < 0 ? it : it.substring(lastIndexOfRegionSeparator); }) .filter(it -> !it.isEmpty()) diff --git a/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/mock/MockObjectsSupport.java b/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/mock/MockObjectsSupport.java index 9d1a4fe..6568ea0 100644 --- a/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/mock/MockObjectsSupport.java +++ b/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/mock/MockObjectsSupport.java @@ -13,7 +13,6 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ - package org.springframework.data.gemfire.tests.mock; import java.util.Collection; @@ -90,6 +89,7 @@ public abstract class MockObjectsSupport { } protected static , R> Answer newAdder(C collection, R returnValue) { + return invocation -> { collection.add(invocation.getArgument(0)); return returnValue; @@ -97,6 +97,7 @@ public abstract class MockObjectsSupport { } protected static Answer newSetter(AtomicBoolean argument, R returnValue) { + return invocation -> { argument.set(invocation.getArgument(0)); return returnValue; @@ -104,6 +105,7 @@ public abstract class MockObjectsSupport { } protected static Answer newSetter(AtomicBoolean argument, Boolean value, R returnValue) { + return invocation -> { argument.set(value); return returnValue; @@ -111,6 +113,7 @@ public abstract class MockObjectsSupport { } protected static Answer newSetter(AtomicInteger argument, R returnValue) { + return invocation -> { argument.set(invocation.getArgument(0)); return returnValue; @@ -118,6 +121,7 @@ public abstract class MockObjectsSupport { } protected static Answer newSetter(AtomicInteger argument, Integer value, R returnValue) { + return invocation -> { argument.set(value); return returnValue; @@ -125,6 +129,7 @@ public abstract class MockObjectsSupport { } protected static Answer newSetter(AtomicLong argument, R returnValue) { + return invocation -> { argument.set(invocation.getArgument(0)); return returnValue; @@ -132,6 +137,7 @@ public abstract class MockObjectsSupport { } protected static Answer newSetter(AtomicLong argument, Long value, R returnValue) { + return invocation -> { argument.set(value); return returnValue; @@ -139,6 +145,7 @@ public abstract class MockObjectsSupport { } protected static Answer newSetter(AtomicReference argument, R returnValue) { + return invocation -> { argument.set(invocation.getArgument(0)); return returnValue; @@ -146,6 +153,7 @@ public abstract class MockObjectsSupport { } protected static Answer newSetter(AtomicReference argument, T value, R returnValue) { + return invocation -> { argument.set(value); return returnValue; @@ -153,6 +161,7 @@ public abstract class MockObjectsSupport { } protected static Answer newSetter(AtomicReference argument, Function converter, R returnValue) { + return invocation -> { argument.set(converter.apply(invocation.getArgument(0))); return returnValue; @@ -160,6 +169,7 @@ public abstract class MockObjectsSupport { } protected static Answer newSetter(Map argument, R returnValue) { + return invocation -> { argument.put(invocation.getArgument(0), invocation.getArgument(1)); return returnValue; @@ -167,6 +177,7 @@ public abstract class MockObjectsSupport { } protected static Answer newVoidAnswer(Consumer methodInvocation) { + return invocation -> { methodInvocation.accept(invocation); return null; diff --git a/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/mock/config/GemFireMockObjectsBeanPostProcessor.java b/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/mock/config/GemFireMockObjectsBeanPostProcessor.java index 36248db..a2c20df 100644 --- a/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/mock/config/GemFireMockObjectsBeanPostProcessor.java +++ b/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/mock/config/GemFireMockObjectsBeanPostProcessor.java @@ -13,7 +13,6 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ - package org.springframework.data.gemfire.tests.mock.config; import static org.mockito.Mockito.when; @@ -120,7 +119,9 @@ public class GemFireMockObjectsBeanPostProcessor implements BeanPostProcessor { implements CacheFactoryBean.CacheFactoryInitializer { protected static CacheFactoryBean spyOn(CacheFactoryBean cacheFactoryBean, boolean useSingletonCache) { + cacheFactoryBean.setCacheFactoryInitializer(new SpyingCacheFactoryInitializer(useSingletonCache)); + return cacheFactoryBean; } @@ -146,8 +147,8 @@ public class GemFireMockObjectsBeanPostProcessor implements BeanPostProcessor { protected static ClientCacheFactoryBean spyOn(ClientCacheFactoryBean clientCacheFactoryBean, boolean useSingletonCache) { - clientCacheFactoryBean.setCacheFactoryInitializer( - new SpyingClientCacheFactoryInitializer(useSingletonCache)); + clientCacheFactoryBean + .setCacheFactoryInitializer(new SpyingClientCacheFactoryInitializer(useSingletonCache)); return clientCacheFactoryBean; } @@ -171,7 +172,9 @@ public class GemFireMockObjectsBeanPostProcessor implements BeanPostProcessor { protected static class MockingPoolFactoryInitializer implements PoolFactoryBean.PoolFactoryInitializer { protected static PoolFactoryBean mock(PoolFactoryBean poolFactoryBean) { + poolFactoryBean.setPoolFactoryInitializer(new MockingPoolFactoryInitializer()); + return poolFactoryBean; } diff --git a/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/mock/context/GemFireMockObjectsApplicationContextInitializer.java b/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/mock/context/GemFireMockObjectsApplicationContextInitializer.java index 1663717..948cd93 100644 --- a/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/mock/context/GemFireMockObjectsApplicationContextInitializer.java +++ b/spring-data-geode-test/src/main/java/org/springframework/data/gemfire/tests/mock/context/GemFireMockObjectsApplicationContextInitializer.java @@ -13,7 +13,6 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ - package org.springframework.data.gemfire.tests.mock.context; import org.springframework.context.ApplicationContextInitializer;