Add test case asserting the Spring ApplicationContext loads and is of the expected type.

This commit is contained in:
John Blum
2020-02-10 20:34:47 -08:00
parent a40c66d015
commit 3a347ba365

View File

@@ -23,8 +23,11 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
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.test.context.junit4.SpringRunner;
import org.springframework.web.context.WebApplicationContext;
/**
* Smoke Tests for {@link InitializerApplication}.
@@ -32,6 +35,7 @@ import org.springframework.test.context.junit4.SpringRunner;
* @author John Blum
* @see org.junit.Test
* @see org.springframework.boot.test.context.SpringBootTest
* @see org.springframework.context.ApplicationContext
* @see org.springframework.data.gemfire.GemfireTemplate
* @see org.springframework.test.context.junit4.SpringRunner
* @see example.app.InitializerApplication
@@ -42,12 +46,23 @@ import org.springframework.test.context.junit4.SpringRunner;
@SuppressWarnings("unused")
public class InitializerApplicationSmokeTests {
@Autowired
private ApplicationContext applicationContext;
@Autowired
@Qualifier("exampleTemplate")
private GemfireTemplate exampleTemplate;
@Test
public void loadsContextAndRegionDataAccessOperationsWork() {
public void applicationContextLoadsAndIsCorrectType() {
assertThat(this.applicationContext).isNotNull();
assertThat(this.applicationContext).isNotInstanceOf(WebApplicationContext.class);
assertThat(this.applicationContext).isNotInstanceOf(ServletWebServerApplicationContext.class);
}
@Test
public void regionDataAccessOperationsFunctionAsExpected() {
assertThat(this.exampleTemplate).isNotNull();
assertThat(this.exampleTemplate.getRegion()).isNotNull();