From 0728ee1e212eb4e5a3728895fcb3a03fdaf46dc7 Mon Sep 17 00:00:00 2001 From: John Blum Date: Tue, 30 Mar 2021 11:25:08 -0700 Subject: [PATCH] Refactor all Unit & Integration Tests starting a Spring container with SpringRunner to extend STDG's IntegrationTestsSupport. --- ...omplexConditionalConfigurationIntegrationTests.java | 10 ++++++---- ...cheDataImportAutoConfigurationIntegrationTests.java | 4 +++- .../SpringBootLocatorApplicationIntegrationTests.java | 4 +++- .../session/MockPersistentSessionAccessSmokeTests.java | 4 +++- .../spring-geode-smoke-tests-multi-store.gradle | 2 ++ ...abaseWithLookAsideCachingApplicationSmokeTests.java | 7 +++---- ...ngBootApacheGeodePeerCacheApplicationUnitTests.java | 6 +++++- .../example/app/InitializerApplicationSmokeTests.java | 4 +++- .../cache/SpringCachingWithMockObjectsUnitTests.java | 6 +++++- ...shableApplicationContextLoaderIntegrationTests.java | 4 +++- 10 files changed, 36 insertions(+), 15 deletions(-) diff --git a/spring-geode-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ComplexConditionalConfigurationIntegrationTests.java b/spring-geode-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ComplexConditionalConfigurationIntegrationTests.java index 235cce08..d7d54f36 100644 --- a/spring-geode-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ComplexConditionalConfigurationIntegrationTests.java +++ b/spring-geode-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ComplexConditionalConfigurationIntegrationTests.java @@ -31,7 +31,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.context.annotation.Condition; import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; @@ -39,6 +38,7 @@ import org.springframework.context.annotation.Import; import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; import org.springframework.core.type.AnnotatedTypeMetadata; import org.springframework.core.type.AnnotationMetadata; +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; @@ -53,7 +53,9 @@ import org.springframework.util.StringUtils; * @see org.springframework.boot.autoconfigure.condition.AnyNestedCondition * @see org.springframework.context.annotation.Condition * @see org.springframework.context.annotation.Conditional + * @see org.springframework.context.annotation.ConditionContext * @see org.springframework.context.annotation.Configuration + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 1.2.0 @@ -61,7 +63,7 @@ import org.springframework.util.StringUtils; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class ComplexConditionalConfigurationIntegrationTests { +public class ComplexConditionalConfigurationIntegrationTests extends IntegrationTestsSupport { private static final AtomicBoolean importBeanDefinitionRegistrarCalled = new AtomicBoolean(false); @@ -121,7 +123,7 @@ public class ComplexConditionalConfigurationIntegrationTests { } - static final class MockConditionOne implements Condition { + static final class MockConditionOne implements org.springframework.context.annotation.Condition { @Override public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { @@ -129,7 +131,7 @@ public class ComplexConditionalConfigurationIntegrationTests { } } - static final class MockConditionTwo implements Condition { + static final class MockConditionTwo implements org.springframework.context.annotation.Condition { @Override public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { diff --git a/spring-geode-autoconfigure/src/test/java/org/springframework/geode/boot/autoconfigure/data/LocalClientCacheDataImportAutoConfigurationIntegrationTests.java b/spring-geode-autoconfigure/src/test/java/org/springframework/geode/boot/autoconfigure/data/LocalClientCacheDataImportAutoConfigurationIntegrationTests.java index 6e652424..bc58d8c5 100644 --- a/spring-geode-autoconfigure/src/test/java/org/springframework/geode/boot/autoconfigure/data/LocalClientCacheDataImportAutoConfigurationIntegrationTests.java +++ b/spring-geode-autoconfigure/src/test/java/org/springframework/geode/boot/autoconfigure/data/LocalClientCacheDataImportAutoConfigurationIntegrationTests.java @@ -28,6 +28,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Profile; import org.springframework.data.gemfire.GemfireTemplate; import org.springframework.data.gemfire.config.annotation.EnableEntityDefinedRegions; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.geode.boot.autoconfigure.DataImportExportAutoConfiguration; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; @@ -43,6 +44,7 @@ import example.app.golf.model.Golfer; * @see org.springframework.boot.test.context.SpringBootTest * @see org.springframework.context.annotation.Profile * @see org.springframework.data.gemfire.GemfireTemplate + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.geode.boot.autoconfigure.DataImportExportAutoConfiguration * @see org.springframework.test.context.ActiveProfiles * @see org.springframework.test.context.junit4.SpringRunner @@ -57,7 +59,7 @@ import example.app.golf.model.Golfer; "spring.boot.data.gemfire.cache.data.import.active-profiles=IMPORT-LOCAL" } ) -public class LocalClientCacheDataImportAutoConfigurationIntegrationTests { +public class LocalClientCacheDataImportAutoConfigurationIntegrationTests extends IntegrationTestsSupport { @Autowired @SuppressWarnings("unused") diff --git a/spring-geode-autoconfigure/src/test/java/org/springframework/geode/boot/autoconfigure/locator/SpringBootLocatorApplicationIntegrationTests.java b/spring-geode-autoconfigure/src/test/java/org/springframework/geode/boot/autoconfigure/locator/SpringBootLocatorApplicationIntegrationTests.java index 6a5e7627..68d66551 100644 --- a/spring-geode-autoconfigure/src/test/java/org/springframework/geode/boot/autoconfigure/locator/SpringBootLocatorApplicationIntegrationTests.java +++ b/spring-geode-autoconfigure/src/test/java/org/springframework/geode/boot/autoconfigure/locator/SpringBootLocatorApplicationIntegrationTests.java @@ -28,6 +28,7 @@ import org.apache.geode.distributed.Locator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects; 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.apache.geode.distributed.Locator * @see org.springframework.boot.autoconfigure.SpringBootApplication + * @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 @@ -50,7 +52,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class SpringBootLocatorApplicationIntegrationTests { +public class SpringBootLocatorApplicationIntegrationTests extends IntegrationTestsSupport { @Autowired(required = false) private GemFireCache clientCache; diff --git a/spring-geode-tests/smoke-tests/mock-session-caching/src/test/java/example/app/geode/caching/session/MockPersistentSessionAccessSmokeTests.java b/spring-geode-tests/smoke-tests/mock-session-caching/src/test/java/example/app/geode/caching/session/MockPersistentSessionAccessSmokeTests.java index 0eebc6b7..8b2d8cc2 100644 --- a/spring-geode-tests/smoke-tests/mock-session-caching/src/test/java/example/app/geode/caching/session/MockPersistentSessionAccessSmokeTests.java +++ b/spring-geode-tests/smoke-tests/mock-session-caching/src/test/java/example/app/geode/caching/session/MockPersistentSessionAccessSmokeTests.java @@ -33,6 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects; import org.springframework.data.gemfire.tests.support.MapBuilder; import org.springframework.hamcrest.RegexMatcher; @@ -63,6 +64,7 @@ import lombok.ToString; * @see org.springframework.boot.autoconfigure.SpringBootApplication * @see org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc * @see org.springframework.boot.test.context.SpringBootTest + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects * @see org.springframework.test.context.junit4.SpringRunner * @see org.springframework.test.web.servlet.MockMvc @@ -79,7 +81,7 @@ import lombok.ToString; ) @AutoConfigureMockMvc @SuppressWarnings("unused") -public class MockPersistentSessionAccessSmokeTests { +public class MockPersistentSessionAccessSmokeTests extends IntegrationTestsSupport { @Autowired private MockMvc mvc; diff --git a/spring-geode-tests/smoke-tests/multi-store/spring-geode-smoke-tests-multi-store.gradle b/spring-geode-tests/smoke-tests/multi-store/spring-geode-smoke-tests-multi-store.gradle index 3c335567..14ee129e 100644 --- a/spring-geode-tests/smoke-tests/multi-store/spring-geode-smoke-tests-multi-store.gradle +++ b/spring-geode-tests/smoke-tests/multi-store/spring-geode-smoke-tests-multi-store.gradle @@ -21,4 +21,6 @@ dependencies { exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' } + testImplementation('org.springframework.data:spring-data-geode-test') + } diff --git a/spring-geode-tests/smoke-tests/multi-store/src/test/java/example/app/DatabaseWithLookAsideCachingApplicationSmokeTests.java b/spring-geode-tests/smoke-tests/multi-store/src/test/java/example/app/DatabaseWithLookAsideCachingApplicationSmokeTests.java index d37ab789..2ad9b228 100644 --- a/spring-geode-tests/smoke-tests/multi-store/src/test/java/example/app/DatabaseWithLookAsideCachingApplicationSmokeTests.java +++ b/spring-geode-tests/smoke-tests/multi-store/src/test/java/example/app/DatabaseWithLookAsideCachingApplicationSmokeTests.java @@ -23,6 +23,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.junit4.SpringRunner; import example.app.model.Contact; @@ -35,16 +36,14 @@ import example.app.service.ContactsService; * @author John Blum * @see org.junit.Test * @see org.springframework.boot.test.context.SpringBootTest + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.junit4.SpringRunner - * @see example.app.model.Contact - * @see example.app.repo.ContactRepository - * @see example.app.service.ContactsService * @since 1.2.0 */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) @SuppressWarnings("unused") -public class DatabaseWithLookAsideCachingApplicationSmokeTests { +public class DatabaseWithLookAsideCachingApplicationSmokeTests extends IntegrationTestsSupport { @Autowired private ContactRepository contactRepository; diff --git a/spring-geode-tests/smoke-tests/peer-cache-application/src/test/java/example/app/geode/cache/peer/SpringBootApacheGeodePeerCacheApplicationUnitTests.java b/spring-geode-tests/smoke-tests/peer-cache-application/src/test/java/example/app/geode/cache/peer/SpringBootApacheGeodePeerCacheApplicationUnitTests.java index 8332ed2c..3ef700da 100644 --- a/spring-geode-tests/smoke-tests/peer-cache-application/src/test/java/example/app/geode/cache/peer/SpringBootApacheGeodePeerCacheApplicationUnitTests.java +++ b/spring-geode-tests/smoke-tests/peer-cache-application/src/test/java/example/app/geode/cache/peer/SpringBootApacheGeodePeerCacheApplicationUnitTests.java @@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.AbstractRefreshableApplicationContext; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects; import org.springframework.geode.distributed.event.ApplicationContextMembershipListener; import org.springframework.geode.distributed.event.MembershipListenerAdapter; @@ -45,7 +46,10 @@ import org.springframework.test.context.junit4.SpringRunner; * @see org.apache.geode.cache.Cache * @see org.springframework.context.ConfigurableApplicationContext * @see org.springframework.context.support.AbstractRefreshableApplicationContext + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects + * @see org.springframework.geode.distributed.event.ApplicationContextMembershipListener + * @see org.springframework.geode.distributed.event.MembershipListenerAdapter * @see org.springframework.geode.test.context.TestRefreshableApplicationContextLoader * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner @@ -58,7 +62,7 @@ import org.springframework.test.context.junit4.SpringRunner; loader = TestRefreshableApplicationContextLoader.class ) @SuppressWarnings({ "unused" }) -public class SpringBootApacheGeodePeerCacheApplicationUnitTests { +public class SpringBootApacheGeodePeerCacheApplicationUnitTests extends IntegrationTestsSupport { @Autowired private ConfigurableApplicationContext applicationContext; diff --git a/spring-geode-tests/smoke-tests/spring-initializer/src/test/java/example/app/InitializerApplicationSmokeTests.java b/spring-geode-tests/smoke-tests/spring-initializer/src/test/java/example/app/InitializerApplicationSmokeTests.java index 75c8e59b..e0d8c76d 100644 --- a/spring-geode-tests/smoke-tests/spring-initializer/src/test/java/example/app/InitializerApplicationSmokeTests.java +++ b/spring-geode-tests/smoke-tests/spring-initializer/src/test/java/example/app/InitializerApplicationSmokeTests.java @@ -26,6 +26,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext; import org.springframework.context.ApplicationContext; import org.springframework.data.gemfire.GemfireTemplate; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.context.WebApplicationContext; @@ -37,6 +38,7 @@ import org.springframework.web.context.WebApplicationContext; * @see org.springframework.boot.test.context.SpringBootTest * @see org.springframework.context.ApplicationContext * @see org.springframework.data.gemfire.GemfireTemplate + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.junit4.SpringRunner * @see example.app.InitializerApplication * @since 1.2.0 @@ -44,7 +46,7 @@ import org.springframework.web.context.WebApplicationContext; @RunWith(SpringRunner.class) @SpringBootTest @SuppressWarnings("unused") -public class InitializerApplicationSmokeTests { +public class InitializerApplicationSmokeTests extends IntegrationTestsSupport { @Autowired private ApplicationContext applicationContext; diff --git a/spring-geode/src/test/java/org/springframework/geode/cache/SpringCachingWithMockObjectsUnitTests.java b/spring-geode/src/test/java/org/springframework/geode/cache/SpringCachingWithMockObjectsUnitTests.java index 443843ed..cde289f9 100644 --- a/spring-geode/src/test/java/org/springframework/geode/cache/SpringCachingWithMockObjectsUnitTests.java +++ b/spring-geode/src/test/java/org/springframework/geode/cache/SpringCachingWithMockObjectsUnitTests.java @@ -40,6 +40,7 @@ import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.lang.Nullable; import org.springframework.stereotype.Service; import org.springframework.test.context.ContextConfiguration; @@ -51,12 +52,15 @@ import org.springframework.test.context.junit4.SpringRunner; * @author John Blum * @see org.junit.Test * @see org.mockito.Mockito + * @see org.springframework.beans.factory.FactoryBean + * @see org.springframework.beans.factory.InitializingBean * @see org.springframework.cache.Cache * @see org.springframework.cache.CacheManager * @see org.springframework.cache.annotation.Cacheable * @see org.springframework.cache.annotation.EnableCaching * @see org.springframework.context.annotation.Bean * @see org.springframework.context.annotation.Configuration + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.stereotype.Service * @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.junit4.SpringRunner @@ -65,7 +69,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration @SuppressWarnings("unused") -public class SpringCachingWithMockObjectsUnitTests { +public class SpringCachingWithMockObjectsUnitTests extends IntegrationTestsSupport { @Autowired private TestCacheableService testService; diff --git a/spring-geode/src/test/java/org/springframework/geode/test/context/TestRefreshableApplicationContextLoaderIntegrationTests.java b/spring-geode/src/test/java/org/springframework/geode/test/context/TestRefreshableApplicationContextLoaderIntegrationTests.java index 5436ded9..5bf47e56 100644 --- a/spring-geode/src/test/java/org/springframework/geode/test/context/TestRefreshableApplicationContextLoaderIntegrationTests.java +++ b/spring-geode/src/test/java/org/springframework/geode/test/context/TestRefreshableApplicationContextLoaderIntegrationTests.java @@ -22,6 +22,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.geode.context.annotation.RefreshableAnnotationConfigApplicationContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -31,6 +32,7 @@ import org.springframework.test.context.junit4.SpringRunner; * * @author John Blum * @see org.junit.Test + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.geode.context.annotation.RefreshableAnnotationConfigApplicationContext * @see org.springframework.geode.test.context.TestRefreshableApplicationContextLoader * @see org.springframework.test.context.ContextConfiguration @@ -40,7 +42,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(loader = TestRefreshableApplicationContextLoader.class) @SuppressWarnings("unused") -public class TestRefreshableApplicationContextLoaderIntegrationTests { +public class TestRefreshableApplicationContextLoaderIntegrationTests extends IntegrationTestsSupport { @Autowired private ApplicationContext applicationContext;