use of cn.taketoday.core.env.PropertyResolver in project today-infrastructure by TAKETODAY.
the class ConfigurationPropertySourcesTests method attachShouldAddAdapterAtBeginning.
@Test
void attachShouldAddAdapterAtBeginning() {
ConfigurableEnvironment environment = new StandardEnvironment();
PropertySources sources = environment.getPropertySources();
sources.addLast(new SystemEnvironmentPropertySource("system", Collections.singletonMap("SERVER_PORT", "1234")));
sources.addLast(new MapPropertySource("config", Collections.singletonMap("server.port", "4568")));
int size = sources.size();
ConfigurationPropertySources.attach(environment);
assertThat(sources.size()).isEqualTo(size + 1);
PropertyResolver resolver = new PropertySourcesPropertyResolver(sources);
assertThat(resolver.getProperty("server.port")).isEqualTo("1234");
}
use of cn.taketoday.core.env.PropertyResolver in project today-framework by TAKETODAY.
the class ResourceBanner method printBanner.
@Override
public void printBanner(Environment environment, Class<?> sourceClass, PrintStream out) {
try {
String banner = StreamUtils.copyToString(this.resource.getInputStream(), environment.getProperty("banner.charset", Charset.class, StandardCharsets.UTF_8));
for (PropertyResolver resolver : getPropertyResolvers(environment, sourceClass)) {
banner = resolver.resolvePlaceholders(banner);
}
out.println(banner);
} catch (Exception ex) {
logger.warn("Banner not printable: %s (%s: '%s')", this.resource, ex.getClass(), ex.getMessage(), ex);
}
}
use of cn.taketoday.core.env.PropertyResolver in project today-framework by TAKETODAY.
the class ConfigurationPropertySourcesTests method attachShouldAddAdapterAtBeginning.
@Test
void attachShouldAddAdapterAtBeginning() {
ConfigurableEnvironment environment = new StandardEnvironment();
PropertySources sources = environment.getPropertySources();
sources.addLast(new SystemEnvironmentPropertySource("system", Collections.singletonMap("SERVER_PORT", "1234")));
sources.addLast(new MapPropertySource("config", Collections.singletonMap("server.port", "4568")));
int size = sources.size();
ConfigurationPropertySources.attach(environment);
assertThat(sources.size()).isEqualTo(size + 1);
PropertyResolver resolver = new PropertySourcesPropertyResolver(sources);
assertThat(resolver.getProperty("server.port")).isEqualTo("1234");
}
use of cn.taketoday.core.env.PropertyResolver in project today-infrastructure by TAKETODAY.
the class ResourceBanner method printBanner.
@Override
public void printBanner(Environment environment, Class<?> sourceClass, PrintStream out) {
try {
String banner = StreamUtils.copyToString(this.resource.getInputStream(), environment.getProperty("banner.charset", Charset.class, StandardCharsets.UTF_8));
for (PropertyResolver resolver : getPropertyResolvers(environment, sourceClass)) {
banner = resolver.resolvePlaceholders(banner);
}
out.println(banner);
} catch (Exception ex) {
logger.warn("Banner not printable: %s (%s: '%s')", this.resource, ex.getClass(), ex.getMessage(), ex);
}
}
Aggregations