Merge branch '2.6.x' into 2.7.x
Closes gh-30665
This commit is contained in:
@@ -24,6 +24,7 @@ import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.test.util.TestPropertyValues;
|
||||
import org.springframework.boot.web.reactive.context.GenericReactiveWebApplicationContext;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
@@ -36,6 +37,7 @@ import org.springframework.test.context.TestContextManager;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.support.TestPropertySourceUtils;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -146,6 +148,20 @@ class SpringBootContextLoaderTests {
|
||||
assertThat(last).startsWith("Config resource");
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenEnvironmentChangesWebApplicationTypeToNoneThenContextTypeChangesAccordingly() {
|
||||
TestContext context = new ExposedTestContextManager(ChangingWebApplicationTypeToNone.class)
|
||||
.getExposedTestContext();
|
||||
assertThat(context.getApplicationContext()).isNotInstanceOf(WebApplicationContext.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenEnvironmentChangesWebApplicationTypeToReactiveThenContextTypeChangesAccordingly() {
|
||||
TestContext context = new ExposedTestContextManager(ChangingWebApplicationTypeToReactive.class)
|
||||
.getExposedTestContext();
|
||||
assertThat(context.getApplicationContext()).isInstanceOf(GenericReactiveWebApplicationContext.class);
|
||||
}
|
||||
|
||||
private String[] getActiveProfiles(Class<?> testClass) {
|
||||
TestContext testContext = new ExposedTestContextManager(testClass).getExposedTestContext();
|
||||
ApplicationContext applicationContext = testContext.getApplicationContext();
|
||||
@@ -228,6 +244,16 @@ class SpringBootContextLoaderTests {
|
||||
|
||||
}
|
||||
|
||||
@SpringBootTest(classes = Config.class, args = "--spring.main.web-application-type=none")
|
||||
static class ChangingWebApplicationTypeToNone {
|
||||
|
||||
}
|
||||
|
||||
@SpringBootTest(classes = Config.class, args = "--spring.main.web-application-type=reactive")
|
||||
static class ChangingWebApplicationTypeToReactive {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link TestContextManager} which exposes the {@link TestContext}.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user