Java 类org.springframework.web.servlet.view.groovy.GroovyMarkupConfig 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:GroovyTemplateAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(GroovyMarkupConfig.class)
@ConfigurationProperties(prefix = "spring.groovy.template.configuration")
public GroovyMarkupConfigurer groovyMarkupConfigurer() {
    GroovyMarkupConfigurer configurer = new GroovyMarkupConfigurer();
    configurer.setResourceLoaderPath(this.properties.getResourceLoaderPath());
    configurer.setCacheTemplates(this.properties.isCache());
    if (this.templateEngine != null) {
        configurer.setTemplateEngine(this.templateEngine);
    }
    return configurer;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:GroovyTemplateAutoConfigurationTests.java   
@Test
public void renderTemplate() throws Exception {
    registerAndRefreshContext();
    GroovyMarkupConfig config = this.context.getBean(GroovyMarkupConfig.class);
    MarkupTemplateEngine engine = config.getTemplateEngine();
    Writer writer = new StringWriter();
    engine.createTemplate(new ClassPathResource("templates/message.tpl").getFile())
            .make(new HashMap<String, Object>(
                    Collections.singletonMap("greeting", "Hello World")))
            .writeTo(writer);
    assertThat(writer.toString()).contains("Hello World");
}
项目:spring-boot-concourse    文件:GroovyTemplateAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(GroovyMarkupConfig.class)
@ConfigurationProperties(prefix = "spring.groovy.template.configuration")
public GroovyMarkupConfigurer groovyMarkupConfigurer() {
    GroovyMarkupConfigurer configurer = new GroovyMarkupConfigurer();
    configurer.setResourceLoaderPath(this.properties.getResourceLoaderPath());
    configurer.setCacheTemplates(this.properties.isCache());
    if (this.templateEngine != null) {
        configurer.setTemplateEngine(this.templateEngine);
    }
    return configurer;
}
项目:spring-boot-concourse    文件:GroovyTemplateAutoConfigurationTests.java   
@Test
public void renderTemplate() throws Exception {
    registerAndRefreshContext();
    GroovyMarkupConfig config = this.context.getBean(GroovyMarkupConfig.class);
    MarkupTemplateEngine engine = config.getTemplateEngine();
    Writer writer = new StringWriter();
    engine.createTemplate(new ClassPathResource("templates/message.tpl").getFile())
            .make(new HashMap<String, Object>(
                    Collections.singletonMap("greeting", "Hello World")))
            .writeTo(writer);
    assertThat(writer.toString()).contains("Hello World");
}
项目:contestparser    文件:GroovyTemplateAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(GroovyMarkupConfig.class)
@ConfigurationProperties(prefix = "spring.groovy.template.configuration")
public GroovyMarkupConfigurer groovyMarkupConfigurer() {
    GroovyMarkupConfigurer configurer = new GroovyMarkupConfigurer();
    configurer.setResourceLoaderPath(this.properties.getResourceLoaderPath());
    configurer.setCacheTemplates(this.properties.isCache());
    if (this.templateEngine != null) {
        configurer.setTemplateEngine(this.templateEngine);
    }
    return configurer;
}
项目:contestparser    文件:GroovyTemplateAutoConfigurationTests.java   
@Test
public void renderTemplate() throws Exception {
    registerAndRefreshContext();
    GroovyMarkupConfig config = this.context.getBean(GroovyMarkupConfig.class);
    MarkupTemplateEngine engine = config.getTemplateEngine();
    Writer writer = new StringWriter();
    engine.createTemplate(new ClassPathResource("templates/message.tpl").getFile())
            .make(new HashMap<String, Object>(
                    Collections.singletonMap("greeting", "Hello World")))
            .writeTo(writer);
    assertThat(writer.toString(), containsString("Hello World"));
}