Examples of FreeMarkerConfigurationFactoryBean


Examples of org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean

    fc.afterPropertiesSet();
    assertTrue(fc.getConfiguration().getTemplateLoader() instanceof MultiTemplateLoader);
  }

  public void testFreemarkerConfigurationFactoryBeanWithConfigLocation() throws TemplateException {
    FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean();
    fcfb.setConfigLocation(new FileSystemResource("myprops.properties"));
    Properties props = new Properties();
    props.setProperty("myprop", "/mydir");
    fcfb.setFreemarkerSettings(props);
    try {
      fcfb.afterPropertiesSet();
      fail("Should have thrown IOException");
    }
    catch (IOException ex) {
      // expected
    }
View Full Code Here

Examples of org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean

      // expected
    }
  }

  public void testFreeMarkerConfigurationFactoryBeanWithResourceLoaderPath() throws Exception {
    FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean();
    fcfb.setTemplateLoaderPath("file:/mydir");
    fcfb.afterPropertiesSet();
    Configuration cfg = (Configuration) fcfb.getObject();
    assertTrue(cfg.getTemplateLoader() instanceof SpringTemplateLoader);
  }
View Full Code Here

Examples of org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean

    assertTrue(cfg.getTemplateLoader() instanceof SpringTemplateLoader);
  }

  public void testFreemarkerConfigurationFactoryBeanWithNonFileResourceLoaderPath()
      throws IOException, TemplateException {
    FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean();
    fcfb.setTemplateLoaderPath("file:/mydir");
    Properties settings = new Properties();
    settings.setProperty("localized_lookup", "false");
    fcfb.setFreemarkerSettings(settings);
    fcfb.setResourceLoader(new ResourceLoader() {
      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");
      }
      public ClassLoader getClassLoader() {
        return getClass().getClassLoader();
      }
    });
    fcfb.afterPropertiesSet();
    assertTrue(fcfb.getObject() instanceof Configuration);
    Configuration fc = (Configuration) fcfb.getObject();
    Template ft = fc.getTemplate("test");
    assertEquals("test", FreeMarkerTemplateUtils.processTemplateIntoString(ft, new HashMap()));
  }
View Full Code Here

Examples of org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean

    @Before
    public void setUp() throws Exception {
        underTest = new CloudFormationTemplateBuilder();
        MockitoAnnotations.initMocks(this);
        FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean();
        factoryBean.setPreferFileSystemAccess(false);
        factoryBean.setTemplateLoaderPath("classpath:/");
        factoryBean.afterPropertiesSet();
        Configuration freemarkerConfiguration = factoryBean.getObject();
        underTest.setFreemarkerConfiguration(freemarkerConfiguration);
    }
View Full Code Here

Examples of org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean

        return props;
    }

    @Bean
    public freemarker.template.Configuration freemarkerConfiguration() throws IOException, TemplateException {
        FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean();
        factoryBean.setPreferFileSystemAccess(false);
        factoryBean.setTemplateLoaderPath("classpath:/");
        factoryBean.afterPropertiesSet();
        return factoryBean.getObject();
    }
View Full Code Here

Examples of org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean

*/
public class FreeMarkerConfigurerTests {

  @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();
  }
View Full Code Here

Examples of org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean

    fcfb.afterPropertiesSet();
  }

  @Test
  public void freeMarkerConfigurationFactoryBeanWithResourceLoaderPath() throws Exception {
    FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean();
    fcfb.setTemplateLoaderPath("file:/mydir");
    fcfb.afterPropertiesSet();
    Configuration cfg = fcfb.getObject();
    assertTrue(cfg.getTemplateLoader() instanceof SpringTemplateLoader);
  }
View Full Code Here

Examples of org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean

  }

  @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()));
  }
View Full Code Here

Examples of org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean

    return javaMailSend;
  }

  @Bean
  public FreeMarkerConfigurationFactoryBean freemarkerMailConfiguration() {
    FreeMarkerConfigurationFactoryBean configuration = new FreeMarkerConfigurationFactoryBean();
    configuration.setTemplateLoaderPath("classpath:notification");
    return configuration;
  }
View Full Code Here

Examples of org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean

  public static class FreeMarkerNonWebConfiguration extends FreeMarkerConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public FreeMarkerConfigurationFactoryBean freeMarkerConfiguration() {
      FreeMarkerConfigurationFactoryBean freeMarkerFactoryBean = new FreeMarkerConfigurationFactoryBean();
      applyProperties(freeMarkerFactoryBean);
      return freeMarkerFactoryBean;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.