Search in sources :

Example 1 with PropertyResolver

use of org.springframework.core.env.PropertyResolver in project spring-boot by spring-projects.

the class LogFileTests method loggingPath.

@Test
public void loggingPath() throws Exception {
    PropertyResolver resolver = getPropertyResolver(null, "logpath");
    LogFile logFile = LogFile.get(resolver);
    Properties properties = new Properties();
    logFile.applyTo(properties);
    assertThat(logFile.toString()).isEqualTo("logpath/spring.log");
    assertThat(properties.getProperty("LOG_FILE")).isEqualTo("logpath/spring.log");
    assertThat(properties.getProperty("LOG_PATH")).isEqualTo("logpath");
}
Also used : PropertyResolver(org.springframework.core.env.PropertyResolver) PropertySourcesPropertyResolver(org.springframework.core.env.PropertySourcesPropertyResolver) Properties(java.util.Properties) Test(org.junit.Test)

Example 2 with PropertyResolver

use of org.springframework.core.env.PropertyResolver in project spring-boot by spring-projects.

the class LogFileTests method loggingFileAndPath.

@Test
public void loggingFileAndPath() throws Exception {
    PropertyResolver resolver = getPropertyResolver("log.file", "logpath");
    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")).isEqualTo("logpath");
}
Also used : PropertyResolver(org.springframework.core.env.PropertyResolver) PropertySourcesPropertyResolver(org.springframework.core.env.PropertySourcesPropertyResolver) Properties(java.util.Properties) Test(org.junit.Test)

Example 3 with PropertyResolver

use of org.springframework.core.env.PropertyResolver in project spring-boot by spring-projects.

the class ThymeleafTemplateAvailabilityProvider method isTemplateAvailable.

@Override
public boolean isTemplateAvailable(String view, Environment environment, ClassLoader classLoader, ResourceLoader resourceLoader) {
    if (ClassUtils.isPresent("org.thymeleaf.spring5.SpringTemplateEngine", classLoader)) {
        PropertyResolver resolver = new RelaxedPropertyResolver(environment, "spring.thymeleaf.");
        String prefix = resolver.getProperty("prefix", ThymeleafProperties.DEFAULT_PREFIX);
        String suffix = resolver.getProperty("suffix", ThymeleafProperties.DEFAULT_SUFFIX);
        return resourceLoader.getResource(prefix + view + suffix).exists();
    }
    return false;
}
Also used : RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver) RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver) PropertyResolver(org.springframework.core.env.PropertyResolver)

Example 4 with PropertyResolver

use of org.springframework.core.env.PropertyResolver in project spring-boot by spring-projects.

the class MustacheTemplateAvailabilityProvider method isTemplateAvailable.

@Override
public boolean isTemplateAvailable(String view, Environment environment, ClassLoader classLoader, ResourceLoader resourceLoader) {
    if (ClassUtils.isPresent("com.samskivert.mustache.Template", classLoader)) {
        PropertyResolver resolver = new RelaxedPropertyResolver(environment, "spring.mustache.");
        String prefix = resolver.getProperty("prefix", MustacheProperties.DEFAULT_PREFIX);
        String suffix = resolver.getProperty("suffix", MustacheProperties.DEFAULT_SUFFIX);
        return resourceLoader.getResource(prefix + view + suffix).exists();
    }
    return false;
}
Also used : RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver) RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver) PropertyResolver(org.springframework.core.env.PropertyResolver)

Example 5 with PropertyResolver

use of org.springframework.core.env.PropertyResolver in project spring-boot by spring-projects.

the class JspTemplateAvailabilityProvider method getResourceName.

private String getResourceName(String view, Environment environment) {
    PropertyResolver resolver = new RelaxedPropertyResolver(environment, "spring.mvc.view.");
    String prefix = resolver.getProperty("prefix", WebMvcAutoConfiguration.DEFAULT_PREFIX);
    String suffix = resolver.getProperty("suffix", WebMvcAutoConfiguration.DEFAULT_SUFFIX);
    return prefix + view + suffix;
}
Also used : RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver) RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver) PropertyResolver(org.springframework.core.env.PropertyResolver)

Aggregations

PropertyResolver (org.springframework.core.env.PropertyResolver)15 Test (org.junit.Test)7 PropertySourcesPropertyResolver (org.springframework.core.env.PropertySourcesPropertyResolver)7 RelaxedPropertyResolver (org.springframework.boot.bind.RelaxedPropertyResolver)5 Properties (java.util.Properties)3 BufferedImage (java.awt.image.BufferedImage)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 URI (java.net.URI)1 Charset (java.nio.charset.Charset)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 CompositePropertySource (org.springframework.core.env.CompositePropertySource)1 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)1 EnumerablePropertySource (org.springframework.core.env.EnumerablePropertySource)1 PropertySource (org.springframework.core.env.PropertySource)1 HttpHeaders (org.springframework.http.HttpHeaders)1 HttpMethod (org.springframework.http.HttpMethod)1 ClientHttpRequest (org.springframework.http.client.ClientHttpRequest)1 ClientHttpRequestFactory (org.springframework.http.client.ClientHttpRequestFactory)1