use of cn.taketoday.core.env.StandardEnvironment in project today-infrastructure by TAKETODAY.
the class AbstractApplicationEnvironmentTests method getActiveProfilesDoesNotResolveProperty.
@Test
void getActiveProfilesDoesNotResolveProperty() {
StandardEnvironment environment = createEnvironment();
new MockPropertySource().withProperty("", "");
environment.getPropertySources().addFirst(new MockPropertySource().withProperty(AbstractEnvironment.KEY_ACTIVE_PROFILES, "test"));
assertThat(environment.getActiveProfiles()).isEmpty();
}
use of cn.taketoday.core.env.StandardEnvironment in project today-infrastructure by TAKETODAY.
the class AbstractApplicationEnvironmentTests method getDefaultProfilesDoesNotResolveProperty.
@Test
void getDefaultProfilesDoesNotResolveProperty() {
StandardEnvironment environment = createEnvironment();
new MockPropertySource().withProperty("", "");
environment.getPropertySources().addFirst(new MockPropertySource().withProperty(AbstractEnvironment.KEY_DEFAULT_PROFILES, "test"));
assertThat(environment.getDefaultProfiles()).containsExactly("default");
}
use of cn.taketoday.core.env.StandardEnvironment in project today-infrastructure by TAKETODAY.
the class EnvironmentConverterTests method convertedEnvironmentHasSameActiveProfiles.
@Test
void convertedEnvironmentHasSameActiveProfiles() {
AbstractEnvironment originalEnvironment = new MockEnvironment();
originalEnvironment.setActiveProfiles("activeProfile1", "activeProfile2");
StandardEnvironment convertedEnvironment = EnvironmentConverter.convertIfNecessary(getClass().getClassLoader(), originalEnvironment, StandardEnvironment.class);
assertThat(convertedEnvironment.getActiveProfiles()).containsExactly("activeProfile1", "activeProfile2");
}
use of cn.taketoday.core.env.StandardEnvironment in project today-infrastructure by TAKETODAY.
the class EnvironmentConverterTests method servletPropertySourcesAreNotCopiedOverIfNotWebEnvironment.
@Test
void servletPropertySourcesAreNotCopiedOverIfNotWebEnvironment() {
StandardServletEnvironment standardServletEnvironment = new StandardServletEnvironment();
StandardEnvironment convertedEnvironment = EnvironmentConverter.convertIfNecessary(getClass().getClassLoader(), standardServletEnvironment, StandardEnvironment.class);
assertThat(convertedEnvironment).isNotSameAs(standardServletEnvironment);
Set<String> names = new HashSet<>();
for (PropertySource<?> propertySource : convertedEnvironment.getPropertySources()) {
names.add(propertySource.getName());
}
assertThat(names).doesNotContain(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME, StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME, StandardServletEnvironment.JNDI_PROPERTY_SOURCE_NAME);
}
use of cn.taketoday.core.env.StandardEnvironment in project today-infrastructure by TAKETODAY.
the class EnvironmentConverterTests method servletPropertySourcesArePresentWhenTypeToConvertIsWeb.
@Test
void servletPropertySourcesArePresentWhenTypeToConvertIsWeb() {
StandardEnvironment standardEnvironment = new StandardEnvironment();
StandardEnvironment convertedEnvironment = EnvironmentConverter.convertIfNecessary(getClass().getClassLoader(), standardEnvironment, StandardServletEnvironment.class);
assertThat(convertedEnvironment).isNotSameAs(standardEnvironment);
Set<String> names = new HashSet<>();
for (PropertySource<?> propertySource : convertedEnvironment.getPropertySources()) {
names.add(propertySource.getName());
}
assertThat(names).contains(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME, StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME);
}
Aggregations