use of cn.taketoday.mock.env.MockEnvironment in project today-infrastructure by TAKETODAY.
the class ProfilesTests method getDefaultWithProfileGroups.
@Test
void getDefaultWithProfileGroups() {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("context.profiles.default", "a,b,c");
environment.setProperty("context.profiles.group.a", "d,e");
Binder binder = Binder.get(environment);
Profiles profiles = new Profiles(environment, binder, null);
assertThat(profiles.getDefault()).containsExactly("a", "d", "e", "b", "c");
}
use of cn.taketoday.mock.env.MockEnvironment in project today-infrastructure by TAKETODAY.
the class ProfilesTests method getActiveWhenHasAdditionalIncludesAdditional.
@Test
void getActiveWhenHasAdditionalIncludesAdditional() {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("context.profiles.active", "d,e,f");
Binder binder = Binder.get(environment);
Profiles profiles = new Profiles(environment, binder, Arrays.asList("a", "b", "c"));
assertThat(profiles.getActive()).containsExactly("a", "b", "c", "d", "e", "f");
}
use of cn.taketoday.mock.env.MockEnvironment in project today-infrastructure by TAKETODAY.
the class ProfilesTests method getDefaultWhenEnvironmentProfilesAndEnvironmentProperty.
@Test
void getDefaultWhenEnvironmentProfilesAndEnvironmentProperty() {
MockEnvironment environment = new MockEnvironment();
environment.setDefaultProfiles("a", "b", "c");
environment.setProperty("context.profiles.default", "d,e,f");
Binder binder = Binder.get(environment);
Profiles profiles = new Profiles(environment, binder, null);
assertThat(profiles.getDefault()).containsExactly("a", "b", "c");
}
use of cn.taketoday.mock.env.MockEnvironment in project today-infrastructure by TAKETODAY.
the class ApplicationTests method defaultPropertiesShouldBeMerged.
@Test
void defaultPropertiesShouldBeMerged() {
MockEnvironment environment = new MockEnvironment();
environment.getPropertySources().addFirst(new MapPropertySource(DefaultPropertiesPropertySource.NAME, Collections.singletonMap("bar", "foo")));
Application application = new ApplicationBuilder(ExampleConfig.class).environment(environment).properties("baz=bing").type(ApplicationType.NONE_WEB).build();
this.context = application.run();
assertThat(getEnvironment().getProperty("bar")).isEqualTo("foo");
assertThat(getEnvironment().getProperty("baz")).isEqualTo("bing");
}
use of cn.taketoday.mock.env.MockEnvironment in project today-infrastructure by TAKETODAY.
the class CloudPlatformTests method getActiveWhenHasDynoShouldReturnHeroku.
@Test
void getActiveWhenHasDynoShouldReturnHeroku() {
Environment environment = new MockEnvironment().withProperty("DYNO", "---");
CloudPlatform platform = CloudPlatform.getActive(environment);
assertThat(platform).isEqualTo(CloudPlatform.HEROKU);
assertThat(platform.isActive(environment)).isTrue();
}
Aggregations