From ddcd01910efce5f444ad6ee57f91eb3e629fa8e5 Mon Sep 17 00:00:00 2001 From: John Blum Date: Thu, 22 Jul 2021 17:44:20 -0700 Subject: [PATCH] Extend the STDG o.s.d.g.tests.integration.IntegrationTestsSupport abstract base class in all Integration-based Tests. This applies to test classes in particular that bootstrap and configure Apache Geode in a Spring ApplicationContext using the JUnit4 SpringRunner class. Resolves gh-296. --- ...onContextBeanOrderingIntegrationTests.java | 6 +- .../AutoRegionLookupIntegrationTests.java | 28 ++-- ...nLookupWithAutowiringIntegrationTests.java | 46 +++--- ...WithComponentScanningIntegrationTests.java | 25 +-- ...onTest.java => CacheIntegrationTests.java} | 46 +++--- .../GemfireTemplateIntegrationTests.java | 5 +- ...ledClientCacheRegionsIntegrationTests.java | 16 +- ...LookupRegionMutationIntegrationTests.java} | 71 ++++----- .../LookupSubRegionIntegrationTests.java | 103 +++++++++++++ .../data/gemfire/LookupSubRegionTest.java | 100 ------------ .../CacheErrorHandlerIntegrationTests.java | 10 +- .../EnableGemfireCachingIntegrationTests.java | 35 ++--- .../ClientCacheIndexingIntegrationTests.java | 65 ++------ .../ClientCachePoolIntegrationTests.java | 30 ++-- .../ClientCacheSecurityIntegrationTests.java | 11 +- ...CacheVariableLocatorsIntegrationTests.java | 9 +- ...tCacheVariableServersIntegrationTests.java | 14 +- .../client/ClientRegionIntegrationTests.java | 1 - ...cheLoaderCacheWriterIntegrationTests.java} | 48 +++--- .../ClientSubRegionIntegrationTests.java | 25 +-- ...> DurableClientCacheIntegrationTests.java} | 16 +- .../GemFireDataSourceIntegrationTest.java | 11 +- .../GemFireDataSourceIntegrationTests.java | 8 +- ...nfiguredGemFireServerIntegrationTests.java | 19 ++- .../LocalOnlyClientCacheIntegrationTests.java | 14 +- ...essionConfiguredPoolsIntegrationTests.java | 12 +- ...eFactoryCacheResolverIntegrationTests.java | 4 +- ...olManagerPoolResolverIntegrationTests.java | 12 +- ...curityManagerSecurityIntegrationTests.java | 13 +- ...pacheShiroIniSecurityIntegrationTests.java | 8 +- ...cheShiroRealmSecurityIntegrationTests.java | 8 +- ...CacheServerConfigurerIntegrationTests.java | 2 + ...liesRegionConfigurersIntegrationTests.java | 1 + ...CacheConfigCacheNamesIntegrationTests.java | 19 +-- ...lientCacheApplicationIntegrationTests.java | 7 +- ...ClientCacheConfigurerIntegrationTests.java | 4 +- ...erverCacheApplicationIntegrationTests.java | 13 +- ...tpRequestInterceptorsIntegrationTests.java | 23 +-- .../DiskStoreConfigurerIntegrationTests.java | 5 +- ...CachingDefinedRegionsIntegrationTests.java | 15 +- ...eClusterConfigurationIntegrationTests.java | 12 +- ...igurationWithSecurityIntegrationTests.java | 1 + ...ClusterDefinedRegionsIntegrationTests.java | 13 +- ...sQueriesConfigurationIntegrationTests.java | 12 +- ...hAssignableTypeFilterIntegrationTests.java | 2 +- ...egionsWithRegexFilterIntegrationTests.java | 3 +- ...IndexingConfigurationIntegrationTests.java | 13 +- ...IndexingConfigurationIntegrationTests.java | 10 +- ...nableSslConfigurationIntegrationTests.java | 31 +--- .../LocatorApplicationIntegrationTests.java | 7 +- .../PeerCacheApplicationIntegrationTests.java | 14 +- ...nWithAddedCacheServerIntegrationTests.java | 4 +- .../PeerCacheConfigurerIntegrationTests.java | 4 +- .../PoolConfigurerIntegrationTests.java | 5 +- ...egionDataAccessTracingAspectUnitTests.java | 32 +++- ...ureLocatorApplicationIntegrationTests.java | 6 +- .../DefinedIndexesIntegrationTests.java | 12 +- ...toryBeanPostProcessorIntegrationTests.java | 7 +- ...nFactoryPostProcessorIntegrationTests.java | 2 + ...cEventQueueNamespaceIntegrationTests.java} | 11 +- .../xml/CacheNamespaceIntegrationTests.java | 6 +- .../ClientCacheNamespaceIntegrationTests.java | 4 +- .../DiskStoreNamespaceIntegrationTests.java | 7 +- ...ctionServiceNamespaceIntegrationTests.java | 3 +- ...ireV8GatewayNamespaceIntegrationTests.java | 7 +- ...euesAndGatewaySendersIntegrationTests.java | 14 +- .../config/xml/LuceneNamespaceUnitTests.java | 19 ++- .../xml/PoolNamespaceIntegrationTests.java | 6 +- ...onAttributesNamespaceIntegrationTests.java | 95 ++++++------ .../SubRegionNamespaceIntegrationTests.java | 3 +- ...lientRegionNamespaceIntegrationTests.java} | 142 +++++++++--------- .../TxManagerNamespaceIntegrationTests.java | 7 + .../PoolAlreadyExistsIntegrationTests.java | 10 +- ...xpirationConfigurationIntegrationTest.java | 5 +- ...wingFunctionExecutionIntegrationTests.java | 59 +------- ...rmissionsRegistrationIntegrationTests.java | 16 +- .../FunctionExecutionClientCacheTests.java | 9 +- .../config/FunctionsWithClientCacheTests.java | 3 +- ...uredFunctionExecutionIntegrationTests.java | 3 +- ...inerXmlConfigurationIntegrationTests.java} | 9 +- ...eMappingPdxSerializerIntegrationTests.java | 17 ++- .../QueryPostProcessorIntegrationTests.java | 21 ++- ...yQueryUsingInOperatorIntegrationTests.java | 11 +- ... AlgorithmRepositoryIntegrationTests.java} | 28 ++-- ... => AnimalRepositoryIntegrationTests.java} | 16 +- ...egionUsingCacheLoaderIntegrationTests.java | 6 +- .../SubRegionRepositoryIntegrationTest.java | 119 ++++++++------- ...serRepositoryQueriesIntegrationTests.java} | 35 +++-- ...mpleGemfireRepositoryIntegrationTests.java | 18 +-- ...epositoryTransactionalIntegrationTest.java | 3 +- .../LuceneOperationsIntegrationTests.java | 10 +- .../serialization/WiringInstantiatorTest.java | 21 +-- .../JSONRegionAdviceIntegrationTests.java | 7 +- ...eFactoryCacheResolverIntegrationTests.java | 4 +- ...catorAnnotationConfigIntegrationTests.java | 4 +- ...ireBeanFactoryLocatorIntegrationTests.java | 8 +- ...toryLocatorJavaConfigIntegrationTests.java | 2 + ...eSupportFunctionBasedIntegrationTests.java | 16 +- ...ringDeclarableSupportIntegrationTests.java | 1 - ...heResolverFactoryBeanIntegrationTests.java | 4 +- ...ringDeclarableSupportIntegrationTests.java | 24 +-- ...actionalEventListenerIntegrationTests.java | 4 +- ...ireTransactionManagerIntegrationTests.java | 22 ++- ...eByIdXmlConfigurationIntegrationTests.java | 2 +- ...GatewayReceiverStartIntegrationTests.java} | 5 +- ...EventQueuesAndGatewaySendersUnitTests.java | 16 +- ...pRegionMutationIntegrationTest-context.xml | 13 +- ...CacheIndexingIntegrationTests-context.xml} | 0 ...dexingIntegrationTests-server-context.xml} | 0 ...ientCachePoolIntegrationTests-context.xml} | 0 ...hePoolIntegrationTests-server-context.xml} | 0 ...CacheSecurityIntegrationTests-context.xml} | 0 ...curityIntegrationTests-server-context.xml} | 0 ...iableLocatorsIntegrationTests-context.xml} | 0 ...catorsIntegrationTests-server-context.xml} | 0 ...ariableServersIntegationTests-context.xml} | 0 ...erversIntegrationTests-server-context.xml} | 0 ...erCacheWriterIntegrationTests-context.xml} | 4 +- ...leClientCacheIntegrationTests-context.xml} | 10 +- ...tCacheIntegrationTests-server-context.xml} | 4 +- ...ueueNamespaceIntegrationTests-context.xml} | 14 +- ...gionNamespaceIntegrationTests-context.xml} | 14 +- ...tionExecutionIntegrationTests-context.xml} | 0 ...cutionIntegrationTests-server-context.xml} | 0 ...ConfigurationIntegrationTests-context.xml} | 0 ...thmRepositoryIntegrationTests-context.xml} | 0 ...malRepositoryIntegrationTests-context.xml} | 0 ...euesAndGatewaySendersUnitTests-context.xml | 2 +- 128 files changed, 1068 insertions(+), 953 deletions(-) rename spring-data-geode/src/test/java/org/springframework/data/gemfire/{CacheIntegrationTest.java => CacheIntegrationTests.java} (52%) rename spring-data-geode/src/test/java/org/springframework/data/gemfire/{LookupRegionMutationIntegrationTest.java => LookupRegionMutationIntegrationTests.java} (72%) create mode 100644 spring-data-geode/src/test/java/org/springframework/data/gemfire/LookupSubRegionIntegrationTests.java delete mode 100644 spring-data-geode/src/test/java/org/springframework/data/gemfire/LookupSubRegionTest.java rename spring-data-geode/src/test/java/org/springframework/data/gemfire/client/{ClientRegionWithCacheLoaderWriterTest.java => ClientRegionWithCacheLoaderCacheWriterIntegrationTests.java} (67%) rename spring-data-geode/src/test/java/org/springframework/data/gemfire/client/{DurableClientCacheIntegrationTest.java => DurableClientCacheIntegrationTests.java} (93%) rename spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/{AsyncEventQueueNamespaceTest.java => AsyncEventQueueNamespaceIntegrationTests.java} (94%) rename spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/{TemplateClientRegionNamespaceTest.java => TemplateClientRegionNamespaceIntegrationTests.java} (51%) rename spring-data-geode/src/test/java/org/springframework/data/gemfire/listener/adapter/{ContainerXmlSetupIntegrationTests.java => ContainerXmlConfigurationIntegrationTests.java} (86%) rename spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/{AlgorithmRepositoryTest.java => AlgorithmRepositoryIntegrationTests.java} (80%) rename spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/{AnimalRepositoryTest.java => AnimalRepositoryIntegrationTests.java} (85%) rename spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/{UserRepositoryQueriesIntegrationTest.java => UserRepositoryQueriesIntegrationTests.java} (77%) rename spring-data-geode/src/test/java/org/springframework/data/gemfire/wan/{ManualGatewayReceiverStartIntegrationTest.java => ManualGatewayReceiverStartIntegrationTests.java} (93%) rename spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/{ClientCacheIndexingTest-context.xml => ClientCacheIndexingIntegrationTests-context.xml} (100%) rename spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/{ClientCacheIndexingTest-server-context.xml => ClientCacheIndexingIntegrationTests-server-context.xml} (100%) rename spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/{ClientCachePoolTests-context.xml => ClientCachePoolIntegrationTests-context.xml} (100%) rename spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/{ClientCachePoolTests-server-context.xml => ClientCachePoolIntegrationTests-server-context.xml} (100%) rename spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/{ClientCacheSecurityTest-context.xml => ClientCacheSecurityIntegrationTests-context.xml} (100%) rename spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/{ClientCacheSecurityTest-server-context.xml => ClientCacheSecurityIntegrationTests-server-context.xml} (100%) rename spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/{ClientCacheVariableLocatorsTest-context.xml => ClientCacheVariableLocatorsIntegrationTests-context.xml} (100%) rename spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/{ClientCacheVariableLocatorsTest-server-context.xml => ClientCacheVariableLocatorsIntegrationTests-server-context.xml} (100%) rename spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/{ClientCacheVariableServersTest-context.xml => ClientCacheVariableServersIntegationTests-context.xml} (100%) rename spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/{ClientCacheVariableServersTest-server-context.xml => ClientCacheVariableServersIntegrationTests-server-context.xml} (100%) rename spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/{ClientRegionWithCacheLoaderWriterTest-context.xml => ClientRegionWithCacheLoaderCacheWriterIntegrationTests-context.xml} (86%) rename spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/{DurableClientCacheIntegrationTest-context.xml => DurableClientCacheIntegrationTests-context.xml} (91%) rename spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/{DurableClientCacheIntegrationTest-server-context.xml => DurableClientCacheIntegrationTests-server-context.xml} (96%) rename spring-data-geode/src/test/resources/org/springframework/data/gemfire/config/xml/{AsyncEventQueueNamespaceTest-context.xml => AsyncEventQueueNamespaceIntegrationTests-context.xml} (80%) rename spring-data-geode/src/test/resources/org/springframework/data/gemfire/config/xml/{TemplateClientRegionNamespaceTest-context.xml => TemplateClientRegionNamespaceIntegrationTests-context.xml} (84%) rename spring-data-geode/src/test/resources/org/springframework/data/gemfire/function/{ExceptionThrowingFunctionExecutionIntegrationTest-context.xml => ExceptionThrowingFunctionExecutionIntegrationTests-context.xml} (100%) rename spring-data-geode/src/test/resources/org/springframework/data/gemfire/function/{ExceptionThrowingFunctionExecutionIntegrationTest-server-context.xml => ExceptionThrowingFunctionExecutionIntegrationTests-server-context.xml} (100%) rename spring-data-geode/src/test/resources/org/springframework/data/gemfire/listener/adapter/{ContainerXmlSetupIntegrationTests-context.xml => ContainerXmlConfigurationIntegrationTests-context.xml} (100%) rename spring-data-geode/src/test/resources/org/springframework/data/gemfire/repository/sample/{AlgorithmRepositoryTest-context.xml => AlgorithmRepositoryIntegrationTests-context.xml} (100%) rename spring-data-geode/src/test/resources/org/springframework/data/gemfire/repository/sample/{AnimalRepositoryTest-context.xml => AnimalRepositoryIntegrationTests-context.xml} (100%) diff --git a/spring-data-geode/src/test/java/org/springframework/context/ApplicationContextBeanOrderingIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/context/ApplicationContextBeanOrderingIntegrationTests.java index 81a4e5b0..eb17080d 100644 --- a/spring-data-geode/src/test/java/org/springframework/context/ApplicationContextBeanOrderingIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/context/ApplicationContextBeanOrderingIntegrationTests.java @@ -43,6 +43,7 @@ import org.springframework.core.Ordered; import org.springframework.core.ResolvableType; import org.springframework.core.annotation.Order; import org.springframework.core.annotation.OrderUtils; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.gemfire.util.CollectionUtils; import org.springframework.data.gemfire.util.SpringUtils; import org.springframework.data.gemfire.util.StreamUtils; @@ -52,7 +53,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * Integration Tests testing the bean ordering applied by the Spring {@link ApplicationContext} + * Integration Tests asserting the bean ordering applied by the Spring {@link ApplicationContext} * or Spring {@link BeanFactory} when using the {@link Order} annotation or implementing the {@link Ordered} interface. * * @author John Blum @@ -60,6 +61,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.springframework.beans.factory.ListableBeanFactory * @see org.springframework.core.Ordered * @see org.springframework.core.annotation.Order + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 2.3.0 @@ -67,7 +69,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class ApplicationContextBeanOrderingIntegrationTests { +public class ApplicationContextBeanOrderingIntegrationTests extends IntegrationTestsSupport { @Autowired private ConfigurableApplicationContext applicationContext; diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/AutoRegionLookupIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/AutoRegionLookupIntegrationTests.java index 4def179f..82118f55 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/AutoRegionLookupIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/AutoRegionLookupIntegrationTests.java @@ -13,25 +13,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.springframework.data.gemfire; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import org.junit.Test; import org.junit.runner.RunWith; +import org.apache.geode.cache.Region; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * Integration tests to test the contract and functionality of Spring Data GemFire's Auto Region Lookup functionality. + * Integration Tests for SDG Auto {@link Region} Lookup functionality. * * @author John Blum * @see org.junit.Test - * @see org.junit.runner.RunWith + * @see org.apache.geode.cache.Region + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner * @since 1.5.0 @@ -39,19 +42,20 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class AutoRegionLookupIntegrationTests { +public class AutoRegionLookupIntegrationTests extends IntegrationTestsSupport { @Autowired private ApplicationContext applicationContext; @Test public void testAutoRegionLookup() { - assertTrue(applicationContext.containsBean("SpringPartitionedRegion")); - assertTrue(applicationContext.containsBean("SpringReplicateParent")); - assertTrue(applicationContext.containsBean("/SpringReplicateParent/SpringReplicateChild")); - assertTrue(applicationContext.containsBean("NativePartitionedRegion")); - assertTrue(applicationContext.containsBean("NativeReplicateParent")); - assertTrue(applicationContext.containsBean("/NativeReplicateParent/NativeReplicateChild")); - assertTrue(applicationContext.containsBean("/NativeReplicateParent/NativeReplicateChild/NativeReplicateGrandchild")); + + assertThat(this.applicationContext.containsBean("SpringPartitionedRegion")).isTrue(); + assertThat(this.applicationContext.containsBean("SpringReplicateParent")).isTrue(); + assertThat(this.applicationContext.containsBean("/SpringReplicateParent/SpringReplicateChild")).isTrue(); + assertThat(this.applicationContext.containsBean("NativePartitionedRegion")).isTrue(); + assertThat(this.applicationContext.containsBean("NativeReplicateParent")).isTrue(); + assertThat(this.applicationContext.containsBean("/NativeReplicateParent/NativeReplicateChild")).isTrue(); + assertThat(this.applicationContext.containsBean("/NativeReplicateParent/NativeReplicateChild/NativeReplicateGrandchild")).isTrue(); } } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/AutoRegionLookupWithAutowiringIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/AutoRegionLookupWithAutowiringIntegrationTests.java index 423cfdd5..0c69208e 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/AutoRegionLookupWithAutowiringIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/AutoRegionLookupWithAutowiringIntegrationTests.java @@ -13,33 +13,32 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.springframework.data.gemfire; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; +import static org.assertj.core.api.Assertions.assertThat; import javax.annotation.Resource; -import org.apache.geode.cache.DataPolicy; -import org.apache.geode.cache.Region; - import org.junit.Test; import org.junit.runner.RunWith; +import org.apache.geode.cache.DataPolicy; +import org.apache.geode.cache.Region; + import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.stereotype.Component; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * Integration tests to test the behavior of Spring Data GemFire's Auto Region Lookup functionality - * when combined with Spring's component auto-wiring capabilities. + * Integration Tests for SDG's Auto {@link Region} Lookup functionality when combined with Spring's component + * auto-wiring capabilities. * * @author John Blum * @see org.junit.Test - * @see org.junit.runner.RunWith + * @see org.apache.geode.cache.Region + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner * @since 1.5.0 @@ -47,10 +46,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class AutoRegionLookupWithAutowiringIntegrationTests { - - @Autowired - private TestComponent testComponent; +public class AutoRegionLookupWithAutowiringIntegrationTests extends IntegrationTestsSupport { private static void assertRegionMetaData(Region region, String expectedName, DataPolicy expectedDataPolicy) { assertRegionMetaData(region, expectedName, Region.SEPARATOR + expectedName, expectedDataPolicy); @@ -59,14 +55,24 @@ public class AutoRegionLookupWithAutowiringIntegrationTests { private static void assertRegionMetaData(Region region, String expectedName, String expectedFullPath, DataPolicy expectedDataPolicy) { - assertNotNull(String.format("Region (%1$s) was not properly configured and initialized!", expectedName), region); - assertEquals(expectedName, region.getName()); - assertEquals(expectedFullPath, region.getFullPath()); - assertNotNull(String.format("Region (%1$s) must have RegionAttributes defined!", expectedName), region.getAttributes()); - assertEquals(expectedDataPolicy, region.getAttributes().getDataPolicy()); - assertFalse(region.getAttributes().getDataPolicy().withPersistence()); + assertThat(region) + .describedAs(String.format("Region (%1$s) was not properly configured and initialized!", expectedName)) + .isNotNull(); + + assertThat(region.getName()).isEqualTo(expectedName); + assertThat(region.getFullPath()).isEqualTo(expectedFullPath); + + assertThat(region.getAttributes()) + .describedAs(String.format("Region (%1$s) must have RegionAttributes defined!", expectedName)) + .isNotNull(); + + assertThat(region.getAttributes().getDataPolicy()).isEqualTo(expectedDataPolicy); + assertThat(region.getAttributes().getDataPolicy().withPersistence()).isFalse(); } + @Autowired + private TestComponent testComponent; + @Test public void testAutowiredNativeRegions() { diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/AutoRegionLookupWithComponentScanningIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/AutoRegionLookupWithComponentScanningIntegrationTests.java index c9984a6b..62d1da46 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/AutoRegionLookupWithComponentScanningIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/AutoRegionLookupWithComponentScanningIntegrationTests.java @@ -13,35 +13,36 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.springframework.data.gemfire; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import org.junit.Test; import org.junit.runner.RunWith; +import org.apache.geode.cache.Region; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * Integration tests to test the behavior of Spring Data GemFire's Auto Region Lookup behavior - * with Spring component scanning functionality. + * Integration Tests for SDG's Auto {@link Region} Lookup behavior with Spring component scanning functionality. * * @author John Blum * @see org.junit.Test - * @see org.junit.runner.RunWith + * @see org.apache.geode.cache.Region + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration - * @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner + * @see org.springframework.test.context.junit4.SpringRunner * @since 1.5.0 */ @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class AutoRegionLookupWithComponentScanningIntegrationTests { +public class AutoRegionLookupWithComponentScanningIntegrationTests extends IntegrationTestsSupport { @Autowired private ApplicationContext applicationContext; @@ -49,8 +50,10 @@ public class AutoRegionLookupWithComponentScanningIntegrationTests { @Test public void testAutowiredNativeRegions() { - assertTrue("The 'autoRegionLookupDao' Spring bean DAO was not properly configured an initialized!", - this.applicationContext.containsBean("autoRegionLookupDao")); - assertNotNull(this.applicationContext.getBean("autoRegionLookupDao", AutoRegionLookupDao.class)); + assertThat(this.applicationContext.containsBean("autoRegionLookupDao")) + .describedAs("The 'autoRegionLookupDao' Spring bean DAO was not properly configured an initialized!") + .isTrue(); + + assertThat(this.applicationContext.getBean("autoRegionLookupDao", AutoRegionLookupDao.class)).isNotNull(); } } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/CacheIntegrationTest.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/CacheIntegrationTests.java similarity index 52% rename from spring-data-geode/src/test/java/org/springframework/data/gemfire/CacheIntegrationTest.java rename to spring-data-geode/src/test/java/org/springframework/data/gemfire/CacheIntegrationTests.java index 55a5cd62..7ca81287 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/CacheIntegrationTest.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/CacheIntegrationTests.java @@ -13,39 +13,41 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.springframework.data.gemfire; -import static org.junit.Assert.assertEquals; - -import org.apache.geode.cache.Cache; +import static org.assertj.core.api.Assertions.assertThat; import org.junit.After; import org.junit.Test; import org.junit.runner.RunWith; +import org.apache.geode.cache.Cache; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * Integration test trying various basic configurations of GemFire through - * Spring. - * - * Made abstract to avoid multiple caches running at the same time. + * Integration Tests trying various basic configurations of Apache Geode caches with Spring. * * @author Costin Leau * @author John Blum + * @see org.junit.Test + * @see org.apache.geode.cache.Cache + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport + * @see org.springframework.test.context.ContextConfiguration + * @see org.springframework.test.context.junit4.SpringRunner */ @RunWith(SpringRunner.class) @ContextConfiguration(locations = "basic-cache.xml") -public class CacheIntegrationTest { +public class CacheIntegrationTests extends IntegrationTestsSupport { @Autowired - ApplicationContext applicationContext; + private ApplicationContext applicationContext; - Cache cache; + private Cache cache; @After public void tearDown() { @@ -53,30 +55,30 @@ public class CacheIntegrationTest { } @Test - public void testBasicCache() throws Exception { - cache = applicationContext.getBean("default-cache",Cache.class); + public void testBasicCache() { + this.cache = this.applicationContext.getBean("default-cache",Cache.class); } @Test - public void testCacheWithProps() throws Exception { + public void testCacheWithProps() { cache = applicationContext.getBean("cache-with-props", Cache.class); // the name property seems to be ignored - assertEquals("cache-with-props", cache.getDistributedSystem().getName()); - assertEquals("cache-with-props", cache.getName()); + assertThat(cache.getDistributedSystem().getName()).isEqualTo("cache-with-props"); + assertThat(cache.getName()).isEqualTo("cache-with-props"); } @Test - public void testNamedCache() throws Exception { + public void testNamedCache() { - cache = applicationContext.getBean("named-cache", Cache.class); + this.cache = this.applicationContext.getBean("named-cache", Cache.class); - assertEquals("named-cache", cache.getDistributedSystem().getName()); - assertEquals("named-cache", cache.getName()); + assertThat(cache.getDistributedSystem().getName()).isEqualTo("named-cache"); + assertThat(cache.getName()).isEqualTo("named-cache"); } @Test - public void testCacheWithXml() throws Exception { - applicationContext.getBean("cache-with-xml", Cache.class); + public void testCacheWithXml() { + this.applicationContext.getBean("cache-with-xml", Cache.class); } } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/GemfireTemplateIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/GemfireTemplateIntegrationTests.java index 63c3d742..f9c8f190 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/GemfireTemplateIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/GemfireTemplateIntegrationTests.java @@ -43,6 +43,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.data.gemfire.repository.sample.User; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.gemfire.util.CacheUtils; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -56,8 +57,10 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.apache.geode.cache.GemFireCache * @see org.apache.geode.cache.Region * @see org.apache.geode.cache.query.SelectResults + * @see org.springframework.context.annotation.Bean * @see org.springframework.context.annotation.Configuration * @see org.springframework.data.gemfire.GemfireTemplate + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 1.4.0 @@ -65,7 +68,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class GemfireTemplateIntegrationTests { +public class GemfireTemplateIntegrationTests extends IntegrationTestsSupport { protected static final String DEFAULT_GEMFIRE_LOG_LEVEL = "error"; diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationTests.java index f50ad98d..ceead40b 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationTests.java @@ -61,22 +61,24 @@ import lombok.NonNull; import lombok.RequiredArgsConstructor; /** - * Integrations Tests for {@link GemfireTemplate} testing the proper function and behavior of executing (OQL) queries - * from a cache client application using the {@link GemfireTemplate} to a cluster of GemFire servers that have + * Integrations Tests for {@link GemfireTemplate} testing the proper function and behavior of executing OQL queries + * from a cache client application using the {@link GemfireTemplate} to a cluster of Apache Geode servers that have * been grouped according to business function and data access in order to distribute the load. * - * Each GemFire {@link Pool} is configured to target a specific server group. Each group of servers in the cluster - * defines specific {@link Region Regions} to manage data independently and separately from other data that might - * garner high frequency access. + * Each Apache Geode {@link Pool} is configured to target a specific server group. Each group of servers in the cluster + * defines specific {@link Region Regions} to manage data independently and separately from other data that might garner + * high frequency access. * - * Spring Data GemFire's {@link GemfireTemplate} should intelligently employ the right + * Spring Data for Apache Geode's {@link GemfireTemplate} should intelligently employ the right * {@link org.apache.geode.cache.query.QueryService} configured with the {@link Region Region's} {@link Pool} * metadata when executing the query in order to ensure the right servers containing the {@link Region Region's} * with the data of interest are targeted. * * @author John Blum * @see org.junit.Test - * @see org.junit.runner.RunWith + * @see org.apache.geode.cache.Cache + * @see org.apache.geode.cache.GemFireCache + * @see org.apache.geode.cache.Region * @see org.springframework.data.gemfire.GemfireTemplate * @see org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/LookupRegionMutationIntegrationTest.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/LookupRegionMutationIntegrationTests.java similarity index 72% rename from spring-data-geode/src/test/java/org/springframework/data/gemfire/LookupRegionMutationIntegrationTest.java rename to spring-data-geode/src/test/java/org/springframework/data/gemfire/LookupRegionMutationIntegrationTests.java index 1e7d3ddd..7370aafd 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/LookupRegionMutationIntegrationTest.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/LookupRegionMutationIntegrationTests.java @@ -15,9 +15,8 @@ */ package org.springframework.data.gemfire; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.data.Offset.offset; import java.util.ArrayList; import java.util.Arrays; @@ -51,18 +50,20 @@ import org.apache.geode.cache.asyncqueue.AsyncEventListener; import org.apache.geode.cache.util.CacheListenerAdapter; import org.springframework.beans.factory.BeanNameAware; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.util.StringUtils; /** - * Integration Tests for {@link LookupRegionFactoryBean} testing the contract and integrated functionality between - * natively-defined GemFire/Geode cache {@link Region Regions} and SDG's {@link Region} lookup functionality - * combined with {@link org.apache.geode.cache.RegionAttributes} {@link Region#getAttributesMutator() mutation}. + * Integration Tests testing the contract and integratino between natively-defined cache {@link Region Regions} + * and SDG's {@link Region} lookup functionality combined with {@link Region} attribute(s) mutation. * * @author John Blum * @see org.junit.Test + * @see org.apache.geode.cache.Region * @see org.springframework.data.gemfire.LookupRegionFactoryBean + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 1.7.0 @@ -70,50 +71,52 @@ import org.springframework.util.StringUtils; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class LookupRegionMutationIntegrationTest { +public class LookupRegionMutationIntegrationTests extends IntegrationTestsSupport { @Resource(name = "Example") private Region example; - private void assertCacheListeners(CacheListener[] cacheListeners, Collection expectedCacheListenerNames) { + private void assertCacheListeners(CacheListener[] cacheListeners, + Collection expectedCacheListenerNames) { if (!expectedCacheListenerNames.isEmpty()) { - assertNotNull("CacheListeners must not be null!", cacheListeners); - assertEquals(expectedCacheListenerNames.size(), cacheListeners.length); - assertTrue(toStrings(cacheListeners).containsAll(expectedCacheListenerNames)); + assertThat(cacheListeners).as("CacheListeners must not be null!").isNotNull(); + assertThat(cacheListeners.length).isEqualTo(expectedCacheListenerNames.size()); + assertThat(toStrings(cacheListeners).containsAll(expectedCacheListenerNames)).isTrue(); } } private void assertEvictionAttributes(EvictionAttributes evictionAttributes, EvictionAction expectedAction, EvictionAlgorithm expectedAlgorithm, int expectedMaximum) { - assertNotNull("EvictionAttributes must not be null!", evictionAttributes); - assertEquals(expectedAction, evictionAttributes.getAction()); - assertEquals(expectedAlgorithm, evictionAttributes.getAlgorithm()); - assertEquals(expectedMaximum, evictionAttributes.getMaximum()); + assertThat(evictionAttributes).as("EvictionAttributes must not be null!").isNotNull(); + assertThat(evictionAttributes.getAction()).isEqualTo(expectedAction); + assertThat(evictionAttributes.getAlgorithm()).isEqualTo(expectedAlgorithm); + assertThat(evictionAttributes.getMaximum()).isEqualTo(expectedMaximum); } private void assertExpirationAttributes(ExpirationAttributes expirationAttributes, String description, int expectedTimeout, ExpirationAction expectedAction) { - assertNotNull(String.format("ExpirationAttributes for '%1$s' must not be null!", description), expirationAttributes); - assertEquals(expectedAction, expirationAttributes.getAction()); - assertEquals(expectedTimeout, expirationAttributes.getTimeout()); + assertThat(expirationAttributes) + .as(String.format("ExpirationAttributes for '%1$s' must not be null!", description)).isNotNull(); + assertThat(expirationAttributes.getAction()).isEqualTo(expectedAction); + assertThat(expirationAttributes.getTimeout()).isEqualTo(expectedTimeout); } private void assertGatewaySenders(Region region, List expectedGatewaySenderIds) { - assertNotNull(region.getAttributes()); - assertNotNull(region.getAttributes().getGatewaySenderIds()); - assertEquals(expectedGatewaySenderIds.size(), region.getAttributes().getGatewaySenderIds().size()); - assertTrue(expectedGatewaySenderIds.containsAll(region.getAttributes().getGatewaySenderIds())); + assertThat(region.getAttributes()).isNotNull(); + assertThat(region.getAttributes().getGatewaySenderIds()).isNotNull(); + assertThat(region.getAttributes().getGatewaySenderIds().size()).isEqualTo(expectedGatewaySenderIds.size()); + assertThat(expectedGatewaySenderIds.containsAll(region.getAttributes().getGatewaySenderIds())).isTrue(); } private void assertGemFireComponent(Object gemfireComponent, String expectedName) { - assertNotNull("The GemFire component must not be null!", gemfireComponent); - assertEquals(expectedName, gemfireComponent.toString()); + assertThat(gemfireComponent).as("The GemFire component must not be null!").isNotNull(); + assertThat(gemfireComponent.toString()).isEqualTo(expectedName); } private void assertRegionAttributes(Region region, String expectedName, DataPolicy expectedDataPolicy) { @@ -125,11 +128,11 @@ public class LookupRegionMutationIntegrationTest { private void assertRegionAttributes(Region region, String expectedName, String expectedFullPath, DataPolicy expectedDataPolicy) { - assertNotNull(String.format("'%1$s' Region was not properly initialized!", region)); - assertEquals(expectedName, region.getName()); - assertEquals(expectedFullPath, region.getFullPath()); - assertNotNull(region.getAttributes()); - assertEquals(expectedDataPolicy, region.getAttributes().getDataPolicy()); + assertThat(String.format("'%1$s' Region was not properly initialized!", region)).isNotNull(); + assertThat(region.getName()).isEqualTo(expectedName); + assertThat(region.getFullPath()).isEqualTo(expectedFullPath); + assertThat(region.getAttributes()).isNotNull(); + assertThat(region.getAttributes().getDataPolicy()).isEqualTo(expectedDataPolicy); } private Collection toStrings(Object[] objects) { @@ -150,8 +153,8 @@ public class LookupRegionMutationIntegrationTest { public void regionConfigurationIsCorrect() { assertRegionAttributes(example, "Example", DataPolicy.NORMAL); - assertEquals(13, example.getAttributes().getInitialCapacity()); - assertEquals(0.85f, example.getAttributes().getLoadFactor(), 0.0f); + assertThat(example.getAttributes().getInitialCapacity()).isEqualTo(13); + assertThat(example.getAttributes().getLoadFactor()).isCloseTo(0.85f, offset(0.0f)); assertCacheListeners(example.getAttributes().getCacheListeners(), Arrays.asList("A", "B")); assertGemFireComponent(example.getAttributes().getCacheLoader(), "C"); assertGemFireComponent(example.getAttributes().getCacheWriter(), "D"); @@ -164,9 +167,9 @@ public class LookupRegionMutationIntegrationTest { assertExpirationAttributes(example.getAttributes().getEntryTimeToLive(), "Entry TTL", 30, ExpirationAction.DESTROY); assertGemFireComponent(example.getAttributes().getCustomEntryIdleTimeout(), "E"); - assertNotNull(example.getAttributes().getAsyncEventQueueIds()); - assertEquals(1, example.getAttributes().getAsyncEventQueueIds().size()); - assertEquals("AEQ", example.getAttributes().getAsyncEventQueueIds().iterator().next()); + assertThat(example.getAttributes().getAsyncEventQueueIds()).isNotNull(); + assertThat(example.getAttributes().getAsyncEventQueueIds().size()).isEqualTo(1); + assertThat(example.getAttributes().getAsyncEventQueueIds().iterator().next()).isEqualTo("AEQ"); assertGatewaySenders(example, Collections.singletonList("GWS")); } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/LookupSubRegionIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/LookupSubRegionIntegrationTests.java new file mode 100644 index 00000000..f8d05ec9 --- /dev/null +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/LookupSubRegionIntegrationTests.java @@ -0,0 +1,103 @@ +/* + * Copyright 2010-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.data.gemfire; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.apache.geode.cache.Region; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; + +/** + * Integration Tests testing the contract and functionality of Region lookups using SDG XML namespace configuration + * metadata and Apache Geode native cache.xml. + * + * @author John Blum + * @see org.junit.Test + * @see org.apache.geode.cache.Region + * @see org.springframework.context.ApplicationContext + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport + * @see org.springframework.test.context.ContextConfiguration + * @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner + * @since 1.3.3 + */ +@RunWith(SpringRunner.class) +@ContextConfiguration("lookupSubRegion.xml") +@SuppressWarnings("unused") +public class LookupSubRegionIntegrationTests extends IntegrationTestsSupport { + + @Autowired + private ApplicationContext applicationContext; + + private void assertRegionExists(String expectedRegionName, String expectedRegionPath, Region region) { + + assertThat(region) + .describedAs("The Region with name (%1$s) at path (%2$s) was null!",expectedRegionName, expectedRegionPath) + .isNotNull(); + + assertThat(region.getName()) + .describedAs("Expected Region name of %1$s; but was %2$s!", expectedRegionName, region.getName()) + .isEqualTo(expectedRegionName); + + assertThat(region.getFullPath()) + .describedAs("Expected Region path of %1$s; but was %2$s!", expectedRegionPath, region.getFullPath()) + .isEqualTo(expectedRegionPath); + } + + @Test + public void testDirectLookup() { + + Region accounts = applicationContext.getBean("/Customers/Accounts", Region.class); + + assertRegionExists("Accounts", "/Customers/Accounts", accounts); + assertThat(applicationContext.containsBean("Customers/Accounts")).isFalse(); + assertThat(applicationContext.containsBean("/Customers")).isFalse(); + assertThat(applicationContext.containsBean("Customers")).isFalse(); + + Region items = applicationContext.getBean("Customers/Accounts/Orders/Items", Region.class); + + assertRegionExists("Items", "/Customers/Accounts/Orders/Items", items); + assertThat(applicationContext.containsBean("/Customers/Accounts/Orders/Items")).isFalse(); + assertThat(applicationContext.containsBean("/Customers/Accounts/Orders")).isFalse(); + assertThat(applicationContext.containsBean("Customers/Accounts/Orders")).isFalse(); + } + + @Test + public void testNestedLookup() { + + Region parent = applicationContext.getBean("Parent", Region.class); + + assertRegionExists("Parent", "/Parent", parent); + assertThat(applicationContext.containsBean("/Parent")).isFalse(); + + Region child = applicationContext.getBean("/Parent/Child", Region.class); + + assertRegionExists("Child", "/Parent/Child", child); + assertThat(applicationContext.containsBean("Parent/Child")).isFalse(); + + Region grandchild = applicationContext.getBean("/Parent/Child/Grandchild", Region.class); + + assertRegionExists("Grandchild", "/Parent/Child/Grandchild", grandchild); + assertThat(applicationContext.containsBean("Parent/Child/Grandchild")).isFalse(); + } +} diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/LookupSubRegionTest.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/LookupSubRegionTest.java deleted file mode 100644 index 8d9e1072..00000000 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/LookupSubRegionTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2010-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.data.gemfire; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; - -import org.apache.geode.cache.Region; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * The LookupSubRegionTest class is a test suite of test cases testing the contract and functionality of Region lookups - * using Spring Data GemFire configuration and GemFire native cache.xml. - * - * @author John Blum - * @see org.junit.Test - * @see org.springframework.context.ApplicationContext - * @see org.springframework.test.context.ContextConfiguration - * @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner - * @see org.apache.geode.cache.Region - * @since 1.3.3 - * @since 7.0.1 (GemFire) - */ -@RunWith(SpringRunner.class) -@ContextConfiguration("lookupSubRegion.xml") -@SuppressWarnings("unused") -public class LookupSubRegionTest { - - @Autowired - private ApplicationContext applicationContext; - - private void assertRegionExists(final String expectedRegionName, final String expectedRegionPath, final Region region) { - - assertNotNull(String.format("The Region with name (%1$s) at path (%2$s) was null!", - expectedRegionName, expectedRegionPath), region); - assertEquals(String.format("Expected Region name of %1$s; but was %2$s!", expectedRegionName, region.getName()), - expectedRegionName, region.getName()); - assertEquals(String.format("Expected Region path of %1$s; but was %2$s!", expectedRegionPath, region.getFullPath()), - expectedRegionPath, region.getFullPath()); - } - - @Test - public void testDirectLookup() { - - Region accounts = applicationContext.getBean("/Customers/Accounts", Region.class); - - assertRegionExists("Accounts", "/Customers/Accounts", accounts); - assertFalse(applicationContext.containsBean("Customers/Accounts")); - assertFalse(applicationContext.containsBean("/Customers")); - assertFalse(applicationContext.containsBean("Customers")); - - Region items = applicationContext.getBean("Customers/Accounts/Orders/Items", Region.class); - - assertRegionExists("Items", "/Customers/Accounts/Orders/Items", items); - assertFalse(applicationContext.containsBean("/Customers/Accounts/Orders/Items")); - assertFalse(applicationContext.containsBean("/Customers/Accounts/Orders")); - assertFalse(applicationContext.containsBean("Customers/Accounts/Orders")); - } - - @Test - public void testNestedLookup() { - - Region parent = applicationContext.getBean("Parent", Region.class); - - assertRegionExists("Parent", "/Parent", parent); - assertFalse(applicationContext.containsBean("/Parent")); - - Region child = applicationContext.getBean("/Parent/Child", Region.class); - - assertRegionExists("Child", "/Parent/Child", child); - assertFalse(applicationContext.containsBean("Parent/Child")); - - Region grandchild = applicationContext.getBean("/Parent/Child/Grandchild", Region.class); - - assertRegionExists("Grandchild", "/Parent/Child/Grandchild", grandchild); - assertFalse(applicationContext.containsBean("Parent/Child/Grandchild")); - } -} diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/cache/CacheErrorHandlerIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/cache/CacheErrorHandlerIntegrationTests.java index cf334626..6b093c78 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/cache/CacheErrorHandlerIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/cache/CacheErrorHandlerIntegrationTests.java @@ -36,6 +36,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.data.gemfire.cache.config.EnableGemfireCaching; import org.springframework.data.gemfire.config.annotation.ClientCacheApplication; import org.springframework.data.gemfire.config.annotation.EnableCachingDefinedRegions; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.lang.Nullable; import org.springframework.stereotype.Service; import org.springframework.test.context.ContextConfiguration; @@ -55,6 +56,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.springframework.data.gemfire.cache.config.EnableGemfireCaching * @see org.springframework.data.gemfire.config.annotation.ClientCacheApplication * @see org.springframework.data.gemfire.config.annotation.EnableCachingDefinedRegions + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 2.3.0 @@ -62,9 +64,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class CacheErrorHandlerIntegrationTests { - - private static final String GEMFIRE_LOG_LEVEL = "error"; +public class CacheErrorHandlerIntegrationTests extends IntegrationTestsSupport { @Autowired private ClientCache clientCache; @@ -92,10 +92,10 @@ public class CacheErrorHandlerIntegrationTests { assertThat(this.cacheableService.processCacheableOperation("one")).isEqualTo("TEST"); } - @ClientCacheApplication(logLevel = GEMFIRE_LOG_LEVEL) + @ClientCacheApplication @EnableCachingDefinedRegions @EnableGemfireCaching - static class GeodeClientConfiguration extends CachingConfigurerSupport { + static class GeodeClientTestConfiguration extends CachingConfigurerSupport { @Nullable @Override public CacheErrorHandler errorHandler() { diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/cache/config/EnableGemfireCachingIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/cache/config/EnableGemfireCachingIntegrationTests.java index 1d4b9265..1181e952 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/cache/config/EnableGemfireCachingIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/cache/config/EnableGemfireCachingIntegrationTests.java @@ -22,39 +22,42 @@ import javax.annotation.Resource; import org.junit.Test; import org.junit.runner.RunWith; -import org.apache.geode.cache.GemFireCache; import org.apache.geode.cache.Region; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.Cacheable; import org.springframework.context.annotation.Bean; -import org.springframework.data.gemfire.LocalRegionFactoryBean; import org.springframework.data.gemfire.cache.GemfireCacheManager; -import org.springframework.data.gemfire.config.annotation.PeerCacheApplication; +import org.springframework.data.gemfire.config.annotation.ClientCacheApplication; +import org.springframework.data.gemfire.config.annotation.EnableCachingDefinedRegions; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; +import org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects; import org.springframework.stereotype.Service; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.util.Assert; /** - * Integration tests for {@link EnableGemfireCaching} and {@link GemfireCachingConfiguration}. + * Integration Tests for {@link EnableGemfireCaching} and {@link GemfireCachingConfiguration}. * * @author John Blum * @see org.junit.Test - * @see org.junit.runner.RunWith - * @see org.apache.geode.cache.GemFireCache + * @see org.apache.geode.cache.Region * @see org.springframework.cache.annotation.Cacheable * @see org.springframework.context.annotation.Bean * @see org.springframework.data.gemfire.cache.config.EnableGemfireCaching * @see org.springframework.data.gemfire.cache.config.GemfireCachingConfiguration - * @see org.springframework.data.gemfire.config.annotation.PeerCacheApplication + * @see org.springframework.data.gemfire.config.annotation.EnableCachingDefinedRegions + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport + * @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 2.0.0 */ @RunWith(SpringRunner.class) @ContextConfiguration -public class EnableGemfireCachingIntegrationTests { +@SuppressWarnings("unused") +public class EnableGemfireCachingIntegrationTests extends IntegrationTestsSupport { @Autowired private CalculatorService calculator; @@ -130,8 +133,10 @@ public class EnableGemfireCachingIntegrationTests { } } + @ClientCacheApplication + @EnableCachingDefinedRegions @EnableGemfireCaching - @PeerCacheApplication(name = "EnableGemfireCachingIntegrationTests", logLevel = "warning") + @EnableGemFireMockObjects @SuppressWarnings("unused") static class TestConfiguration { @@ -139,17 +144,5 @@ public class EnableGemfireCachingIntegrationTests { CalculatorService calculatorService() { return new CalculatorService(); } - - @Bean("Factorials") - LocalRegionFactoryBean factorialsRegion(GemFireCache gemfireCache) { - - LocalRegionFactoryBean factorials = new LocalRegionFactoryBean<>(); - - factorials.setCache(gemfireCache); - factorials.setClose(false); - factorials.setPersistent(false); - - return factorials; - } } } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCacheIndexingIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCacheIndexingIntegrationTests.java index 75552b83..46102086 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCacheIndexingIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCacheIndexingIntegrationTests.java @@ -17,13 +17,10 @@ package org.springframework.data.gemfire.client; import static org.assertj.core.api.Assertions.assertThat; -import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.TimeUnit; -import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -36,26 +33,20 @@ import org.apache.geode.cache.query.QueryService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.gemfire.fork.ServerProcess; -import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; -import org.springframework.data.gemfire.tests.process.ProcessExecutor; -import org.springframework.data.gemfire.tests.process.ProcessWrapper; -import org.springframework.data.gemfire.tests.util.FileSystemUtils; -import org.springframework.data.gemfire.tests.util.ThreadUtils; +import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.util.Assert; /** * Integration Tests for testing {@link ClientCache} {@link Index Indexes}. * * @author John Blum * @see org.junit.Test - * @see org.apache.geode.cache.GemFireCache * @see org.apache.geode.cache.client.ClientCache * @see org.apache.geode.cache.query.Index * @see org.apache.geode.cache.query.QueryService * @see org.springframework.data.gemfire.IndexFactoryBean - * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport + * @see org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 1.5.2 @@ -63,9 +54,7 @@ import org.springframework.util.Assert; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class ClientCacheIndexingIntegrationTests extends IntegrationTestsSupport { - - private static ProcessWrapper serverProcess; +public class ClientCacheIndexingIntegrationTests extends ForkingClientServerIntegrationTestsSupport { @Autowired private ClientCache clientCache; @@ -74,51 +63,19 @@ public class ClientCacheIndexingIntegrationTests extends IntegrationTestsSupport private Index exampleIndex; @BeforeClass - public static void setup() throws IOException { - - String serverName = "GemFireIndexingCacheServer"; - - File serverWorkingDirectory = new File(FileSystemUtils.WORKING_DIRECTORY, serverName.toLowerCase()); - - Assert.isTrue(serverWorkingDirectory.isDirectory() || serverWorkingDirectory.mkdirs(), - String.format("Server working directory [%s] does not exist and could not be created", serverWorkingDirectory)); + public static void startGeodeServer() throws IOException { List arguments = new ArrayList<>(); - arguments.add("-Dgemfire.name=" + serverName); - arguments.add("/org/springframework/data/gemfire/client/ClientCacheIndexingTest-server-context.xml"); + arguments.add(String.format("-Dgemfire.name=%s", + ClientCacheIndexingIntegrationTests.class.getSimpleName().contains("Server"))); - serverProcess = ProcessExecutor.launch(serverWorkingDirectory, ServerProcess.class, - arguments.toArray(new String[0])); + arguments.add(getServerContextXmlFileLocation(ClientCacheIndexingIntegrationTests.class)); - waitForServerStart(TimeUnit.SECONDS.toMillis(20)); + startGemFireServer(ServerProcess.class, arguments.toArray(new String[0])); } - private static void waitForServerStart(final long milliseconds) { - - ThreadUtils.timedWait(milliseconds, TimeUnit.MILLISECONDS.toMillis(500), new ThreadUtils.Condition() { - - private final File serverPidControlFile = - new File(serverProcess.getWorkingDirectory(), ServerProcess.getServerProcessControlFilename()); - - @Override - public boolean evaluate() { - return !serverPidControlFile.isFile(); - } - }); - } - - @AfterClass - public static void tearDown() { - - serverProcess.shutdown(); - - if (Boolean.parseBoolean(System.getProperty("spring.gemfire.fork.clean", Boolean.TRUE.toString()))) { - org.springframework.util.FileSystemUtils.deleteRecursively(serverProcess.getWorkingDirectory()); - } - } - - protected Index getIndex(final GemFireCache gemfireCache, final String indexName) { + private Index getIndex(GemFireCache gemfireCache, String indexName) { QueryService queryService = gemfireCache instanceof ClientCache ? ((ClientCache) gemfireCache).getLocalQueryService() @@ -137,7 +94,9 @@ public class ClientCacheIndexingIntegrationTests extends IntegrationTestsSupport @SuppressWarnings("deprecation") public void testIndexByName() { - assertThat(clientCache).as("The GemFire ClientCache was not properly configured and initialized!").isNotNull(); + assertThat(clientCache) + .describedAs("The GemFire ClientCache was not properly configured and initialized!") + .isNotNull(); Index actualIndex = getIndex(clientCache, "ExampleIndex"); diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCachePoolIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCachePoolIntegrationTests.java index ca723c2f..a0c181c3 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCachePoolIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCachePoolIntegrationTests.java @@ -16,9 +16,7 @@ */ package org.springframework.data.gemfire.client; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import javax.annotation.Resource; @@ -31,6 +29,7 @@ import org.apache.geode.cache.CacheLoaderException; import org.apache.geode.cache.LoaderHelper; import org.apache.geode.cache.Region; +import org.springframework.data.gemfire.fork.ServerProcess; import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -55,8 +54,9 @@ import org.springframework.util.Assert; public class ClientCachePoolIntegrationTests extends ForkingClientServerIntegrationTestsSupport { @BeforeClass - public static void setupGemFireServer() throws Exception { - startGemFireServer(ClientCachePoolIntegrationTests.class); + public static void startGeodeServer() throws Exception { + startGemFireServer(ServerProcess.class, + getServerContextXmlFileLocation(ClientCachePoolIntegrationTests.class)); } @Resource(name = "Factorials") @@ -65,16 +65,16 @@ public class ClientCachePoolIntegrationTests extends ForkingClientServerIntegrat @Test public void computeFactorials() { - assertThat(factorials.get(0l), is(equalTo(1l))); - assertThat(factorials.get(1l), is(equalTo(1l))); - assertThat(factorials.get(2l), is(equalTo(2l))); - assertThat(factorials.get(3l), is(equalTo(6l))); - assertThat(factorials.get(4l), is(equalTo(24l))); - assertThat(factorials.get(5l), is(equalTo(120l))); - assertThat(factorials.get(6l), is(equalTo(720l))); - assertThat(factorials.get(7l), is(equalTo(5040l))); - assertThat(factorials.get(8l), is(equalTo(40320l))); - assertThat(factorials.get(9l), is(equalTo(362880l))); + assertThat(factorials.get(0l)).isEqualTo(1l); + assertThat(factorials.get(1l)).isEqualTo(1l); + assertThat(factorials.get(2l)).isEqualTo(2l); + assertThat(factorials.get(3l)).isEqualTo(6l); + assertThat(factorials.get(4l)).isEqualTo(24l); + assertThat(factorials.get(5l)).isEqualTo(120l); + assertThat(factorials.get(6l)).isEqualTo(720l); + assertThat(factorials.get(7l)).isEqualTo(5040l); + assertThat(factorials.get(8l)).isEqualTo(40320l); + assertThat(factorials.get(9l)).isEqualTo(362880l); } public static class FactorialsClassLoader implements CacheLoader { diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCacheSecurityIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCacheSecurityIntegrationTests.java index 351bc5e9..3398e5cd 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCacheSecurityIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCacheSecurityIntegrationTests.java @@ -15,9 +15,7 @@ */ package org.springframework.data.gemfire.client; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import java.io.IOException; import java.util.ArrayList; @@ -66,7 +64,7 @@ public class ClientCacheSecurityIntegrationTests extends ForkingClientServerInte arguments.add(String.format("-Dgemfire.name=%1$s", ClientCacheSecurityIntegrationTests.class.getSimpleName().concat("Server"))); arguments.add(String.format("-Djavax.net.ssl.keyStore=%1$s", System.getProperty("javax.net.ssl.keyStore"))); - arguments.add("/org/springframework/data/gemfire/client/ClientCacheSecurityTest-server-context.xml"); + arguments.add(getServerContextXmlFileLocation(ClientCacheSecurityIntegrationTests.class)); startGemFireServer(ServerProcess.class, arguments.toArray(new String[arguments.size()])); } @@ -86,7 +84,7 @@ public class ClientCacheSecurityIntegrationTests extends ForkingClientServerInte @Test public void exampleRegionGet() { - assertThat(String.valueOf(example.get("TestKey")), is(equalTo("TestValue"))); + assertThat(String.valueOf(example.get("TestKey"))).isEqualTo("TestValue"); } @SuppressWarnings("unused") @@ -106,7 +104,8 @@ public class ClientCacheSecurityIntegrationTests extends ForkingClientServerInte public static void main(String[] args) { - String configLocation = "org/springframework/data/gemfire/client/ClientCacheSecurityTest-server-context.xml"; + String configLocation = args.length > 0 ? args[0] + : "org/springframework/data/gemfire/client/ClientCacheSecurityIntegrationTests-server-context.xml"; ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext(configLocation); diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCacheVariableLocatorsIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCacheVariableLocatorsIntegrationTests.java index 43ecbfd1..eabe4329 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCacheVariableLocatorsIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCacheVariableLocatorsIntegrationTests.java @@ -42,12 +42,14 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.util.FileSystemUtils; /** - * IntegrationTests with test cases testing the use of variable "locators" attribute + * IntegrationTests with test cases testing the use of variable {@literal locators} attribute * on <gfe:pool/< in SDG XML namespace configuration metadata when connecting a client/server. * * @author John Blum * @see org.junit.Test - * @see org.junit.runner.RunWith + * @see org.apache.geode.cache.Region + * @see org.springframework.data.gemfire.fork.ServerProcess + * @see org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner * @since 1.6.3 @@ -65,8 +67,7 @@ public class ClientCacheVariableLocatorsIntegrationTests extends ForkingClientSe arguments.add(String.format("-Dgemfire.name=%1$s", ClientCacheVariableLocatorsIntegrationTests.class.getSimpleName().concat("Server"))); - arguments.add("/".concat(ClientCacheVariableLocatorsIntegrationTests.class.getName().replace(".", "/") - .concat("-server-context.xml"))); + arguments.add(getServerContextXmlFileLocation(ClientCacheVariableLocatorsIntegrationTests.class)); startGemFireServer(ServerProcess.class, arguments.toArray(new String[arguments.size()])); } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCacheVariableServersIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCacheVariableServersIntegrationTests.java index df5f4277..fa72acfd 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCacheVariableServersIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCacheVariableServersIntegrationTests.java @@ -42,11 +42,14 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.util.FileSystemUtils; /** - * Integration Tests with test cases testing the use of variable "servers" attribute on <gfe:pool/< - * in SDG XML namespace configuration metadata when connecting a client/server. + * Integration Tests with test cases testing the use of variable {@literal servers} attribute + * on <gfe:pool/< in SDG XML namespace configuration metadata when connecting a client/server. * * @author John Blum * @see org.junit.Test + * @see org.apache.geode.cache.Region + * @see org.springframework.data.gemfire.fork.ServerProcess + * @see org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 1.6.3 @@ -61,9 +64,10 @@ public class ClientCacheVariableServersIntegrationTests extends ForkingClientSer List arguments = new ArrayList(); - arguments.add(String.format("-Dgemfire.name=%1$s", ClientCacheVariableServersIntegrationTests.class.getSimpleName().concat("Server"))); - arguments.add("/".concat(ClientCacheVariableServersIntegrationTests.class.getName().replace(".", "/") - .concat("-server-context.xml"))); + arguments.add(String.format("-Dgemfire.name=%1$s", + ClientCacheVariableServersIntegrationTests.class.getSimpleName().concat("Server"))); + + arguments.add(getServerContextXmlFileLocation(ClientCacheVariableServersIntegrationTests.class)); startGemFireServer(ServerProcess.class, arguments.toArray(new String[arguments.size()])); } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientRegionIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientRegionIntegrationTests.java index b3350026..5ed217fe 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientRegionIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientRegionIntegrationTests.java @@ -70,7 +70,6 @@ public class ClientRegionIntegrationTests extends IntegrationTestsSupport { ClientRegionFactoryBean exampleRegion = new ClientRegionFactoryBean<>(); exampleRegion.setCache(gemfireCache); - exampleRegion.setClose(false); exampleRegion.setShortcut(ClientRegionShortcut.LOCAL); return exampleRegion; diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientRegionWithCacheLoaderWriterTest.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientRegionWithCacheLoaderCacheWriterIntegrationTests.java similarity index 67% rename from spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientRegionWithCacheLoaderWriterTest.java rename to spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientRegionWithCacheLoaderCacheWriterIntegrationTests.java index bda0d346..c28cb0b8 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientRegionWithCacheLoaderWriterTest.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientRegionWithCacheLoaderCacheWriterIntegrationTests.java @@ -13,11 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.springframework.data.gemfire.client; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.assertj.core.api.Assertions.assertThat; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -30,6 +28,7 @@ import org.junit.runner.RunWith; import org.apache.geode.cache.CacheLoader; import org.apache.geode.cache.CacheLoaderException; +import org.apache.geode.cache.CacheWriter; import org.apache.geode.cache.CacheWriterException; import org.apache.geode.cache.EntryEvent; import org.apache.geode.cache.LoaderHelper; @@ -38,33 +37,34 @@ import org.apache.geode.cache.util.CacheWriterAdapter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * The ClientRegionWithCacheLoaderWriterTest class is a test suite of test cases testing the addition of CacheLoaders - * and CacheWriters to a client, local Region inside a GemFire Cache. + * Integration Tests testing the addition of {@link CacheLoader CacheLoaders} and {@link CacheWriter CacheWriters} + * to a client, local {@link Region} cache. * * @author John Blum * @see org.junit.Test - * @see org.junit.runner.RunWith - * @see org.springframework.context.ApplicationContext - * @see org.springframework.test.context.ContextConfiguration - * @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner * @see org.apache.geode.cache.CacheLoader * @see org.apache.geode.cache.CacheWriter * @see org.apache.geode.cache.Region + * @see org.springframework.context.ApplicationContext + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport + * @see org.springframework.test.context.ContextConfiguration + * @see org.springframework.test.context.junit4.SpringRunner * @since 1.3.3 */ @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class ClientRegionWithCacheLoaderWriterTest { +public class ClientRegionWithCacheLoaderCacheWriterIntegrationTests extends IntegrationTestsSupport { private static final int REGION_SIZE = 100; @Autowired - private ApplicationContext context; + private ApplicationContext applicationContext; @Resource(name = "localAppDataRegion") private Region localAppData; @@ -72,25 +72,26 @@ public class ClientRegionWithCacheLoaderWriterTest { @Test public void testCacheLoaderWriter() { - assertNotNull(localAppData); - assertEquals(0, localAppData.size()); + assertThat(localAppData).isNotNull(); + assertThat(localAppData.size()).isEqualTo(0); for (int key = 0; key < REGION_SIZE; key++) { - assertEquals(key + 1, localAppData.get(key).intValue()); + assertThat(localAppData.get(key).intValue()).isEqualTo(key + 1); } - assertEquals(REGION_SIZE, localAppData.size()); + assertThat(localAppData.size()).isEqualTo(REGION_SIZE); for (int key = 0; key < REGION_SIZE; key++) { - assertEquals(key + 1, localAppData.put(key, REGION_SIZE - key).intValue()); + assertThat(localAppData.put(key, REGION_SIZE - key).intValue()).isEqualTo(key + 1); } - LocalAppDataCacheWriter localCacheWriter = context.getBean("localCacheWriter", LocalAppDataCacheWriter.class); + LocalAppDataCacheWriter localCacheWriter = applicationContext + .getBean("localCacheWriter", LocalAppDataCacheWriter.class); - assertNotNull(localCacheWriter); + assertThat(localCacheWriter).isNotNull(); for (int key = 0; key < REGION_SIZE; key++) { - assertEquals(REGION_SIZE - key, localCacheWriter.get(key).intValue()); + assertThat(localCacheWriter.get(key).intValue()).isEqualTo(REGION_SIZE - key); } } @@ -104,8 +105,8 @@ public class ClientRegionWithCacheLoaderWriterTest { } @Override - public void close() { - } + public void close() { } + } public static class LocalAppDataCacheWriter extends CacheWriterAdapter { @@ -113,13 +114,12 @@ public class ClientRegionWithCacheLoaderWriterTest { private static final Map data = new ConcurrentHashMap<>(REGION_SIZE); @Override - public void beforeUpdate(final EntryEvent event) throws CacheWriterException { + public void beforeUpdate(EntryEvent event) throws CacheWriterException { data.put(event.getKey(), event.getNewValue()); } - public Integer get(final Integer key) { + public Integer get(Integer key) { return data.get(key); } } - } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientSubRegionIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientSubRegionIntegrationTests.java index 4b227636..b8ca3458 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientSubRegionIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientSubRegionIntegrationTests.java @@ -34,7 +34,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * Integration Tests testing {@link Region sub-Region} functionality from a cache client. + * Integration Tests for client {@link Region sub-Region} configuration. * * @author John Blum * @see org.junit.Test @@ -51,7 +51,7 @@ import org.springframework.test.context.junit4.SpringRunner; public class ClientSubRegionIntegrationTests extends ForkingClientServerIntegrationTestsSupport { @BeforeClass - public static void startGemFireServer() throws Exception { + public static void startGeodeServer() throws Exception { startGemFireServer(ServerProcess.class, getServerContextXmlFileLocation(ClientSubRegionIntegrationTests.class)); } @@ -76,6 +76,7 @@ public class ClientSubRegionIntegrationTests extends ForkingClientServerIntegrat } private void assertRegion(Region region, String name, String fullPath) { + assertThat(region).isNotNull(); assertThat(region.getName()).isEqualTo(name); assertThat(region.getFullPath()).isEqualTo(fullPath); @@ -84,9 +85,11 @@ public class ClientSubRegionIntegrationTests extends ForkingClientServerIntegrat @Test public void gemFireSubRegionCreationConfigurationIsCorrect() { - assertThat(clientCache).describedAs("The Client Cache was not properly initialized!").isNotNull(); + assertThat(this.clientCache) + .describedAs("The Client Cache was not properly initialized!") + .isNotNull(); - Region parent = clientCache.getRegion("Parent"); + Region parent = this.clientCache.getRegion("Parent"); assertRegion(parent, "Parent"); @@ -94,7 +97,7 @@ public class ClientSubRegionIntegrationTests extends ForkingClientServerIntegrat assertRegion(child, "Child", "/Parent/Child"); - Region clientCacheChild = clientCache.getRegion("/Parent/Child"); + Region clientCacheChild = this.clientCache.getRegion("/Parent/Child"); assertThat(child).isSameAs(clientCacheChild); } @@ -102,16 +105,16 @@ public class ClientSubRegionIntegrationTests extends ForkingClientServerIntegrat @Test public void springSubRegionCreationConfigurationIsCorrect() { - assertRegion(parent, "Parent"); - assertRegion(child, "Child", "/Parent/Child"); + assertRegion(this.parent, "Parent"); + assertRegion(this.child, "Child", "/Parent/Child"); } @Test public void templateCreationConfigurationIsCorrect() { - assertThat(parentTemplate).isNotNull(); - assertThat(parentTemplate.getRegion()).isSameAs(parent); - assertThat(childTemplate).isNotNull(); - assertThat(childTemplate.getRegion()).isSameAs(child); + assertThat(this.parentTemplate).isNotNull(); + assertThat(this.parentTemplate.getRegion()).isSameAs(this.parent); + assertThat(this.childTemplate).isNotNull(); + assertThat(this.childTemplate.getRegion()).isSameAs(this.child); } } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/DurableClientCacheIntegrationTest.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/DurableClientCacheIntegrationTests.java similarity index 93% rename from spring-data-geode/src/test/java/org/springframework/data/gemfire/client/DurableClientCacheIntegrationTest.java rename to spring-data-geode/src/test/java/org/springframework/data/gemfire/client/DurableClientCacheIntegrationTests.java index ff99e1e8..3b6447c5 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/DurableClientCacheIntegrationTest.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/DurableClientCacheIntegrationTests.java @@ -53,6 +53,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.data.gemfire.GemfireUtils; +import org.springframework.data.gemfire.fork.ServerProcess; import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport; import org.springframework.data.gemfire.tests.util.ThreadUtils; import org.springframework.data.gemfire.util.DistributedSystemUtils; @@ -80,7 +81,7 @@ import org.springframework.util.Assert; @FixMethodOrder(MethodSorters.NAME_ASCENDING) @ContextConfiguration @SuppressWarnings("all") -public class DurableClientCacheIntegrationTest extends ForkingClientServerIntegrationTestsSupport { +public class DurableClientCacheIntegrationTests extends ForkingClientServerIntegrationTestsSupport { private static final boolean DEBUG = true; @@ -90,19 +91,20 @@ public class DurableClientCacheIntegrationTest extends ForkingClientServerIntegr Collections.synchronizedList(new ArrayList()); private static final String CACHE_SERVER_PORT = - DurableClientCacheIntegrationTest.class.getName().concat(".cache-server-port"); + DurableClientCacheIntegrationTests.class.getName().concat(".cache-server-port"); private static final String CLIENT_CACHE_INTERESTS_RESULT_POLICY = - DurableClientCacheIntegrationTest.class.getName().concat(".interests-result-policy"); + DurableClientCacheIntegrationTests.class.getName().concat(".interests-result-policy"); private static final String DURABLE_CLIENT_TIMEOUT = - DurableClientCacheIntegrationTest.class.getName().concat(".durable-client-timeout"); + DurableClientCacheIntegrationTests.class.getName().concat(".durable-client-timeout"); private static final String SERVER_HOST = "localhost"; @BeforeClass - public static void startGemFireServer() throws IOException { - startGemFireServer(DurableClientCacheIntegrationTest.class); + public static void startGeodeServer() throws IOException { + startGemFireServer(ServerProcess.class, + getServerContextXmlFileLocation(DurableClientCacheIntegrationTests.class)); } private static boolean isAfterDirtiesContext() { @@ -138,7 +140,7 @@ public class DurableClientCacheIntegrationTest extends ForkingClientServerIntegr assertThat(distributedSystemProperties).isNotNull(); assertThat(distributedSystemProperties.getProperty(DistributedSystemUtils.DURABLE_CLIENT_ID_PROPERTY_NAME)) - .isEqualTo(DurableClientCacheIntegrationTest.class.getSimpleName()); + .isEqualTo(DurableClientCacheIntegrationTests.class.getSimpleName()); assertThat(distributedSystemProperties.getProperty(DistributedSystemUtils.DURABLE_CLIENT_TIMEOUT_PROPERTY_NAME)) .isEqualTo(valueBeforeAndAfterDirtiesContext("300", "600")); diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/GemFireDataSourceIntegrationTest.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/GemFireDataSourceIntegrationTest.java index 9dfcbc48..73cc1cf0 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/GemFireDataSourceIntegrationTest.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/GemFireDataSourceIntegrationTest.java @@ -51,6 +51,7 @@ import org.springframework.util.FileSystemUtils; * @see org.apache.geode.cache.Region * @see org.apache.geode.cache.client.ClientCache * @see org.springframework.data.gemfire.client.GemfireDataSourcePostProcessor + * @see org.springframework.data.gemfire.fork.ServerProcess * @see org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner @@ -62,16 +63,16 @@ import org.springframework.util.FileSystemUtils; public class GemFireDataSourceIntegrationTest extends ForkingClientServerIntegrationTestsSupport { @BeforeClass - public static void startGemFireServer() throws IOException { + public static void startGeodeServer() throws IOException { List arguments = new ArrayList<>(); - arguments.add(String.format("-Dgemfire.name=%s", GemFireDataSourceIntegrationTest.class.getSimpleName().concat("Server"))); - arguments.add(GemFireDataSourceIntegrationTest.class.getName() - .replace(".", "/").concat("-server-context.xml")); + arguments.add(String.format("-Dgemfire.name=%s", + GemFireDataSourceIntegrationTest.class.getSimpleName().concat("Server"))); + + arguments.add(getServerContextXmlFileLocation(GemFireDataSourceIntegrationTest.class)); startGemFireServer(ServerProcess.class, arguments.toArray(new String[0])); - } @AfterClass diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/GemFireDataSourceIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/GemFireDataSourceIntegrationTests.java index da8b3534..73e67837 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/GemFireDataSourceIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/GemFireDataSourceIntegrationTests.java @@ -42,6 +42,12 @@ import org.springframework.test.context.junit4.SpringRunner; * @author David Turanski * @author John Blum * @see org.junit.Test + * @see org.apache.geode.cache.Region + * @see org.springframework.data.gemfire.fork.ServerProcess + * @see org.springframework.data.gemfire.client.GemfireDataSourcePostProcessor + * @see org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport + * @see org.springframework.test.context.ContextConfiguration + * @see org.springframework.test.context.junit4.SpringRunner */ @RunWith(SpringRunner.class) @ContextConfiguration @@ -50,7 +56,7 @@ import org.springframework.test.context.junit4.SpringRunner; public class GemFireDataSourceIntegrationTests extends ForkingClientServerIntegrationTestsSupport { @BeforeClass - public static void startGemFireServer() throws Exception { + public static void startGeodeServer() throws Exception { startGemFireServer(ServerProcess.class, getServerContextXmlFileLocation(GemFireDataSourceIntegrationTests.class)); } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTests.java index e989cb78..80906f15 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTests.java @@ -60,7 +60,12 @@ import org.springframework.util.StringUtils; * * @author John Blum * @see org.junit.Test + * @see org.apache.geode.cache.Region + * @see org.apache.geode.cache.client.ClientCache * @see org.springframework.data.gemfire.client.GemfireDataSourcePostProcessor + * @see org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport + * @see org.springframework.test.context.ContextConfiguration + * @see org.springframework.test.context.junit4.SpringRunner * @since 1.7.0 */ @RunWith(SpringRunner.class) @@ -102,12 +107,6 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe GemFireBasedServerProcess.getServerProcessControlFilename()); } - private static void writeAsCacheXmlFileToDirectory(String classpathResource, File serverWorkingDirectory) throws IOException { - - FileCopyUtils.copy(new ClassPathResource(classpathResource).getInputStream(), - new FileOutputStream(new File(serverWorkingDirectory, "cache.xml"))); - } - private static String customClasspath() { String[] classpathElements = ProcessExecutor.JAVA_CLASSPATH.split(File.pathSeparator); @@ -123,6 +122,12 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe return StringUtils.collectionToDelimitedString(customClasspath, File.pathSeparator); } + private static void writeAsCacheXmlFileToDirectory(String classpathResource, File serverWorkingDirectory) throws IOException { + + FileCopyUtils.copy(new ClassPathResource(classpathResource).getInputStream(), + new FileOutputStream(new File(serverWorkingDirectory, "cache.xml"))); + } + private static void waitForProcessStart(long milliseconds, ProcessWrapper process, String processControlFilename) { ThreadUtils.timedWait(milliseconds, TimeUnit.MILLISECONDS.toMillis(500), new ThreadUtils.Condition() { @@ -139,6 +144,8 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe @AfterClass public static void stopGemFireServer() { + stop(gemfireServer); + if (Boolean.parseBoolean(System.getProperty("spring.gemfire.fork.clean", String.valueOf(true)))) { org.springframework.util.FileSystemUtils.deleteRecursively(gemfireServer.getWorkingDirectory()); } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/LocalOnlyClientCacheIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/LocalOnlyClientCacheIntegrationTests.java index 6de27e9f..b9e12251 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/LocalOnlyClientCacheIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/LocalOnlyClientCacheIntegrationTests.java @@ -36,21 +36,27 @@ import org.springframework.data.gemfire.config.annotation.ClientCacheApplication import org.springframework.data.gemfire.config.annotation.EnableEntityDefinedRegions; import org.springframework.data.gemfire.test.model.Gender; import org.springframework.data.gemfire.test.model.Person; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * Integration tests testing the configuration of a {@link ClientRegionShortcut#LOCAL} + * Integration Tests testing the configuration of a {@link ClientRegionShortcut#LOCAL} * {@link ClientCache} {@link Region}. * * @author John Blum * @see org.junit.Test + * @see org.apache.geode.cache.Region + * @see org.apache.geode.cache.client.ClientCache + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport + * @see org.springframework.test.context.ContextConfiguration + * @see org.springframework.test.context.junit4.SpringRunner * @since 1.6.3 */ @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class LocalOnlyClientCacheIntegrationTests { +public class LocalOnlyClientCacheIntegrationTests extends IntegrationTestsSupport { @Resource(name = "People") private Region people; @@ -81,9 +87,9 @@ public class LocalOnlyClientCacheIntegrationTests { assertThat(this.people).hasSize(1); } - @ClientCacheApplication(logLevel = "error") + @ClientCacheApplication @EnableEntityDefinedRegions(basePackageClasses = Person.class, clientRegionShortcut = ClientRegionShortcut.LOCAL, strict = true) - static class GemFireClientCacheConfiguration { } + static class TestConfiguration { } } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/SpELExpressionConfiguredPoolsIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/SpELExpressionConfiguredPoolsIntegrationTests.java index 328fb256..cee22d73 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/SpELExpressionConfiguredPoolsIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/SpELExpressionConfiguredPoolsIntegrationTests.java @@ -190,19 +190,25 @@ public class SpELExpressionConfiguredPoolsIntegrationTests extends IntegrationTe } public static class AnotherServerPoolFactoryBean extends TestPoolFactoryBean { - @Override ConnectionEndpointList getServerList() { + + @Override + ConnectionEndpointList getServerList() { return anotherServers; } } public static class LocatorPoolFactoryBean extends TestPoolFactoryBean { - @Override ConnectionEndpointList getLocatorList() { + + @Override + ConnectionEndpointList getLocatorList() { return locators; } } public static class ServerPoolFactoryBean extends TestPoolFactoryBean { - @Override ConnectionEndpointList getServerList() { + + @Override + ConnectionEndpointList getServerList() { return servers; } } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/support/ClientCacheFactoryCacheResolverIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/support/ClientCacheFactoryCacheResolverIntegrationTests.java index b09d0c4b..bd4a9984 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/support/ClientCacheFactoryCacheResolverIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/support/ClientCacheFactoryCacheResolverIntegrationTests.java @@ -29,6 +29,7 @@ import org.apache.geode.cache.GemFireCache; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.gemfire.GemfireUtils; import org.springframework.data.gemfire.config.annotation.ClientCacheApplication; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -42,6 +43,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.apache.geode.cache.client.ClientCache * @see org.springframework.data.gemfire.client.support.ClientCacheFactoryCacheResolver * @see org.springframework.data.gemfire.config.annotation.ClientCacheApplication + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 2.3.0 @@ -49,7 +51,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class ClientCacheFactoryCacheResolverIntegrationTests { +public class ClientCacheFactoryCacheResolverIntegrationTests extends IntegrationTestsSupport { @Autowired private GemFireCache clientCache; diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/support/PoolManagerPoolResolverIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/support/PoolManagerPoolResolverIntegrationTests.java index 37a84039..e7357988 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/support/PoolManagerPoolResolverIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/support/PoolManagerPoolResolverIntegrationTests.java @@ -37,6 +37,7 @@ import org.springframework.data.gemfire.client.PoolResolver; import org.springframework.data.gemfire.config.annotation.ClientCacheApplication; import org.springframework.data.gemfire.config.annotation.EnablePool; import org.springframework.data.gemfire.config.annotation.EnablePools; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -50,6 +51,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.apache.geode.cache.client.PoolManager * @see org.springframework.data.gemfire.client.PoolResolver * @see org.springframework.data.gemfire.client.support.PoolManagerPoolResolver + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 2.3.0 @@ -57,7 +59,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class PoolManagerPoolResolverIntegrationTests { +public class PoolManagerPoolResolverIntegrationTests extends IntegrationTestsSupport { @Autowired private ClientCache clientCache; @@ -72,7 +74,7 @@ public class PoolManagerPoolResolverIntegrationTests { @Qualifier("SwimmingPool") private Pool swimmingPool; - private PoolResolver poolResolver = new PoolManagerPoolResolver(); + private final PoolResolver poolResolver = new PoolManagerPoolResolver(); @Resource(name = "RegionWithDefaultPool") private Region regionWithDefaultPool; @@ -129,7 +131,7 @@ public class PoolManagerPoolResolverIntegrationTests { @Test public void resolvePoolFromNullRegionIsNullSafeAndReturnsNull() { - assertThat(this.poolResolver.resolve((Region) null)).isNull(); + assertThat(this.poolResolver.resolve((Region) null)).isNull(); } @ClientCacheApplication(name = "PoolManagerPoolResolverIntegrationTests") @@ -141,7 +143,7 @@ public class PoolManagerPoolResolverIntegrationTests { static class TestConfiguration { @Bean("RegionWithDefaultPool") - ClientRegionFactoryBean regionWithDefaultPool(ClientCache clientCache) { + ClientRegionFactoryBean regionWithDefaultPool(ClientCache clientCache) { ClientRegionFactoryBean clientRegion = new ClientRegionFactoryBean<>(); @@ -153,7 +155,7 @@ public class PoolManagerPoolResolverIntegrationTests { @Bean("RegionWithSwimmingPool") @DependsOn("SwimmingPool") - ClientRegionFactoryBean regionWithNamedPool(ClientCache clientCache) { + ClientRegionFactoryBean regionWithNamedPool(ClientCache clientCache) { ClientRegionFactoryBean clientRegion = new ClientRegionFactoryBean<>(); diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ApacheGeodeSecurityManagerSecurityIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ApacheGeodeSecurityManagerSecurityIntegrationTests.java index 8a998431..9e51d6d4 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ApacheGeodeSecurityManagerSecurityIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ApacheGeodeSecurityManagerSecurityIntegrationTests.java @@ -42,8 +42,14 @@ import org.springframework.test.context.junit4.SpringRunner; * {@link org.apache.geode.security.SecurityManager}. * * @author John Blum + * @see org.junit.Test + * @see org.apache.geode.security.SecurityManager * @see org.springframework.data.gemfire.config.annotation.AbstractGeodeSecurityIntegrationTests - * @since 1.0.0 + * @see org.springframework.data.gemfire.config.annotation.EnableSecurity + * @see org.springframework.test.context.ActiveProfiles + * @see org.springframework.test.context.ContextConfiguration + * @see org.springframework.test.context.junit4.SpringRunner + * @since 2.0.0 */ @RunWith(SpringRunner.class) @ContextConfiguration(classes = AbstractGeodeSecurityIntegrationTests.GeodeClientConfiguration.class) @@ -54,7 +60,7 @@ public class ApacheGeodeSecurityManagerSecurityIntegrationTests extends Abstract "geode-security-manager-property-configuration"; @BeforeClass - public static void setup() throws IOException { + public static void startGeodeServer() throws IOException { runGeodeServer(GEODE_SECURITY_MANAGER_PROPERTY_CONFIGURATION_PROFILE); } @@ -62,8 +68,7 @@ public class ApacheGeodeSecurityManagerSecurityIntegrationTests extends Abstract @EnableSecurity(securityManagerClassName = "org.springframework.data.gemfire.config.annotation.ApacheGeodeSecurityManagerSecurityIntegrationTests$TestGeodeSecurityManager") @Profile(GEODE_SECURITY_MANAGER_PROPERTY_CONFIGURATION_PROFILE) - public static class ApacheGeodeSecurityManagerConfiguration { - } + public static class ApacheGeodeSecurityManagerConfiguration { } protected interface GeodeSecurityRepository { diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ApacheShiroIniSecurityIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ApacheShiroIniSecurityIntegrationTests.java index 71e1ed40..1662f1a9 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ApacheShiroIniSecurityIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ApacheShiroIniSecurityIntegrationTests.java @@ -31,8 +31,12 @@ import org.springframework.test.context.junit4.SpringRunner; * Integration tests for Apache Geode Integrated Security using an Apache Shiro INI security configuration resource. * * @author John Blum + * @see org.junit.Test * @see org.springframework.data.gemfire.config.annotation.AbstractGeodeSecurityIntegrationTests - * @since 1.0.0 + * @see org.springframework.test.context.ActiveProfiles + * @see org.springframework.test.context.ContextConfiguration + * @see org.springframework.test.context.junit4.SpringRunner + * @since 2.0.0 */ @RunWith(SpringRunner.class) @ContextConfiguration(classes = AbstractGeodeSecurityIntegrationTests.GeodeClientConfiguration.class) @@ -42,7 +46,7 @@ public class ApacheShiroIniSecurityIntegrationTests extends AbstractGeodeSecurit protected static final String SHIRO_INI_CONFIGURATION_PROFILE = "shiro-ini-configuration"; @BeforeClass - public static void setup() throws IOException { + public static void startGeodeServer() throws IOException { runGeodeServer(SHIRO_INI_CONFIGURATION_PROFILE); } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ApacheShiroRealmSecurityIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ApacheShiroRealmSecurityIntegrationTests.java index 9ebb3b4a..fe6eab87 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ApacheShiroRealmSecurityIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ApacheShiroRealmSecurityIntegrationTests.java @@ -37,8 +37,12 @@ import org.springframework.test.context.junit4.SpringRunner; * as a Spring managed bean in a Spring {@link org.springframework.context.ApplicationContext}. * * @author John Blum + * @see org.junit.Test + * @see org.apache.shiro.realm.text.PropertiesRealm * @see org.springframework.data.gemfire.config.annotation.AbstractGeodeSecurityIntegrationTests - * @since 1.0.0 + * @see org.springframework.test.context.ContextConfiguration + * @see org.springframework.test.context.junit4.SpringRunner + * @since 2.0.0 */ @RunWith(SpringRunner.class) @ContextConfiguration(classes = AbstractGeodeSecurityIntegrationTests.GeodeClientConfiguration.class) @@ -48,7 +52,7 @@ public class ApacheShiroRealmSecurityIntegrationTests extends AbstractGeodeSecur protected static final String SHIRO_REALM_CONFIGURATION_PROFILE = "shiro-realm-configuration"; @BeforeClass - public static void setup() throws IOException { + public static void startGeodeServer() throws IOException { runGeodeServer(SHIRO_REALM_CONFIGURATION_PROFILE); } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/CacheServerConfigurerIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/CacheServerConfigurerIntegrationTests.java index 72b14c19..da6278bb 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/CacheServerConfigurerIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/CacheServerConfigurerIntegrationTests.java @@ -43,6 +43,8 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.mockito.Mockito * @see org.apache.geode.cache.server.CacheServer * @see org.springframework.context.annotation.Configuration + * @see org.springframework.data.gemfire.config.annotation.AddCacheServerConfiguration + * @see org.springframework.data.gemfire.config.annotation.AddCacheServersConfiguration * @see org.springframework.data.gemfire.config.annotation.CacheServerConfigurer * @see org.springframework.data.gemfire.config.annotation.EnableCacheServer * @see org.springframework.data.gemfire.config.annotation.EnableCacheServers diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/CachingDefinedRegionsAppliesRegionConfigurersIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/CachingDefinedRegionsAppliesRegionConfigurersIntegrationTests.java index 2e31bb98..ced3a808 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/CachingDefinedRegionsAppliesRegionConfigurersIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/CachingDefinedRegionsAppliesRegionConfigurersIntegrationTests.java @@ -51,6 +51,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.springframework.cache.annotation.Cacheable * @see org.springframework.data.gemfire.config.annotation.CachingDefinedRegionsConfiguration * @see org.springframework.data.gemfire.config.annotation.EnableCachingDefinedRegions + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/CachingDefinedRegionsUsesCacheConfigCacheNamesIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/CachingDefinedRegionsUsesCacheConfigCacheNamesIntegrationTests.java index bed225cc..049bd037 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/CachingDefinedRegionsUsesCacheConfigCacheNamesIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/CachingDefinedRegionsUsesCacheConfigCacheNamesIntegrationTests.java @@ -24,19 +24,20 @@ import java.util.stream.Collectors; import javax.annotation.Resource; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.client.ClientCache; -import org.apache.geode.cache.client.ClientRegionShortcut; - import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.apache.geode.cache.Region; +import org.apache.geode.cache.client.ClientCache; +import org.apache.geode.cache.client.ClientRegionShortcut; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.Cacheable; import org.springframework.context.annotation.Bean; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.gemfire.util.CollectionUtils; import org.springframework.stereotype.Service; import org.springframework.test.context.ContextConfiguration; @@ -54,6 +55,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.springframework.cache.annotation.Cacheable * @see org.springframework.data.gemfire.config.annotation.EnableCachingDefinedRegions * @see org.springframework.data.gemfire.config.annotation.CachingDefinedRegionsConfiguration + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @see Add support for @CacheConfig in @EnableCachingDefinedRegions @@ -62,9 +64,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class CachingDefinedRegionsUsesCacheConfigCacheNamesIntegrationTests { - - private static final String LOG_LEVEL = "error"; +public class CachingDefinedRegionsUsesCacheConfigCacheNamesIntegrationTests extends IntegrationTestsSupport { @Autowired private ClientCache clientCache; @@ -117,7 +117,6 @@ public class CachingDefinedRegionsUsesCacheConfigCacheNamesIntegrationTests { assertThat(region).doesNotContainKey("0"); assertThat(region).isEmpty(); }); - } @Test @@ -132,7 +131,6 @@ public class CachingDefinedRegionsUsesCacheConfigCacheNamesIntegrationTests { @Test public void cacheableMethodTwoCachesToCOnly() { - assertThat(this.service.cacheableMethodTwo("3")).isEqualTo("TWO"); Collections.singletonList(this.c).forEach(region -> assertThat(region).containsKey("3")); @@ -142,14 +140,13 @@ public class CachingDefinedRegionsUsesCacheConfigCacheNamesIntegrationTests { @Test public void cacheableMethodThreeCachesToAAndD() { - assertThat(this.service.cacheableMethodThree("4")).isEqualTo("THREE"); Arrays.asList(this.a, this.d).forEach(region -> assertThat(region).containsKey("4")); Arrays.asList(this.b, this.c).forEach(region -> assertThat(region).isEmpty()); } - @ClientCacheApplication(name = "CachingDefinedRegionsUsesCacheConfigCacheNamesIntegrationTests", logLevel = LOG_LEVEL) + @ClientCacheApplication @EnableCachingDefinedRegions(clientRegionShortcut = ClientRegionShortcut.LOCAL) static class TestConfiguration { diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ClientCacheApplicationIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ClientCacheApplicationIntegrationTests.java index aba906c8..5a13f96e 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ClientCacheApplicationIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ClientCacheApplicationIntegrationTests.java @@ -31,6 +31,7 @@ import org.apache.geode.cache.client.ClientRegionShortcut; import org.springframework.context.annotation.Bean; import org.springframework.data.gemfire.client.ClientRegionFactoryBean; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -44,6 +45,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.springframework.context.annotation.Bean * @see org.springframework.data.gemfire.client.ClientRegionFactoryBean * @see org.springframework.data.gemfire.config.annotation.ClientCacheApplication + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 2.1.0 @@ -51,19 +53,20 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class ClientCacheApplicationIntegrationTests { +public class ClientCacheApplicationIntegrationTests extends IntegrationTestsSupport { @Resource(name = "Echo") private Region echo; @Test public void echoClientRegionEchoesKeysAsValues() { + assertThat(this.echo.get("hello")).isEqualTo("hello"); assertThat(this.echo.get("test")).isEqualTo("test"); assertThat(this.echo.get("good-bye")).isEqualTo("good-bye"); } - @ClientCacheApplication(name = "ClientCacheApplicationIntegrationTests", logLevel = "error") + @ClientCacheApplication static class TestConfiguration { @Bean("Echo") diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ClientCacheConfigurerIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ClientCacheConfigurerIntegrationTests.java index 89d8b84e..dd2e52f9 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ClientCacheConfigurerIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ClientCacheConfigurerIntegrationTests.java @@ -59,8 +59,6 @@ public class ClientCacheConfigurerIntegrationTests extends IntegrationTestsSuppo private static final AtomicBoolean testClientCacheConfigurerThreeCalled = new AtomicBoolean(false); - private static final String GEMFIRE_LOG_LEVEL = "error"; - @Autowired private ClientCache clientCache; @@ -100,8 +98,8 @@ public class ClientCacheConfigurerIntegrationTests extends IntegrationTestsSuppo assertThat(testClientCacheConfigurerThreeCalled.get()).isTrue(); } + @ClientCacheApplication @EnableGemFireMockObjects - @ClientCacheApplication(logLevel = GEMFIRE_LOG_LEVEL) static class TestConfiguration { @Bean diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ClientServerCacheApplicationIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ClientServerCacheApplicationIntegrationTests.java index a0717139..366f8087 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ClientServerCacheApplicationIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ClientServerCacheApplicationIntegrationTests.java @@ -47,6 +47,7 @@ import org.springframework.test.context.junit4.SpringRunner; * * @author John Blum * @see org.junit.Test + * @see org.apache.geode.cache.Region * @see org.apache.geode.cache.client.ClientCache * @see org.apache.geode.cache.server.CacheServer * @see org.springframework.data.gemfire.config.annotation.CacheServerApplication @@ -57,13 +58,13 @@ import org.springframework.test.context.junit4.SpringRunner; * @since 1.9.0 */ @RunWith(SpringRunner.class) -@ContextConfiguration(classes = ClientServerCacheApplicationIntegrationTests.ClientTestConfiguration.class) +@ContextConfiguration(classes = ClientServerCacheApplicationIntegrationTests.GeodeClientTestConfiguration.class) @SuppressWarnings("all") public class ClientServerCacheApplicationIntegrationTests extends ForkingClientServerIntegrationTestsSupport { @BeforeClass - public static void setupGemFireServer() throws Exception { - startGemFireServer(ServerTestConfiguration.class); + public static void startGeodeServer() throws Exception { + startGemFireServer(GeodeServerTestConfiguration.class); } @Autowired @@ -79,7 +80,7 @@ public class ClientServerCacheApplicationIntegrationTests extends ForkingClientS } @ClientCacheApplication - static class ClientTestConfiguration { + static class GeodeClientTestConfiguration { @Bean(name = "Echo") ClientRegionFactoryBean echoRegion(ClientCache gemfireCache) { @@ -95,10 +96,10 @@ public class ClientServerCacheApplicationIntegrationTests extends ForkingClientS } @CacheServerApplication(name = "ClientServerCacheApplicationIntegrationTests") - public static class ServerTestConfiguration { + public static class GeodeServerTestConfiguration { public static void main(String[] args) { - runSpringApplication(ServerTestConfiguration.class, args); + runSpringApplication(GeodeServerTestConfiguration.class, args); } @Bean("Echo") diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ClusterConfigurationWithClientHttpRequestInterceptorsIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ClusterConfigurationWithClientHttpRequestInterceptorsIntegrationTests.java index 3cfae06b..762fac84 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ClusterConfigurationWithClientHttpRequestInterceptorsIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/ClusterConfigurationWithClientHttpRequestInterceptorsIntegrationTests.java @@ -22,9 +22,7 @@ import static org.mockito.Mockito.spy; import static org.springframework.data.gemfire.config.annotation.ClusterConfigurationConfiguration.ClusterSchemaObjectInitializer; import static org.springframework.data.gemfire.config.annotation.ClusterConfigurationConfiguration.SchemaObjectContext; -import java.lang.reflect.Field; import java.util.List; -import java.util.Optional; import org.junit.Before; import org.junit.Test; @@ -43,12 +41,12 @@ import org.springframework.data.gemfire.config.admin.remote.RestHttpGemfireAdmin import org.springframework.data.gemfire.config.support.RestTemplateConfigurer; import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects; +import org.springframework.data.gemfire.tests.util.ReflectionUtils; import org.springframework.http.client.ClientHttpRequestInterceptor; import org.springframework.http.client.InterceptingClientHttpRequestFactory; import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.util.ReflectionUtils; import org.springframework.web.client.RestTemplate; /** @@ -107,23 +105,6 @@ public class ClusterConfigurationWithClientHttpRequestInterceptorsIntegrationTes @Qualifier("testRestTemplateConfigurerTwo") private RestTemplateConfigurer restTemplateConfigurerTwo; - // TODO: Replace with STDG - @SuppressWarnings("unchecked") - private T getFieldValue(Object target, String fieldName) throws NoSuchFieldException { - - Field field = ReflectionUtils.findField(target.getClass(), fieldName); - - return Optional.ofNullable(field) - .map(it -> { - ReflectionUtils.makeAccessible(it); - return field; - }) - .map(it -> (T) ReflectionUtils.getField(it, target)) - .orElseThrow(() -> - new NoSuchFieldException(String.format("Field with name [%s] was not found on Object of type [%s]", - fieldName, target.getClass().getName()))); - } - @Before public void setupIsCorrect() { @@ -158,7 +139,7 @@ public class ClusterConfigurationWithClientHttpRequestInterceptorsIntegrationTes RestHttpGemfireAdminTemplate template = schemaObjectContext.getGemfireAdminOperations(); - this.theRestTemplate = getFieldValue(template, "restTemplate"); + this.theRestTemplate = ReflectionUtils.getFieldValue(template, "restTemplate"); assertThat(this.theRestTemplate).isNotNull(); } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/DiskStoreConfigurerIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/DiskStoreConfigurerIntegrationTests.java index af6a95ff..ba9add85 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/DiskStoreConfigurerIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/DiskStoreConfigurerIntegrationTests.java @@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.data.gemfire.DiskStoreFactoryBean; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.gemfire.tests.mock.beans.factory.config.GemFireMockObjectsBeanPostProcessor; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -48,6 +49,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.springframework.data.gemfire.config.annotation.DiskStoreConfigurer * @see org.springframework.data.gemfire.config.annotation.EnableDiskStore * @see org.springframework.data.gemfire.config.annotation.EnableDiskStores + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.data.gemfire.tests.mock.beans.factory.config.GemFireMockObjectsBeanPostProcessor * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner @@ -56,7 +58,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class DiskStoreConfigurerIntegrationTests { +public class DiskStoreConfigurerIntegrationTests extends IntegrationTestsSupport { @Autowired @Qualifier("configurerOne") @@ -67,6 +69,7 @@ public class DiskStoreConfigurerIntegrationTests { private TestDiskStoreConfigurer configurerTwo; private void assertDiskStoreConfigurerCalled(TestDiskStoreConfigurer configurer, String... beanNames) { + assertThat(configurer).isNotNull(); assertThat(configurer).hasSize(beanNames.length); assertThat(configurer).contains(beanNames); diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableCachingDefinedRegionsIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableCachingDefinedRegionsIntegrationTests.java index 951bb246..5b0d44d7 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableCachingDefinedRegionsIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableCachingDefinedRegionsIntegrationTests.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.springframework.data.gemfire.config.annotation; import static org.assertj.core.api.Assertions.assertThat; @@ -36,20 +35,28 @@ import org.springframework.cache.annotation.CachePut; import org.springframework.cache.annotation.Cacheable; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.stereotype.Service; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * The EnableCachingDefinedRegionsIntegrationTests class... + * Integration Tests for {@link EnableCachingDefinedRegions} and {@link CachingDefinedRegionsConfiguration}. * * @author John Blum - * @since 1.0.0 + * @see org.apache.geode.cache.GemFireCache + * @see org.apache.geode.cache.Region + * @see org.springframework.data.gemfire.config.annotation.CachingDefinedRegionsConfiguration + * @see org.springframework.data.gemfire.config.annotation.EnableCachingDefinedRegions + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport + * @see org.springframework.test.context.ContextConfiguration + * @see org.springframework.test.context.junit4.SpringRunner + * @since 2.0.0 */ @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class EnableCachingDefinedRegionsIntegrationTests { +public class EnableCachingDefinedRegionsIntegrationTests extends IntegrationTestsSupport { @Autowired private ApplicationContext applicationContext; diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableClusterConfigurationIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableClusterConfigurationIntegrationTests.java index f0702715..05522b5a 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableClusterConfigurationIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableClusterConfigurationIntegrationTests.java @@ -60,12 +60,10 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.springframework.context.annotation.Bean * @see org.springframework.context.annotation.Configuration * @see org.springframework.context.annotation.Import - * @see org.springframework.data.gemfire.IndexFactoryBean * @see org.springframework.data.gemfire.client.ClientRegionFactoryBean * @see org.springframework.data.gemfire.config.admin.GemfireAdminOperations * @see org.springframework.data.gemfire.config.annotation.ClusterConfigurationConfiguration * @see org.springframework.data.gemfire.config.annotation.EnableClusterConfiguration - * @see org.springframework.data.gemfire.process.ProcessWrapper * @see org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner @@ -83,7 +81,7 @@ public class EnableClusterConfigurationIntegrationTests extends ForkingClientSer @BeforeClass public static void startGemFireServer() throws Exception { - startGemFireServer(ServerTestConfiguration.class); + startGemFireServer(GeodeServerTestConfiguration.class); } @Before @@ -112,11 +110,11 @@ public class EnableClusterConfigurationIntegrationTests extends ForkingClientSer @Configuration @EnableClusterConfiguration - @Import(ClientTestConfiguration.class) + @Import(GeodeClientTestConfiguration.class) static class TestConfiguration { } @ClientCacheApplication(subscriptionEnabled = true) - static class ClientTestConfiguration { + static class GeodeClientTestConfiguration { @Bean ClientCacheConfigurer clientCachePoolPortConfigurer( @@ -178,12 +176,12 @@ public class EnableClusterConfigurationIntegrationTests extends ForkingClientSer } @CacheServerApplication(name = "EnableClusterConfigurationIntegrationTests") - static class ServerTestConfiguration { + static class GeodeServerTestConfiguration { public static void main(String[] args) { AnnotationConfigApplicationContext applicationContext = - new AnnotationConfigApplicationContext(ServerTestConfiguration.class); + new AnnotationConfigApplicationContext(GeodeServerTestConfiguration.class); applicationContext.registerShutdownHook(); } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableClusterConfigurationWithSecurityIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableClusterConfigurationWithSecurityIntegrationTests.java index 635306bd..d26ab6e4 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableClusterConfigurationWithSecurityIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableClusterConfigurationWithSecurityIntegrationTests.java @@ -73,6 +73,7 @@ import org.springframework.web.client.RestTemplate; * @see org.springframework.core.env.ConfigurableEnvironment * @see org.springframework.core.env.PropertiesPropertySource * @see org.springframework.data.gemfire.config.admin.GemfireAdminOperations + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects * @see org.springframework.http.client.ClientHttpRequestInterceptor * @see org.springframework.http.client.InterceptingClientHttpRequestFactory diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableClusterDefinedRegionsIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableClusterDefinedRegionsIntegrationTests.java index 91b3ee94..3c14d88e 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableClusterDefinedRegionsIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableClusterDefinedRegionsIntegrationTests.java @@ -54,6 +54,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.junit.Test * @see org.apache.geode.cache.GemFireCache * @see org.apache.geode.cache.Region + * @see org.apache.geode.cache.client.ClientCache * @see org.springframework.data.gemfire.config.annotation.ClusterDefinedRegionsConfiguration * @see org.springframework.data.gemfire.config.annotation.EnableClusterDefinedRegions * @see org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport @@ -62,13 +63,13 @@ import org.springframework.test.context.junit4.SpringRunner; * @since 2.1.0 */ @RunWith(SpringRunner.class) -@ContextConfiguration(classes = EnableClusterDefinedRegionsIntegrationTests.ClientTestConfiguration.class) +@ContextConfiguration(classes = EnableClusterDefinedRegionsIntegrationTests.GeodeClientTestConfiguration.class) @SuppressWarnings("unused") public class EnableClusterDefinedRegionsIntegrationTests extends ForkingClientServerIntegrationTestsSupport { @BeforeClass - public static void startGemFireServer() throws Exception { - startGemFireServer(ServerTestConfiguration.class); + public static void startGeodeServer() throws Exception { + startGemFireServer(GeodeServerTestConfiguration.class); } @Autowired @@ -109,7 +110,7 @@ public class EnableClusterDefinedRegionsIntegrationTests extends ForkingClientSe @ClientCacheApplication @EnableClusterDefinedRegions - static class ClientTestConfiguration { + static class GeodeClientTestConfiguration { @Bean static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { @@ -131,12 +132,12 @@ public class EnableClusterDefinedRegionsIntegrationTests extends ForkingClientSe } @CacheServerApplication(name = "EnableClusterDefinedRegionsIntegrationTests") - static class ServerTestConfiguration { + static class GeodeServerTestConfiguration { public static void main(String[] args) { AnnotationConfigApplicationContext applicationContext = - new AnnotationConfigApplicationContext(ServerTestConfiguration.class); + new AnnotationConfigApplicationContext(GeodeServerTestConfiguration.class); applicationContext.registerShutdownHook(); } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableContinuousQueriesConfigurationIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableContinuousQueriesConfigurationIntegrationTests.java index 705d88ed..61ce6cb2 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableContinuousQueriesConfigurationIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableContinuousQueriesConfigurationIntegrationTests.java @@ -87,7 +87,7 @@ public class EnableContinuousQueriesConfigurationIntegrationTests extends Forkin @BeforeClass public static void startGeodeServer() throws Exception { - startGemFireServer(GemFireServerConfiguration.class); + startGemFireServer(GeodeServerTestConfiguration.class); } @Resource(name = "TemperatureReadings") @@ -120,7 +120,7 @@ public class EnableContinuousQueriesConfigurationIntegrationTests extends Forkin @Configuration @EnableContinuousQueries - @Import(GemFireClientConfiguration.class) + @Import(GeodeClientConfiguration.class) static class TestConfiguration { @ContinuousQuery(name = "BoilingTemperatures", @@ -137,7 +137,7 @@ public class EnableContinuousQueriesConfigurationIntegrationTests extends Forkin } @ClientCacheApplication(logLevel = "error", subscriptionEnabled = true) - static class GemFireClientConfiguration { + static class GeodeClientConfiguration { @Bean ClientCacheConfigurer clientCachePoolPortConfigurer( @@ -175,13 +175,13 @@ public class EnableContinuousQueriesConfigurationIntegrationTests extends Forkin } } - @CacheServerApplication(name = "EnableContinuousQueriesConfigurationIntegrationTests", logLevel = "error") - static class GemFireServerConfiguration { + @CacheServerApplication + static class GeodeServerTestConfiguration { public static void main(String[] args) { AnnotationConfigApplicationContext applicationContext = - new AnnotationConfigApplicationContext(GemFireServerConfiguration.class); + new AnnotationConfigApplicationContext(GeodeServerTestConfiguration.class); applicationContext.registerShutdownHook(); } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableEntityDefinedRegionsWithAssignableTypeFilterIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableEntityDefinedRegionsWithAssignableTypeFilterIntegrationTests.java index 8dd40d18..dd3cf100 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableEntityDefinedRegionsWithAssignableTypeFilterIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableEntityDefinedRegionsWithAssignableTypeFilterIntegrationTests.java @@ -88,6 +88,6 @@ public class EnableEntityDefinedRegionsWithAssignableTypeFilterIntegrationTests excludeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern = "Programmer"), includeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = User.class) ) - static class TestGeodeConfiguration { } + static class TestConfiguration { } } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableEntityDefinedRegionsWithRegexFilterIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableEntityDefinedRegionsWithRegexFilterIntegrationTests.java index 1bf70079..eb277aa2 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableEntityDefinedRegionsWithRegexFilterIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableEntityDefinedRegionsWithRegexFilterIntegrationTests.java @@ -55,6 +55,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @see java.util.regex.Pattern * @see org.junit.Test * @see org.apache.geode.cache.Region + * @see org.springframework.context.ApplicationContext * @see org.springframework.data.gemfire.config.annotation.EnableEntityDefinedRegions * @see org.springframework.data.gemfire.config.annotation.EntityDefinedRegionsConfiguration * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport @@ -113,6 +114,6 @@ public class EnableEntityDefinedRegionsWithRegexFilterIntegrationTests extends I clientRegionShortcut = ClientRegionShortcut.LOCAL, includeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern = ".*Programmer") ) - static class TestGeodeConfiguration { } + static class TestConfiguration { } } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableLuceneIndexingConfigurationIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableLuceneIndexingConfigurationIntegrationTests.java index 3c2e8f0c..30439e79 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableLuceneIndexingConfigurationIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableLuceneIndexingConfigurationIntegrationTests.java @@ -34,6 +34,7 @@ import org.springframework.context.annotation.DependsOn; import org.springframework.data.gemfire.search.lucene.ProjectingLuceneOperations; import org.springframework.data.gemfire.search.lucene.ProjectingLuceneTemplate; import org.springframework.data.gemfire.test.model.Book; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -42,12 +43,18 @@ import org.springframework.test.context.junit4.SpringRunner; * * @author John Blum * @see org.junit.Test - * @since 1.0.0 + * @see org.apache.geode.cache.Region + * @see org.springframework.data.gemfire.search.lucene.ProjectingLuceneOperations + * @see org.springframework.data.gemfire.search.lucene.ProjectingLuceneTemplate + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport + * @see org.springframework.test.context.ContextConfiguration + * @see org.springframework.test.context.junit4.SpringRunner + * @since 2.0.0 */ @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class EnableLuceneIndexingConfigurationIntegrationTests { +public class EnableLuceneIndexingConfigurationIntegrationTests extends IntegrationTestsSupport { @Autowired private ProjectingLuceneOperations luceneTemplate; @@ -86,7 +93,7 @@ public class EnableLuceneIndexingConfigurationIntegrationTests { "Star Wars VIII - The Last Jedi"); } - @PeerCacheApplication(name = "EnableLuceneIndexingConfigurationIntegrationTests", logLevel = "error") + @PeerCacheApplication @EnableEntityDefinedRegions(basePackageClasses = Book.class) @EnableIndexing static class TestConfiguration { diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableOqlIndexingConfigurationIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableOqlIndexingConfigurationIntegrationTests.java index 44c3770c..2d20a12d 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableOqlIndexingConfigurationIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableOqlIndexingConfigurationIntegrationTests.java @@ -34,19 +34,21 @@ import org.springframework.data.gemfire.IndexType; import org.springframework.data.gemfire.mapping.annotation.Indexed; import org.springframework.data.gemfire.test.model.Book; import org.springframework.data.gemfire.test.model.Person; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * Integration tests for {@link EnableIndexing} and the {@link Indexed} annotation. + * Integration Tests for {@link EnableIndexing}, {@link IndexConfiguration} and the {@link Indexed} annotation. * * @author John Blum * @see org.junit.Test * @see org.apache.geode.cache.Region * @see org.apache.geode.cache.query.Index * @see org.springframework.data.gemfire.config.annotation.EnableIndexing + * @see org.springframework.data.gemfire.config.annotation.IndexConfiguration * @see org.springframework.data.gemfire.mapping.annotation.Indexed - * @see org.springframework.data.gemfire.test.model.Person + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 2.0.3 @@ -54,7 +56,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class EnableOqlIndexingConfigurationIntegrationTests { +public class EnableOqlIndexingConfigurationIntegrationTests extends IntegrationTestsSupport { @Resource(name = "People") private Region people; @@ -95,7 +97,7 @@ public class EnableOqlIndexingConfigurationIntegrationTests { "lastName", "/People", IndexType.FUNCTIONAL); } - @ClientCacheApplication(logLevel = "none") + @ClientCacheApplication @EnableEntityDefinedRegions( basePackageClasses = Person.class, clientRegionShortcut = ClientRegionShortcut.LOCAL, diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableSslConfigurationIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableSslConfigurationIntegrationTests.java index fe546a31..11bc83f7 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableSslConfigurationIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableSslConfigurationIntegrationTests.java @@ -19,7 +19,6 @@ import static org.assertj.core.api.Assertions.assertThat; import javax.annotation.Resource; -import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -57,7 +56,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @since 2.1.0 */ @RunWith(SpringRunner.class) -@ContextConfiguration(classes = EnableSslConfigurationIntegrationTests.ClientTestConfiguration.class) +@ContextConfiguration(classes = EnableSslConfigurationIntegrationTests.GeodeClientTestConfiguration.class) @SuppressWarnings("all") public class EnableSslConfigurationIntegrationTests extends ForkingClientServerIntegrationTestsSupport { @@ -69,26 +68,10 @@ public class EnableSslConfigurationIntegrationTests extends ForkingClientServerI private Region echo; @BeforeClass - public static void setupGemFireServer() throws Exception { - - String hostname = "localhost"; - - int availablePort = findAvailablePort(); - - gemfireServer = run(ServerTestConfiguration.class, + public static void startGeodeServer() throws Exception { + startGemFireServer(GeodeServerTestConfiguration.class, String.format("-Dgemfire.name=%s", asApplicationName(EnableSslConfigurationIntegrationTests.class)), - String.format("-Djavax.net.ssl.keyStore=%s", System.getProperty("javax.net.ssl.keyStore")), - String.format("-D%s=%d", GEMFIRE_CACHE_SERVER_PORT_PROPERTY, availablePort)); - - waitForServerToStart("localhost", availablePort); - - System.setProperty(GEMFIRE_CACHE_SERVER_PORT_PROPERTY, String.format("%s[%d]", hostname, availablePort)); - System.setProperty(GEMFIRE_POOL_SERVERS_PROPERTY, String.format("%s[%d]", hostname, availablePort)); - } - - @AfterClass - public static void tearDownGemFireServer() { - stop(gemfireServer); + String.format("-Djavax.net.ssl.keyStore=%s", System.getProperty("javax.net.ssl.keyStore"))); } @Test @@ -98,7 +81,7 @@ public class EnableSslConfigurationIntegrationTests extends ForkingClientServerI @ClientCacheApplication(logLevel = LOG_LEVEL) @EnableSsl(keystorePassword = "s3cr3t", truststorePassword = "s3cr3t") - static class ClientTestConfiguration { + static class GeodeClientTestConfiguration { @Bean ClientCacheConfigurer clientCacheSslConfigurer( @@ -125,12 +108,12 @@ public class EnableSslConfigurationIntegrationTests extends ForkingClientServerI @CacheServerApplication(name = "EnableSslConfigurationIntegrationTests", logLevel = LOG_LEVEL) @EnableSsl(keystorePassword = "s3cr3t", truststorePassword = "s3cr3t") - static class ServerTestConfiguration { + static class GeodeServerTestConfiguration { public static void main(String[] args) { AnnotationConfigApplicationContext applicationContext = - new AnnotationConfigApplicationContext(ServerTestConfiguration.class); + new AnnotationConfigApplicationContext(GeodeServerTestConfiguration.class); applicationContext.registerShutdownHook(); } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/LocatorApplicationIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/LocatorApplicationIntegrationTests.java index 345f35c1..72a781f7 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/LocatorApplicationIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/LocatorApplicationIntegrationTests.java @@ -30,6 +30,7 @@ import org.apache.geode.distributed.Locator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.gemfire.GemfireUtils; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.junit4.SpringRunner; /** @@ -46,14 +47,13 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.apache.geode.distributed.Locator * @see org.springframework.data.gemfire.config.annotation.LocatorApplication * @see org.springframework.data.gemfire.config.annotation.LocatorApplicationConfiguration + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.junit4.SpringRunner * @since 2.2.0 */ @RunWith(SpringRunner.class) @SuppressWarnings("unused") -public class LocatorApplicationIntegrationTests { - - private static final String GEMFIRE_LOG_LEVEL = "error"; +public class LocatorApplicationIntegrationTests extends IntegrationTestsSupport { @Autowired private Locator locator; @@ -101,7 +101,6 @@ public class LocatorApplicationIntegrationTests { @LocatorApplication( name = "LocatorApplicationIntegrationTests", bindAddress = "localhost", - logLevel = GEMFIRE_LOG_LEVEL, port = 0 ) static class TestConfiguration { } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/PeerCacheApplicationIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/PeerCacheApplicationIntegrationTests.java index 9b4ec54a..2c63b7bc 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/PeerCacheApplicationIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/PeerCacheApplicationIntegrationTests.java @@ -14,7 +14,6 @@ * limitations under the License. * */ - package org.springframework.data.gemfire.config.annotation; import static org.assertj.core.api.Assertions.assertThat; @@ -32,6 +31,7 @@ import org.apache.geode.cache.Region; import org.springframework.context.annotation.Bean; import org.springframework.data.gemfire.PartitionedRegionFactoryBean; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -40,28 +40,30 @@ import org.springframework.test.context.junit4.SpringRunner; * * @author John Blum * @see org.junit.Test + * @see org.apache.geode.cache.Cache * @see org.springframework.data.gemfire.config.annotation.PeerCacheApplication + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner - * @see org.apache.geode.cache.Cache * @since 1.9.0 */ @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("all") -public class PeerCacheApplicationIntegrationTests { +public class PeerCacheApplicationIntegrationTests extends IntegrationTestsSupport { @Resource(name = "Echo") private Region echo; @Test public void echoPartitionRegionEchoesKeysAsValues() { + assertThat(this.echo.get("hello")).isEqualTo("hello"); assertThat(this.echo.get("test")).isEqualTo("test"); assertThat(this.echo.get("good-bye")).isEqualTo("good-bye"); } - @PeerCacheApplication(name = "PeerCacheApplicationIntegrationTests", logLevel="error") + @PeerCacheApplication static class PeerCacheApplicationConfiguration { @Bean("Echo") @@ -88,8 +90,8 @@ public class PeerCacheApplicationIntegrationTests { } @Override - public void close() { - } + public void close() { } + }; } } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/PeerCacheApplicationWithAddedCacheServerIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/PeerCacheApplicationWithAddedCacheServerIntegrationTests.java index 8b453f9a..303145ce 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/PeerCacheApplicationWithAddedCacheServerIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/PeerCacheApplicationWithAddedCacheServerIntegrationTests.java @@ -45,6 +45,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.junit.Test * @see org.apache.geode.cache.Cache * @see org.apache.geode.cache.server.CacheServer + * @see org.apache.geode.distributed.Locator * @see org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner @@ -53,7 +54,6 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(classes = PeerCacheApplicationWithAddedCacheServerIntegrationTests.TestPeerCacheConfiguration.class) @SuppressWarnings("unused") -// TODO: Convert to Unit Test once STDG is used by SDG. public class PeerCacheApplicationWithAddedCacheServerIntegrationTests extends ForkingClientServerIntegrationTestsSupport { @@ -132,7 +132,7 @@ public class PeerCacheApplicationWithAddedCacheServerIntegrationTests } @EnableCacheServer - @PeerCacheApplication(name = "PeerCacheApplicationWithAddedCacheServerIntegrationTests") + @PeerCacheApplication static class TestPeerCacheConfiguration { } } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/PeerCacheConfigurerIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/PeerCacheConfigurerIntegrationTests.java index 949377eb..840c4886 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/PeerCacheConfigurerIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/PeerCacheConfigurerIntegrationTests.java @@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.data.gemfire.CacheFactoryBean; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.gemfire.tests.mock.beans.factory.config.GemFireMockObjectsBeanPostProcessor; import org.springframework.test.context.junit4.SpringRunner; @@ -44,13 +45,14 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.springframework.data.gemfire.CacheFactoryBean * @see org.springframework.data.gemfire.config.annotation.PeerCacheApplication * @see org.springframework.data.gemfire.config.annotation.PeerCacheConfigurer + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.data.gemfire.tests.mock.beans.factory.config.GemFireMockObjectsBeanPostProcessor * @see org.springframework.test.context.junit4.SpringRunner * @since 1.0.0 */ @RunWith(SpringRunner.class) @SuppressWarnings("unused") -public class PeerCacheConfigurerIntegrationTests { +public class PeerCacheConfigurerIntegrationTests extends IntegrationTestsSupport { @Autowired private Cache peerCache; diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/PoolConfigurerIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/PoolConfigurerIntegrationTests.java index 133aa3f6..a1d7877f 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/PoolConfigurerIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/PoolConfigurerIntegrationTests.java @@ -30,6 +30,7 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.gemfire.client.PoolFactoryBean; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -47,6 +48,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.springframework.data.gemfire.config.annotation.PoolConfigurer * @see org.springframework.data.gemfire.config.annotation.EnablePool * @see org.springframework.data.gemfire.config.annotation.EnablePools + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 2.1.0 @@ -54,7 +56,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class PoolConfigurerIntegrationTests { +public class PoolConfigurerIntegrationTests extends IntegrationTestsSupport { @Autowired @Qualifier("configurerOne") @@ -65,6 +67,7 @@ public class PoolConfigurerIntegrationTests { private TestPoolConfigurer configurerTwo; protected void assertPoolConfigurerCalled(TestPoolConfigurer configurer, String... beanNames) { + assertThat(configurer).isNotNull(); assertThat(configurer).hasSize(beanNames.length); assertThat(configurer).contains(beanNames); diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/RegionDataAccessTracingAspectUnitTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/RegionDataAccessTracingAspectUnitTests.java index 55a35887..a69596c3 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/RegionDataAccessTracingAspectUnitTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/RegionDataAccessTracingAspectUnitTests.java @@ -92,6 +92,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.create\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionCreate", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -106,6 +107,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.create\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionCreateWithCallbackArgument", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -119,6 +121,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.get\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionGet", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -132,6 +135,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.getAll\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionGetAll", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -146,6 +150,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.getAll\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionGetAllWithCallbackArgument", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -159,6 +164,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.getEntry\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionGetEntry", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -172,6 +178,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.invalidate\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionInvalidate", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -185,6 +192,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.invalidate\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionInvalidateWithCallbackArgument", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -198,6 +206,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.keySet\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionKeySet", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -211,6 +220,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.keySetOnServer\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionKeySetOnServer", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -224,6 +234,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.localClear\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionLocalClear", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -237,6 +248,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.localDestroy\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionLocalDestroy", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -250,6 +262,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.localDestroy\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionLocalDestroyWithCallbackArgument", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -263,6 +276,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.localInvalidate\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionLocalInvalidate", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -276,6 +290,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.localInvalidate\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionLocalInvalidateWithCallbackArgument", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -289,6 +304,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.put\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionPut", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -302,6 +318,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.put\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionPutWithCallbackArgument", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -315,6 +332,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.putAll\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionPutAll", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -328,6 +346,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.putAll\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionPutAllWithCallbackArgument", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -341,6 +360,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.putIfAbsent\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionPutIfAbsent", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -354,6 +374,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.query\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionQuery", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -367,6 +388,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.remove\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionRemoveWithKey", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -380,6 +402,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.remove\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionRemoveWithKeyAndValue", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -393,6 +416,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.removeAll\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionRemoveAll", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -407,6 +431,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.removeAll\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionRemoveAllWithCallbackArgument", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -420,6 +445,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.replace\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionReplace", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -433,6 +459,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.replace\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionReplaceWithKeyOldValueNewValue", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -446,6 +473,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.selectValue\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionSelectValue", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -459,6 +487,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.size\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionSize", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -472,6 +501,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.sizeOnServer\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionSizeOnServer", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -485,6 +515,7 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp assertThat(logMessage) .containsPattern("Region data access call \\[org.apache.geode.cache.Region.*.values\\(..\\)\\] with stack trace"); + assertThat(logMessage).contains(String.format("%s.logsRegionValues", RegionDataAccessTracingAspectUnitTests.class.getName())); } @@ -514,6 +545,5 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp return clientRegion; } - } } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/SecureLocatorApplicationIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/SecureLocatorApplicationIntegrationTests.java index a9c9b683..876cc52f 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/SecureLocatorApplicationIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/SecureLocatorApplicationIntegrationTests.java @@ -31,6 +31,7 @@ import org.apache.geode.security.ResourcePermission; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.gemfire.GemFireProperties; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -40,11 +41,12 @@ import org.springframework.test.context.junit4.SpringRunner; * @author John Blum * @see java.util.Properties * @see org.junit.Test - * @see org.apache.geode.distributed.Locator * @see org.apache.geode.distributed.DistributedSystem + * @see org.apache.geode.distributed.Locator * @see org.springframework.data.gemfire.GemFireProperties * @see org.springframework.data.gemfire.config.annotation.LocatorApplication * @see org.springframework.data.gemfire.config.annotation.EnableSecurity + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 2.3.0 @@ -52,7 +54,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class SecureLocatorApplicationIntegrationTests { +public class SecureLocatorApplicationIntegrationTests extends IntegrationTestsSupport { @Autowired private Locator locator; diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/support/DefinedIndexesIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/support/DefinedIndexesIntegrationTests.java index ef699f23..3ebdc4a8 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/support/DefinedIndexesIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/support/DefinedIndexesIntegrationTests.java @@ -49,6 +49,7 @@ import org.springframework.data.gemfire.PartitionedRegionFactoryBean; import org.springframework.data.gemfire.config.annotation.PeerCacheApplication; import org.springframework.data.gemfire.test.model.Gender; import org.springframework.data.gemfire.test.model.Person; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -57,17 +58,20 @@ import org.springframework.test.context.junit4.SpringRunner; * * @author John Blum * @see org.junit.Test - * @see org.springframework.data.gemfire.IndexFactoryBean * @see org.apache.geode.cache.Cache * @see org.apache.geode.cache.Region * @see org.apache.geode.cache.query.Index * @see org.apache.geode.cache.query.QueryService + * @see org.springframework.data.gemfire.IndexFactoryBean + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport + * @see org.springframework.test.context.ContextConfiguration + * @see org.springframework.test.context.junit4.SpringRunner * @since 1.7.0 */ @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class DefinedIndexesIntegrationTests { +public class DefinedIndexesIntegrationTests extends IntegrationTestsSupport { private static final List definedIndexNames = new ArrayList<>(3); @@ -121,8 +125,8 @@ public class DefinedIndexesIntegrationTests { assertThat(name).isEqualTo(queryService.getIndex(people, name.getName())); } - @PeerCacheApplication(logLevel = "error") - static class DefinedIndexesConfiguration { + @PeerCacheApplication + static class TestConfiguration { @Bean // TODO remove when the Annotation config model includes support diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/support/DiskStoreDirectoryBeanPostProcessorIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/support/DiskStoreDirectoryBeanPostProcessorIntegrationTests.java index d6899fbd..b9a4220f 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/support/DiskStoreDirectoryBeanPostProcessorIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/support/DiskStoreDirectoryBeanPostProcessorIntegrationTests.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.springframework.data.gemfire.config.support; import static org.assertj.core.api.Assertions.assertThat; @@ -32,6 +31,7 @@ import org.apache.geode.cache.GemFireCache; import org.springframework.context.annotation.Bean; import org.springframework.data.gemfire.DiskStoreFactoryBean; import org.springframework.data.gemfire.config.annotation.PeerCacheApplication; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.gemfire.tests.util.FileSystemUtils; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -41,16 +41,17 @@ import org.springframework.test.context.junit4.SpringRunner; * * @author John Blum * @see org.junit.Test - * @see org.junit.runner.RunWith + * @see org.apache.geode.cache.DiskStore * @see org.springframework.data.gemfire.DiskStoreFactoryBean * @see org.springframework.data.gemfire.config.support.DiskStoreDirectoryBeanPostProcessor + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 1.5.0 */ @RunWith(SpringRunner.class) @ContextConfiguration -public class DiskStoreDirectoryBeanPostProcessorIntegrationTests { +public class DiskStoreDirectoryBeanPostProcessorIntegrationTests extends IntegrationTestsSupport { @BeforeClass public static void testSuiteSetup() { diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/support/LuceneIndexRegionBeanFactoryPostProcessorIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/support/LuceneIndexRegionBeanFactoryPostProcessorIntegrationTests.java index a1e96eac..46400258 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/support/LuceneIndexRegionBeanFactoryPostProcessorIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/support/LuceneIndexRegionBeanFactoryPostProcessorIntegrationTests.java @@ -73,6 +73,7 @@ public class LuceneIndexRegionBeanFactoryPostProcessorIntegrationTests extends I .map(beanFactory -> beanFactory.getBeanDefinition(beanName)) .orElse(null); } + @Test public void regionLuceneIndexAndDiskStoreBeanDependenciesAreCorrect() { @@ -115,6 +116,7 @@ public class LuceneIndexRegionBeanFactoryPostProcessorIntegrationTests extends I @Test public void gemfireBeanProcessingOrderIsCorrect() { + assertThat(beanNames.indexOf("BookTitleLuceneIndex")).isLessThan(beanNames.indexOf("Books")); assertThat(beanNames.indexOf("ContractDescriptionLuceneIndex")).isLessThan(beanNames.indexOf("Contracts")); } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/AsyncEventQueueNamespaceTest.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/AsyncEventQueueNamespaceIntegrationTests.java similarity index 94% rename from spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/AsyncEventQueueNamespaceTest.java rename to spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/AsyncEventQueueNamespaceIntegrationTests.java index 768ce90f..a461f570 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/AsyncEventQueueNamespaceTest.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/AsyncEventQueueNamespaceIntegrationTests.java @@ -35,27 +35,28 @@ import org.apache.geode.cache.wan.GatewayEventSubstitutionFilter; import org.apache.geode.cache.wan.GatewayQueueEvent; import org.apache.geode.cache.wan.GatewaySender; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * The AsyncEventQueueNamespaceTest class is a test suite of test cases testing the contract and functionality - * of configuring a Pivotal GemFire or Apache Geode {@link AsyncEventQueue} using the SDG XML namespace. + * Integration Tests testing the contract and functionality of an {@link AsyncEventQueue} + * using SDG XML namespace configuration metadata. * * @author John Blum * @see org.junit.Test - * @see org.junit.runner.RunWith + * @see org.apache.geode.cache.asyncqueue.AsyncEventQueue * @see org.springframework.data.gemfire.config.AsyncEventQueueParser + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.data.gemfire.wan.AsyncEventQueueFactoryBean * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner - * @see org.apache.geode.cache.asyncqueue.AsyncEventQueue * @since 1.0.0 */ @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("all") -public class AsyncEventQueueNamespaceTest { +public class AsyncEventQueueNamespaceIntegrationTests extends IntegrationTestsSupport { @Resource(name = "TestAsyncEventQueue") private AsyncEventQueue asyncEventQueue; diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/CacheNamespaceIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/CacheNamespaceIntegrationTests.java index 824457e8..56a37270 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/CacheNamespaceIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/CacheNamespaceIntegrationTests.java @@ -34,11 +34,12 @@ import org.springframework.context.ApplicationContext; import org.springframework.core.io.Resource; import org.springframework.data.gemfire.CacheFactoryBean; import org.springframework.data.gemfire.TestUtils; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * Integration Tests for {@link CacheParser}. + * Integration Tests for {@link CacheParser} and {@link CacheFactoryBean}. * * @author Costin Leau * @author John Blum @@ -46,12 +47,13 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.apache.geode.cache.Cache * @see org.springframework.data.gemfire.CacheFactoryBean * @see org.springframework.data.gemfire.config.xml.CacheParser + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner */ @RunWith(SpringRunner.class) @ContextConfiguration -public class CacheNamespaceIntegrationTests { +public class CacheNamespaceIntegrationTests extends IntegrationTestsSupport { @Autowired @SuppressWarnings("unused") diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/ClientCacheNamespaceIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/ClientCacheNamespaceIntegrationTests.java index ee7f8d11..e96b2529 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/ClientCacheNamespaceIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/ClientCacheNamespaceIntegrationTests.java @@ -30,6 +30,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.core.io.Resource; import org.springframework.data.gemfire.TestUtils; import org.springframework.data.gemfire.client.ClientCacheFactoryBean; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -41,6 +42,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.apache.geode.cache.client.ClientCache * @see org.springframework.data.gemfire.client.ClientCacheFactoryBean * @see org.springframework.data.gemfire.config.xml.ClientCacheParser + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 1.6.3 @@ -48,7 +50,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class ClientCacheNamespaceIntegrationTests { +public class ClientCacheNamespaceIntegrationTests extends IntegrationTestsSupport { @Autowired private ApplicationContext applicationContext; diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/DiskStoreNamespaceIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/DiskStoreNamespaceIntegrationTests.java index c3db9122..5d369f74 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/DiskStoreNamespaceIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/DiskStoreNamespaceIntegrationTests.java @@ -33,8 +33,8 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * Integration Tests with test cases testing the contract and functionality of using SDG's XML namespace configuration - * metadata to configure {@link DiskStore DiskStores}. + * Integration Tests testing the contract and functionality of using SDG's XML namespace configuration metadata to + * configure {@link DiskStore DiskStores}. * * @author John Blum * @see org.junit.Test @@ -46,7 +46,8 @@ import org.springframework.test.context.junit4.SpringRunner; * @since 2.0.0 */ @RunWith(SpringRunner.class) -@ContextConfiguration(locations = "diskstore-ns.xml", initializers = GemFireMockObjectsApplicationContextInitializer.class) +@ContextConfiguration(locations = "diskstore-ns.xml", + initializers = GemFireMockObjectsApplicationContextInitializer.class) @SuppressWarnings("unused") public class DiskStoreNamespaceIntegrationTests extends IntegrationTestsSupport { diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/FunctionServiceNamespaceIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/FunctionServiceNamespaceIntegrationTests.java index 8b49f65c..58a6c450 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/FunctionServiceNamespaceIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/FunctionServiceNamespaceIntegrationTests.java @@ -31,7 +31,8 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * Integration Tests for SDG Function XML namespace configuration metadata + * Integration Tests for {@link Function} configuration, declaration and registration + * using SDG XML namespace configuration metadata. * * @author Costin Leau * @author David Turanski diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/GemfireV8GatewayNamespaceIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/GemfireV8GatewayNamespaceIntegrationTests.java index 110882cc..26865afb 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/GemfireV8GatewayNamespaceIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/GemfireV8GatewayNamespaceIntegrationTests.java @@ -33,15 +33,16 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * Integration Tests with test cases testing the contract and functionality of GemFire 8 {@link GatewaySender} - * and {@link GatewayReceiver} support. + * Integration Tests testing GemFire 8 {@link GatewaySender} and {@link GatewayReceiver} configuration + * using SDG XML namespace configuration metadata. * * @author John Blum * @see org.junit.Test + * @see org.apache.geode.cache.wan.GatewayReceiver * @see org.apache.geode.cache.wan.GatewaySender - * @see org.apache.geode.cache.wan.GatewayEventSubstitutionFilter * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer + * @see org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean * @see org.springframework.data.gemfire.wan.GatewaySenderFactoryBean * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/LookupRegionWithAsyncEventQueuesAndGatewaySendersIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/LookupRegionWithAsyncEventQueuesAndGatewaySendersIntegrationTests.java index c6b9d58a..093cd05c 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/LookupRegionWithAsyncEventQueuesAndGatewaySendersIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/LookupRegionWithAsyncEventQueuesAndGatewaySendersIntegrationTests.java @@ -27,22 +27,32 @@ import org.apache.geode.cache.DataPolicy; import org.apache.geode.cache.Region; import org.apache.geode.cache.RegionAttributes; import org.apache.geode.cache.asyncqueue.AsyncEventListener; +import org.apache.geode.cache.asyncqueue.AsyncEventQueue; +import org.apache.geode.cache.wan.GatewaySender; import org.springframework.data.gemfire.support.AbstractFactoryBeanSupport; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * The LookupRegionWithAsyncEventQueuesAndGatewaySendersIntegrationTests class... + * Integration Tests for SDG lookup {@link Region} resolution configured with an {@link AsyncEventQueue} + * and {@link GatewaySender} using SDG XML namespace configuration metadata. * * @author John Blum + * @see org.apache.geode.cache.Region + * @see org.apache.geode.cache.asyncqueue.AsyncEventQueue + * @see org.apache.geode.cache.wan.GatewaySender + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport + * @see org.springframework.test.context.ContextConfiguration + * @see org.springframework.test.context.junit4.SpringRunner * @since 1.0.0 */ @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class LookupRegionWithAsyncEventQueuesAndGatewaySendersIntegrationTests { +public class LookupRegionWithAsyncEventQueuesAndGatewaySendersIntegrationTests extends IntegrationTestsSupport { @Resource(name = "Example") private Region example; diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/LuceneNamespaceUnitTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/LuceneNamespaceUnitTests.java index f5c88c85..612a28c9 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/LuceneNamespaceUnitTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/LuceneNamespaceUnitTests.java @@ -14,7 +14,6 @@ * limitations under the License. * */ - package org.springframework.data.gemfire.config.xml; import static org.assertj.core.api.Assertions.assertThat; @@ -55,6 +54,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -64,19 +64,21 @@ import org.springframework.test.context.junit4.SpringRunner; * * @author John Blum * @see org.junit.Test - * @see org.junit.runner.RunWith * @see org.apache.geode.cache.lucene.LuceneIndex * @see org.apache.geode.cache.lucene.LuceneService * @see org.springframework.data.gemfire.config.xml.LuceneIndexParser * @see org.springframework.data.gemfire.config.xml.LuceneServiceParser + * @see org.springframework.data.gemfire.search.lucene.LuceneIndexFactoryBean + * @see org.springframework.data.gemfire.search.lucene.LuceneServiceFactoryBean + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner - * @since 1.1.0 + * @since 2.1.0 */ @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class LuceneNamespaceUnitTests { +public class LuceneNamespaceUnitTests extends IntegrationTestsSupport { private static final String[] EMPTY_STRING_ARRAY = {}; @@ -100,10 +102,10 @@ public class LuceneNamespaceUnitTests { private LuceneIndex luceneIndexFour; @Autowired - private LuceneSerializer luceneSerializer; + private LuceneSerializer luceneSerializer; private static String[] asArray(List list) { - return list.toArray(new String[list.size()]); + return list.toArray(new String[0]); } private static String[] toStringArray(Object[] array) { @@ -207,7 +209,7 @@ public class LuceneNamespaceUnitTests { } @Override - @SuppressWarnings("unchecked") + @SuppressWarnings({ "rawtypes", "unchecked" }) public LuceneService getObject() throws Exception { return Optional.ofNullable(this.luceneService).orElseGet(() -> { @@ -251,7 +253,7 @@ public class LuceneNamespaceUnitTests { }); } - @SuppressWarnings("unchecked") + @SuppressWarnings("rawtypes") private Answer mockLuceneIndex(LuceneService mockLuceneService, Map fieldAnalyzers, List fieldNames, AtomicReference luceneSerializer) { @@ -313,6 +315,7 @@ public class LuceneNamespaceUnitTests { } } + @SuppressWarnings("rawtypes") public static class MockLuceneSerializerFactoryBean implements FactoryBean { private LuceneSerializer luceneSerializer; diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/PoolNamespaceIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/PoolNamespaceIntegrationTests.java index fa8ccb6b..fc49b2ed 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/PoolNamespaceIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/PoolNamespaceIntegrationTests.java @@ -59,7 +59,7 @@ public class PoolNamespaceIntegrationTests extends IntegrationTestsSupport { @Autowired private ApplicationContext applicationContext; - protected void assertConnectionEndpoint(ConnectionEndpointList connectionEndpoints, + private void assertConnectionEndpoint(ConnectionEndpointList connectionEndpoints, String expectedHost, int expectedPort) { assertThat(connectionEndpoints).isNotNull(); @@ -67,7 +67,7 @@ public class PoolNamespaceIntegrationTests extends IntegrationTestsSupport { assertConnectionEndpoint(connectionEndpoints.get(0), expectedHost, expectedPort); } - protected void assertConnectionEndpoint(ConnectionEndpoint connectionEndpoint, + private void assertConnectionEndpoint(ConnectionEndpoint connectionEndpoint, String expectedHost, int expectedPort) { assertThat(connectionEndpoint).isNotNull(); @@ -75,7 +75,7 @@ public class PoolNamespaceIntegrationTests extends IntegrationTestsSupport { assertThat(connectionEndpoint.getPort()).isEqualTo(expectedPort); } - protected void assertNoConnectionEndpoints(ConnectionEndpointList connectionEndpoints) { + private void assertNoConnectionEndpoints(ConnectionEndpointList connectionEndpoints) { assertThat(connectionEndpoints).isNotNull(); assertThat(connectionEndpoints.isEmpty()).isTrue(); } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/RegionEvictionAttributesNamespaceIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/RegionEvictionAttributesNamespaceIntegrationTests.java index 7d0c3515..a2570de1 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/RegionEvictionAttributesNamespaceIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/RegionEvictionAttributesNamespaceIntegrationTests.java @@ -15,8 +15,7 @@ */ package org.springframework.data.gemfire.config.xml; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.assertj.core.api.Assertions.assertThat; import javax.annotation.Resource; @@ -35,8 +34,8 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * Integration Tests with test cases testing the use of Eviction configuration settings (EvictionAttributes) - * in the SDG XML namespace configuration metadata. + * Integration Tests for Apache Geode {@link Region} Eviction configuration settings ({@link EvictionAttributes}) + * using SDG XML namespace configuration metadata. * * @author John Blum * @see org.junit.Test @@ -74,65 +73,63 @@ public class RegionEvictionAttributesNamespaceIntegrationTests extends Integrati @Test public void testEntryCountRegionEvictionAttributes() { - assertNotNull(one); - assertNotNull(one.getAttributes()); - assertEquals(DataPolicy.REPLICATE, one.getAttributes().getDataPolicy()); - assertNotNull(one.getAttributes().getEvictionAttributes()); - assertEquals(EvictionAction.OVERFLOW_TO_DISK, one.getAttributes().getEvictionAttributes().getAction()); - assertEquals(EvictionAlgorithm.LRU_ENTRY, one.getAttributes().getEvictionAttributes().getAlgorithm()); - assertEquals(4096, one.getAttributes().getEvictionAttributes().getMaximum()); + assertThat(one).isNotNull(); + assertThat(one.getAttributes()).isNotNull(); + assertThat(one.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.REPLICATE); + assertThat(one.getAttributes().getEvictionAttributes()).isNotNull(); + assertThat(one.getAttributes().getEvictionAttributes().getAction()).isEqualTo(EvictionAction.OVERFLOW_TO_DISK); + assertThat(one.getAttributes().getEvictionAttributes().getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_ENTRY); + assertThat(one.getAttributes().getEvictionAttributes().getMaximum()).isEqualTo(4096); - assertNotNull(two); - assertNotNull(two.getAttributes()); - assertEquals(DataPolicy.PARTITION, two.getAttributes().getDataPolicy()); - assertNotNull(two.getAttributes().getEvictionAttributes()); - assertEquals(EvictionAction.LOCAL_DESTROY, two.getAttributes().getEvictionAttributes().getAction()); - assertEquals(EvictionAlgorithm.LRU_ENTRY, two.getAttributes().getEvictionAttributes().getAlgorithm()); - - assertEquals(EvictionAttributes.DEFAULT_ENTRIES_MAXIMUM, - two.getAttributes().getEvictionAttributes().getMaximum()); + assertThat(two).isNotNull(); + assertThat(two.getAttributes()).isNotNull(); + assertThat(two.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.PARTITION); + assertThat(two.getAttributes().getEvictionAttributes()).isNotNull(); + assertThat(two.getAttributes().getEvictionAttributes().getAction()).isEqualTo(EvictionAction.LOCAL_DESTROY); + assertThat(two.getAttributes().getEvictionAttributes().getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_ENTRY); + assertThat(two.getAttributes().getEvictionAttributes().getMaximum()).isEqualTo(EvictionAttributes.DEFAULT_ENTRIES_MAXIMUM); } @Test public void testHeapPercentageRegionEvictionAttributes() { - assertNotNull(three); - assertNotNull(three.getAttributes()); - assertEquals(DataPolicy.REPLICATE, three.getAttributes().getDataPolicy()); - assertNotNull(three.getAttributes().getEvictionAttributes()); - assertEquals(EvictionAction.OVERFLOW_TO_DISK, three.getAttributes().getEvictionAttributes().getAction()); - assertEquals(EvictionAlgorithm.LRU_HEAP, three.getAttributes().getEvictionAttributes().getAlgorithm()); + assertThat(three).isNotNull(); + assertThat(three.getAttributes()).isNotNull(); + assertThat(three.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.REPLICATE); + assertThat(three.getAttributes().getEvictionAttributes()).isNotNull(); + assertThat(three.getAttributes().getEvictionAttributes().getAction()).isEqualTo(EvictionAction.OVERFLOW_TO_DISK); + assertThat(three.getAttributes().getEvictionAttributes().getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_HEAP); - assertNotNull(four); - assertNotNull(four.getAttributes()); - assertEquals(DataPolicy.PARTITION, four.getAttributes().getDataPolicy()); - assertNotNull(four.getAttributes().getEvictionAttributes()); - assertEquals(EvictionAction.OVERFLOW_TO_DISK, four.getAttributes().getEvictionAttributes().getAction()); - assertEquals(EvictionAlgorithm.LRU_HEAP, three.getAttributes().getEvictionAttributes().getAlgorithm()); - assertEquals(0, four.getAttributes().getEvictionAttributes().getMaximum()); + assertThat(four).isNotNull(); + assertThat(four.getAttributes()).isNotNull(); + assertThat(four.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.PARTITION); + assertThat(four.getAttributes().getEvictionAttributes()).isNotNull(); + assertThat(four.getAttributes().getEvictionAttributes().getAction()).isEqualTo(EvictionAction.OVERFLOW_TO_DISK); + assertThat(three.getAttributes().getEvictionAttributes().getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_HEAP); + assertThat(four.getAttributes().getEvictionAttributes().getMaximum()).isEqualTo(0); } @Test public void testMemorySizeRegionEvictionAttributes() { - assertNotNull(five); - assertNotNull(five.getAttributes()); - assertEquals(DataPolicy.REPLICATE, five.getAttributes().getDataPolicy()); - assertNotNull(five.getAttributes().getEvictionAttributes()); - assertEquals(EvictionAction.OVERFLOW_TO_DISK, five.getAttributes().getEvictionAttributes().getAction()); - assertEquals(EvictionAlgorithm.LRU_MEMORY, five.getAttributes().getEvictionAttributes().getAlgorithm()); - assertEquals(128, five.getAttributes().getEvictionAttributes().getMaximum()); + assertThat(five).isNotNull(); + assertThat(five.getAttributes()).isNotNull(); + assertThat(five.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.REPLICATE); + assertThat(five.getAttributes().getEvictionAttributes()).isNotNull(); + assertThat(five.getAttributes().getEvictionAttributes().getAction()).isEqualTo(EvictionAction.OVERFLOW_TO_DISK); + assertThat(five.getAttributes().getEvictionAttributes().getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_MEMORY); + assertThat(five.getAttributes().getEvictionAttributes().getMaximum()).isEqualTo(128); - assertNotNull(six); - assertNotNull(six.getAttributes()); - assertEquals(DataPolicy.PARTITION, six.getAttributes().getDataPolicy()); - assertNotNull(six.getAttributes().getEvictionAttributes()); - assertEquals(EvictionAction.OVERFLOW_TO_DISK, six.getAttributes().getEvictionAttributes().getAction()); - assertEquals(EvictionAlgorithm.LRU_MEMORY, six.getAttributes().getEvictionAttributes().getAlgorithm()); + assertThat(six).isNotNull(); + assertThat(six.getAttributes()).isNotNull(); + assertThat(six.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.PARTITION); + assertThat(six.getAttributes().getEvictionAttributes()).isNotNull(); + assertThat(six.getAttributes().getEvictionAttributes().getAction()).isEqualTo(EvictionAction.OVERFLOW_TO_DISK); + assertThat(six.getAttributes().getEvictionAttributes().getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_MEMORY); - int expectedMaximum = - Boolean.getBoolean("org.springframework.data.gemfire.test.GemfireTestRunner.nomock") ? 512 : 256; + int expectedMaximum = Boolean.getBoolean("org.springframework.data.gemfire.test.GemfireTestRunner.nomock") + ? 512 : 256; - assertEquals(expectedMaximum, six.getAttributes().getEvictionAttributes().getMaximum()); + assertThat(six.getAttributes().getEvictionAttributes().getMaximum()).isEqualTo(expectedMaximum); } } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/SubRegionNamespaceIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/SubRegionNamespaceIntegrationTests.java index 2eedafaa..e33d9f37 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/SubRegionNamespaceIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/SubRegionNamespaceIntegrationTests.java @@ -34,11 +34,12 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * Integration Tests with test cases testing the contract and functionality of Region/SubRegion creation in a cache. + * Integration Tests for {@link Region} and {@link Region sub-Region} creation in a cache. * * @author David Turanski * @author John Blum * @see org.junit.Test + * @see org.apache.geode.cache.Cache * @see org.apache.geode.cache.Region * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/TemplateClientRegionNamespaceTest.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/TemplateClientRegionNamespaceIntegrationTests.java similarity index 51% rename from spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/TemplateClientRegionNamespaceTest.java rename to spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/TemplateClientRegionNamespaceIntegrationTests.java index 5a8fcfe5..e50f23d9 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/TemplateClientRegionNamespaceTest.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/TemplateClientRegionNamespaceIntegrationTests.java @@ -13,14 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.springframework.data.gemfire.config.xml; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assume.assumeNotNull; import java.util.Arrays; @@ -45,60 +40,63 @@ import org.apache.geode.cache.util.CacheListenerAdapter; import org.apache.geode.cache.util.CacheWriterAdapter; import org.apache.geode.cache.util.ObjectSizer; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; +import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.util.StringUtils; /** - * The TemplateClientRegionNamespaceTest class is a test suite of test cases testing the contract and functionality - * of Client Region Templates using Spring Data GemFire XML namespace configuration meta-data. + * Integration Tests for client {@link Region} templates using SDG XML namespace configuration metadata. * * @author John Blum * @see org.junit.Test - * @see org.junit.runner.RunWith - * @see org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer + * @see org.apache.geode.cache.Region + * @see org.apache.geode.cache.client.ClientCache + * @see org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner - * @see org.apache.geode.cache.Cache - * @see org.apache.geode.cache.Region * @since 1.5.0 */ @RunWith(SpringRunner.class) -@ContextConfiguration +@ContextConfiguration(initializers = GemFireMockObjectsApplicationContextInitializer.class) @SuppressWarnings("unused") -public class TemplateClientRegionNamespaceTest { +public class TemplateClientRegionNamespaceIntegrationTests extends IntegrationTestsSupport { @Resource(name = "TemplateBasedClientRegion") private Region templateBasedClientRegion; private void assertCacheListeners(Region region, String... expectedNames) { - assertNotNull(region); - assertNotNull(region.getAttributes()); - assertNotNull(region.getAttributes().getCacheListeners()); - assertEquals(expectedNames.length, region.getAttributes().getCacheListeners().length); + assertThat(region).isNotNull(); + assertThat(region.getAttributes()).isNotNull(); + assertThat(region.getAttributes().getCacheListeners()).isNotNull(); + assertThat(region.getAttributes().getCacheListeners().length).isEqualTo(expectedNames.length); - for (CacheListener cacheListener : region.getAttributes().getCacheListeners()) { - assertTrue(cacheListener instanceof TestCacheListener); - assertTrue(Arrays.asList(expectedNames).contains(cacheListener.toString())); + for (CacheListener cacheListener : region.getAttributes().getCacheListeners()) { + assertThat(cacheListener instanceof TestCacheListener).isTrue(); + assertThat(Arrays.asList(expectedNames).contains(cacheListener.toString())).isTrue(); } } private void assertCacheLoader(Region region, String expectedName) { - assertNotNull(region); - assertNotNull(region.getAttributes()); - assertTrue(region.getAttributes().getCacheLoader() instanceof TestCacheLoader); - assertEquals(expectedName, region.getAttributes().getCacheLoader().toString()); + + assertThat(region).isNotNull(); + assertThat(region.getAttributes()).isNotNull(); + assertThat(region.getAttributes().getCacheLoader() instanceof TestCacheLoader).isTrue(); + assertThat(region.getAttributes().getCacheLoader().toString()).isEqualTo(expectedName); } private void assertCacheWriter(Region region, String expectedName) { - assertNotNull(region); - assertNotNull(region.getAttributes()); - assertTrue(region.getAttributes().getCacheWriter() instanceof TestCacheWriter); - assertEquals(expectedName, region.getAttributes().getCacheWriter().toString()); + + assertThat(region).isNotNull(); + assertThat(region.getAttributes()).isNotNull(); + assertThat(region.getAttributes().getCacheWriter() instanceof TestCacheWriter).isTrue(); + assertThat(region.getAttributes().getCacheWriter().toString()).isEqualTo(expectedName); } private void assertDefaultEvictionAttributes(EvictionAttributes evictionAttributes) { + assumeNotNull(evictionAttributes); assertEvictionAttributes(evictionAttributes, EvictionAction.NONE, EvictionAlgorithm.NONE, 0, null); } @@ -106,51 +104,53 @@ public class TemplateClientRegionNamespaceTest { private void assertEvictionAttributes(EvictionAttributes evictionAttributes, EvictionAction expectedAction, EvictionAlgorithm expectedAlgorithm, int expectedMaximum, ObjectSizer expectedObjectSizer) { - assertNotNull("The 'EvictionAttributes' must not be null!", evictionAttributes); - assertEquals(expectedAction, evictionAttributes.getAction()); - assertEquals(expectedAlgorithm, evictionAttributes.getAlgorithm()); - assertEquals(expectedMaximum, evictionAttributes.getMaximum()); - assertEquals(expectedObjectSizer, evictionAttributes.getObjectSizer()); + assertThat(evictionAttributes).describedAs("The 'EvictionAttributes' must not be null!").isNotNull(); + assertThat(evictionAttributes.getAction()).isEqualTo(expectedAction); + assertThat(evictionAttributes.getAlgorithm()).isEqualTo(expectedAlgorithm); + assertThat(evictionAttributes.getMaximum()).isEqualTo(expectedMaximum); + assertThat(evictionAttributes.getObjectSizer()).isEqualTo(expectedObjectSizer); } private void assertDefaultExpirationAttributes(ExpirationAttributes expirationAttributes) { + assumeNotNull(expirationAttributes); - assertEquals(ExpirationAction.INVALIDATE, expirationAttributes.getAction()); - assertEquals(0, expirationAttributes.getTimeout()); + assertThat(expirationAttributes.getAction()).isEqualTo(ExpirationAction.INVALIDATE); + assertThat(expirationAttributes.getTimeout()).isEqualTo(0); } private void assertExpirationAttributes(ExpirationAttributes expirationAttributes, ExpirationAction expectedAction, int expectedTimeout) { - assertNotNull("The 'ExpirationAttributes' must not be null!", expirationAttributes); - assertEquals(expectedAction, expirationAttributes.getAction()); - assertEquals(expectedTimeout, expirationAttributes.getTimeout()); + assertThat(expirationAttributes).as("The 'ExpirationAttributes' must not be null!").isNotNull(); + assertThat(expirationAttributes.getAction()).isEqualTo(expectedAction); + assertThat(expirationAttributes.getTimeout()).isEqualTo(expectedTimeout); } - private void assertDefaultRegionAttributes(Region region) { + private void assertDefaultRegionAttributes(Region region) { - assertNotNull("The Region must not be null!", region); - assertNotNull(String.format("The Region (%1$s) must have 'RegionAttributes' defined!", - region.getFullPath()), region.getAttributes()); - assertNull(region.getAttributes().getCompressor()); - assertNull(region.getAttributes().getCustomEntryIdleTimeout()); - assertNull(region.getAttributes().getCustomEntryTimeToLive()); - assertNull(region.getAttributes().getDiskStoreName()); - assertFalse(region.getAttributes().getMulticastEnabled()); + assertThat(region).describedAs("The Region must not be null!").isNotNull(); + assertThat(region.getAttributes()) + .describedAs("The Region (%1$s) must have 'RegionAttributes' defined!", region.getFullPath()) + .isNotNull(); + assertThat(region.getAttributes().getCompressor()).isNull(); + assertThat(region.getAttributes().getCustomEntryIdleTimeout()).isNull(); + assertThat(region.getAttributes().getCustomEntryTimeToLive()).isNull(); + assertThat(region.getAttributes().getDiskStoreName()).isNull(); + assertThat(region.getAttributes().getMulticastEnabled()).isFalse(); assertDefaultExpirationAttributes(region.getAttributes().getRegionTimeToLive()); assertDefaultExpirationAttributes(region.getAttributes().getRegionIdleTimeout()); } private static void assertEmpty(Object[] array) { - assertTrue((array == null || array.length == 0)); + assertThat(array == null || array.length == 0).isTrue(); } private static void assertEmpty(Iterable collection) { - assertTrue(collection == null || !collection.iterator().hasNext()); + assertThat(collection == null || !collection.iterator().hasNext()).isTrue(); } private static void assertNullEmpty(String value) { - assertFalse(StringUtils.hasText(value)); + assertThat(StringUtils.hasText(value)).isFalse(); } private static void assertRegionMetaData(Region region, String expectedRegionName) { @@ -159,12 +159,12 @@ public class TemplateClientRegionNamespaceTest { private static void assertRegionMetaData(Region region, String expectedRegionName, String expectedRegionPath) { - assertNotNull(String.format("The '%1$s' Region was not properly configured and initialized!", - expectedRegionName), region); - assertEquals(expectedRegionName, region.getName()); - assertEquals(expectedRegionPath, region.getFullPath()); - assertNotNull(String.format("The '%1$s' Region must have RegionAttributes defined!", - expectedRegionName), region.getAttributes()); + assertThat(region).as(String.format("The '%1$s' Region was not properly configured and initialized!", + expectedRegionName)).isNotNull(); + assertThat(region.getName()).isEqualTo(expectedRegionName); + assertThat(region.getFullPath()).isEqualTo(expectedRegionPath); + assertThat(region.getAttributes()).as(String.format("The '%1$s' Region must have RegionAttributes defined!", + expectedRegionName)).isNotNull(); } @Test @@ -175,23 +175,23 @@ public class TemplateClientRegionNamespaceTest { assertCacheListeners(templateBasedClientRegion, "XYZ"); assertCacheLoader(templateBasedClientRegion, "A"); assertCacheWriter(templateBasedClientRegion, "B"); - assertFalse(templateBasedClientRegion.getAttributes().getCloningEnabled()); - assertFalse(templateBasedClientRegion.getAttributes().getConcurrencyChecksEnabled()); - assertEquals(16, templateBasedClientRegion.getAttributes().getConcurrencyLevel()); - assertEquals(DataPolicy.NORMAL, templateBasedClientRegion.getAttributes().getDataPolicy()); - assertFalse(templateBasedClientRegion.getAttributes().isDiskSynchronous()); + assertThat(templateBasedClientRegion.getAttributes().getCloningEnabled()).isFalse(); + assertThat(templateBasedClientRegion.getAttributes().getConcurrencyChecksEnabled()).isFalse(); + assertThat(templateBasedClientRegion.getAttributes().getConcurrencyLevel()).isEqualTo(16); + assertThat(templateBasedClientRegion.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.NORMAL); + assertThat(templateBasedClientRegion.getAttributes().isDiskSynchronous()).isFalse(); assertEvictionAttributes(templateBasedClientRegion.getAttributes().getEvictionAttributes(), EvictionAction.OVERFLOW_TO_DISK, EvictionAlgorithm.LRU_ENTRY, 1024, null); - assertEquals(51, templateBasedClientRegion.getAttributes().getInitialCapacity()); - assertEquals(Integer.class, templateBasedClientRegion.getAttributes().getKeyConstraint()); - assertEquals("0.85", String.valueOf(templateBasedClientRegion.getAttributes().getLoadFactor())); - assertEquals("ServerPool", templateBasedClientRegion.getAttributes().getPoolName()); - assertTrue(templateBasedClientRegion.getAttributes().getStatisticsEnabled()); - assertEquals(Object.class, templateBasedClientRegion.getAttributes().getValueConstraint()); + assertThat(templateBasedClientRegion.getAttributes().getInitialCapacity()).isEqualTo(51); + assertThat(templateBasedClientRegion.getAttributes().getKeyConstraint()).isEqualTo(Integer.class); + assertThat(String.valueOf(templateBasedClientRegion.getAttributes().getLoadFactor())).isEqualTo("0.85"); + assertThat(templateBasedClientRegion.getAttributes().getPoolName()).isEqualTo("ServerPool"); + assertThat(templateBasedClientRegion.getAttributes().getStatisticsEnabled()).isTrue(); + assertThat(templateBasedClientRegion.getAttributes().getValueConstraint()).isEqualTo(Object.class); templateBasedClientRegion.getInterestList(); } - public static final class TestCacheListener extends CacheListenerAdapter { + public static final class TestCacheListener extends CacheListenerAdapter { private String name; @@ -205,7 +205,7 @@ public class TemplateClientRegionNamespaceTest { } } - public static final class TestCacheLoader implements CacheLoader { + public static final class TestCacheLoader implements CacheLoader { private String name; @@ -227,7 +227,7 @@ public class TemplateClientRegionNamespaceTest { } } - public static final class TestCacheWriter extends CacheWriterAdapter { + public static final class TestCacheWriter extends CacheWriterAdapter { private String name; diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/TxManagerNamespaceIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/TxManagerNamespaceIntegrationTests.java index 86f60eba..3dfe829c 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/TxManagerNamespaceIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/TxManagerNamespaceIntegrationTests.java @@ -29,8 +29,15 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** + * Integration Tests for SDG Transaction Manager configuration in SDG XML namespace configuration metadata. + * * @author Costin Leau * @author John Blum + * @see org.junit.Test + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport + * @see org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer + * @see org.springframework.test.context.ContextConfiguration + * @see org.springframework.test.context.junit4.SpringRunner */ @RunWith(SpringRunner.class) @ContextConfiguration(locations = "/org/springframework/data/gemfire/config/xml/tx-ns.xml", diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/support/PoolAlreadyExistsIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/support/PoolAlreadyExistsIntegrationTests.java index 9245441a..1436d7e1 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/support/PoolAlreadyExistsIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/xml/support/PoolAlreadyExistsIntegrationTests.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.springframework.data.gemfire.config.xml.support; import static org.assertj.core.api.Assertions.assertThat; @@ -30,11 +29,12 @@ import org.apache.geode.cache.client.Pool; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.gemfire.GemfireUtils; import org.springframework.data.gemfire.function.annotation.OnRegion; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * Integration tests to test the configuration of the {@link ClientCache} {@literal DEFAULT} {@link Pool}, + * Integration Tests testing the configuration of the {@link ClientCache} {@literal DEFAULT} {@link Pool}, * client {@link Region Region's} using a configured {@link Pool} and a {@link Function} referring to * a client {@link Region} requiring the configured {@link Pool}. * @@ -43,12 +43,16 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.apache.geode.cache.Region * @see org.apache.geode.cache.client.ClientCache * @see org.apache.geode.cache.client.Pool + * @see org.springframework.data.gemfire.client.PoolFactoryBean + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport + * @see org.springframework.test.context.ContextConfiguration + * @see org.springframework.test.context.junit4.SpringRunner * @since 1.0.0 */ @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class PoolAlreadyExistsIntegrationTests { +public class PoolAlreadyExistsIntegrationTests extends IntegrationTestsSupport { @Autowired private ClientCache clientCache; diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/expiration/AnnotationBasedExpirationConfigurationIntegrationTest.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/expiration/AnnotationBasedExpirationConfigurationIntegrationTest.java index 9fbf8ccf..b9ccbc50 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/expiration/AnnotationBasedExpirationConfigurationIntegrationTest.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/expiration/AnnotationBasedExpirationConfigurationIntegrationTest.java @@ -33,6 +33,7 @@ import org.apache.geode.cache.Region; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer; import org.springframework.expression.EvaluationException; import org.springframework.test.context.ContextConfiguration; @@ -46,10 +47,10 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.junit.Test * @see org.mockito.Mockito * @see org.apache.geode.cache.CustomExpiry - * @see org.apache.geode.cache.ExpirationAction * @see org.apache.geode.cache.ExpirationAttributes * @see org.apache.geode.cache.Region * @see org.springframework.data.gemfire.expiration.AnnotationBasedExpiration + * @see org.springframework.data.gemfire.expiration.ExpirationAttributesFactoryBean * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer * @see org.springframework.test.context.ContextConfiguration @@ -59,7 +60,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(initializers = GemFireMockObjectsApplicationContextInitializer.class) @SuppressWarnings("unused") -public class AnnotationBasedExpirationConfigurationIntegrationTest { +public class AnnotationBasedExpirationConfigurationIntegrationTest extends IntegrationTestsSupport { @Autowired @Qualifier("genericExpiration") diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/function/ExceptionThrowingFunctionExecutionIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/function/ExceptionThrowingFunctionExecutionIntegrationTests.java index 9677aded..cd9a2998 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/function/ExceptionThrowingFunctionExecutionIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/function/ExceptionThrowingFunctionExecutionIntegrationTests.java @@ -17,13 +17,10 @@ package org.springframework.data.gemfire.function; import static org.assertj.core.api.Assertions.assertThat; -import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.TimeUnit; -import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -35,14 +32,10 @@ import org.apache.geode.cache.execute.FunctionException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.gemfire.fork.ServerProcess; import org.springframework.data.gemfire.function.sample.ExceptionThrowingFunctionExecution; -import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; -import org.springframework.data.gemfire.tests.process.ProcessExecutor; +import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport; import org.springframework.data.gemfire.tests.process.ProcessWrapper; -import org.springframework.data.gemfire.tests.util.FileSystemUtils; -import org.springframework.data.gemfire.tests.util.ThreadUtils; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.util.Assert; /** * Integration Tests testing the proper behavior of SDG's {@link Function} annotation support when the {@link Function} @@ -56,8 +49,7 @@ import org.springframework.util.Assert; * @see org.springframework.data.gemfire.fork.ServerProcess * @see org.springframework.data.gemfire.function.annotation.GemfireFunction * @see org.springframework.data.gemfire.function.sample.ExceptionThrowingFunctionExecution - * @see org.springframework.data.gemfire.process.ProcessExecutor - * @see org.springframework.data.gemfire.process.ProcessWrapper + * @see org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 1.7.0 @@ -65,7 +57,7 @@ import org.springframework.util.Assert; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class ExceptionThrowingFunctionExecutionIntegrationTests extends IntegrationTestsSupport { +public class ExceptionThrowingFunctionExecutionIntegrationTests extends ForkingClientServerIntegrationTestsSupport { private static ProcessWrapper gemfireServer; @@ -73,51 +65,16 @@ public class ExceptionThrowingFunctionExecutionIntegrationTests extends Integrat private ExceptionThrowingFunctionExecution exceptionThrowingFunctionExecution; @BeforeClass - public static void startGemFireServer() throws IOException { - - String serverName = ExceptionThrowingFunctionExecutionIntegrationTests.class.getSimpleName().concat("Server"); - - File serverWorkingDirectory = new File(FileSystemUtils.WORKING_DIRECTORY, serverName.toLowerCase()); - - Assert.isTrue(serverWorkingDirectory.isDirectory() || serverWorkingDirectory.mkdirs(), - String.format("Failed to create working directory [%s]", serverWorkingDirectory)); + public static void startGeodeServer() throws IOException { List arguments = new ArrayList<>(); - arguments.add("-Dgemfire.name=" + serverName); - arguments.add("-Dgemfire.log-level=error"); - arguments.add(ExceptionThrowingFunctionExecutionIntegrationTests.class.getName() - .replace(".", "/") - .concat("-server-context.xml")); + arguments.add(String.format("-Dgemfire.name=%s", + ExceptionThrowingFunctionExecutionIntegrationTests.class.getSimpleName().concat("Server"))); - gemfireServer = ProcessExecutor.launch(serverWorkingDirectory, ServerProcess.class, - arguments.toArray(new String[0])); + arguments.add(getServerContextXmlFileLocation(ExceptionThrowingFunctionExecutionIntegrationTests.class)); - waitForServerStart(TimeUnit.SECONDS.toMillis(20)); - } - - private static void waitForServerStart(final long milliseconds) { - - ThreadUtils.timedWait(milliseconds, TimeUnit.MILLISECONDS.toMillis(500), new ThreadUtils.Condition() { - - private final File serverPidControlFile = new File(gemfireServer.getWorkingDirectory(), - ServerProcess.getServerProcessControlFilename()); - - @Override - public boolean evaluate() { - return !serverPidControlFile.isFile(); - } - }); - } - - @AfterClass - public static void stopGemFireServer() { - - gemfireServer.shutdown(); - - if (Boolean.parseBoolean(System.getProperty("spring.gemfire.fork.clean", Boolean.TRUE.toString()))) { - org.springframework.util.FileSystemUtils.deleteRecursively(gemfireServer.getWorkingDirectory()); - } + startGemFireServer(ServerProcess.class, arguments.toArray(new String[0])); } @Test(expected = FunctionException.class) diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/function/FunctionWithRequiredPermissionsRegistrationIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/function/FunctionWithRequiredPermissionsRegistrationIntegrationTests.java index dfc697f6..a02ababc 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/function/FunctionWithRequiredPermissionsRegistrationIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/function/FunctionWithRequiredPermissionsRegistrationIntegrationTests.java @@ -13,24 +13,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.springframework.data.gemfire.function; import static org.assertj.core.api.Assertions.assertThat; import java.lang.annotation.Annotation; +import org.junit.Test; +import org.junit.runner.RunWith; + import org.apache.geode.cache.execute.Function; import org.apache.geode.cache.execute.FunctionService; import org.apache.geode.security.ResourcePermission; -import org.junit.Test; -import org.junit.runner.RunWith; - import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.gemfire.function.annotation.GemfireFunction; import org.springframework.data.gemfire.function.config.EnableGemfireFunctions; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -44,21 +44,23 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.springframework.context.annotation.Configuration * @see org.springframework.data.gemfire.function.annotation.GemfireFunction * @see org.springframework.data.gemfire.function.config.EnableGemfireFunctions + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 2.1.0 */ @RunWith(SpringRunner.class) @ContextConfiguration -@SuppressWarnings({ "unchecked", "unused" }) -public class FunctionWithRequiredPermissionsRegistrationIntegrationTests { +@SuppressWarnings("unused") +public class FunctionWithRequiredPermissionsRegistrationIntegrationTests extends IntegrationTestsSupport { @Test public void functionsRegisteredWithRequiredPermissionsSuccessfully() { - Function function = FunctionService.getFunction("testFunctionWithRequiredPermissions"); + Function function = FunctionService.getFunction("testFunctionWithRequiredPermissions"); assertThat(function).isNotNull(); + assertThat(function.getRequiredPermissions("test")).containsExactly( new ResourcePermission(ResourcePermission.Resource.CLUSTER, ResourcePermission.Operation.MANAGE), new ResourcePermission(ResourcePermission.Resource.DATA, ResourcePermission.Operation.READ, "Example") diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/function/config/FunctionExecutionClientCacheTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/function/config/FunctionExecutionClientCacheTests.java index 4f6b9d5d..a7d6eea4 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/function/config/FunctionExecutionClientCacheTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/function/config/FunctionExecutionClientCacheTests.java @@ -35,16 +35,17 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; import org.springframework.data.gemfire.function.execution.GemfireOnServerFunctionTemplate; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** * @author David Turanski - * + * @author John Blum */ @RunWith(SpringRunner.class) -@ContextConfiguration(classes = { TestClientCacheConfig.class }) -public class FunctionExecutionClientCacheTests { +@ContextConfiguration(classes = ClientCacheTestConfiguration.class) +public class FunctionExecutionClientCacheTests extends IntegrationTestsSupport { @Autowired ApplicationContext applicationContext; @@ -79,7 +80,7 @@ public class FunctionExecutionClientCacheTests { @ImportResource("/org/springframework/data/gemfire/function/config/FunctionExecutionCacheClientTests-context.xml") @EnableGemfireFunctionExecutions(basePackages = "org.springframework.data.gemfire.function.config.three") @SuppressWarnings("unused") -class TestClientCacheConfig { +class ClientCacheTestConfiguration { @Bean MyResultCollector myResultCollector() { diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/function/config/FunctionsWithClientCacheTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/function/config/FunctionsWithClientCacheTests.java index 4fe1fcc8..5202dc46 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/function/config/FunctionsWithClientCacheTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/function/config/FunctionsWithClientCacheTests.java @@ -15,6 +15,7 @@ package org.springframework.data.gemfire.function.config; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -25,7 +26,7 @@ import org.springframework.test.context.junit4.SpringRunner; */ @RunWith(SpringRunner.class) @ContextConfiguration(initializers = GemFireMockObjectsApplicationContextInitializer.class) -public class FunctionsWithClientCacheTests { +public class FunctionsWithClientCacheTests extends IntegrationTestsSupport { @Test public void doNothing() { diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/function/config/XmlConfiguredFunctionExecutionIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/function/config/XmlConfiguredFunctionExecutionIntegrationTests.java index 99d4f81c..a72b3a5b 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/function/config/XmlConfiguredFunctionExecutionIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/function/config/XmlConfiguredFunctionExecutionIntegrationTests.java @@ -25,6 +25,7 @@ import org.springframework.data.gemfire.TestUtils; import org.springframework.data.gemfire.function.config.two.TestOnRegionFunction; import org.springframework.data.gemfire.function.execution.GemfireOnRegionFunctionTemplate; import org.springframework.data.gemfire.function.execution.OnRegionFunctionProxyFactoryBean; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -36,7 +37,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(initializers = GemFireMockObjectsApplicationContextInitializer.class) @SuppressWarnings("unused") -public class XmlConfiguredFunctionExecutionIntegrationTests { +public class XmlConfiguredFunctionExecutionIntegrationTests extends IntegrationTestsSupport { @Autowired private ApplicationContext applicationContext; diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/listener/adapter/ContainerXmlSetupIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/listener/adapter/ContainerXmlConfigurationIntegrationTests.java similarity index 86% rename from spring-data-geode/src/test/java/org/springframework/data/gemfire/listener/adapter/ContainerXmlSetupIntegrationTests.java rename to spring-data-geode/src/test/java/org/springframework/data/gemfire/listener/adapter/ContainerXmlConfigurationIntegrationTests.java index 1e5e126f..1eda587e 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/listener/adapter/ContainerXmlSetupIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/listener/adapter/ContainerXmlConfigurationIntegrationTests.java @@ -30,6 +30,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.data.gemfire.fork.CqCacheServerProcess; import org.springframework.data.gemfire.listener.ContinuousQueryListenerContainer; import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport; +import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -44,14 +45,14 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.springframework.data.gemfire.fork.CqCacheServerProcess * @see org.springframework.data.gemfire.listener.ContinuousQueryListenerContainer * @see org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport + * @see org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner */ @RunWith(SpringRunner.class) -@ContextConfiguration +@ContextConfiguration(initializers = GemFireMockObjectsApplicationContextInitializer.class) @SuppressWarnings("unused") -// TODO change this test to use mocks!! -public class ContainerXmlSetupIntegrationTests extends ForkingClientServerIntegrationTestsSupport { +public class ContainerXmlConfigurationIntegrationTests extends ForkingClientServerIntegrationTestsSupport { @BeforeClass public static void startGemFireServer() throws Exception { @@ -75,7 +76,7 @@ public class ContainerXmlSetupIntegrationTests extends ForkingClientServerIntegr ClientCache cache = applicationContext.getBean(ClientCache.class); Pool pool = applicationContext.getBean(Pool.class); - assertThat(cache.getName()).isEqualTo("ContainerXmlSetupIntegrationTests"); + assertThat(cache.getName()).isEqualTo("ContainerXmlConfigurationIntegrationTests"); assertThat(pool.getName()).isEqualTo("client"); CqQuery[] cacheCqs = cache.getQueryService().getCqs(); diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/mapping/TypeMappingPdxSerializerIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/mapping/TypeMappingPdxSerializerIntegrationTests.java index 06d1c27b..ed39e509 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/mapping/TypeMappingPdxSerializerIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/mapping/TypeMappingPdxSerializerIntegrationTests.java @@ -35,6 +35,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -49,11 +50,15 @@ import example.app.model.ComplexType; * @see org.apache.geode.pdx.PdxSerializer * @see org.apache.geode.pdx.PdxWriter * @see org.springframework.data.gemfire.mapping.MappingPdxSerializer + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport + * @see org.springframework.test.context.ContextConfiguration + * @see org.springframework.test.context.junit4.SpringRunner * @since 2.5.0 */ @RunWith(SpringRunner.class) @ContextConfiguration -public class TypeMappingPdxSerializerIntegrationTests { +@SuppressWarnings("unused") +public class TypeMappingPdxSerializerIntegrationTests extends IntegrationTestsSupport { @Autowired private MappingPdxSerializer pdxSerializer; @@ -78,13 +83,11 @@ public class TypeMappingPdxSerializerIntegrationTests { this.pdxSerializer.toData(complexType, mockPdxWriter); verify(mockPdxWriter, times(1)).writeField(eq("id"), eq(2L), eq(Long.class)); - verify(mockPdxWriter, times(1)) - .writeField(eq("decimalValue"), eq(new BigDecimal(123)), eq(BigDecimal.class)); - verify(mockPdxWriter, times(1)) - .writeField(eq("integerValue"), eq(new BigInteger("987")), eq(BigInteger.class)); - verify(mockPdxWriter, times(1)) - .writeField(eq("name"), eq("TEST"), eq(String.class)); + verify(mockPdxWriter, times(1)).writeField(eq("decimalValue"), eq(new BigDecimal(123)), eq(BigDecimal.class)); + verify(mockPdxWriter, times(1)).writeField(eq("integerValue"), eq(new BigInteger("987")), eq(BigInteger.class)); + verify(mockPdxWriter, times(1)).writeField(eq("name"), eq("TEST"), eq(String.class)); verify(mockPdxWriter, times(1)).markIdentityField(eq("id")); + verifyNoMoreInteractions(mockPdxWriter); } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/query/QueryPostProcessorIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/query/QueryPostProcessorIntegrationTests.java index adc89f33..94579290 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/query/QueryPostProcessorIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/query/QueryPostProcessorIntegrationTests.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.springframework.data.gemfire.repository.query; import static org.assertj.core.api.Assertions.assertThat; @@ -23,13 +22,13 @@ import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicLong; -import org.apache.geode.cache.GemFireCache; -import org.apache.geode.cache.client.ClientRegionShortcut; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.apache.geode.cache.GemFireCache; +import org.apache.geode.cache.client.ClientRegionShortcut; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.data.gemfire.client.ClientRegionFactoryBean; @@ -40,21 +39,28 @@ import org.springframework.data.gemfire.repository.sample.PersonRepository; import org.springframework.data.gemfire.repository.sample.User; import org.springframework.data.gemfire.repository.sample.UserRepository; import org.springframework.data.gemfire.repository.support.GemfireRepositoryFactoryBean; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.repository.Repository; import org.springframework.data.repository.query.QueryMethod; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * The QueryPostProcessorIntegrationTests class... + * Integration Tests for {@link QueryPostProcessor}. * * @author John Blum - * @since 1.0.0 + * @see org.junit.Test + * @see org.apache.geode.cache.GemFireCache + * @see org.springframework.data.gemfire.repository.query.QueryPostProcessor + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport + * @see org.springframework.test.context.ContextConfiguration + * @see org.springframework.test.context.junit4.SpringRunner + * @since 2.0.0 */ @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class QueryPostProcessorIntegrationTests { +public class QueryPostProcessorIntegrationTests extends IntegrationTestsSupport { private static final AtomicLong idSequence = new AtomicLong(0L); @@ -212,6 +218,7 @@ public class QueryPostProcessorIntegrationTests { } } + @SuppressWarnings("rawtypes") static class RecordingQueryPostProcessor implements QueryPostProcessor { List queries = new CopyOnWriteArrayList<>(); diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/query/RepositoryQueryUsingInOperatorIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/query/RepositoryQueryUsingInOperatorIntegrationTests.java index 1ffdc4e0..996c0e91 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/query/RepositoryQueryUsingInOperatorIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/query/RepositoryQueryUsingInOperatorIntegrationTests.java @@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.gemfire.config.annotation.ClientCacheApplication; import org.springframework.data.gemfire.config.annotation.EnableEntityDefinedRegions; import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.gemfire.util.ArrayUtils; import org.springframework.data.gemfire.util.CollectionUtils; import org.springframework.test.context.ContextConfiguration; @@ -45,8 +46,10 @@ import example.app.repo.UserRepository; * * @author John Blum * @see org.junit.Test + * @see org.apache.geode.cache.Region * @see org.springframework.data.gemfire.repository.GemfireRepository * @see org.springframework.data.gemfire.repository.config.EnableGemfireRepositories + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @see Fix bug with SDG Repository derived queries using the IN operator with numeric values. @@ -55,11 +58,11 @@ import example.app.repo.UserRepository; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class RepositoryQueryUsingInOperatorIntegrationTests { +public class RepositoryQueryUsingInOperatorIntegrationTests extends IntegrationTestsSupport { private static final AtomicBoolean initialized = new AtomicBoolean(false); - private List users = Arrays.asList( + private final List users = Arrays.asList( User.as("jonDoe").identifiedBy(1), User.as("janeDoe").identifiedBy(2), User.as("cookieDoe").identifiedBy(3), @@ -144,9 +147,9 @@ public class RepositoryQueryUsingInOperatorIntegrationTests { assertThat(usersByName).containsExactly(findUsersByNames("jonDoe", "sourDoe")); } - @ClientCacheApplication(name = "RepositoryQueryUsingInOperatorIntegrationTests") + @ClientCacheApplication @EnableEntityDefinedRegions(basePackageClasses = User.class, clientRegionShortcut = ClientRegionShortcut.LOCAL) @EnableGemfireRepositories(basePackageClasses = UserRepository.class) - static class TestGeodeConfiguration { } + static class TestConfiguration { } } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/AlgorithmRepositoryTest.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/AlgorithmRepositoryIntegrationTests.java similarity index 80% rename from spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/AlgorithmRepositoryTest.java rename to spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/AlgorithmRepositoryIntegrationTests.java index 28fe8405..e1c49bab 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/AlgorithmRepositoryTest.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/AlgorithmRepositoryIntegrationTests.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.springframework.data.gemfire.repository.sample; import static org.junit.Assert.assertEquals; @@ -23,23 +22,26 @@ import static org.junit.Assert.assertTrue; import javax.annotation.Resource; -import org.apache.geode.cache.Region; - import org.junit.Test; import org.junit.runner.RunWith; +import org.apache.geode.cache.Region; + import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * The AlgorithmRepositoryTest class is a test suite of test cases testing the contract and functionality of GemFire's - * Repository extension when using a plain old Java interface for defining the application domain object/entity type, - * rather than a Java class, that is the subject of the persistence operations. + * The AlgorithmRepositoryIntegrationTests class is a test suite of test cases testing the contract and functionality of + * GemFire's Repository extension when using a plain old Java interface for defining the application domain object + * /entity type, rather than a Java class, that is the subject of the persistence operations. * * @author John Blum * @see org.junit.Test - * @see org.junit.runner.RunWith + * @see org.apache.geode.cache.Region + * @see org.springframework.data.gemfire.repository.GemfireRepository + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner * @since 1.4.0 @@ -47,16 +49,17 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class AlgorithmRepositoryTest { +public class AlgorithmRepositoryIntegrationTests extends IntegrationTestsSupport { @Autowired private AlgorithmRepository algorithmRepo; @Resource(name = "Algorithms") - private Region algorithmsRegion; + private Region algorithmsRegion; @Test public void algorithmsRepositoryFunctionsCorrectly() { + assertNotNull("A reference to the AlgorithmRepository was not properly configured!", algorithmRepo); assertNotNull("A reference to the 'Algorithms' GemFire Cache Region was not properly configured!", algorithmsRegion); @@ -92,9 +95,8 @@ public class AlgorithmRepositoryTest { } } - protected static final class BinarySearch extends AbstractAlgorithm { - } + protected static final class BinarySearch extends AbstractAlgorithm { } + + protected static final class HeapSort extends AbstractAlgorithm { } - protected static final class HeapSort extends AbstractAlgorithm { - } } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/AnimalRepositoryTest.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/AnimalRepositoryIntegrationTests.java similarity index 85% rename from spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/AnimalRepositoryTest.java rename to spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/AnimalRepositoryIntegrationTests.java index 734ddcc4..e48efa76 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/AnimalRepositoryTest.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/AnimalRepositoryIntegrationTests.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.springframework.data.gemfire.repository.sample; import static org.assertj.core.api.Assertions.assertThat; @@ -24,17 +23,20 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * Integration test testing the functionality behind PR #55 involving persisting application domain object/entities - * to multiple Regions in a GemFire Cache. + * Integration Tests testing the functionality behind PR #55 involving persisting application domain object/entities + * to multiple Regions in an Apache Geode cache. * * @author Stuart Williams * @author John Blum * @see org.junit.Test - * @see org.junit.runner.RunWith + * @see org.apache.geode.cache.Region + * @see org.springframework.data.gemfire.repository.GemfireRepository + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @link https://github.com/spring-projects/spring-data-gemfire/pull/55 @@ -43,7 +45,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class AnimalRepositoryTest { +public class AnimalRepositoryIntegrationTests extends IntegrationTestsSupport { @Autowired private CatRepository catRepo; @@ -52,14 +54,18 @@ public class AnimalRepositoryTest { private DogRepository dogRepo; protected static Animal newAnimal(long id, String name) { + Animal animal = new Animal(); + animal.setId(id); animal.setName(name); + return animal; } @Test public void entityStoredInMultipleRegionsIsSuccessful() { + Animal felix = newAnimal(1, "Felix"); Animal leo = newAnimal(2, "Leo"); Animal cerberus = newAnimal(3, "Cerberus"); diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/RepositoryDataAccessOnRegionUsingCacheLoaderIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/RepositoryDataAccessOnRegionUsingCacheLoaderIntegrationTests.java index 73e0ebc0..2dd42a29 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/RepositoryDataAccessOnRegionUsingCacheLoaderIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/RepositoryDataAccessOnRegionUsingCacheLoaderIntegrationTests.java @@ -40,6 +40,7 @@ import org.springframework.data.gemfire.client.ClientRegionFactoryBean; import org.springframework.data.gemfire.config.annotation.ClientCacheApplication; import org.springframework.data.gemfire.mapping.GemfireMappingContext; import org.springframework.data.gemfire.repository.support.GemfireRepositoryFactoryBean; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.repository.Repository; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -55,6 +56,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.apache.geode.cache.Region * @see org.springframework.data.gemfire.config.annotation.ClientCacheApplication * @see org.springframework.data.gemfire.repository.support.GemfireRepositoryFactoryBean + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.data.repository.Repository * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner @@ -63,7 +65,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class RepositoryDataAccessOnRegionUsingCacheLoaderIntegrationTests { +public class RepositoryDataAccessOnRegionUsingCacheLoaderIntegrationTests extends IntegrationTestsSupport { @Autowired private PersonRepository personRepository; @@ -106,7 +108,7 @@ public class RepositoryDataAccessOnRegionUsingCacheLoaderIntegrationTests { assertThat(people).isEmpty(); } - @ClientCacheApplication(name = "RepositoryDataAccessOnRegionUsingCacheLoaderIntegrationTests") + @ClientCacheApplication static class TestConfiguration { @Bean("simple") diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/SubRegionRepositoryIntegrationTest.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/SubRegionRepositoryIntegrationTest.java index fbcc3148..23f20378 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/SubRegionRepositoryIntegrationTest.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/SubRegionRepositoryIntegrationTest.java @@ -13,14 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.springframework.data.gemfire.repository.sample; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.Collections; @@ -30,28 +25,30 @@ import java.util.Map; import javax.annotation.Resource; -import org.apache.geode.cache.Region; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.apache.geode.cache.Region; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.gemfire.repository.Wrapper; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * Integration tests testing the use of GemFire Repositories on GemFire Cache Subregions. + * Integration Tests testing the use of GemFire Repositories on GemFire Cache Subregions. * * @author John Blum * @see org.junit.Test - * @see org.junit.runner.RunWith + * @see org.springframework.data.gemfire.repository.GemfireRepository * @see org.springframework.data.gemfire.repository.Wrapper * @see org.springframework.data.gemfire.repository.sample.Programmer * @see org.springframework.data.gemfire.repository.sample.ProgrammerRepository + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration - * @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner + * @see org.springframework.test.context.junit4.SpringRunner * @see org.apache.geode.cache.Region * @link https://jira.springsource.org/browse/SGF-251 * @link https://jira.springsource.org/browse/SGF-252 @@ -60,7 +57,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration("subregionRepository.xml") @SuppressWarnings("unused") -public class SubRegionRepositoryIntegrationTest { +public class SubRegionRepositoryIntegrationTest extends IntegrationTestsSupport { private static final Map ADMIN_USER_DATA = new HashMap<>(5, 0.90f); @@ -112,38 +109,39 @@ public class SubRegionRepositoryIntegrationTest { @Autowired private RootUserRepository adminUserRepo; - protected static RootUser createAdminUser(final String username) { + private static RootUser createAdminUser(String username) { RootUser user = new RootUser(username); ADMIN_USER_DATA.put(username, user); return user; } - protected static GuestUser createGuestUser(final String username) { + private static GuestUser createGuestUser(String username) { GuestUser user = new GuestUser(username); GUEST_USER_DATA.put(username, user); return user; } - protected static RootUser getAdminUser(final String username) { + private static RootUser getAdminUser(String username) { List users = getAdminUsers(username); return (users.isEmpty() ? null : users.get(0)); } - protected static List getAdminUsers(final String... usernames) { + private static List getAdminUsers(String... usernames) { return getUsers(ADMIN_USER_DATA, usernames); } - protected static GuestUser getGuestUser(final String username) { + private static GuestUser getGuestUser(String username) { List users = getGuestUsers(username); return (users.isEmpty() ? null : users.get(0)); } - protected static List getGuestUsers(final String... usernames) { + private static List getGuestUsers(String... usernames) { return getUsers(GUEST_USER_DATA, usernames); } - protected static List getUsers(final Map userData, final String... usernames) { - List users = new ArrayList(usernames.length); + private static List getUsers(Map userData, String... usernames) { + + List users = new ArrayList<>(usernames.length); for (String username : usernames) { T user = userData.get(username); @@ -158,15 +156,16 @@ public class SubRegionRepositoryIntegrationTest { return users; } - protected static Programmer createProgrammer(final String username, final String programmingLanguage) { + private static Programmer createProgrammer(String username, String programmingLanguage) { Programmer programmer = new Programmer(username); programmer.setProgrammingLanguage(programmingLanguage); PROGRAMMER_USER_DATA.put(username, programmer); return programmer; } - protected static List getProgrammers(final String... usernames) { - List programmers = new ArrayList(usernames.length); + private static List getProgrammers(String... usernames) { + + List programmers = new ArrayList<>(usernames.length); for (String username : usernames) { Programmer programmer = PROGRAMMER_USER_DATA.get(username); @@ -183,46 +182,48 @@ public class SubRegionRepositoryIntegrationTest { @Before public void setup() { - assertNotNull("The /Users/Programmers Subregion was null!", programmers); + + assertThat(programmers).as("The /Users/Programmers Subregion was null!").isNotNull(); if (programmers.isEmpty()) { programmers.putAll(PROGRAMMER_USER_DATA); } - assertEquals(PROGRAMMER_USER_DATA.size(), programmers.size()); - assertNotNull("The /Local/Admins/Users Subregion was null!", adminUsers); + assertThat(programmers.size()).isEqualTo(PROGRAMMER_USER_DATA.size()); + assertThat(adminUsers).as("The /Local/Admins/Users Subregion was null!").isNotNull(); if (adminUsers.isEmpty()) { adminUsers.putAll(ADMIN_USER_DATA); } - assertEquals(ADMIN_USER_DATA.size(), adminUsers.size()); - assertNotNull("The /Local/Guest/Users Subregion was null!", guestUsers); + assertThat(adminUsers.size()).isEqualTo(ADMIN_USER_DATA.size()); + assertThat(guestUsers).as("The /Local/Guest/Users Subregion was null!").isNotNull(); if (guestUsers.isEmpty()) { guestUsers.putAll(GUEST_USER_DATA); } - assertEquals(GUEST_USER_DATA.size(), guestUsers.size()); + assertThat(guestUsers.size()).isEqualTo(GUEST_USER_DATA.size()); } @Test public void testSubregionRepositoryInteractions() { + assertThat(programmersRepo.findById("JamesGosling").orElse(null)).isEqualTo(PROGRAMMER_USER_DATA.get("JamesGosling")); List javaProgrammers = programmersRepo.findDistinctByProgrammingLanguageOrderByUsernameAsc("Java"); - assertNotNull(javaProgrammers); - assertFalse(javaProgrammers.isEmpty()); - assertEquals(2, javaProgrammers.size()); - assertEquals(javaProgrammers, getProgrammers("JamesGosling", "JoshuaBloch")); + assertThat(javaProgrammers).isNotNull(); + assertThat(javaProgrammers.isEmpty()).isFalse(); + assertThat(javaProgrammers.size()).isEqualTo(2); + assertThat(getProgrammers("JamesGosling", "JoshuaBloch")).isEqualTo(javaProgrammers); List groovyProgrammers = programmersRepo.findDistinctByProgrammingLanguageLikeOrderByUsernameAsc("Groovy"); - assertNotNull(groovyProgrammers); - assertFalse(groovyProgrammers.isEmpty()); - assertEquals(1, groovyProgrammers.size()); - assertEquals(groovyProgrammers, getProgrammers("JamesStrachan")); + assertThat(groovyProgrammers).isNotNull(); + assertThat(groovyProgrammers.isEmpty()).isFalse(); + assertThat(groovyProgrammers.size()).isEqualTo(1); + assertThat(getProgrammers("JamesStrachan")).isEqualTo(groovyProgrammers); programmersRepo.save(new Wrapper<>(createProgrammer("RodJohnson", "Java"), "RodJohnson")); programmersRepo.save(new Wrapper<>(createProgrammer("GuillaumeLaforge", "Groovy"), "GuillaumeLaforge")); @@ -230,49 +231,51 @@ public class SubRegionRepositoryIntegrationTest { javaProgrammers = programmersRepo.findDistinctByProgrammingLanguageOrderByUsernameAsc("Java"); - assertNotNull(javaProgrammers); - assertFalse(javaProgrammers.isEmpty()); - assertEquals(3, javaProgrammers.size()); - assertEquals(javaProgrammers, getProgrammers("JamesGosling", "JoshuaBloch", "RodJohnson")); + assertThat(javaProgrammers).isNotNull(); + assertThat(javaProgrammers.isEmpty()).isFalse(); + assertThat(javaProgrammers.size()).isEqualTo(3); + assertThat(getProgrammers("JamesGosling", "JoshuaBloch", "RodJohnson")).isEqualTo(javaProgrammers); groovyProgrammers = programmersRepo.findDistinctByProgrammingLanguageLikeOrderByUsernameAsc("Groovy"); - assertNotNull(groovyProgrammers); - assertFalse(groovyProgrammers.isEmpty()); - assertEquals(3, groovyProgrammers.size()); - assertEquals(groovyProgrammers, getProgrammers("GraemeRocher", "GuillaumeLaforge", "JamesStrachan")); + assertThat(groovyProgrammers).isNotNull(); + assertThat(groovyProgrammers.isEmpty()).isFalse(); + assertThat(groovyProgrammers.size()).isEqualTo(3); + assertThat(getProgrammers("GraemeRocher", "GuillaumeLaforge", "JamesStrachan")).isEqualTo(groovyProgrammers); List javaLikeProgrammers = programmersRepo.findDistinctByProgrammingLanguageLikeOrderByUsernameAsc("Java%"); - assertNotNull(javaLikeProgrammers); - assertFalse(javaLikeProgrammers.isEmpty()); - assertEquals(4, javaLikeProgrammers.size()); - assertEquals(javaLikeProgrammers, getProgrammers("BrendanEich", "JamesGosling", "JoshuaBloch", "RodJohnson")); + assertThat(javaLikeProgrammers).isNotNull(); + assertThat(javaLikeProgrammers.isEmpty()).isFalse(); + assertThat(javaLikeProgrammers.size()).isEqualTo(4); + assertThat(getProgrammers("BrendanEich", "JamesGosling", "JoshuaBloch", "RodJohnson")) + .isEqualTo(javaLikeProgrammers); List pseudoCodeProgrammers = programmersRepo.findDistinctByProgrammingLanguageLikeOrderByUsernameAsc("PseudoCode"); - assertNotNull(pseudoCodeProgrammers); - assertTrue(pseudoCodeProgrammers.isEmpty()); + assertThat(pseudoCodeProgrammers).isNotNull(); + assertThat(pseudoCodeProgrammers.isEmpty()).isTrue(); } @Test public void testIdenticallyNamedSubregionDataAccess() { + assertThat(adminUserRepo.findById("supertool").orElse(null)).isEqualTo(getAdminUser("supertool")); assertThat(guestUserRepo.findById("joeblow").orElse(null)).isEqualTo(getGuestUser("joeblow")); List rootUsers = adminUserRepo.findDistinctByUsername("zeus"); - assertNotNull(rootUsers); - assertFalse(rootUsers.isEmpty()); - assertEquals(1, rootUsers.size()); + assertThat(rootUsers).isNotNull(); + assertThat(rootUsers.isEmpty()).isFalse(); + assertThat(rootUsers.size()).isEqualTo(1); - assertEquals(getAdminUser("zeus"), rootUsers.get(0)); + assertThat(rootUsers.get(0)).isEqualTo(getAdminUser("zeus")); List guestUsers = guestUserRepo.findDistinctByUsername("bubba"); - assertNotNull(guestUsers); - assertFalse(guestUsers.isEmpty()); - assertEquals(1, guestUsers.size()); - assertEquals(getGuestUser("bubba"), guestUsers.get(0)); + assertThat(guestUsers).isNotNull(); + assertThat(guestUsers.isEmpty()).isFalse(); + assertThat(guestUsers.size()).isEqualTo(1); + assertThat(guestUsers.get(0)).isEqualTo(getGuestUser("bubba")); } } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/UserRepositoryQueriesIntegrationTest.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/UserRepositoryQueriesIntegrationTests.java similarity index 77% rename from spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/UserRepositoryQueriesIntegrationTest.java rename to spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/UserRepositoryQueriesIntegrationTests.java index e2fedff3..0e9b8ed1 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/UserRepositoryQueriesIntegrationTest.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/sample/UserRepositoryQueriesIntegrationTests.java @@ -15,10 +15,7 @@ */ package org.springframework.data.gemfire.repository.sample; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import java.time.Instant; import java.util.ArrayList; @@ -34,16 +31,17 @@ import org.junit.runner.RunWith; import org.apache.geode.cache.Region; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * The RepositoryQueriesTest class is a test suite of test cases testing the GemFire Query capability of Spring Data - * GemFire Repositories. + * Integration Tests for Apache Geode OQL query capabilities provided by Spring Data for Apache Geode Repositories. * * @author John Blum * @see org.junit.Test - * @see org.junit.runner.RunWith + * @see org.apache.geode.cache.Region + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 1.3.3 @@ -51,7 +49,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration("userRepositoryQueriesIntegrationTest.xml") @SuppressWarnings("unused") -public class UserRepositoryQueriesIntegrationTest { +public class UserRepositoryQueriesIntegrationTests extends IntegrationTestsSupport { @Resource(name = "Users") @SuppressWarnings("rawtypes") @@ -62,7 +60,7 @@ public class UserRepositoryQueriesIntegrationTest { private static void assertQueryResults(Iterable actualUsers, String... expectedUsernames) { - assertNotNull("The query did not return any results!", actualUsers); + assertThat(actualUsers).as("The query did not return any results!").isNotNull(); List actualUsernames = new ArrayList<>(expectedUsernames.length); @@ -70,8 +68,8 @@ public class UserRepositoryQueriesIntegrationTest { actualUsernames.add(actualUser.getUsername()); } - assertEquals(expectedUsernames.length, actualUsernames.size()); - assertTrue(actualUsernames.containsAll(Arrays.asList(expectedUsernames))); + assertThat(actualUsernames.size()).isEqualTo(expectedUsernames.length); + assertThat(actualUsernames.containsAll(Arrays.asList(expectedUsernames))).isTrue(); } private static User createUser(String username) { @@ -98,9 +96,10 @@ public class UserRepositoryQueriesIntegrationTest { } @Before + @SuppressWarnings("unchecked") public void setup() { - assertNotNull("The 'Users' GemFire Cache Region cannot be null!", users); + assertThat(users).describedAs("The 'Users' GemFire Cache Region cannot be null!").isNotNull(); if (users.isEmpty()) { userRepository.save(createUser("blumj", true)); @@ -113,8 +112,8 @@ public class UserRepositoryQueriesIntegrationTest { userRepository.save(createUser("doep", false)); userRepository.save(createUser("doec", false)); - assertFalse(users.isEmpty()); - assertEquals(9, users.size()); + assertThat(users.isEmpty()).isFalse(); + assertThat(users.size()).isEqualTo(9); } } @@ -139,15 +138,15 @@ public class UserRepositoryQueriesIntegrationTest { Integer count = userRepository.countUsersByUsernameLike("doe%"); - assertEquals(3, toIntValue(count)); + assertThat(toIntValue(count)).isEqualTo(3); count = userRepository.countUsersByUsernameLike("handy%"); - assertEquals(2, toIntValue(count)); + assertThat(toIntValue(count)).isEqualTo(2); count = userRepository.countUsersByUsernameLike("smith%"); - assertNotNull(count); - assertEquals(0, toIntValue(count)); + assertThat(count).isNotNull(); + assertThat(toIntValue(count)).isEqualTo(0); } } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/support/SimpleGemfireRepositoryIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/support/SimpleGemfireRepositoryIntegrationTests.java index 7592e659..ee6d5144 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/support/SimpleGemfireRepositoryIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/support/SimpleGemfireRepositoryIntegrationTests.java @@ -44,6 +44,7 @@ import org.springframework.data.gemfire.config.annotation.PeerCacheApplication; import org.springframework.data.gemfire.mapping.GemfireMappingContext; import org.springframework.data.gemfire.mapping.GemfirePersistentEntity; import org.springframework.data.gemfire.repository.sample.Person; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.repository.core.EntityInformation; import org.springframework.data.repository.core.support.PersistentEntityInformation; import org.springframework.test.context.ContextConfiguration; @@ -62,15 +63,14 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.springframework.data.gemfire.LocalRegionFactoryBean * @see org.springframework.data.gemfire.config.annotation.PeerCacheApplication * @see org.springframework.data.gemfire.repository.support.SimpleGemfireRepository + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner */ @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class SimpleGemfireRepositoryIntegrationTests { - - static final String GEMFIRE_LOG_LEVEL = "warning"; +public class SimpleGemfireRepositoryIntegrationTests extends IntegrationTestsSupport { @Autowired private GemfireTemplate template; @@ -130,8 +130,9 @@ public class SimpleGemfireRepositoryIntegrationTests { this.repository.deleteAllById(Arrays.asList(1L, 2L)); assertThat(this.repository.count()).isEqualTo(3L); - assertThat(this.repository.findAll()) // - .extracting(Person::getFirstname) // + + assertThat(this.repository.findAll()) + .extracting(Person::getFirstname) .containsExactlyInAnyOrder("Cookie", "Pie", "Sour"); } @@ -226,8 +227,8 @@ public class SimpleGemfireRepositoryIntegrationTests { assertThat(this.template.put(oliverGierke.getId(), oliverGierke)).isNull(); - SelectResults people = this.template.find("SELECT * FROM /People p WHERE p.firstname = $1", - oliverGierke.getFirstname()); + SelectResults people = + this.template.find("SELECT * FROM /People p WHERE p.firstname = $1", oliverGierke.getFirstname()); assertThat(people.size()).isEqualTo(1); assertThat(people.iterator().next()).isEqualTo(oliverGierke); @@ -278,7 +279,7 @@ public class SimpleGemfireRepositoryIntegrationTests { } } - @PeerCacheApplication(name = "SimpleGemfireRepositoryIntegrationTests", logLevel = GEMFIRE_LOG_LEVEL) + @PeerCacheApplication static class SimpleGemfireRepositoryConfiguration { @Bean(name = "People") @@ -287,7 +288,6 @@ public class SimpleGemfireRepositoryIntegrationTests { LocalRegionFactoryBean peopleRegion = new LocalRegionFactoryBean<>(); peopleRegion.setCache(gemfireCache); - peopleRegion.setClose(false); peopleRegion.setPersistent(false); return peopleRegion; diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/support/SimpleGemfireRepositoryTransactionalIntegrationTest.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/support/SimpleGemfireRepositoryTransactionalIntegrationTest.java index fc697479..e3746bc5 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/support/SimpleGemfireRepositoryTransactionalIntegrationTest.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/repository/support/SimpleGemfireRepositoryTransactionalIntegrationTest.java @@ -40,6 +40,7 @@ import org.springframework.data.gemfire.mapping.GemfireMappingContext; import org.springframework.data.gemfire.mapping.GemfirePersistentEntity; import org.springframework.data.gemfire.repository.GemfireRepository; import org.springframework.data.gemfire.repository.sample.Customer; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.repository.core.EntityInformation; import org.springframework.data.repository.core.support.PersistentEntityInformation; import org.springframework.test.context.ContextConfiguration; @@ -64,7 +65,7 @@ import org.springframework.transaction.support.TransactionTemplate; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class SimpleGemfireRepositoryTransactionalIntegrationTest { +public class SimpleGemfireRepositoryTransactionalIntegrationTest extends IntegrationTestsSupport { // TODO add additional test cases for SimpleGemfireRepository (Region operations) in the presence of Transactions!!! diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/search/lucene/LuceneOperationsIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/search/lucene/LuceneOperationsIntegrationTests.java index 47703661..595d368a 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/search/lucene/LuceneOperationsIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/search/lucene/LuceneOperationsIntegrationTests.java @@ -43,6 +43,7 @@ import org.springframework.context.event.EventListener; import org.springframework.data.annotation.Id; import org.springframework.data.gemfire.PartitionedRegionFactoryBean; import org.springframework.data.gemfire.config.annotation.PeerCacheApplication; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.gemfire.util.SpringUtils; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -61,6 +62,9 @@ import lombok.RequiredArgsConstructor; * @see org.apache.geode.cache.Region * @see org.apache.geode.cache.lucene.LuceneIndex * @see org.springframework.data.gemfire.config.annotation.PeerCacheApplication + * @see org.springframework.data.gemfire.search.lucene.LuceneIndexFactoryBean + * @see org.springframework.data.gemfire.search.lucene.LuceneOperations + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 1.1.0 @@ -68,12 +72,10 @@ import lombok.RequiredArgsConstructor; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class LuceneOperationsIntegrationTests { +public class LuceneOperationsIntegrationTests extends IntegrationTestsSupport { private static final AtomicLong IDENTIFIER = new AtomicLong(0L); - protected static final String GEMFIRE_LOG_LEVEL = "none"; - private static final Person jonDoe = Person.newPerson(LocalDate.of(1969, Month.JULY, 4), "Jon", "Doe").with("Master of Science"); private static final Person janeDoe = Person.newPerson(LocalDate.of(1969, Month.AUGUST, 16), "Jane", "Doe").with("Doctor of Astrophysics"); private static final Person cookieDoe = Person.newPerson(LocalDate.of(1991, Month.APRIL, 2), "Cookie", "Doe").with("Bachelor of Physics"); @@ -120,8 +122,8 @@ public class LuceneOperationsIntegrationTests { assertThat(asNames(masterDoes)).containsAll(asNames(asUsers(jonDoe, pieDoe))); } + @PeerCacheApplication @SuppressWarnings("unused") - @PeerCacheApplication(name = "LuceneOperationsIntegrationTests", logLevel = GEMFIRE_LOG_LEVEL) static class TestConfiguration { @Bean(name = "People") diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/serialization/WiringInstantiatorTest.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/serialization/WiringInstantiatorTest.java index baf81d09..346689ea 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/serialization/WiringInstantiatorTest.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/serialization/WiringInstantiatorTest.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.springframework.data.gemfire.serialization; import static org.junit.Assert.assertEquals; @@ -29,24 +28,32 @@ import java.io.DataInput; import java.io.DataOutput; import java.util.List; -import org.apache.geode.DataSerializable; -import org.apache.geode.Instantiator; - import org.junit.Test; import org.junit.runner.RunWith; +import org.apache.geode.DataSerializable; +import org.apache.geode.Instantiator; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** * @author Costin Leau + * @author John Blum + * + * @see org.junit.Test + * @see org.apache.geode.Instantiator + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport + * @see org.springframework.test.context.ContextConfiguration + * @see org.springframework.test.context.junit4.SpringRunner */ @RunWith(SpringRunner.class) @ContextConfiguration("simple-config.xml") @SuppressWarnings("unused") -public class WiringInstantiatorTest { +public class WiringInstantiatorTest extends IntegrationTestsSupport { @Autowired private ApplicationContext applicationContext; @@ -55,7 +62,6 @@ public class WiringInstantiatorTest { private WiringInstantiator instantiator; - @SuppressWarnings("serial") public static class AnnotatedBean implements DataSerializable { @Autowired @@ -73,7 +79,6 @@ public class WiringInstantiatorTest { } - @SuppressWarnings("serial") public static class TemplateWiringBean implements DataSerializable { Beans beans; @@ -89,7 +94,6 @@ public class WiringInstantiatorTest { } - @SuppressWarnings("serial") public static class TypeA implements DataSerializable { public void fromData(DataInput arg0) { } @@ -98,7 +102,6 @@ public class WiringInstantiatorTest { } - @SuppressWarnings("serial") public static class TypeB implements DataSerializable { public void fromData(DataInput arg0) { } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/serialization/json/JSONRegionAdviceIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/serialization/json/JSONRegionAdviceIntegrationTests.java index a9803184..8857bcef 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/serialization/json/JSONRegionAdviceIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/serialization/json/JSONRegionAdviceIntegrationTests.java @@ -38,11 +38,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.gemfire.GemfireOperations; import org.springframework.data.gemfire.repository.sample.Person; import org.springframework.data.gemfire.test.support.MapBuilder; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * Integration test to test SDG support for storing and reading JSON data to/from a {@link Region} + * Integration Tests testings SDG support for storing and reading JSON data to/from a {@link Region} * by (un)marshalling JSON data using Jackson. * * @author David Turanski @@ -56,8 +57,8 @@ import org.springframework.test.context.junit4.SpringRunner; */ @RunWith(SpringRunner.class) @ContextConfiguration -@SuppressWarnings({ "unused" }) -public class JSONRegionAdviceIntegrationTests { +@SuppressWarnings("unused") +public class JSONRegionAdviceIntegrationTests extends IntegrationTestsSupport { // TODO figure out why auto-proxying the Region for JSON support prevents the GemfireTemplate from being "auto-wired", // as a GemfireTemplate rather than GemfireOperations, resulting in a NoSuchBeanDefinitionException thrown by the diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/CacheFactoryCacheResolverIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/CacheFactoryCacheResolverIntegrationTests.java index 10aea2be..7fa20a8d 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/CacheFactoryCacheResolverIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/CacheFactoryCacheResolverIntegrationTests.java @@ -29,6 +29,7 @@ import org.apache.geode.cache.GemFireCache; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.gemfire.GemfireUtils; import org.springframework.data.gemfire.config.annotation.PeerCacheApplication; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -42,6 +43,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.apache.geode.cache.GemFireCache * @see org.springframework.data.gemfire.config.annotation.PeerCacheApplication * @see org.springframework.data.gemfire.support.CacheFactoryCacheResolver + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 2.3.0 @@ -49,7 +51,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class CacheFactoryCacheResolverIntegrationTests { +public class CacheFactoryCacheResolverIntegrationTests extends IntegrationTestsSupport { @Autowired private GemFireCache peerCache; diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/GemfireBeanFactoryLocatorAnnotationConfigIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/GemfireBeanFactoryLocatorAnnotationConfigIntegrationTests.java index 1c65975d..caa1c618 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/GemfireBeanFactoryLocatorAnnotationConfigIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/GemfireBeanFactoryLocatorAnnotationConfigIntegrationTests.java @@ -57,6 +57,7 @@ public class GemfireBeanFactoryLocatorAnnotationConfigIntegrationTests extends I @Test public void beanFactoryContainsTestBeanFactoryLocatorBean() { + assertThat(beanFactory.containsBean("testBeanFactoryLocator")).isTrue(); GemfireBeanFactoryLocator testBeanFactoryLocator = beanFactory.getBean("testBeanFactoryLocator", @@ -73,6 +74,7 @@ public class GemfireBeanFactoryLocatorAnnotationConfigIntegrationTests extends I @Test public void registeredBeanFactoriesIsCorrect() { + Set beanNames = asSet("gemfireCache", "testBeanFactoryLocator", "aliasOne", "aliasTwo"); assertThat(GemfireBeanFactoryLocator.BEAN_FACTORIES).hasSameSizeAs(beanNames); @@ -83,8 +85,8 @@ public class GemfireBeanFactoryLocatorAnnotationConfigIntegrationTests extends I } } - @SuppressWarnings("unused") @PeerCacheApplication(useBeanFactoryLocator = true) + @SuppressWarnings("unused") static class TestConfiguration { @Bean diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/GemfireBeanFactoryLocatorIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/GemfireBeanFactoryLocatorIntegrationTests.java index bf2adb2a..3bf4a86a 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/GemfireBeanFactoryLocatorIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/GemfireBeanFactoryLocatorIntegrationTests.java @@ -14,7 +14,6 @@ * limitations under the License. * */ - package org.springframework.data.gemfire.support; import static org.assertj.core.api.Assertions.assertThat; @@ -27,6 +26,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -37,13 +37,14 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.junit.Test * @see org.springframework.beans.factory.BeanFactory * @see org.springframework.data.gemfire.support.GemfireBeanFactoryLocator + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 2.0.0 */ @RunWith(SpringRunner.class) @ContextConfiguration -public class GemfireBeanFactoryLocatorIntegrationTests { +public class GemfireBeanFactoryLocatorIntegrationTests extends IntegrationTestsSupport { @Autowired @SuppressWarnings("unused") @@ -51,6 +52,7 @@ public class GemfireBeanFactoryLocatorIntegrationTests { @Test public void beanFactoryContainsGemfireBeanFactoryLocatorBean() { + assertThat(beanFactory.containsBean(GemfireBeanFactoryLocator.class.getName())).isTrue(); GemfireBeanFactoryLocator gemfireBeanFactoryLocator = @@ -69,6 +71,7 @@ public class GemfireBeanFactoryLocatorIntegrationTests { @Test public void beanFactoryContainsTestBeanFactoryLocatorBean() { + assertThat(beanFactory.containsBean("testBeanFactoryLocator")).isTrue(); GemfireBeanFactoryLocator testBeanFactoryLocator = beanFactory.getBean("testBeanFactoryLocator", @@ -85,6 +88,7 @@ public class GemfireBeanFactoryLocatorIntegrationTests { @Test public void registeredBeanFactoriesIsCorrect() { + Set beanNames = asSet("gemfire-cache", "gemfireCache", "testBeanFactoryLocator", "aliasOne", "aliasTwo", GemfireBeanFactoryLocator.class.getName()); diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/GemfireBeanFactoryLocatorJavaConfigIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/GemfireBeanFactoryLocatorJavaConfigIntegrationTests.java index bf93dcb4..9c99650e 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/GemfireBeanFactoryLocatorJavaConfigIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/GemfireBeanFactoryLocatorJavaConfigIntegrationTests.java @@ -60,6 +60,7 @@ public class GemfireBeanFactoryLocatorJavaConfigIntegrationTests extends Integra @Test public void beanFactoryContainsTestBeanFactoryLocatorBean() { + assertThat(beanFactory.containsBean("testBeanFactoryLocator")).isTrue(); GemfireBeanFactoryLocator testBeanFactoryLocator = beanFactory.getBean("testBeanFactoryLocator", @@ -76,6 +77,7 @@ public class GemfireBeanFactoryLocatorJavaConfigIntegrationTests extends Integra @Test public void registeredBeanFactoriesIsCorrect() { + Set beanNames = asSet("gemfireCache", "testBeanFactoryLocator", "aliasOne", "aliasTwo"); assertThat(GemfireBeanFactoryLocator.BEAN_FACTORIES).hasSameSizeAs(beanNames); diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/LazyWiringDeclarableSupportFunctionBasedIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/LazyWiringDeclarableSupportFunctionBasedIntegrationTests.java index e2255241..3247c801 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/LazyWiringDeclarableSupportFunctionBasedIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/LazyWiringDeclarableSupportFunctionBasedIntegrationTests.java @@ -14,7 +14,6 @@ * limitations under the License. * */ - package org.springframework.data.gemfire.support; import static org.assertj.core.api.Assertions.assertThat; @@ -31,6 +30,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.gemfire.function.sample.HelloFunctionExecution; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.util.Assert; @@ -43,6 +43,9 @@ import org.springframework.util.StringUtils; * * @author John Blum * @see org.junit.Test + * @see org.apache.geode.cache.GemFireCache + * @see org.apache.geode.cache.execute.Function + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 1.7.0 @@ -50,7 +53,7 @@ import org.springframework.util.StringUtils; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class LazyWiringDeclarableSupportFunctionBasedIntegrationTests { +public class LazyWiringDeclarableSupportFunctionBasedIntegrationTests extends IntegrationTestsSupport { @Autowired private Cache gemfireCache; @@ -83,7 +86,7 @@ public class LazyWiringDeclarableSupportFunctionBasedIntegrationTests { assertThat(helloFunctionExecution.hello(null)).isEqualTo("Hello Everyone!"); } - protected static abstract class FunctionAdaptor extends LazyWiringDeclarableSupport implements Function { + protected static abstract class FunctionAdaptor extends LazyWiringDeclarableSupport implements Function { private final String id; @@ -114,7 +117,7 @@ public class LazyWiringDeclarableSupportFunctionBasedIntegrationTests { } @SuppressWarnings("all") - public static class HelloGemFireFunction extends FunctionAdaptor { + public static class HelloGemFireFunction extends FunctionAdaptor { protected static final String ADDRESS_TO_PARAMETER = "hello.address.to"; protected static final String DEFAULT_ADDRESS_TO = "World"; @@ -139,17 +142,18 @@ public class LazyWiringDeclarableSupportFunctionBasedIntegrationTests { } @Override - protected void doPostInit(final Properties parameters) { + protected void doPostInit(Properties parameters) { addressTo = parameters.getProperty(ADDRESS_TO_PARAMETER, getDefaultAddressTo()); } @Override - public void execute(final FunctionContext context) { + public void execute(FunctionContext context) { context.getResultSender().lastResult(formatHelloGreeting(addressTo(context))); } // precedence is... 1. Caller 2. GemFire 3. Spring protected String addressTo(FunctionContext context) { + Object arguments = context.getArguments(); String addressTo = null; diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/LazyWiringDeclarableSupportIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/LazyWiringDeclarableSupportIntegrationTests.java index f14b8c70..e7fa94af 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/LazyWiringDeclarableSupportIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/LazyWiringDeclarableSupportIntegrationTests.java @@ -40,7 +40,6 @@ import org.springframework.util.Assert; * Integration Tests for {@link LazyWiringDeclarableSupport}. * * @author John Blum - * @see java.util.Properties * @see org.junit.Test * @see org.springframework.context.ApplicationContext * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/SmartCacheResolverFactoryBeanIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/SmartCacheResolverFactoryBeanIntegrationTests.java index 0b087fd6..88b62179 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/SmartCacheResolverFactoryBeanIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/SmartCacheResolverFactoryBeanIntegrationTests.java @@ -43,6 +43,7 @@ import org.springframework.core.annotation.Order; import org.springframework.data.gemfire.CacheResolver; import org.springframework.data.gemfire.support.SmartCacheResolverFactoryBean.CacheResolverProxy; import org.springframework.data.gemfire.support.SmartCacheResolverFactoryBean.CompositionStrategy; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -59,6 +60,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.springframework.core.annotation.Order * @see org.springframework.data.gemfire.CacheResolver * @see org.springframework.data.gemfire.support.SmartCacheResolverFactoryBean + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 2.3.0 @@ -66,7 +68,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings({ "rawtypes", "unused" }) -public class SmartCacheResolverFactoryBeanIntegrationTests { +public class SmartCacheResolverFactoryBeanIntegrationTests extends IntegrationTestsSupport { @Autowired private ApplicationContext applicationContext; diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/WiringDeclarableSupportIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/WiringDeclarableSupportIntegrationTests.java index 3675e20a..b7c962f2 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/WiringDeclarableSupportIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/support/WiringDeclarableSupportIntegrationTests.java @@ -14,16 +14,14 @@ * limitations under the License. * */ - package org.springframework.data.gemfire.support; - import static org.assertj.core.api.Assertions.assertThat; import javax.annotation.Resource; -import lombok.Data; -import lombok.NoArgsConstructor; +import org.junit.Test; +import org.junit.runner.RunWith; import org.apache.geode.cache.CacheLoader; import org.apache.geode.cache.CacheLoaderException; @@ -31,31 +29,33 @@ import org.apache.geode.cache.DataPolicy; import org.apache.geode.cache.LoaderHelper; import org.apache.geode.cache.Region; -import org.junit.Test; -import org.junit.runner.RunWith; - import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; +import lombok.Data; +import lombok.NoArgsConstructor; + /** - * Integration test for {@link WiringDeclarableSupport} and {@link GemfireBeanFactoryLocator}. + * Integration Tests for {@link WiringDeclarableSupport} and {@link GemfireBeanFactoryLocator}. * * @author Costin Leau * @author John Blum * @see org.junit.Test - * @see lombok * @see org.apache.geode.cache.CacheLoader + * @see org.apache.geode.cache.Region * @see org.springframework.beans.factory.BeanFactory * @see org.springframework.data.gemfire.support.GemfireBeanFactoryLocator * @see org.springframework.data.gemfire.support.WiringDeclarableSupport + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner */ @RunWith(SpringRunner.class) @ContextConfiguration -public class WiringDeclarableSupportIntegrationTests { +public class WiringDeclarableSupportIntegrationTests extends IntegrationTestsSupport { @Autowired @SuppressWarnings("unused") @@ -66,6 +66,7 @@ public class WiringDeclarableSupportIntegrationTests { private Region example; private void assertRegion(Region region, String name, DataPolicy dataPolicy) { + assertThat(region).isNotNull(); assertThat(region.getName()).isEqualTo(name); assertThat(region.getFullPath()).isEqualTo(String.format("%1$s%2$s", Region.SEPARATOR, name)); @@ -75,10 +76,11 @@ public class WiringDeclarableSupportIntegrationTests { @Test public void declarableObjectAutoWiredSuccessfully() throws Exception { + assertThat(beanFactory.containsBean("testBean")).isTrue(); assertRegion(example, "Example", DataPolicy.NORMAL); - CacheLoader testCacheLoader = example.getAttributes().getCacheLoader(); + CacheLoader testCacheLoader = example.getAttributes().getCacheLoader(); assertThat(testCacheLoader).isInstanceOf(TestCacheLoader.class); assertThat(((TestCacheLoader) testCacheLoader).getBeanFactory()).isSameAs(beanFactory); diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/transaction/AbstractTransactionalEventListenerIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/transaction/AbstractTransactionalEventListenerIntegrationTests.java index 366d495a..a179403f 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/transaction/AbstractTransactionalEventListenerIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/transaction/AbstractTransactionalEventListenerIntegrationTests.java @@ -30,6 +30,7 @@ import org.springframework.data.annotation.Id; import org.springframework.data.gemfire.mapping.GemfireMappingContext; import org.springframework.data.gemfire.mapping.annotation.Region; import org.springframework.data.gemfire.repository.support.GemfireRepositoryFactoryBean; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.gemfire.transaction.event.TransactionApplicationEvent; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Service; @@ -50,12 +51,13 @@ import lombok.ToString; * @see org.springframework.context.ApplicationEventPublisher * @see org.springframework.context.annotation.Bean * @see org.springframework.context.annotation.Configuration + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.data.gemfire.transaction.event.TransactionApplicationEvent * @see org.springframework.transaction.annotation.Transactional * @since 2.3.0 */ @SuppressWarnings("unused") -public abstract class AbstractTransactionalEventListenerIntegrationTests { +public abstract class AbstractTransactionalEventListenerIntegrationTests extends IntegrationTestsSupport { protected static final String GEMFIRE_LOG_LEVEL = "error"; diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/transaction/GemfireTransactionManagerIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/transaction/GemfireTransactionManagerIntegrationTests.java index a87795a5..487160e2 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/transaction/GemfireTransactionManagerIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/transaction/GemfireTransactionManagerIntegrationTests.java @@ -14,23 +14,23 @@ * limitations under the License. * */ - package org.springframework.data.gemfire.transaction; import static org.assertj.core.api.Assertions.assertThat; import javax.annotation.Resource; -import org.apache.geode.cache.GemFireCache; -import org.apache.geode.cache.Region; - import org.junit.Test; import org.junit.runner.RunWith; +import org.apache.geode.cache.GemFireCache; +import org.apache.geode.cache.Region; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.data.gemfire.LocalRegionFactoryBean; import org.springframework.data.gemfire.config.annotation.PeerCacheApplication; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.gemfire.transaction.config.EnableGemfireCacheTransactions; import org.springframework.stereotype.Repository; import org.springframework.stereotype.Service; @@ -45,7 +45,9 @@ import org.springframework.util.Assert; * * @author John Blum * @see org.junit.Test - * @see org.junit.runner.RunWith + * @see org.apache.geode.cache.GemFireCache + * @see org.apache.geode.cache.Region + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.data.gemfire.transaction.GemfireTransactionManager * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner @@ -56,15 +58,12 @@ import org.springframework.util.Assert; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class GemfireTransactionManagerIntegrationTests { - - private static final String GEMFIRE_LOG_LEVEL = "error"; +public class GemfireTransactionManagerIntegrationTests extends IntegrationTestsSupport { @Resource(name = "Example") private Region example; @Autowired - @SuppressWarnings("all") private SuspendAndResumeCacheTransactionsService service; @Test(expected = IllegalArgumentException.class) @@ -90,10 +89,7 @@ public class GemfireTransactionManagerIntegrationTests { } } - @PeerCacheApplication( - name = "GemfireTransactionManagerIntegrationTests", - logLevel = GEMFIRE_LOG_LEVEL - ) + @PeerCacheApplication @EnableGemfireCacheTransactions static class TestConfiguration { diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/wan/AsyncEventQueueByIdXmlConfigurationIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/wan/AsyncEventQueueByIdXmlConfigurationIntegrationTests.java index 86c880c1..4543ea2a 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/wan/AsyncEventQueueByIdXmlConfigurationIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/wan/AsyncEventQueueByIdXmlConfigurationIntegrationTests.java @@ -65,7 +65,7 @@ import org.springframework.test.context.junit4.SpringRunner; * @since 2.2.0 */ @RunWith(SpringRunner.class) -@ContextConfiguration(locations = "AsyncEventQueueByIdXmlConfigurationIntegrationTests-context.xml") +@ContextConfiguration @SuppressWarnings("unused") public class AsyncEventQueueByIdXmlConfigurationIntegrationTests extends ForkingClientServerIntegrationTestsSupport { diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/wan/ManualGatewayReceiverStartIntegrationTest.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/wan/ManualGatewayReceiverStartIntegrationTests.java similarity index 93% rename from spring-data-geode/src/test/java/org/springframework/data/gemfire/wan/ManualGatewayReceiverStartIntegrationTest.java rename to spring-data-geode/src/test/java/org/springframework/data/gemfire/wan/ManualGatewayReceiverStartIntegrationTests.java index 105ee0af..845c8250 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/wan/ManualGatewayReceiverStartIntegrationTest.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/wan/ManualGatewayReceiverStartIntegrationTests.java @@ -26,12 +26,13 @@ import org.junit.runner.RunWith; import org.apache.geode.cache.wan.GatewayReceiver; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * Integration Tests with test cases testing the manual start capability of {@link GatewayReceiver GatewayReceivers} + * Integration Tests testing the manual start capability of {@link GatewayReceiver GatewayReceivers} * when configured with SDG XML namespace configuration metadata. * * @author John Blum @@ -47,7 +48,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(initializers = GemFireMockObjectsApplicationContextInitializer.class) @SuppressWarnings("unused") -public class ManualGatewayReceiverStartIntegrationTest { +public class ManualGatewayReceiverStartIntegrationTests extends IntegrationTestsSupport { @Resource(name = "Auto") private GatewayReceiver autoGatewayReceiver; diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/wan/RegionsWithAsyncEventQueuesAndGatewaySendersUnitTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/wan/RegionsWithAsyncEventQueuesAndGatewaySendersUnitTests.java index f64975e9..8509908d 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/wan/RegionsWithAsyncEventQueuesAndGatewaySendersUnitTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/wan/RegionsWithAsyncEventQueuesAndGatewaySendersUnitTests.java @@ -27,22 +27,32 @@ import org.apache.geode.cache.DataPolicy; import org.apache.geode.cache.Region; import org.apache.geode.cache.RegionAttributes; import org.apache.geode.cache.asyncqueue.AsyncEventListener; +import org.apache.geode.cache.asyncqueue.AsyncEventQueue; +import org.apache.geode.cache.wan.GatewaySender; import org.springframework.data.gemfire.support.AbstractFactoryBeanSupport; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * The RegionsWithAsyncEventQueuesAndGatewaySendersUnitTests class... + * Unit Tests for {@link Region} with {@link AsyncEventQueue} and {@link GatewaySender}. * * @author John Blum - * @since 1.0.0 + * @see org.junit.Test + * @see org.apache.geode.cache.Region + * @see org.apache.geode.cache.asyncqueue.AsyncEventQueue + * @see org.apache.geode.cache.wan.GatewaySender + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport + * @see org.springframework.test.context.ContextConfiguration + * @see org.springframework.test.context.junit4.SpringRunner + * @since 2.0.0 */ @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class RegionsWithAsyncEventQueuesAndGatewaySendersUnitTests { +public class RegionsWithAsyncEventQueuesAndGatewaySendersUnitTests extends IntegrationTestsSupport { @Resource(name = "TemplateBasedLocalRegion") private Region templateBasedLocalRegion; diff --git a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/LookupRegionMutationIntegrationTest-context.xml b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/LookupRegionMutationIntegrationTest-context.xml index c743e7a8..e74dce43 100644 --- a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/LookupRegionMutationIntegrationTest-context.xml +++ b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/LookupRegionMutationIntegrationTest-context.xml @@ -17,33 +17,34 @@ - + - - - - - diff --git a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheIndexingTest-context.xml b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheIndexingIntegrationTests-context.xml similarity index 100% rename from spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheIndexingTest-context.xml rename to spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheIndexingIntegrationTests-context.xml diff --git a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheIndexingTest-server-context.xml b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheIndexingIntegrationTests-server-context.xml similarity index 100% rename from spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheIndexingTest-server-context.xml rename to spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheIndexingIntegrationTests-server-context.xml diff --git a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCachePoolTests-context.xml b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCachePoolIntegrationTests-context.xml similarity index 100% rename from spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCachePoolTests-context.xml rename to spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCachePoolIntegrationTests-context.xml diff --git a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCachePoolTests-server-context.xml b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCachePoolIntegrationTests-server-context.xml similarity index 100% rename from spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCachePoolTests-server-context.xml rename to spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCachePoolIntegrationTests-server-context.xml diff --git a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheSecurityTest-context.xml b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheSecurityIntegrationTests-context.xml similarity index 100% rename from spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheSecurityTest-context.xml rename to spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheSecurityIntegrationTests-context.xml diff --git a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheSecurityTest-server-context.xml b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheSecurityIntegrationTests-server-context.xml similarity index 100% rename from spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheSecurityTest-server-context.xml rename to spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheSecurityIntegrationTests-server-context.xml diff --git a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheVariableLocatorsTest-context.xml b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheVariableLocatorsIntegrationTests-context.xml similarity index 100% rename from spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheVariableLocatorsTest-context.xml rename to spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheVariableLocatorsIntegrationTests-context.xml diff --git a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheVariableLocatorsTest-server-context.xml b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheVariableLocatorsIntegrationTests-server-context.xml similarity index 100% rename from spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheVariableLocatorsTest-server-context.xml rename to spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheVariableLocatorsIntegrationTests-server-context.xml diff --git a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheVariableServersTest-context.xml b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheVariableServersIntegationTests-context.xml similarity index 100% rename from spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheVariableServersTest-context.xml rename to spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheVariableServersIntegationTests-context.xml diff --git a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheVariableServersTest-server-context.xml b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheVariableServersIntegrationTests-server-context.xml similarity index 100% rename from spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheVariableServersTest-server-context.xml rename to spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientCacheVariableServersIntegrationTests-server-context.xml diff --git a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientRegionWithCacheLoaderWriterTest-context.xml b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientRegionWithCacheLoaderCacheWriterIntegrationTests-context.xml similarity index 86% rename from spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientRegionWithCacheLoaderWriterTest-context.xml rename to spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientRegionWithCacheLoaderCacheWriterIntegrationTests-context.xml index b937d3a2..4077eb6e 100644 --- a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientRegionWithCacheLoaderWriterTest-context.xml +++ b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/ClientRegionWithCacheLoaderCacheWriterIntegrationTests-context.xml @@ -16,8 +16,8 @@ - - + + diff --git a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/DurableClientCacheIntegrationTest-context.xml b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/DurableClientCacheIntegrationTests-context.xml similarity index 91% rename from spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/DurableClientCacheIntegrationTest-context.xml rename to spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/DurableClientCacheIntegrationTests-context.xml index 7e1671a6..c5eea806 100644 --- a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/DurableClientCacheIntegrationTest-context.xml +++ b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/DurableClientCacheIntegrationTests-context.xml @@ -14,20 +14,20 @@ DurableClientCacheIntegrationTest - ${org.springframework.data.gemfire.client.DurableClientCacheIntegrationTest.durable-client-timeout:300} + ${org.springframework.data.gemfire.client.DurableClientCacheIntegrationTests.durable-client-timeout:300} - ${org.springframework.data.gemfire.client.DurableClientCacheIntegrationTest.interests-result-policy:KEYS_VALUES} + ${org.springframework.data.gemfire.client.DurableClientCacheIntegrationTests.interests-result-policy:KEYS_VALUES} localhost - ${org.springframework.data.gemfire.client.DurableClientCacheIntegrationTest.cache-server-port} + ${org.springframework.data.gemfire.client.DurableClientCacheIntegrationTests.cache-server-port} - + DurableClientCacheIntegrationTestClient @@ -46,7 +46,7 @@ - + diff --git a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/DurableClientCacheIntegrationTest-server-context.xml b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/DurableClientCacheIntegrationTests-server-context.xml similarity index 96% rename from spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/DurableClientCacheIntegrationTest-server-context.xml rename to spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/DurableClientCacheIntegrationTests-server-context.xml index 6342aabd..07a3d54e 100644 --- a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/DurableClientCacheIntegrationTest-server-context.xml +++ b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/client/DurableClientCacheIntegrationTests-server-context.xml @@ -16,7 +16,7 @@ localhost - ${org.springframework.data.gemfire.client.DurableClientCacheIntegrationTest.cache-server-port} + ${org.springframework.data.gemfire.client.DurableClientCacheIntegrationTests.cache-server-port} @@ -45,7 +45,7 @@ - diff --git a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/config/xml/AsyncEventQueueNamespaceTest-context.xml b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/config/xml/AsyncEventQueueNamespaceIntegrationTests-context.xml similarity index 80% rename from spring-data-geode/src/test/resources/org/springframework/data/gemfire/config/xml/AsyncEventQueueNamespaceTest-context.xml rename to spring-data-geode/src/test/resources/org/springframework/data/gemfire/config/xml/AsyncEventQueueNamespaceIntegrationTests-context.xml index 670c4cb4..9692adf2 100644 --- a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/config/xml/AsyncEventQueueNamespaceTest-context.xml +++ b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/config/xml/AsyncEventQueueNamespaceIntegrationTests-context.xml @@ -12,7 +12,7 @@ http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd "> - + AsyncEventQueueNamespaceTest @@ -41,28 +41,28 @@ pause-event-dispatching="false" persistent="true"> - + - - - + + - - + diff --git a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/config/xml/TemplateClientRegionNamespaceTest-context.xml b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/config/xml/TemplateClientRegionNamespaceIntegrationTests-context.xml similarity index 84% rename from spring-data-geode/src/test/resources/org/springframework/data/gemfire/config/xml/TemplateClientRegionNamespaceTest-context.xml rename to spring-data-geode/src/test/resources/org/springframework/data/gemfire/config/xml/TemplateClientRegionNamespaceIntegrationTests-context.xml index b37b62ce..7243dbc0 100644 --- a/spring-data-geode/src/test/resources/org/springframework/data/gemfire/config/xml/TemplateClientRegionNamespaceTest-context.xml +++ b/spring-data-geode/src/test/resources/org/springframework/data/gemfire/config/xml/TemplateClientRegionNamespaceIntegrationTests-context.xml @@ -11,7 +11,7 @@ "> - TemplateClientRegionNamespaceTest + TemplateClientRegionNamespaceIntegrationTests error @@ -27,9 +27,9 @@ disk-synchronous="false" initial-capacity="51" key-constraint="java.lang.Long" load-factor="0.85" persistent="false" statistics="true" value-constraint="java.lang.String"> - - - + + + @@ -37,10 +37,10 @@ - + - +