Java Code Examples for org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean#setFreemarkerSettings()
The following examples show how to use
org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean#setFreemarkerSettings() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FreeMarkerConfigurerTests.java From spring-analysis-note with MIT License | 5 votes |
@Test(expected = IOException.class) public void freeMarkerConfigurationFactoryBeanWithConfigLocation() throws Exception { FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); fcfb.setConfigLocation(new FileSystemResource("myprops.properties")); Properties props = new Properties(); props.setProperty("myprop", "/mydir"); fcfb.setFreemarkerSettings(props); fcfb.afterPropertiesSet(); }
Example 2
Source File: FreeMarkerConfigurerTests.java From spring-analysis-note with MIT License | 5 votes |
@Test @SuppressWarnings("rawtypes") public void freeMarkerConfigurationFactoryBeanWithNonFileResourceLoaderPath() throws Exception { FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); fcfb.setTemplateLoaderPath("file:/mydir"); Properties settings = new Properties(); settings.setProperty("localized_lookup", "false"); fcfb.setFreemarkerSettings(settings); fcfb.setResourceLoader(new ResourceLoader() { @Override public Resource getResource(String location) { if (!("file:/mydir".equals(location) || "file:/mydir/test".equals(location))) { throw new IllegalArgumentException(location); } return new ByteArrayResource("test".getBytes(), "test"); } @Override public ClassLoader getClassLoader() { return getClass().getClassLoader(); } }); fcfb.afterPropertiesSet(); assertThat(fcfb.getObject(), instanceOf(Configuration.class)); Configuration fc = fcfb.getObject(); Template ft = fc.getTemplate("test"); assertEquals("test", FreeMarkerTemplateUtils.processTemplateIntoString(ft, new HashMap())); }
Example 3
Source File: FreeMarkerConfigurerTests.java From java-technology-stack with MIT License | 5 votes |
@Test(expected = IOException.class) public void freeMarkerConfigurationFactoryBeanWithConfigLocation() throws Exception { FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); fcfb.setConfigLocation(new FileSystemResource("myprops.properties")); Properties props = new Properties(); props.setProperty("myprop", "/mydir"); fcfb.setFreemarkerSettings(props); fcfb.afterPropertiesSet(); }
Example 4
Source File: FreeMarkerConfigurerTests.java From java-technology-stack with MIT License | 5 votes |
@Test @SuppressWarnings("rawtypes") public void freeMarkerConfigurationFactoryBeanWithNonFileResourceLoaderPath() throws Exception { FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); fcfb.setTemplateLoaderPath("file:/mydir"); Properties settings = new Properties(); settings.setProperty("localized_lookup", "false"); fcfb.setFreemarkerSettings(settings); fcfb.setResourceLoader(new ResourceLoader() { @Override public Resource getResource(String location) { if (!("file:/mydir".equals(location) || "file:/mydir/test".equals(location))) { throw new IllegalArgumentException(location); } return new ByteArrayResource("test".getBytes(), "test"); } @Override public ClassLoader getClassLoader() { return getClass().getClassLoader(); } }); fcfb.afterPropertiesSet(); assertThat(fcfb.getObject(), instanceOf(Configuration.class)); Configuration fc = fcfb.getObject(); Template ft = fc.getTemplate("test"); assertEquals("test", FreeMarkerTemplateUtils.processTemplateIntoString(ft, new HashMap())); }
Example 5
Source File: EmailConfiguration.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Bean public FreeMarkerConfigurationFactoryBean freeMarkerConfig() { Properties props = new Properties(); props.setProperty("number_format","0.##"); props.setProperty("locale","en-US"); FreeMarkerConfigurationFactoryBean factory = new FreeMarkerConfigurationFactoryBean(); factory.setFreemarkerSettings(props); factory.setTemplateLoaderPath("classpath:/email-templates/"); return factory; }
Example 6
Source File: FreeMarkerConfigurerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test(expected = IOException.class) public void freeMarkerConfigurationFactoryBeanWithConfigLocation() throws Exception { FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); fcfb.setConfigLocation(new FileSystemResource("myprops.properties")); Properties props = new Properties(); props.setProperty("myprop", "/mydir"); fcfb.setFreemarkerSettings(props); fcfb.afterPropertiesSet(); }
Example 7
Source File: FreeMarkerConfigurerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings("rawtypes") public void freeMarkerConfigurationFactoryBeanWithNonFileResourceLoaderPath() throws Exception { FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); fcfb.setTemplateLoaderPath("file:/mydir"); Properties settings = new Properties(); settings.setProperty("localized_lookup", "false"); fcfb.setFreemarkerSettings(settings); fcfb.setResourceLoader(new ResourceLoader() { @Override public Resource getResource(String location) { if (!("file:/mydir".equals(location) || "file:/mydir/test".equals(location))) { throw new IllegalArgumentException(location); } return new ByteArrayResource("test".getBytes(), "test"); } @Override public ClassLoader getClassLoader() { return getClass().getClassLoader(); } }); fcfb.afterPropertiesSet(); assertThat(fcfb.getObject(), instanceOf(Configuration.class)); Configuration fc = fcfb.getObject(); Template ft = fc.getTemplate("test"); assertEquals("test", FreeMarkerTemplateUtils.processTemplateIntoString(ft, new HashMap())); }