use of freemarker.test.MonitoredTemplateLoader.GetLastModifiedEvent in project freemarker by apache.
the class TemplateCacheTest method testWrongEncodingReload.
@Test
public void testWrongEncodingReload() throws IOException {
Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
cfg.setLocale(Locale.US);
MonitoredTemplateLoader tl = new MonitoredTemplateLoader();
tl.putTemplate("utf-8_en.ftl", "<#ftl encoding='utf-8'>Foo");
tl.putTemplate("utf-8.ftl", "Bar");
cfg.setTemplateLoader(tl);
{
Template t = cfg.getTemplate("utf-8.ftl", "Utf-8");
assertEquals("utf-8.ftl", t.getName());
assertEquals("utf-8_en.ftl", t.getSourceName());
assertEquals("Utf-8", t.getEncoding());
assertEquals("Foo", t.toString());
assertEquals(ImmutableList.of(new FindTemplateSourceEvent("utf-8_en_US.ftl", false), new FindTemplateSourceEvent("utf-8_en.ftl", true), new GetLastModifiedEvent("utf-8_en.ftl"), // Attempt 1
new GetReaderEvent("utf-8_en.ftl"), new CloseTemplateSourceEvent("utf-8_en.ftl")), tl.getEvents());
}
{
tl.clearEvents();
Template t = cfg.getTemplate("utf-8.ftl", "Utf-16");
assertEquals("utf-8.ftl", t.getName());
assertEquals("utf-8_en.ftl", t.getSourceName());
assertEquals("utf-8", t.getEncoding());
assertEquals("Foo", t.toString());
assertEquals(ImmutableList.of(new FindTemplateSourceEvent("utf-8_en_US.ftl", false), new FindTemplateSourceEvent("utf-8_en.ftl", true), new GetLastModifiedEvent("utf-8_en.ftl"), // Attempt 1
new GetReaderEvent("utf-8_en.ftl"), // Attempt 2
new GetReaderEvent("utf-8_en.ftl"), new CloseTemplateSourceEvent("utf-8_en.ftl")), tl.getEvents());
}
}
Aggregations