use of cn.taketoday.core.env.StandardEnvironment in project today-infrastructure by TAKETODAY.
the class ApplicationTests method addProfilesOrderWithProperties.
@Test
void addProfilesOrderWithProperties() {
Application application = new Application(ExampleConfig.class);
application.setApplicationType(ApplicationType.NONE_WEB);
application.setAdditionalProfiles("other");
ConfigurableEnvironment environment = new StandardEnvironment();
application.setEnvironment(environment);
this.context = application.run();
// Active profile should win over default
assertThat(environment.getProperty("my.property")).isEqualTo("fromotherpropertiesfile");
}
use of cn.taketoday.core.env.StandardEnvironment in project today-infrastructure by TAKETODAY.
the class ApplicationTests method propertiesFileEnhancesEnvironment.
@Test
void propertiesFileEnhancesEnvironment() {
Application application = new Application(ExampleConfig.class);
application.setApplicationType(ApplicationType.NONE_WEB);
ConfigurableEnvironment environment = new StandardEnvironment();
application.setEnvironment(environment);
this.context = application.run();
assertThat(environment.getProperty("foo")).isEqualTo("bucket");
}
use of cn.taketoday.core.env.StandardEnvironment in project today-infrastructure by TAKETODAY.
the class ApplicationTests method commandLinePropertySource.
@Test
void commandLinePropertySource() {
Application application = new Application(ExampleConfig.class);
application.setApplicationType(ApplicationType.NONE_WEB);
ConfigurableEnvironment environment = new StandardEnvironment();
application.setEnvironment(environment);
this.context = application.run("--foo=bar");
assertThat(environment).has(matchingPropertySource(CommandLinePropertySource.class, "commandLineArgs"));
}
use of cn.taketoday.core.env.StandardEnvironment in project today-infrastructure by TAKETODAY.
the class ApplicationTests method customEnvironment.
@Test
void customEnvironment() {
TestApplication application = new TestApplication(ExampleConfig.class);
application.setApplicationType(ApplicationType.NONE_WEB);
ConfigurableEnvironment environment = new StandardEnvironment();
application.setEnvironment(environment);
this.context = application.run();
then(application.getLoader()).should().setEnvironment(environment);
}
use of cn.taketoday.core.env.StandardEnvironment in project today-infrastructure by TAKETODAY.
the class ApplicationTests method addProfiles.
@Test
void addProfiles() {
Application application = new Application(ExampleConfig.class);
application.setApplicationType(ApplicationType.NONE_WEB);
application.setAdditionalProfiles("foo");
ConfigurableEnvironment environment = new StandardEnvironment();
application.setEnvironment(environment);
this.context = application.run();
assertThat(environment.acceptsProfiles(Profiles.of("foo"))).isTrue();
}
Aggregations