diff --git a/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/cache/client/SpringBootApacheGeodeClientCacheApplicationIntegrationTests.java b/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/cache/client/SpringBootApacheGeodeClientCacheApplicationIntegrationTests.java index 3df784b3..a582b73e 100644 --- a/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/cache/client/SpringBootApacheGeodeClientCacheApplicationIntegrationTests.java +++ b/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/cache/client/SpringBootApacheGeodeClientCacheApplicationIntegrationTests.java @@ -26,6 +26,7 @@ import org.apache.geode.cache.Region; import org.apache.geode.cache.client.ClientCache; import org.apache.geode.cache.client.ClientRegionShortcut; import org.apache.geode.internal.cache.GemFireCacheImpl; +import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -34,12 +35,12 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; import org.springframework.data.gemfire.client.ClientRegionFactoryBean; import org.springframework.data.gemfire.config.annotation.EnableLogging; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.gemfire.util.RegionUtils; import org.springframework.test.context.junit4.SpringRunner; /** - * Integration test testing the auto-configuration of an Apache Geode {@link ClientCache} instance - * using Spring Boot auto-configuration. + * Integration test testing the auto-configuration of an Apache Geode {@link ClientCache} instance. * * @author John Blum * @see org.junit.Test @@ -52,15 +53,20 @@ import org.springframework.test.context.junit4.SpringRunner; * @since 1.0.0 */ @RunWith(SpringRunner.class) -@SpringBootTest +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) @SuppressWarnings("unused") -public class SpringBootApacheGeodeClientCacheApplicationIntegrationTests { +public class SpringBootApacheGeodeClientCacheApplicationIntegrationTests extends IntegrationTestsSupport { private static final String GEMFIRE_LOG_LEVEL = "error"; @Autowired private ClientCache clientCache; + @BeforeClass + public static void setup() { + closeGemFireCacheWaitOnCloseEvent(); + } + @Test public void clientCacheAndClientRegionAreAvailable() { diff --git a/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/cache/peer/SpringBootApacheGeodePeerCacheApplicationIntegrationTests.java b/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/cache/peer/SpringBootApacheGeodePeerCacheApplicationIntegrationTests.java index a5b7b470..40ff073f 100644 --- a/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/cache/peer/SpringBootApacheGeodePeerCacheApplicationIntegrationTests.java +++ b/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/cache/peer/SpringBootApacheGeodePeerCacheApplicationIntegrationTests.java @@ -21,36 +21,54 @@ import static org.springframework.data.gemfire.util.RuntimeExceptionFactory.newI import java.util.Optional; +import org.apache.geode.cache.Cache; import org.apache.geode.cache.GemFireCache; import org.apache.geode.cache.Region; +import org.apache.geode.cache.client.ClientCache; import org.apache.geode.internal.cache.GemFireCacheImpl; +import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; 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.util.RegionUtils; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; /** - * The SpringBootApacheGeodePeerCacheApplicationIntegrationTests class... + * Integration tests testing the auto-configuration of an Apache Geode peer {@link Cache} instance, overriding + * the default, {@link ClientCache} instance. * * @author John Blum + * @see org.apache.geode.cache.Cache + * @see org.apache.geode.cache.Region + * @see org.apache.geode.cache.client.ClientCache + * @see org.springframework.boot.autoconfigure.SpringBootApplication + * @see org.springframework.boot.test.context.SpringBootTest + * @see org.springframework.data.gemfire.config.annotation.PeerCacheApplication + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport + * @see org.springframework.test.context.junit4.SpringRunner * @since 1.0.0 */ @RunWith(SpringRunner.class) -@ContextConfiguration +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) @SuppressWarnings("unused") -public class SpringBootApacheGeodePeerCacheApplicationIntegrationTests { +public class SpringBootApacheGeodePeerCacheApplicationIntegrationTests extends IntegrationTestsSupport { private static final String GEMFIRE_LOG_LEVEL = "error"; @Autowired private GemFireCache peerCache; + @BeforeClass + public static void setup() { + closeGemFireCacheWaitOnCloseEvent(); + } + @Test public void peerCacheWithPeerLocalRegionAreAvailable() { diff --git a/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/caching/AutoConfiguredCachingIntegrationTests.java b/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/caching/AutoConfiguredCachingIntegrationTests.java index 38f87c9b..393b6a6f 100644 --- a/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/caching/AutoConfiguredCachingIntegrationTests.java +++ b/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/caching/AutoConfiguredCachingIntegrationTests.java @@ -22,16 +22,17 @@ import javax.annotation.Resource; import org.apache.geode.cache.Region; import org.apache.geode.cache.client.ClientRegionShortcut; +import org.junit.BeforeClass; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.data.geode.repository.model.Customer; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.gemfire.config.annotation.EnableCachingDefinedRegions; import org.springframework.data.gemfire.config.annotation.EnableLogging; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.gemfire.util.RegionUtils; import org.springframework.test.context.junit4.SpringRunner; @@ -40,16 +41,23 @@ import example.app.model.Book; import example.app.service.support.CachingBookService; /** - * The AutoConfiguredCachingIntegrationTests class... + * Integration tests testing the auto-configuration of Spring's Cache Abstraction with Apache Geode + * or Pivotal GemFire as the caching provider. * * @author John Blum + * @see org.apache.geode.cache.Region + * @see org.springframework.boot.autoconfigure.SpringBootApplication + * @see org.springframework.boot.test.context.SpringBootTest + * @see org.springframework.data.gemfire.config.annotation.EnableCachingDefinedRegions + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport + * @see org.springframework.test.context.junit4.SpringRunner * @since 1.0.0 */ @RunWith(SpringRunner.class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) @SuppressWarnings("unused") -public class AutoConfiguredCachingIntegrationTests { +public class AutoConfiguredCachingIntegrationTests extends IntegrationTestsSupport { private static final String GEMFIRE_LOG_LEVEL = "error"; @@ -57,7 +65,12 @@ public class AutoConfiguredCachingIntegrationTests { private CachingBookService bookService; @Resource(name = "CachedBooks") - private Region cachedBooks; + private Region cachedBooks; + + @BeforeClass + public static void setup() { + closeGemFireCacheWaitOnCloseEvent(); + } private void assertBook(Book book, String title) { diff --git a/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/function/AutoConfiguredFunctionExecutionsIntegrationTests.java b/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/function/AutoConfiguredFunctionExecutionsIntegrationTests.java index e3952e68..9abfe4ed 100644 --- a/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/function/AutoConfiguredFunctionExecutionsIntegrationTests.java +++ b/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/function/AutoConfiguredFunctionExecutionsIntegrationTests.java @@ -26,6 +26,7 @@ import java.util.Optional; import org.apache.geode.cache.GemFireCache; import org.apache.geode.cache.execute.FunctionService; import org.apache.shiro.util.Assert; +import org.junit.BeforeClass; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; @@ -38,25 +39,51 @@ import org.springframework.context.annotation.Bean; import org.springframework.data.gemfire.config.annotation.EnableGemFireProperties; import org.springframework.data.gemfire.config.annotation.EnableLogging; import org.springframework.data.gemfire.function.annotation.GemfireFunction; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.test.context.junit4.SpringRunner; /** - * The AutoConfiguredFunctionExecutionsIntegrationTests class... + * Integration tests testing the auto-configuration for Spring Data Apache Geode/Pivotal GemFire + * Function implementations and executions support. * * @author John Blum + * @see org.apache.geode.cache.GemFireCache + * @see org.apache.geode.cache.execute.FunctionService + * @see org.springframework.boot.autoconfigure.SpringBootApplication + * @see org.springframework.boot.data.geode.function.executions.Calculator + * @see org.springframework.boot.test.context.SpringBootTest + * @see org.springframework.data.gemfire.function.annotation.GemfireFunction + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport + * @see org.springframework.test.context.junit4.SpringRunner * @since 1.0.0 */ @RunWith(SpringRunner.class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) @SuppressWarnings("unused") -public class AutoConfiguredFunctionExecutionsIntegrationTests { +public class AutoConfiguredFunctionExecutionsIntegrationTests extends IntegrationTestsSupport { private static final String GEMFIRE_LOG_LEVEL = "error"; + @Autowired + private GemFireCache gemfireCache; + @Autowired private Calculator calculator; + @BeforeClass + public static void setup() { + closeGemFireCacheWaitOnCloseEvent(); + } + + @Test + public void cacheClientIsInGroupTest() { + + assertThat(this.gemfireCache).isNotNull(); + assertThat(this.gemfireCache.getDistributedSystem().getGroupMembers("test")) + .contains(this.gemfireCache.getDistributedSystem().getDistributedMember()); + } + @Test public void firstFunctionsMustBeRegistered() { diff --git a/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/repository/AutoConfiguredRepositoriesIntegrationTests.java b/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/repository/AutoConfiguredRepositoriesIntegrationTests.java index a46b7025..620b4102 100644 --- a/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/repository/AutoConfiguredRepositoriesIntegrationTests.java +++ b/geode-spring-boot-starter/src/test/java/org/springframework/boot/data/geode/repository/AutoConfiguredRepositoriesIntegrationTests.java @@ -22,6 +22,7 @@ import javax.annotation.Resource; import org.apache.geode.cache.Region; import org.apache.geode.cache.client.ClientRegionShortcut; +import org.junit.BeforeClass; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,6 +34,7 @@ import org.springframework.boot.data.geode.repository.service.CustomerService; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.gemfire.config.annotation.EnableEntityDefinedRegions; import org.springframework.data.gemfire.config.annotation.EnableLogging; +import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport; import org.springframework.data.gemfire.util.RegionUtils; import org.springframework.test.context.junit4.SpringRunner; @@ -41,8 +43,11 @@ import org.springframework.test.context.junit4.SpringRunner; * or Pivotal GemFire. * * @author John Blum + * @see org.apache.geode.cache.Region * @see org.springframework.boot.autoconfigure.SpringBootApplication * @see org.springframework.boot.test.context.SpringBootTest + * @see org.springframework.data.gemfire.config.annotation.EnableEntityDefinedRegions + * @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport * @see org.springframework.test.context.junit4.SpringRunner * @since 1.0.0 */ @@ -50,7 +55,7 @@ import org.springframework.test.context.junit4.SpringRunner; @FixMethodOrder(MethodSorters.NAME_ASCENDING) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) @SuppressWarnings("unused") -public class AutoConfiguredRepositoriesIntegrationTests { +public class AutoConfiguredRepositoriesIntegrationTests extends IntegrationTestsSupport { private static final String GEMFIRE_LOG_LEVEL = "error"; @@ -60,6 +65,11 @@ public class AutoConfiguredRepositoriesIntegrationTests { @Resource(name = "Customers") private Region customers; + @BeforeClass + public static void setup() { + closeGemFireCacheWaitOnCloseEvent(); + } + @Test public void customerServiceWasConfiguredCorrectly() {