Refactor all integration test classes to extend o.s.d.g.tests.integration.IntegrationTestsSupport.

Add test suite setup method to close any existing GemFireCache instance before test execution.
This commit is contained in:
John Blum
2018-05-23 20:32:20 -07:00
parent dc63e34bc4
commit d3aa26a3ee
5 changed files with 89 additions and 15 deletions

View File

@@ -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() {

View File

@@ -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() {

View File

@@ -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<String, Customer> cachedBooks;
private Region<String, Book> cachedBooks;
@BeforeClass
public static void setup() {
closeGemFireCacheWaitOnCloseEvent();
}
private void assertBook(Book book, String title) {

View File

@@ -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() {

View File

@@ -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<Long, Customer> customers;
@BeforeClass
public static void setup() {
closeGemFireCacheWaitOnCloseEvent();
}
@Test
public void customerServiceWasConfiguredCorrectly() {