From 39d57d62caf350cb21b4f972717d7c25e6b28b45 Mon Sep 17 00:00:00 2001 From: John Blum Date: Mon, 10 Jun 2019 19:22:04 -0700 Subject: [PATCH] Complete ServerDefinedRegionTemplateAutoConfigurationIntegrationTests. --- ...lateAutoConfigurationIntegrationTests.java | 52 ++++++++++++++++--- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/spring-geode-autoconfigure/src/test/java/org/springframework/geode/boot/autoconfigure/template/ServerDefinedRegionTemplateAutoConfigurationIntegrationTests.java b/spring-geode-autoconfigure/src/test/java/org/springframework/geode/boot/autoconfigure/template/ServerDefinedRegionTemplateAutoConfigurationIntegrationTests.java index 5493cced..e1ca317e 100644 --- a/spring-geode-autoconfigure/src/test/java/org/springframework/geode/boot/autoconfigure/template/ServerDefinedRegionTemplateAutoConfigurationIntegrationTests.java +++ b/spring-geode-autoconfigure/src/test/java/org/springframework/geode/boot/autoconfigure/template/ServerDefinedRegionTemplateAutoConfigurationIntegrationTests.java @@ -15,21 +15,29 @@ */ package org.springframework.geode.boot.autoconfigure.template; +import static org.assertj.core.api.Assertions.assertThat; + import java.io.IOException; import org.junit.BeforeClass; -import org.junit.Ignore; +import org.junit.Test; import org.junit.runner.RunWith; +import org.apache.geode.cache.DataPolicy; import org.apache.geode.cache.GemFireCache; import org.apache.geode.cache.Region; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; +import org.springframework.data.gemfire.GemfireTemplate; import org.springframework.data.gemfire.LocalRegionFactoryBean; import org.springframework.data.gemfire.config.annotation.CacheServerApplication; +import org.springframework.data.gemfire.config.annotation.EnableClusterDefinedRegions; +import org.springframework.data.gemfire.config.annotation.EnableLogging; import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport; import org.springframework.geode.boot.autoconfigure.RegionTemplateAutoConfiguration; import org.springframework.test.context.junit4.SpringRunner; @@ -40,34 +48,66 @@ import org.springframework.test.context.junit4.SpringRunner; * * @author John Blum * @see org.junit.Test + * @see org.apache.geode.cache.GemFireCache * @see org.apache.geode.cache.Region * @see org.springframework.boot.autoconfigure.SpringBootApplication * @see org.springframework.boot.test.context.SpringBootTest + * @see org.springframework.context.ApplicationContext + * @see org.springframework.context.annotation.Bean * @see org.springframework.data.gemfire.GemfireTemplate - * @see org.springframework.data.gemfire.config.annotation.EnableServerDefinedRegions + * @see org.springframework.data.gemfire.LocalRegionFactoryBean + * @see org.springframework.data.gemfire.config.annotation.CacheServerApplication + * @see org.springframework.data.gemfire.config.annotation.EnableClusterDefinedRegions * @see org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport * @see org.springframework.geode.boot.autoconfigure.RegionTemplateAutoConfiguration * @see org.springframework.test.context.junit4.SpringRunner * @since 1.1.0 */ -@Ignore @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = ServerDefinedRegionTemplateAutoConfigurationIntegrationTests.GemFireClientConfiguration.class) -// TODO enable and complete test class when SBDG is rebased on SD Lovelace +@SuppressWarnings("unused") public class ServerDefinedRegionTemplateAutoConfigurationIntegrationTests extends ForkingClientServerIntegrationTestsSupport { + private static final String GEMFIRE_LOG_LEVEL = "off"; + @BeforeClass public static void startGemFireServer() throws IOException { startGemFireServer(GemFireServerConfiguration.class); } + @Autowired + private ApplicationContext applicationContext; + + @Autowired + private GemfireTemplate exampleServerRegionTemplate; + + @Test + public void exampleServerRegionExistsAsClientRegion() { + + Region exampleServerRegion = this.applicationContext.getBean("ExampleServerRegion", Region.class); + + assertThat(exampleServerRegion).isNotNull(); + assertThat(exampleServerRegion.getName()).isEqualTo("ExampleServerRegion"); + assertThat(exampleServerRegion.getAttributes()).isNotNull(); + assertThat(exampleServerRegion.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.EMPTY); + } + + @Test + public void exampleServerRegionTemplateIsPresent() { + + assertThat(this.exampleServerRegionTemplate).isNotNull(); + assertThat(this.exampleServerRegionTemplate.getRegion()).isNotNull(); + assertThat(this.exampleServerRegionTemplate.getRegion().getName()).isEqualTo("ExampleServerRegion"); + } + @SpringBootApplication - //@EnableServerDefinedRegions + @EnableClusterDefinedRegions + @EnableLogging(logLevel = GEMFIRE_LOG_LEVEL) static class GemFireClientConfiguration { } - @CacheServerApplication + @CacheServerApplication(logLevel = GEMFIRE_LOG_LEVEL) static class GemFireServerConfiguration { public static void main(String[] args) {