|
|
|
|
@ -249,37 +249,49 @@ class SpringApplicationTests {
@@ -249,37 +249,49 @@ class SpringApplicationTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void logsNoActiveProfiles(CapturedOutput output) { |
|
|
|
|
void logsActiveProfilesWithoutProfileAndSingleDefault(CapturedOutput output) { |
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class); |
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE); |
|
|
|
|
this.context = application.run(); |
|
|
|
|
assertThat(output).contains("No active profile set, falling back to 1 default profile(s): \"default\""); |
|
|
|
|
assertThat(output).contains("No active profile set, falling back to 1 default profile: \"default\""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void logsActiveProfiles(CapturedOutput output) { |
|
|
|
|
void logsActiveProfilesWithoutProfileAndMultipleDefaults(CapturedOutput output) { |
|
|
|
|
MockEnvironment environment = new MockEnvironment(); |
|
|
|
|
environment.setDefaultProfiles("p0,p1", "default"); |
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class); |
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE); |
|
|
|
|
this.context = application.run("--spring.profiles.active=myprofiles"); |
|
|
|
|
assertThat(output).contains("The following 1 profile(s) are active: \"myprofiles\""); |
|
|
|
|
application.setEnvironment(environment); |
|
|
|
|
this.context = application.run(); |
|
|
|
|
assertThat(output) |
|
|
|
|
.contains("No active profile set, falling back to 2 default profiles: \"p0,p1\", \"default\""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void enableBannerInLogViaProperty(CapturedOutput output) { |
|
|
|
|
SpringApplication application = spy(new SpringApplication(ExampleConfig.class)); |
|
|
|
|
void logsActiveProfilesWithSingleProfile(CapturedOutput output) { |
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class); |
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE); |
|
|
|
|
this.context = application.run("--spring.main.banner-mode=log"); |
|
|
|
|
then(application).should(atLeastOnce()).setBannerMode(Banner.Mode.LOG); |
|
|
|
|
assertThat(output).contains("o.s.b.SpringApplication"); |
|
|
|
|
this.context = application.run("--spring.profiles.active=myprofiles"); |
|
|
|
|
assertThat(output).contains("The following 1 profile is active: \"myprofiles\""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void logsMultipleActiveProfilesWithComma(CapturedOutput output) { |
|
|
|
|
void logsActiveProfilesWithMultipleProfiles(CapturedOutput output) { |
|
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class); |
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE); |
|
|
|
|
application.setAdditionalProfiles("p1,p2", "p3"); |
|
|
|
|
application.run(); |
|
|
|
|
assertThat(output).contains("The following 2 profile(s) are active: \"p1,p2\",\"p3\""); |
|
|
|
|
assertThat(output).contains("The following 2 profiles are active: \"p1,p2\", \"p3\""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void enableBannerInLogViaProperty(CapturedOutput output) { |
|
|
|
|
SpringApplication application = spy(new SpringApplication(ExampleConfig.class)); |
|
|
|
|
application.setWebApplicationType(WebApplicationType.NONE); |
|
|
|
|
this.context = application.run("--spring.main.banner-mode=log"); |
|
|
|
|
then(application).should(atLeastOnce()).setBannerMode(Banner.Mode.LOG); |
|
|
|
|
assertThat(output).contains("o.s.b.SpringApplication"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|