use of freemarker.template.Configuration in project freemarker by apache.
the class EncodingOverrideTest method createConfig.
private Configuration createConfig(String charset) {
Configuration cfg = new Configuration(Configuration.VERSION_2_3_21);
cfg.setClassForTemplateLoading(EncodingOverrideTest.class, "");
cfg.setDefaultEncoding(charset);
return cfg;
}
use of freemarker.template.Configuration in project freemarker by apache.
the class EnvironmentCustomStateTest method test.
@Test
public void test() throws Exception {
Configuration cfg = new Configuration(Configuration.VERSION_2_3_24);
Template t = new Template(null, "", cfg);
Environment env = t.createProcessingEnvironment(null, null);
assertNull(env.getCustomState(KEY_1));
assertNull(env.getCustomState(KEY_2));
env.setCustomState(KEY_1, "a");
env.setCustomState(KEY_2, "b");
assertEquals("a", env.getCustomState(KEY_1));
assertEquals("b", env.getCustomState(KEY_2));
env.setCustomState(KEY_1, "c");
env.setCustomState(KEY_2, null);
assertEquals("c", env.getCustomState(KEY_1));
assertNull(env.getCustomState(KEY_2));
}
use of freemarker.template.Configuration in project freemarker by apache.
the class GetOptionalTemplateTest method createConfiguration.
@Override
protected Configuration createConfiguration() throws Exception {
Configuration cfg = super.createConfiguration();
cfg.setTemplateLoader(new MultiTemplateLoader(new TemplateLoader[] { new StringTemplateLoader(), byteArrayTemplateLoader }));
return cfg;
}
use of freemarker.template.Configuration in project freemarker by apache.
the class CanonicalFormTest method assertCanonicalFormOf.
private void assertCanonicalFormOf(String ftlFileName) throws TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException {
Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
cfg.setTemplateLoader(new CopyrightCommentRemoverTemplateLoader(new ClassTemplateLoader(CanonicalFormTest.class, "")));
StringWriter sw = new StringWriter();
cfg.getTemplate(ftlFileName).dump(sw);
assertExpectedFileEqualsString(ftlFileName + ".out", sw.toString());
}
use of freemarker.template.Configuration in project freemarker by apache.
the class CapturingAssignmentTest method createConfiguration.
@Override
protected Configuration createConfiguration() throws Exception {
Configuration cfg = super.createConfiguration();
cfg.setTemplateLoader(new StringTemplateLoader());
return cfg;
}
Aggregations