|
|
|
@ -171,7 +171,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void customBanner() throws Exception {
|
|
|
|
|
SpringApplication application = spy(new SpringApplication(ExampleConfig.class));
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
this.context = application.run("--banner.location=classpath:test-banner.txt");
|
|
|
|
|
assertThat(this.output.toString()).startsWith("Running a Test!");
|
|
|
|
|
}
|
|
|
|
@ -179,7 +179,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void customBannerWithProperties() throws Exception {
|
|
|
|
|
SpringApplication application = spy(new SpringApplication(ExampleConfig.class));
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
this.context = application.run(
|
|
|
|
|
"--banner.location=classpath:test-banner-with-placeholder.txt",
|
|
|
|
|
"--test.property=123456");
|
|
|
|
@ -192,7 +192,7 @@ public class SpringApplicationTests {
|
|
|
|
|
MockResourceLoader resourceLoader = new MockResourceLoader();
|
|
|
|
|
resourceLoader.addResource("banner.gif", "black-and-white.gif");
|
|
|
|
|
resourceLoader.addResource("banner.txt", "foobar.txt");
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
application.setResourceLoader(resourceLoader);
|
|
|
|
|
application.run();
|
|
|
|
|
assertThat(this.output.toString()).contains("@@@@").contains("Foo Bar");
|
|
|
|
@ -203,7 +203,7 @@ public class SpringApplicationTests {
|
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
|
|
|
|
MockResourceLoader resourceLoader = new MockResourceLoader();
|
|
|
|
|
resourceLoader.addResource("banner.gif", "black-and-white.gif");
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
application.setResourceLoader(resourceLoader);
|
|
|
|
|
application.run();
|
|
|
|
|
assertThat(this.output.toString()).contains("@@@@@@");
|
|
|
|
@ -212,7 +212,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void logsNoActiveProfiles() throws Exception {
|
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
this.context = application.run();
|
|
|
|
|
assertThat(this.output.toString()).contains(
|
|
|
|
|
"No active profile set, falling back to default profiles: default");
|
|
|
|
@ -221,7 +221,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void logsActiveProfiles() throws Exception {
|
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
this.context = application.run("--spring.profiles.active=myprofiles");
|
|
|
|
|
assertThat(this.output.toString())
|
|
|
|
|
.contains("The following profiles are active: myprofile");
|
|
|
|
@ -230,7 +230,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void enableBannerInLogViaProperty() throws Exception {
|
|
|
|
|
SpringApplication application = spy(new SpringApplication(ExampleConfig.class));
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
this.context = application.run("--spring.main.banner-mode=log");
|
|
|
|
|
verify(application, atLeastOnce()).setBannerMode(Banner.Mode.LOG);
|
|
|
|
|
assertThat(this.output.toString()).contains("o.s.boot.SpringApplication");
|
|
|
|
@ -281,7 +281,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void customId() throws Exception {
|
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
this.context = application.run("--spring.application.name=foo");
|
|
|
|
|
assertThat(this.context.getId()).startsWith("foo");
|
|
|
|
|
}
|
|
|
|
@ -297,7 +297,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void specificApplicationContextInitializer() throws Exception {
|
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
final AtomicReference<ApplicationContext> reference = new AtomicReference<ApplicationContext>();
|
|
|
|
|
application.setInitializers(Arrays.asList(
|
|
|
|
|
new ApplicationContextInitializer<ConfigurableApplicationContext>() {
|
|
|
|
@ -315,7 +315,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void applicationRunningEventListener() {
|
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
final AtomicReference<SpringApplication> reference = new AtomicReference<SpringApplication>();
|
|
|
|
|
class ApplicationReadyEventListener
|
|
|
|
|
implements ApplicationListener<ApplicationReadyEvent> {
|
|
|
|
@ -334,7 +334,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void contextRefreshedEventListener() throws Exception {
|
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
final AtomicReference<ApplicationContext> reference = new AtomicReference<ApplicationContext>();
|
|
|
|
|
class InitializerListener implements ApplicationListener<ContextRefreshedEvent> {
|
|
|
|
|
|
|
|
|
@ -355,7 +355,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
|
public void eventsOrder() {
|
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
final List<ApplicationEvent> events = new ArrayList<ApplicationEvent>();
|
|
|
|
|
class ApplicationRunningEventListener
|
|
|
|
|
implements ApplicationListener<ApplicationEvent> {
|
|
|
|
@ -381,7 +381,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void defaultApplicationContext() throws Exception {
|
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
this.context = application.run();
|
|
|
|
|
assertThat(this.context).isInstanceOf(AnnotationConfigApplicationContext.class);
|
|
|
|
|
}
|
|
|
|
@ -389,7 +389,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void defaultApplicationContextForWeb() throws Exception {
|
|
|
|
|
SpringApplication application = new SpringApplication(ExampleWebConfig.class);
|
|
|
|
|
application.setWebEnvironment(true);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.SERVLET);
|
|
|
|
|
this.context = application.run();
|
|
|
|
|
assertThat(this.context)
|
|
|
|
|
.isInstanceOf(AnnotationConfigEmbeddedWebApplicationContext.class);
|
|
|
|
@ -399,7 +399,7 @@ public class SpringApplicationTests {
|
|
|
|
|
public void customEnvironment() throws Exception {
|
|
|
|
|
TestSpringApplication application = new TestSpringApplication(
|
|
|
|
|
ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
ConfigurableEnvironment environment = new StandardEnvironment();
|
|
|
|
|
application.setEnvironment(environment);
|
|
|
|
|
this.context = application.run();
|
|
|
|
@ -410,7 +410,7 @@ public class SpringApplicationTests {
|
|
|
|
|
public void customResourceLoader() throws Exception {
|
|
|
|
|
TestSpringApplication application = new TestSpringApplication(
|
|
|
|
|
ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
ResourceLoader resourceLoader = new DefaultResourceLoader();
|
|
|
|
|
application.setResourceLoader(resourceLoader);
|
|
|
|
|
this.context = application.run();
|
|
|
|
@ -443,7 +443,7 @@ public class SpringApplicationTests {
|
|
|
|
|
public void customBeanNameGeneratorWithNonWebApplication() throws Exception {
|
|
|
|
|
TestSpringApplication application = new TestSpringApplication(
|
|
|
|
|
ExampleWebConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator();
|
|
|
|
|
application.setBeanNameGenerator(beanNameGenerator);
|
|
|
|
|
this.context = application.run();
|
|
|
|
@ -456,7 +456,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void commandLinePropertySource() throws Exception {
|
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
ConfigurableEnvironment environment = new StandardEnvironment();
|
|
|
|
|
application.setEnvironment(environment);
|
|
|
|
|
this.context = application.run("--foo=bar");
|
|
|
|
@ -467,7 +467,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void commandLinePropertySourceEnhancesEnvironment() throws Exception {
|
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
ConfigurableEnvironment environment = new StandardEnvironment();
|
|
|
|
|
environment.getPropertySources().addFirst(new MapPropertySource("commandLineArgs",
|
|
|
|
|
Collections.<String, Object>singletonMap("foo", "original")));
|
|
|
|
@ -483,7 +483,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void propertiesFileEnhancesEnvironment() throws Exception {
|
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
ConfigurableEnvironment environment = new StandardEnvironment();
|
|
|
|
|
application.setEnvironment(environment);
|
|
|
|
|
this.context = application.run();
|
|
|
|
@ -493,7 +493,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void addProfiles() throws Exception {
|
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
application.setAdditionalProfiles("foo");
|
|
|
|
|
ConfigurableEnvironment environment = new StandardEnvironment();
|
|
|
|
|
application.setEnvironment(environment);
|
|
|
|
@ -504,7 +504,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void addProfilesOrder() throws Exception {
|
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
application.setAdditionalProfiles("foo");
|
|
|
|
|
ConfigurableEnvironment environment = new StandardEnvironment();
|
|
|
|
|
application.setEnvironment(environment);
|
|
|
|
@ -516,7 +516,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void addProfilesOrderWithProperties() throws Exception {
|
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
application.setAdditionalProfiles("other");
|
|
|
|
|
ConfigurableEnvironment environment = new StandardEnvironment();
|
|
|
|
|
application.setEnvironment(environment);
|
|
|
|
@ -529,7 +529,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void emptyCommandLinePropertySourceNotAdded() throws Exception {
|
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
ConfigurableEnvironment environment = new StandardEnvironment();
|
|
|
|
|
application.setEnvironment(environment);
|
|
|
|
|
this.context = application.run();
|
|
|
|
@ -539,7 +539,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void disableCommandLinePropertySource() throws Exception {
|
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
application.setAddCommandLineProperties(false);
|
|
|
|
|
ConfigurableEnvironment environment = new StandardEnvironment();
|
|
|
|
|
application.setEnvironment(environment);
|
|
|
|
@ -551,7 +551,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void runCommandLineRunnersAndApplicationRunners() throws Exception {
|
|
|
|
|
SpringApplication application = new SpringApplication(CommandLineRunConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
this.context = application.run("arg");
|
|
|
|
|
assertThat(this.context).has(runTestRunnerBean("runnerA"));
|
|
|
|
|
assertThat(this.context).has(runTestRunnerBean("runnerB"));
|
|
|
|
@ -562,7 +562,7 @@ public class SpringApplicationTests {
|
|
|
|
|
public void loadSources() throws Exception {
|
|
|
|
|
Object[] sources = { ExampleConfig.class, "a", TestCommandLineRunner.class };
|
|
|
|
|
TestSpringApplication application = new TestSpringApplication(sources);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
application.setUseMockLoader(true);
|
|
|
|
|
this.context = application.run();
|
|
|
|
|
Set<Object> initialSources = application.getSources();
|
|
|
|
@ -574,7 +574,7 @@ public class SpringApplicationTests {
|
|
|
|
|
Object[] sources = {
|
|
|
|
|
"classpath:org/springframework/boot/sample-${sample.app.test.prop}.xml" };
|
|
|
|
|
TestSpringApplication application = new TestSpringApplication(sources);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
this.context = application.run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -594,7 +594,7 @@ public class SpringApplicationTests {
|
|
|
|
|
@Test
|
|
|
|
|
public void exit() throws Exception {
|
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
this.context = application.run();
|
|
|
|
|
assertThat(this.context).isNotNull();
|
|
|
|
|
assertThat(SpringApplication.exit(this.context)).isEqualTo(0);
|
|
|
|
@ -605,7 +605,7 @@ public class SpringApplicationTests {
|
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
|
|
|
|
ExitCodeListener listener = new ExitCodeListener();
|
|
|
|
|
application.addListeners(listener);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
this.context = application.run();
|
|
|
|
|
assertThat(this.context).isNotNull();
|
|
|
|
|
assertThat(SpringApplication.exit(this.context, new ExitCodeGenerator() {
|
|
|
|
@ -633,7 +633,7 @@ public class SpringApplicationTests {
|
|
|
|
|
};
|
|
|
|
|
ExitCodeListener listener = new ExitCodeListener();
|
|
|
|
|
application.addListeners(listener);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
try {
|
|
|
|
|
application.run();
|
|
|
|
|
fail("Did not throw");
|
|
|
|
@ -658,7 +658,7 @@ public class SpringApplicationTests {
|
|
|
|
|
};
|
|
|
|
|
ExitCodeListener listener = new ExitCodeListener();
|
|
|
|
|
application.addListeners(listener);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
try {
|
|
|
|
|
application.run();
|
|
|
|
|
fail("Did not throw");
|
|
|
|
@ -683,7 +683,7 @@ public class SpringApplicationTests {
|
|
|
|
|
};
|
|
|
|
|
ExitCodeListener listener = new ExitCodeListener();
|
|
|
|
|
application.addListeners(listener);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
try {
|
|
|
|
|
application.run();
|
|
|
|
|
fail("Did not throw");
|
|
|
|
@ -703,7 +703,7 @@ public class SpringApplicationTests {
|
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
|
|
|
|
application.setDefaultProperties(StringUtils.splitArrayElementsIntoProperties(
|
|
|
|
|
new String[] { "baz=", "bar=spam" }, "="));
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
this.context = application.run("--bar=foo", "bucket", "crap");
|
|
|
|
|
assertThat(this.context).isInstanceOf(AnnotationConfigApplicationContext.class);
|
|
|
|
|
assertThat(getEnvironment().getProperty("bar")).isEqualTo("foo");
|
|
|
|
@ -714,7 +714,7 @@ public class SpringApplicationTests {
|
|
|
|
|
public void commandLineArgsApplyToSpringApplication() throws Exception {
|
|
|
|
|
TestSpringApplication application = new TestSpringApplication(
|
|
|
|
|
ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
this.context = application.run("--spring.main.banner-mode=OFF");
|
|
|
|
|
assertThat(application.getBannerMode()).isEqualTo(Banner.Mode.OFF);
|
|
|
|
|
}
|
|
|
|
@ -792,7 +792,7 @@ public class SpringApplicationTests {
|
|
|
|
|
public void headless() throws Exception {
|
|
|
|
|
TestSpringApplication application = new TestSpringApplication(
|
|
|
|
|
ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
this.context = application.run();
|
|
|
|
|
assertThat(System.getProperty("java.awt.headless")).isEqualTo("true");
|
|
|
|
|
}
|
|
|
|
@ -801,7 +801,7 @@ public class SpringApplicationTests {
|
|
|
|
|
public void headlessFalse() throws Exception {
|
|
|
|
|
TestSpringApplication application = new TestSpringApplication(
|
|
|
|
|
ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
application.setHeadless(false);
|
|
|
|
|
this.context = application.run();
|
|
|
|
|
assertThat(System.getProperty("java.awt.headless")).isEqualTo("false");
|
|
|
|
@ -812,7 +812,7 @@ public class SpringApplicationTests {
|
|
|
|
|
System.setProperty("java.awt.headless", "false");
|
|
|
|
|
TestSpringApplication application = new TestSpringApplication(
|
|
|
|
|
ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
this.context = application.run();
|
|
|
|
|
assertThat(System.getProperty("java.awt.headless")).isEqualTo("false");
|
|
|
|
|
}
|
|
|
|
@ -821,7 +821,7 @@ public class SpringApplicationTests {
|
|
|
|
|
public void getApplicationArgumentsBean() throws Exception {
|
|
|
|
|
TestSpringApplication application = new TestSpringApplication(
|
|
|
|
|
ExampleConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
this.context = application.run("--debug", "spring", "boot");
|
|
|
|
|
ApplicationArguments args = this.context.getBean(ApplicationArguments.class);
|
|
|
|
|
assertThat(args.getNonOptionArgs()).containsExactly("spring", "boot");
|
|
|
|
@ -829,7 +829,7 @@ public class SpringApplicationTests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void webEnvironmentSwitchedOffInListener() throws Exception {
|
|
|
|
|
public void webApplicationSwitchedOffInListener() throws Exception {
|
|
|
|
|
TestSpringApplication application = new TestSpringApplication(
|
|
|
|
|
ExampleConfig.class);
|
|
|
|
|
application.addListeners(
|
|
|
|
@ -842,7 +842,8 @@ public class SpringApplicationTests {
|
|
|
|
|
.isInstanceOf(StandardServletEnvironment.class);
|
|
|
|
|
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(
|
|
|
|
|
event.getEnvironment(), "foo=bar");
|
|
|
|
|
event.getSpringApplication().setWebEnvironment(false);
|
|
|
|
|
event.getSpringApplication()
|
|
|
|
|
.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
@ -863,7 +864,7 @@ public class SpringApplicationTests {
|
|
|
|
|
public void run() {
|
|
|
|
|
SpringApplication application = new SpringApplication(
|
|
|
|
|
FailingConfig.class);
|
|
|
|
|
application.setWebEnvironment(false);
|
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE);
|
|
|
|
|
application.run();
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|