use of org.springframework.core.env.ConfigurableEnvironment in project spring-boot by spring-projects.
the class SpringApplicationTests method addProfilesOrder.
@Test
public void addProfilesOrder() throws Exception {
SpringApplication application = new SpringApplication(ExampleConfig.class);
application.setWebApplicationType(WebApplicationType.NONE);
application.setAdditionalProfiles("foo");
ConfigurableEnvironment environment = new StandardEnvironment();
application.setEnvironment(environment);
this.context = application.run("--spring.profiles.active=bar,spam");
// Command line should always come last
assertThat(environment.getActiveProfiles()).containsExactly("foo", "bar", "spam");
}
use of org.springframework.core.env.ConfigurableEnvironment in project spring-boot by spring-projects.
the class ApplicationPidFileWriterTests method createReadyEvent.
private SpringApplicationEvent createReadyEvent(String propName, String propValue) {
ConfigurableEnvironment environment = createEnvironment(propName, propValue);
ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class);
given(context.getEnvironment()).willReturn(environment);
return new ApplicationReadyEvent(new SpringApplication(), new String[] {}, context);
}
use of org.springframework.core.env.ConfigurableEnvironment in project spring-boot by spring-projects.
the class ApplicationPidFileWriterTests method createPreparedEvent.
private SpringApplicationEvent createPreparedEvent(String propName, String propValue) {
ConfigurableEnvironment environment = createEnvironment(propName, propValue);
ConfigurableApplicationContext context = mock(ConfigurableApplicationContext.class);
given(context.getEnvironment()).willReturn(environment);
return new ApplicationPreparedEvent(new SpringApplication(), new String[] {}, context);
}
use of org.springframework.core.env.ConfigurableEnvironment in project spring-framework by spring-projects.
the class ClassPathScanningCandidateComponentProviderTests method testWithActiveProfile.
@Test
public void testWithActiveProfile() {
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(true);
ConfigurableEnvironment env = new StandardEnvironment();
env.setActiveProfiles(ProfileAnnotatedComponent.PROFILE_NAME);
provider.setEnvironment(env);
Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_PROFILE_PACKAGE);
assertThat(containsBeanClass(candidates, ProfileAnnotatedComponent.class), is(true));
}
use of org.springframework.core.env.ConfigurableEnvironment in project spring-framework by spring-projects.
the class ClassPathScanningCandidateComponentProviderTests method testWithInactiveProfile.
@Test
public void testWithInactiveProfile() {
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(true);
ConfigurableEnvironment env = new StandardEnvironment();
env.setActiveProfiles("other");
provider.setEnvironment(env);
Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_PROFILE_PACKAGE);
assertThat(containsBeanClass(candidates, ProfileAnnotatedComponent.class), is(false));
}
Aggregations