use of cn.taketoday.core.env.StandardEnvironment in project today-infrastructure by TAKETODAY.
the class EnvironmentConverterTests method envClassSameShouldReturnEnvironmentUnconverted.
@Test
void envClassSameShouldReturnEnvironmentUnconverted() {
StandardEnvironment standardEnvironment = new StandardEnvironment();
StandardEnvironment convertedEnvironment = EnvironmentConverter.convertIfNecessary(getClass().getClassLoader(), standardEnvironment, StandardEnvironment.class);
assertThat(convertedEnvironment).isSameAs(standardEnvironment);
}
use of cn.taketoday.core.env.StandardEnvironment in project today-infrastructure by TAKETODAY.
the class EnvironmentConverterTests method envClassSameShouldReturnEnvironmentUnconvertedEvenForWeb.
@Test
void envClassSameShouldReturnEnvironmentUnconvertedEvenForWeb() {
StandardServletEnvironment standardServletEnvironment = new StandardServletEnvironment();
StandardEnvironment convertedEnvironment = EnvironmentConverter.convertIfNecessary(getClass().getClassLoader(), standardServletEnvironment, StandardServletEnvironment.class);
assertThat(convertedEnvironment).isSameAs(standardServletEnvironment);
}
use of cn.taketoday.core.env.StandardEnvironment in project today-infrastructure by TAKETODAY.
the class EnvironmentConverter method convertEnvironment.
static StandardEnvironment convertEnvironment(ClassLoader classLoader, ConfigurableEnvironment environment, Class<? extends StandardEnvironment> type) {
StandardEnvironment result = createEnvironment(type);
result.setActiveProfiles(environment.getActiveProfiles());
result.setConversionService(environment.getConversionService());
copyPropertySources(environment, result, classLoader);
return result;
}
use of cn.taketoday.core.env.StandardEnvironment in project today-infrastructure by TAKETODAY.
the class MapBinderTests method bindToMapWithPlaceholdersShouldBeGreedyForScalars.
@Test
void bindToMapWithPlaceholdersShouldBeGreedyForScalars() {
StandardEnvironment environment = new StandardEnvironment();
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(environment, "foo=boo");
MockConfigurationPropertySource source = new MockConfigurationPropertySource("foo.aaa.bbb.ccc", "baz-${foo}");
this.sources.add(source);
this.binder = new Binder(this.sources, new PropertySourcesPlaceholdersResolver(environment));
Map<String, ExampleEnum> result = this.binder.bind("foo", Bindable.mapOf(String.class, ExampleEnum.class)).get();
assertThat(result).containsEntry("aaa.bbb.ccc", ExampleEnum.BAZ_BOO);
}
use of cn.taketoday.core.env.StandardEnvironment in project today-infrastructure by TAKETODAY.
the class BinderTests method bindToValueWithPlaceholdersShouldResolve.
@Test
void bindToValueWithPlaceholdersShouldResolve() {
StandardEnvironment environment = new StandardEnvironment();
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(environment, "bar=23");
this.sources.add(new MockConfigurationPropertySource("foo", "1${bar}"));
this.binder = new Binder(this.sources, new PropertySourcesPlaceholdersResolver(environment));
BindResult<Integer> result = this.binder.bind("foo", Bindable.of(Integer.class));
assertThat(result.get()).isEqualTo(123);
}
Aggregations