use of org.springframework.core.env.PropertyResolver in project spring-boot by spring-projects.
the class ImageBanner method printBanner.
private void printBanner(Environment environment, PrintStream out) throws IOException {
PropertyResolver properties = new RelaxedPropertyResolver(environment, "banner.image.");
int width = properties.getProperty("width", Integer.class, 76);
int height = properties.getProperty("height", Integer.class, 0);
int margin = properties.getProperty("margin", Integer.class, 2);
boolean invert = properties.getProperty("invert", Boolean.class, false);
BufferedImage image = readImage(width, height);
printBanner(image, margin, invert, out);
}
use of org.springframework.core.env.PropertyResolver in project spring-boot by spring-projects.
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, Charset.forName("UTF-8")));
for (PropertyResolver resolver : getPropertyResolvers(environment, sourceClass)) {
banner = resolver.resolvePlaceholders(banner);
}
out.println(banner);
} catch (Exception ex) {
logger.warn("Banner not printable: " + this.resource + " (" + ex.getClass() + ": '" + ex.getMessage() + "')", ex);
}
}
use of org.springframework.core.env.PropertyResolver in project spring-boot by spring-projects.
the class LogFileTests method loggingFile.
@Test
public void loggingFile() throws Exception {
PropertyResolver resolver = getPropertyResolver("log.file", null);
LogFile logFile = LogFile.get(resolver);
Properties properties = new Properties();
logFile.applyTo(properties);
assertThat(logFile.toString()).isEqualTo("log.file");
assertThat(properties.getProperty("LOG_FILE")).isEqualTo("log.file");
assertThat(properties.getProperty("LOG_PATH")).isNull();
}
use of org.springframework.core.env.PropertyResolver in project spring-boot by spring-projects.
the class LogFileTests method noProperties.
@Test
public void noProperties() throws Exception {
PropertyResolver resolver = getPropertyResolver(null, null);
LogFile logFile = LogFile.get(resolver);
assertThat(logFile).isNull();
}
use of org.springframework.core.env.PropertyResolver in project uPortal by Jasig.
the class BasicAuthInterceptorTest method testInterceptorWithUsernamePassword.
@Test
public void testInterceptorWithUsernamePassword() throws Exception {
final String id = "test";
final String username = "test";
final String password = "test";
PropertyResolver resolver = mock(PropertyResolver.class);
when(resolver.getProperty(eq("org.jasig.rest.interceptor.basic-auth." + id + ".username"))).thenReturn(username);
when(resolver.getProperty(eq("org.jasig.rest.interceptor.basic-auth." + id + ".password"))).thenReturn(password);
doInterceptorTest(resolver, id, "dGVzdDp0ZXN0");
}
Aggregations