use of org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean in project cloudbreak by hortonworks.
the class TestConfig method configurationProvider.
@Bean
public freemarker.template.Configuration configurationProvider() throws IOException, TemplateException {
FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean();
factoryBean.setPreferFileSystemAccess(false);
factoryBean.setTemplateLoaderPath("classpath:/");
factoryBean.afterPropertiesSet();
return factoryBean.getObject();
}
use of org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean in project cloudbreak by hortonworks.
the class UserDataBuilderTest method setup.
@BeforeEach
void setup() throws IOException, TemplateException {
FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean();
factoryBean.setPreferFileSystemAccess(false);
factoryBean.setTemplateLoaderPath("classpath:/");
factoryBean.afterPropertiesSet();
Configuration configuration = factoryBean.getObject();
underTest.setFreemarkerConfiguration(configuration);
UserDataBuilderParams params = new UserDataBuilderParams();
params.setCustomData("date >> /tmp/time.txt");
ReflectionTestUtils.setField(underTest, "userDataBuilderParams", params);
environment = new DetailedEnvironmentResponse();
environment.setCrn("environmentCrn");
}
use of org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean in project spring-boot by spring-projects.
the class FreeMarkerNonWebConfiguration method freeMarkerConfiguration.
@Bean
@ConditionalOnMissingBean
FreeMarkerConfigurationFactoryBean freeMarkerConfiguration() {
FreeMarkerConfigurationFactoryBean freeMarkerFactoryBean = new FreeMarkerConfigurationFactoryBean();
applyProperties(freeMarkerFactoryBean);
return freeMarkerFactoryBean;
}
use of org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean in project springframework-source-5.1.x by wb02125055.
the class FreeMarkerConfigurerTests method freeMarkerConfigurationFactoryBeanWithResourceLoaderPath.
@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);
}
use of org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean in project springframework-source-5.1.x by wb02125055.
the class FreeMarkerConfigurerTests method freeMarkerConfigurationFactoryBeanWithNonFileResourceLoaderPath.
@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()));
}
Aggregations