http://git-wip-us.apache.org/repos/asf/freemarker/blob/7a3c4817/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateConfigurationTest.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateConfigurationTest.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateConfigurationTest.java index 4204d3e..fdd699c 100644 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateConfigurationTest.java +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateConfigurationTest.java @@ -116,9 +116,9 @@ public class TemplateConfigurationTest { static { TestConfigurationBuilder cfgB = new TestConfigurationBuilder(); StringTemplateLoader stl = new StringTemplateLoader(); - stl.putTemplate("t1.ftl", "<#global loaded = (loaded!) + 't1;'>In t1;"); - stl.putTemplate("t2.ftl", "<#global loaded = (loaded!) + 't2;'>In t2;"); - stl.putTemplate("t3.ftl", "<#global loaded = (loaded!) + 't3;'>In t3;"); + stl.putTemplate("t1.f3ah", "<#global loaded = (loaded!) + 't1;'>In t1;"); + stl.putTemplate("t2.f3ah", "<#global loaded = (loaded!) + 't2;'>In t2;"); + stl.putTemplate("t3.f3ah", "<#global loaded = (loaded!) + 't3;'>In t3;"); try { DEFAULT_CFG = cfgB.templateLoader(stl).build(); } catch (ConfigurationException e) { @@ -201,8 +201,8 @@ public class TemplateConfigurationTest { SETTING_ASSIGNMENTS.put("tabSize", 1); SETTING_ASSIGNMENTS.put("lazyImports", Boolean.TRUE); SETTING_ASSIGNMENTS.put("lazyAutoImports", Boolean.FALSE); - SETTING_ASSIGNMENTS.put("autoImports", ImmutableMap.of("a", "/lib/a.ftl")); - SETTING_ASSIGNMENTS.put("autoIncludes", ImmutableList.of("/lib/b.ftl")); + SETTING_ASSIGNMENTS.put("autoImports", ImmutableMap.of("a", "/lib/a.f3ah")); + SETTING_ASSIGNMENTS.put("autoIncludes", ImmutableList.of("/lib/b.f3ah")); // Special settings: SETTING_ASSIGNMENTS.put("sourceEncoding", NON_DEFAULT_ENCODING); @@ -332,7 +332,7 @@ public class TemplateConfigurationTest { tcb1.setCustomNumberFormats(ImmutableMap.of( "hex", HexTemplateNumberFormatFactory.INSTANCE, "x", LocaleSensitiveTemplateNumberFormatFactory.INSTANCE)); - tcb1.setAutoImports(ImmutableMap.of("a", "a1.ftl", "b", "b1.ftl")); + tcb1.setAutoImports(ImmutableMap.of("a", "a1.f3ah", "b", "b1.f3ah")); TemplateConfiguration.Builder tcb2 = new TemplateConfiguration.Builder(); tcb2.setCustomDateFormats(ImmutableMap.of( @@ -341,7 +341,7 @@ public class TemplateConfigurationTest { tcb2.setCustomNumberFormats(ImmutableMap.of( "loc", LocaleSensitiveTemplateNumberFormatFactory.INSTANCE, "x", BaseNTemplateNumberFormatFactory.INSTANCE)); - tcb2.setAutoImports(ImmutableMap.of("b", "b2.ftl", "c", "c2.ftl")); + tcb2.setAutoImports(ImmutableMap.of("b", "b2.f3ah", "c", "c2.f3ah")); tcb1.merge(tcb2.build()); @@ -356,9 +356,9 @@ public class TemplateConfigurationTest { assertEquals(BaseNTemplateNumberFormatFactory.INSTANCE, mergedCustomNumberFormats.get("x")); Map<String, String> mergedAutoImports = tcb1.getAutoImports(); - assertEquals("a1.ftl", mergedAutoImports.get("a")); - assertEquals("b2.ftl", mergedAutoImports.get("b")); - assertEquals("c2.ftl", mergedAutoImports.get("c")); + assertEquals("a1.f3ah", mergedAutoImports.get("a")); + assertEquals("b2.f3ah", mergedAutoImports.get("b")); + assertEquals("c2.f3ah", mergedAutoImports.get("c")); // Empty map merging optimization: tcb1.merge(new TemplateConfiguration.Builder().build()); @@ -375,14 +375,14 @@ public class TemplateConfigurationTest { @Test public void testMergeListSettings() throws Exception { TemplateConfiguration.Builder tcb1 = new TemplateConfiguration.Builder(); - tcb1.setAutoIncludes(ImmutableList.of("a.ftl", "x.ftl", "b.ftl")); + tcb1.setAutoIncludes(ImmutableList.of("a.f3ah", "x.f3ah", "b.f3ah")); TemplateConfiguration.Builder tcb2 = new TemplateConfiguration.Builder(); - tcb2.setAutoIncludes(ImmutableList.of("c.ftl", "x.ftl", "d.ftl")); + tcb2.setAutoIncludes(ImmutableList.of("c.f3ah", "x.f3ah", "d.f3ah")); tcb1.merge(tcb2.build()); - assertEquals(ImmutableList.of("a.ftl", "b.ftl", "c.ftl", "x.ftl", "d.ftl"), tcb1.getAutoIncludes()); + assertEquals(ImmutableList.of("a.f3ah", "b.f3ah", "c.f3ah", "x.f3ah", "d.f3ah"), tcb1.getAutoIncludes()); } @Test @@ -628,7 +628,7 @@ public class TemplateConfigurationTest { new ConditionalTemplateConfigurationFactory(new FileExtensionMatcher("txt"), tcb.build())); StringTemplateLoader templateLoader = new StringTemplateLoader(); - templateLoader.putTemplate("adhoc.ftl", "${1+1}"); + templateLoader.putTemplate("adhoc.f3ah", "${1+1}"); templateLoader.putTemplate("adhoc.txt", "${1+1}"); cfgB.setTemplateLoader(templateLoader); @@ -636,7 +636,7 @@ public class TemplateConfigurationTest { { StringWriter out = new StringWriter(); - cfg.getTemplate("adhoc.ftl").process(null, out); + cfg.getTemplate("adhoc.f3ah").process(null, out); assertEquals("2", out.toString()); } { @@ -658,23 +658,23 @@ public class TemplateConfigurationTest { TestConfigurationBuilder cfgB = new TestConfigurationBuilder(); cfgB.setSourceEncoding(StandardCharsets.UTF_8); cfgB.setTemplateConfigurations(new ConditionalTemplateConfigurationFactory( - new FileNameGlobMatcher("latin1.ftl"), tcb.build())); + new FileNameGlobMatcher("latin1.f3ah"), tcb.build())); MonitoredTemplateLoader templateLoader = new MonitoredTemplateLoader(); - templateLoader.putBinaryTemplate("utf8.ftl", "próba", StandardCharsets.UTF_8, 1); - templateLoader.putBinaryTemplate("latin1.ftl", "próba", StandardCharsets.ISO_8859_1, 1); + templateLoader.putBinaryTemplate("utf8.f3ah", "próba", StandardCharsets.UTF_8, 1); + templateLoader.putBinaryTemplate("latin1.f3ah", "próba", StandardCharsets.ISO_8859_1, 1); cfgB.setTemplateLoader(templateLoader); Configuration cfg = cfgB.build(); { StringWriter out = new StringWriter(); - cfg.getTemplate("utf8.ftl").process(null, out); + cfg.getTemplate("utf8.f3ah").process(null, out); assertEquals("próba", out.toString()); } { StringWriter out = new StringWriter(); - cfg.getTemplate("latin1.ftl").process(null, out); + cfg.getTemplate("latin1.f3ah").process(null, out); assertEquals("próba", out.toString()); } @@ -705,17 +705,17 @@ public class TemplateConfigurationTest { @Test public void testAutoImport() throws TemplateException, IOException { TemplateConfiguration.Builder tcb = new TemplateConfiguration.Builder(); - tcb.setAutoImports(ImmutableMap.of("t1", "t1.ftl", "t2", "t2.ftl")); + tcb.setAutoImports(ImmutableMap.of("t1", "t1.f3ah", "t2", "t2.f3ah")); TemplateConfiguration tc = tcb.build(); - assertOutputWithoutAndWithTC(tc, "<#import 't3.ftl' as t3>${loaded}", "t3;", "t1;t2;t3;"); + assertOutputWithoutAndWithTC(tc, "<#import 't3.f3ah' as t3>${loaded}", "t3;", "t1;t2;t3;"); } @Test public void testAutoIncludes() throws TemplateException, IOException { TemplateConfiguration.Builder tcb = new TemplateConfiguration.Builder(); - tcb.setAutoIncludes(ImmutableList.of("t1.ftl", "t2.ftl")); + tcb.setAutoIncludes(ImmutableList.of("t1.f3ah", "t2.f3ah")); TemplateConfiguration tc = tcb.build(); - assertOutputWithoutAndWithTC(tc, "<#include 't3.ftl'>", "In t3;", "In t1;In t2;In t3;"); + assertOutputWithoutAndWithTC(tc, "<#include 't3.f3ah'>", "In t3;", "In t1;In t2;In t3;"); } @Test
http://git-wip-us.apache.org/repos/asf/freemarker/blob/7a3c4817/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateConfigurationWithDefaultTemplateResolverTest.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateConfigurationWithDefaultTemplateResolverTest.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateConfigurationWithDefaultTemplateResolverTest.java index 5e42e3b..48b830e 100644 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateConfigurationWithDefaultTemplateResolverTest.java +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateConfigurationWithDefaultTemplateResolverTest.java @@ -18,7 +18,7 @@ */ package org.apache.freemarker.core; -import static org.apache.freemarker.core.ProcessingConfiguration.MISSING_VALUE_MARKER; +import static org.apache.freemarker.core.ProcessingConfiguration.*; import static org.junit.Assert.*; import java.io.IOException; @@ -52,27 +52,27 @@ public class TemplateConfigurationWithDefaultTemplateResolverTest { Configuration cfg = createCommonEncodingTesterConfig(); { - Template t = cfg.getTemplate("utf8.ftl"); + Template t = cfg.getTemplate("utf8.f3ah"); assertEquals(StandardCharsets.UTF_8, t.getActualSourceEncoding()); assertEquals(TEXT_WITH_ACCENTS, getTemplateOutput(t)); } { - Template t = cfg.getTemplate("utf16.ftl"); + Template t = cfg.getTemplate("utf16.f3ah"); assertEquals(StandardCharsets.UTF_16LE, t.getActualSourceEncoding()); assertEquals(TEXT_WITH_ACCENTS, getTemplateOutput(t)); } { - Template t = cfg.getTemplate("default.ftl"); + Template t = cfg.getTemplate("default.f3ah"); assertEquals(StandardCharsets.ISO_8859_1, t.getActualSourceEncoding()); assertEquals(TEXT_WITH_ACCENTS, getTemplateOutput(t)); } { - Template t = cfg.getTemplate("utf8-latin2.ftl"); + Template t = cfg.getTemplate("utf8-latin2.f3ah"); assertEquals(ISO_8859_2, t.getActualSourceEncoding()); assertEquals(TEXT_WITH_ACCENTS, getTemplateOutput(t)); } { - Template t = cfg.getTemplate("default-latin2.ftl"); + Template t = cfg.getTemplate("default-latin2.f3ah"); assertEquals(ISO_8859_2, t.getActualSourceEncoding()); assertEquals(TEXT_WITH_ACCENTS, getTemplateOutput(t)); } @@ -82,25 +82,25 @@ public class TemplateConfigurationWithDefaultTemplateResolverTest { public void testIncludeAndEncoding() throws Exception { Configuration cfg = createCommonEncodingTesterConfig(); ByteArrayTemplateLoader tl = (ByteArrayTemplateLoader) cfg.getTemplateLoader(); - tl.putTemplate("main.ftl", ( - "<#include 'utf8.ftl'>" - + "<#include 'utf16.ftl'>" - + "<#include 'default.ftl'>" - + "<#include 'utf8-latin2.ftl'>" + tl.putTemplate("main.f3ah", ( + "<#include 'utf8.f3ah'>" + + "<#include 'utf16.f3ah'>" + + "<#include 'default.f3ah'>" + + "<#include 'utf8-latin2.f3ah'>" ).getBytes(StandardCharsets.ISO_8859_1)); assertEquals( TEXT_WITH_ACCENTS + TEXT_WITH_ACCENTS + TEXT_WITH_ACCENTS + TEXT_WITH_ACCENTS, - getTemplateOutput(cfg.getTemplate("main.ftl"))); + getTemplateOutput(cfg.getTemplate("main.f3ah"))); } @Test public void testLocale() throws Exception { StringTemplateLoader loader = new StringTemplateLoader(); - loader.putTemplate("(de).ftl", "${.locale}"); - loader.putTemplate("default.ftl", "${.locale}"); - loader.putTemplate("(de)-fr.ftl", + loader.putTemplate("(de).f3ah", "${.locale}"); + loader.putTemplate("default.f3ah", "${.locale}"); + loader.putTemplate("(de)-fr.f3ah", ("<#ftl locale='fr_FR'>${.locale}")); - loader.putTemplate("default-fr.ftl", + loader.putTemplate("default-fr.f3ah", ("<#ftl locale='fr_FR'>${.locale}")); Configuration cfg = new TestConfigurationBuilder() @@ -114,22 +114,22 @@ public class TemplateConfigurationWithDefaultTemplateResolverTest { .build(); { - Template t = cfg.getTemplate("(de).ftl"); + Template t = cfg.getTemplate("(de).f3ah"); assertEquals(Locale.GERMANY, t.getLocale()); assertEquals("de_DE", getTemplateOutput(t)); } { - Template t = cfg.getTemplate("(de).ftl", Locale.ITALY); + Template t = cfg.getTemplate("(de).f3ah", Locale.ITALY); assertEquals(Locale.GERMANY, t.getLocale()); assertEquals("de_DE", getTemplateOutput(t)); } { - Template t = cfg.getTemplate("default.ftl"); + Template t = cfg.getTemplate("default.f3ah"); assertEquals(Locale.US, t.getLocale()); assertEquals("en_US", getTemplateOutput(t)); } { - Template t = cfg.getTemplate("default.ftl", Locale.ITALY); + Template t = cfg.getTemplate("default.f3ah", Locale.ITALY); assertEquals(Locale.ITALY, t.getLocale()); assertEquals("it_IT", getTemplateOutput(t)); } @@ -237,12 +237,12 @@ public class TemplateConfigurationWithDefaultTemplateResolverTest { private Configuration createCommonEncodingTesterConfig() throws UnsupportedEncodingException { ByteArrayTemplateLoader tl = new ByteArrayTemplateLoader(); - tl.putTemplate("utf8.ftl", TEXT_WITH_ACCENTS.getBytes(StandardCharsets.UTF_8)); - tl.putTemplate("utf16.ftl", TEXT_WITH_ACCENTS.getBytes(StandardCharsets.UTF_16LE)); - tl.putTemplate("default.ftl", TEXT_WITH_ACCENTS.getBytes(ISO_8859_2)); - tl.putTemplate("utf8-latin2.ftl", + tl.putTemplate("utf8.f3ah", TEXT_WITH_ACCENTS.getBytes(StandardCharsets.UTF_8)); + tl.putTemplate("utf16.f3ah", TEXT_WITH_ACCENTS.getBytes(StandardCharsets.UTF_16LE)); + tl.putTemplate("default.f3ah", TEXT_WITH_ACCENTS.getBytes(ISO_8859_2)); + tl.putTemplate("utf8-latin2.f3ah", ("<#ftl encoding='iso-8859-2'>" + TEXT_WITH_ACCENTS).getBytes(ISO_8859_2)); - tl.putTemplate("default-latin2.ftl", + tl.putTemplate("default-latin2.f3ah", ("<#ftl encoding='iso-8859-2'>" + TEXT_WITH_ACCENTS).getBytes(ISO_8859_2)); return new TestConfigurationBuilder() http://git-wip-us.apache.org/repos/asf/freemarker/blob/7a3c4817/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateConstructorsTest.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateConstructorsTest.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateConstructorsTest.java index 97c43ad..ab51cd6 100644 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateConstructorsTest.java +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateConstructorsTest.java @@ -39,8 +39,8 @@ public class TemplateConstructorsTest { public void test() throws IOException { final Configuration cfg = new TestConfigurationBuilder().sourceEncoding(StandardCharsets.ISO_8859_1).build(); - final String name = "foo/bar.ftl"; - final String sourceName = "foo/bar_de.ftl"; + final String name = "foo/bar.f3ah"; + final String sourceName = "foo/bar_de.f3ah"; final Charset sourceEncoding = StandardCharsets.UTF_16LE; { Template t = new Template(name, createReader(), cfg); http://git-wip-us.apache.org/repos/asf/freemarker/blob/7a3c4817/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateNameSpecialVariablesTest.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateNameSpecialVariablesTest.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateNameSpecialVariablesTest.java index 7c9a98f..f800f9f 100644 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateNameSpecialVariablesTest.java +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateNameSpecialVariablesTest.java @@ -32,73 +32,73 @@ public class TemplateNameSpecialVariablesTest extends TemplateTest { @Test public void testMainTemplateName() throws IOException, TemplateException { addTemplateNameTestTemplates(".mainTemplateName"); - assertOutputForNamed("main.ftl", - "In main: main.ftl\n" - + "In imp: main.ftl\n" - + "In main: main.ftl\n" - + "main.ftl\n" - + "{main.ftl}\n" + assertOutputForNamed("main.f3au", + "In main: main.f3au\n" + + "In imp: main.f3au\n" + + "In main: main.f3au\n" + + "main.f3au\n" + + "{main.f3au}\n" + "In imp call imp:\n" - + "main.ftl\n" - + "{main.ftl}\n" - + "After: main.ftl\n" - + "In main: main.ftl\n" - + "In inc: main.ftl\n" + + "main.f3au\n" + + "{main.f3au}\n" + + "After: main.f3au\n" + + "In main: main.f3au\n" + + "In inc: main.f3au\n" + "In inc call imp:\n" - + "main.ftl\n" - + "{main.ftl}\n" - + "In main: main.ftl\n" - + "main.ftl\n" - + "{main.ftl}\n" + + "main.f3au\n" + + "{main.f3au}\n" + + "In main: main.f3au\n" + + "main.f3au\n" + + "{main.f3au}\n" + "In inc call imp:\n" - + "main.ftl\n" - + "{main.ftl}\n" - + "In main: main.ftl\n"); + + "main.f3au\n" + + "{main.f3au}\n" + + "In main: main.f3au\n"); } @Test public void testCurrentTemplateName() throws IOException, TemplateException { addTemplateNameTestTemplates(".currentTemplateName"); - assertOutputForNamed("main.ftl", - "In main: main.ftl\n" - + "In imp: imp.ftl\n" - + "In main: main.ftl\n" - + "imp.ftl\n" - + "{main.ftl}\n" + assertOutputForNamed("main.f3au", + "In main: main.f3au\n" + + "In imp: imp.f3au\n" + + "In main: main.f3au\n" + + "imp.f3au\n" + + "{main.f3au}\n" + "In imp call imp:\n" - + "imp.ftl\n" - + "{imp.ftl}\n" - + "After: imp.ftl\n" - + "In main: main.ftl\n" - + "In inc: inc.ftl\n" + + "imp.f3au\n" + + "{imp.f3au}\n" + + "After: imp.f3au\n" + + "In main: main.f3au\n" + + "In inc: inc.f3au\n" + "In inc call imp:\n" - + "imp.ftl\n" - + "{inc.ftl}\n" - + "In main: main.ftl\n" - + "inc.ftl\n" - + "{main.ftl}\n" + + "imp.f3au\n" + + "{inc.f3au}\n" + + "In main: main.f3au\n" + + "inc.f3au\n" + + "{main.f3au}\n" + "In inc call imp:\n" - + "imp.ftl\n" - + "{inc.ftl}\n" - + "In main: main.ftl\n"); + + "imp.f3au\n" + + "{inc.f3au}\n" + + "In main: main.f3au\n"); } private void addTemplateNameTestTemplates(String specVar) { - addTemplate("main.ftl", + addTemplate("main.f3au", "In main: ${" + specVar + "}\n" - + "<#import 'imp.ftl' as i>" + + "<#import 'imp.f3au' as i>" + "In imp: ${inImp}\n" + "In main: ${" + specVar + "}\n" + "<@i.impM>${" + specVar + "}</@>\n" + "<@i.impM2 />\n" + "In main: ${" + specVar + "}\n" - + "<#include 'inc.ftl'>" + + "<#include 'inc.f3au'>" + "In main: ${" + specVar + "}\n" + "<@incM>${" + specVar + "}</@>\n" + "<@incM2 />\n" + "In main: ${" + specVar + "}\n" ); - addTemplate("imp.ftl", + addTemplate("imp.f3au", "<#global inImp = " + specVar + ">" + "<#macro impM>" + "${" + specVar + "}\n" @@ -110,7 +110,7 @@ public class TemplateNameSpecialVariablesTest extends TemplateTest { + "After: ${" + specVar + "}" + "</#macro>" ); - addTemplate("inc.ftl", + addTemplate("inc.f3au", "In inc: ${" + specVar + "}\n" + "In inc call imp:\n" + "<@i.impM>${" + specVar + "}</@>\n" @@ -127,28 +127,28 @@ public class TemplateNameSpecialVariablesTest extends TemplateTest { @Test public void testInAdhocTemplate() throws TemplateException, IOException { - addTemplate("inc.ftl", "Inc: " + PRINT_ALL_FTL); + addTemplate("inc.f3au", "Inc: " + PRINT_ALL_FTL); // In nameless templates, the deprecated .templateName is "", but the new variables are missing values. - assertOutput(new Template(null, PRINT_ALL_FTL + "; <#include 'inc.ftl'>", getConfiguration()), - "ct=-, mt=-; Inc: ct=inc.ftl, mt=-"); + assertOutput(new Template(null, PRINT_ALL_FTL + "; <#include 'inc.f3au'>", getConfiguration()), + "ct=-, mt=-; Inc: ct=inc.f3au, mt=-"); - assertOutput(new Template("foo.ftl", PRINT_ALL_FTL + "; <#include 'inc.ftl'>", getConfiguration()), - "ct=foo.ftl, mt=foo.ftl; Inc: ct=inc.ftl, mt=foo.ftl"); + assertOutput(new Template("foo.f3au", PRINT_ALL_FTL + "; <#include 'inc.f3au'>", getConfiguration()), + "ct=foo.f3au, mt=foo.f3au; Inc: ct=inc.f3au, mt=foo.f3au"); } @Test public void testInInterpretTemplate() throws TemplateException, IOException { addToDataModel("t", PRINT_ALL_FTL); - assertOutput(new Template("foo.ftl", PRINT_ALL_FTL + "; <@t?interpret />", getConfiguration()), - "ct=foo.ftl, mt=foo.ftl; " - + "ct=foo.ftl->anonymous_interpreted, mt=foo.ftl"); + assertOutput(new Template("foo.f3au", PRINT_ALL_FTL + "; <@t?interpret />", getConfiguration()), + "ct=foo.f3au, mt=foo.f3au; " + + "ct=foo.f3au->anonymous_interpreted, mt=foo.f3au"); assertOutput(new Template(null, PRINT_ALL_FTL + "; <@t?interpret />", getConfiguration()), "ct=-, mt=-; " + "ct=nameless_template->anonymous_interpreted, mt=-"); - assertOutput(new Template("foo.ftl", PRINT_ALL_FTL + "; <@[t,'bar']?interpret />", getConfiguration()), - "ct=foo.ftl, mt=foo.ftl; " - + "ct=foo.ftl->bar, mt=foo.ftl"); + assertOutput(new Template("foo.f3au", PRINT_ALL_FTL + "; <@[t,'bar']?interpret />", getConfiguration()), + "ct=foo.f3au, mt=foo.f3au; " + + "ct=foo.f3au->bar, mt=foo.f3au"); } @Override http://git-wip-us.apache.org/repos/asf/freemarker/blob/7a3c4817/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateNotFoundMessageTest.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateNotFoundMessageTest.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateNotFoundMessageTest.java index f8d142b..c553d45 100644 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateNotFoundMessageTest.java +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/TemplateNotFoundMessageTest.java @@ -193,7 +193,7 @@ public class TemplateNotFoundMessageTest { } private String failWith(TemplateLoader tl) { - return failWith(tl, "missing.ftl", null); + return failWith(tl, "missing.f3ah", null); } @SuppressWarnings("serial") http://git-wip-us.apache.org/repos/asf/freemarker/blob/7a3c4817/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/DefaultTemplateResolverTest.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/DefaultTemplateResolverTest.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/DefaultTemplateResolverTest.java index 844b41b..2c33e6a 100644 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/DefaultTemplateResolverTest.java +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/DefaultTemplateResolverTest.java @@ -152,23 +152,23 @@ public class DefaultTemplateResolverTest { .templateUpdateDelayMilliseconds(Long.MAX_VALUE) .build(); - loader.putTemplate("1.ftl", "1 v1"); - loader.putTemplate("2.ftl", "2 v1"); - assertEquals("1 v1", cfg.getTemplate("1.ftl").toString()); - assertEquals("2 v1", cfg.getTemplate("2.ftl").toString()); + loader.putTemplate("1.f3ah", "1 v1"); + loader.putTemplate("2.f3ah", "2 v1"); + assertEquals("1 v1", cfg.getTemplate("1.f3ah").toString()); + assertEquals("2 v1", cfg.getTemplate("2.f3ah").toString()); - loader.putTemplate("1.ftl", "1 v2"); - loader.putTemplate("2.ftl", "2 v2"); - assertEquals("1 v1", cfg.getTemplate("1.ftl").toString()); // no change - assertEquals("2 v1", cfg.getTemplate("2.ftl").toString()); // no change + loader.putTemplate("1.f3ah", "1 v2"); + loader.putTemplate("2.f3ah", "2 v2"); + assertEquals("1 v1", cfg.getTemplate("1.f3ah").toString()); // no change + assertEquals("2 v1", cfg.getTemplate("2.f3ah").toString()); // no change - cfg.removeTemplateFromCache("1.ftl", cfg.getLocale(), null); - assertEquals("1 v2", cfg.getTemplate("1.ftl").toString()); // changed - assertEquals("2 v1", cfg.getTemplate("2.ftl").toString()); + cfg.removeTemplateFromCache("1.f3ah", cfg.getLocale(), null); + assertEquals("1 v2", cfg.getTemplate("1.f3ah").toString()); // changed + assertEquals("2 v1", cfg.getTemplate("2.f3ah").toString()); - cfg.removeTemplateFromCache("2.ftl", cfg.getLocale(), null); - assertEquals("1 v2", cfg.getTemplate("1.ftl").toString()); - assertEquals("2 v2", cfg.getTemplate("2.ftl").toString()); // changed + cfg.removeTemplateFromCache("2.f3ah", cfg.getLocale(), null); + assertEquals("1 v2", cfg.getTemplate("1.f3ah").toString()); + assertEquals("2 v2", cfg.getTemplate("2.f3ah").toString()); // changed } @Test @@ -180,36 +180,36 @@ public class DefaultTemplateResolverTest { .templateUpdateDelayMilliseconds(Long.MAX_VALUE) .build(); - loader.putTemplate("1_en_US.ftl", "1_en_US v1"); - loader.putTemplate("1_en.ftl", "1_en v1"); - loader.putTemplate("1.ftl", "1 v1"); + loader.putTemplate("1_en_US.f3ah", "1_en_US v1"); + loader.putTemplate("1_en.f3ah", "1_en v1"); + loader.putTemplate("1.f3ah", "1 v1"); - assertEquals("1_en_US v1", cfg.getTemplate("1.ftl").toString()); - assertEquals("1_en v1", cfg.getTemplate("1.ftl", Locale.UK).toString()); - assertEquals("1 v1", cfg.getTemplate("1.ftl", Locale.GERMANY).toString()); + assertEquals("1_en_US v1", cfg.getTemplate("1.f3ah").toString()); + assertEquals("1_en v1", cfg.getTemplate("1.f3ah", Locale.UK).toString()); + assertEquals("1 v1", cfg.getTemplate("1.f3ah", Locale.GERMANY).toString()); - loader.putTemplate("1_en_US.ftl", "1_en_US v2"); - loader.putTemplate("1_en.ftl", "1_en v2"); - loader.putTemplate("1.ftl", "1 v2"); - assertEquals("1_en_US v1", cfg.getTemplate("1.ftl").toString()); - assertEquals("1_en v1", cfg.getTemplate("1.ftl", Locale.UK).toString()); - assertEquals("1 v1", cfg.getTemplate("1.ftl", Locale.GERMANY).toString()); + loader.putTemplate("1_en_US.f3ah", "1_en_US v2"); + loader.putTemplate("1_en.f3ah", "1_en v2"); + loader.putTemplate("1.f3ah", "1 v2"); + assertEquals("1_en_US v1", cfg.getTemplate("1.f3ah").toString()); + assertEquals("1_en v1", cfg.getTemplate("1.f3ah", Locale.UK).toString()); + assertEquals("1 v1", cfg.getTemplate("1.f3ah", Locale.GERMANY).toString()); - cfg.removeTemplateFromCache("1.ftl", cfg.getLocale(), null); - assertEquals("1_en_US v2", cfg.getTemplate("1.ftl").toString()); - assertEquals("1_en v1", cfg.getTemplate("1.ftl", Locale.UK).toString()); - assertEquals("1 v1", cfg.getTemplate("1.ftl", Locale.GERMANY).toString()); - assertEquals("1 v2", cfg.getTemplate("1.ftl", Locale.ITALY).toString()); + cfg.removeTemplateFromCache("1.f3ah", cfg.getLocale(), null); + assertEquals("1_en_US v2", cfg.getTemplate("1.f3ah").toString()); + assertEquals("1_en v1", cfg.getTemplate("1.f3ah", Locale.UK).toString()); + assertEquals("1 v1", cfg.getTemplate("1.f3ah", Locale.GERMANY).toString()); + assertEquals("1 v2", cfg.getTemplate("1.f3ah", Locale.ITALY).toString()); - cfg.removeTemplateFromCache("1.ftl", Locale.GERMANY, null); - assertEquals("1_en v1", cfg.getTemplate("1.ftl", Locale.UK).toString()); - assertEquals("1 v2", cfg.getTemplate("1.ftl", Locale.GERMANY).toString()); + cfg.removeTemplateFromCache("1.f3ah", Locale.GERMANY, null); + assertEquals("1_en v1", cfg.getTemplate("1.f3ah", Locale.UK).toString()); + assertEquals("1 v2", cfg.getTemplate("1.f3ah", Locale.GERMANY).toString()); - cfg.removeTemplateFromCache("1.ftl", Locale.CANADA, null); - assertEquals("1_en v1", cfg.getTemplate("1.ftl", Locale.UK).toString()); + cfg.removeTemplateFromCache("1.f3ah", Locale.CANADA, null); + assertEquals("1_en v1", cfg.getTemplate("1.f3ah", Locale.UK).toString()); - cfg.removeTemplateFromCache("1.ftl", Locale.UK, null); - assertEquals("1_en v2", cfg.getTemplate("1.ftl", Locale.UK).toString()); + cfg.removeTemplateFromCache("1.f3ah", Locale.UK, null); + assertEquals("1_en v2", cfg.getTemplate("1.f3ah", Locale.UK).toString()); } @Test @@ -223,34 +223,34 @@ public class DefaultTemplateResolverTest { .templateUpdateDelayMilliseconds(0L) .build(); for (int i = 1; i <= 3; i++) { - loader.putTextTemplate("t.ftl", "v" + i); - assertEquals("v" + i, cfg.getTemplate("t.ftl").toString()); + loader.putTextTemplate("t.f3ah", "v" + i); + assertEquals("v" + i, cfg.getTemplate("t.f3ah").toString()); } loader.clearEvents(); - loader.putTextTemplate("t.ftl", "v8"); - assertEquals("v8", cfg.getTemplate("t.ftl").toString()); - assertEquals("v8", cfg.getTemplate("t.ftl").toString()); - loader.putTextTemplate("t.ftl", "v9"); - assertEquals("v9", cfg.getTemplate("t.ftl").toString()); - assertEquals("v9", cfg.getTemplate("t.ftl").toString()); + loader.putTextTemplate("t.f3ah", "v8"); + assertEquals("v8", cfg.getTemplate("t.f3ah").toString()); + assertEquals("v8", cfg.getTemplate("t.f3ah").toString()); + loader.putTextTemplate("t.f3ah", "v9"); + assertEquals("v9", cfg.getTemplate("t.f3ah").toString()); + assertEquals("v9", cfg.getTemplate("t.f3ah").toString()); assertEquals( ImmutableList.of( - new LoadEvent("t_en_US.ftl", TemplateLoadingResultStatus.NOT_FOUND), // v8 - new LoadEvent("t_en.ftl", TemplateLoadingResultStatus.NOT_FOUND), - new LoadEvent("t.ftl", TemplateLoadingResultStatus.OPENED), + new LoadEvent("t_en_US.f3ah", TemplateLoadingResultStatus.NOT_FOUND), // v8 + new LoadEvent("t_en.f3ah", TemplateLoadingResultStatus.NOT_FOUND), + new LoadEvent("t.f3ah", TemplateLoadingResultStatus.OPENED), - new LoadEvent("t_en_US.ftl", TemplateLoadingResultStatus.NOT_FOUND), // v8 - new LoadEvent("t_en.ftl", TemplateLoadingResultStatus.NOT_FOUND), - new LoadEvent("t.ftl", TemplateLoadingResultStatus.NOT_MODIFIED), + new LoadEvent("t_en_US.f3ah", TemplateLoadingResultStatus.NOT_FOUND), // v8 + new LoadEvent("t_en.f3ah", TemplateLoadingResultStatus.NOT_FOUND), + new LoadEvent("t.f3ah", TemplateLoadingResultStatus.NOT_MODIFIED), - new LoadEvent("t_en_US.ftl", TemplateLoadingResultStatus.NOT_FOUND), // v9 - new LoadEvent("t_en.ftl", TemplateLoadingResultStatus.NOT_FOUND), - new LoadEvent("t.ftl", TemplateLoadingResultStatus.OPENED), + new LoadEvent("t_en_US.f3ah", TemplateLoadingResultStatus.NOT_FOUND), // v9 + new LoadEvent("t_en.f3ah", TemplateLoadingResultStatus.NOT_FOUND), + new LoadEvent("t.f3ah", TemplateLoadingResultStatus.OPENED), - new LoadEvent("t_en_US.ftl", TemplateLoadingResultStatus.NOT_FOUND), // v9 - new LoadEvent("t_en.ftl", TemplateLoadingResultStatus.NOT_FOUND), - new LoadEvent("t.ftl", TemplateLoadingResultStatus.NOT_MODIFIED) + new LoadEvent("t_en_US.f3ah", TemplateLoadingResultStatus.NOT_FOUND), // v9 + new LoadEvent("t_en.f3ah", TemplateLoadingResultStatus.NOT_FOUND), + new LoadEvent("t.f3ah", TemplateLoadingResultStatus.NOT_MODIFIED) ), loader.getEvents(LoadEvent.class)); } @@ -263,26 +263,26 @@ public class DefaultTemplateResolverTest { .localizedTemplateLookup(false) .build(); loader.clearEvents(); - loader.putTextTemplate("t.ftl", "v10"); - assertEquals("v10", cfg.getTemplate("t.ftl").toString()); - loader.putTextTemplate("t.ftl", "v11"); // same time stamp, different content - assertEquals("v11", cfg.getTemplate("t.ftl").toString()); - assertEquals("v11", cfg.getTemplate("t.ftl").toString()); - assertEquals("v11", cfg.getTemplate("t.ftl").toString()); + loader.putTextTemplate("t.f3ah", "v10"); + assertEquals("v10", cfg.getTemplate("t.f3ah").toString()); + loader.putTextTemplate("t.f3ah", "v11"); // same time stamp, different content + assertEquals("v11", cfg.getTemplate("t.f3ah").toString()); + assertEquals("v11", cfg.getTemplate("t.f3ah").toString()); + assertEquals("v11", cfg.getTemplate("t.f3ah").toString()); Thread.sleep(17L); - assertEquals("v11", cfg.getTemplate("t.ftl").toString()); - loader.putTextTemplate("t.ftl", "v12"); - assertEquals("v12", cfg.getTemplate("t.ftl").toString()); - assertEquals("v12", cfg.getTemplate("t.ftl").toString()); + assertEquals("v11", cfg.getTemplate("t.f3ah").toString()); + loader.putTextTemplate("t.f3ah", "v12"); + assertEquals("v12", cfg.getTemplate("t.f3ah").toString()); + assertEquals("v12", cfg.getTemplate("t.f3ah").toString()); assertEquals( ImmutableList.of( - new LoadEvent("t.ftl", TemplateLoadingResultStatus.OPENED), // v10 - new LoadEvent("t.ftl", TemplateLoadingResultStatus.OPENED), // v11 - new LoadEvent("t.ftl", TemplateLoadingResultStatus.NOT_MODIFIED), - new LoadEvent("t.ftl", TemplateLoadingResultStatus.NOT_MODIFIED), - new LoadEvent("t.ftl", TemplateLoadingResultStatus.NOT_MODIFIED), - new LoadEvent("t.ftl", TemplateLoadingResultStatus.OPENED), // v12 - new LoadEvent("t.ftl", TemplateLoadingResultStatus.NOT_MODIFIED) + new LoadEvent("t.f3ah", TemplateLoadingResultStatus.OPENED), // v10 + new LoadEvent("t.f3ah", TemplateLoadingResultStatus.OPENED), // v11 + new LoadEvent("t.f3ah", TemplateLoadingResultStatus.NOT_MODIFIED), + new LoadEvent("t.f3ah", TemplateLoadingResultStatus.NOT_MODIFIED), + new LoadEvent("t.f3ah", TemplateLoadingResultStatus.NOT_MODIFIED), + new LoadEvent("t.f3ah", TemplateLoadingResultStatus.OPENED), // v12 + new LoadEvent("t.f3ah", TemplateLoadingResultStatus.NOT_MODIFIED) ), loader.getEvents(LoadEvent.class)); } @@ -291,24 +291,24 @@ public class DefaultTemplateResolverTest { @Test public void testWrongEncodingReload() throws Exception { MonitoredTemplateLoader loader = new MonitoredTemplateLoader(); - loader.putBinaryTemplate("utf-8_en.ftl", "<#ftl encoding='utf-8'>Béka"); - loader.putBinaryTemplate("utf-8.ftl", "Bar"); - loader.putBinaryTemplate("iso-8859-1_en_US.ftl", "<#ftl encoding='ISO-8859-1'>Béka", + loader.putBinaryTemplate("utf-8_en.f3ah", "<#ftl encoding='utf-8'>Béka"); + loader.putBinaryTemplate("utf-8.f3ah", "Bar"); + loader.putBinaryTemplate("iso-8859-1_en_US.f3ah", "<#ftl encoding='ISO-8859-1'>Béka", StandardCharsets.ISO_8859_1, "v1"); Configuration cfg = new TestConfigurationBuilder().templateLoader(loader).build(); { - Template t = cfg.getTemplate("utf-8.ftl"); - assertEquals("utf-8.ftl", t.getLookupName()); - assertEquals("utf-8_en.ftl", t.getSourceName()); + Template t = cfg.getTemplate("utf-8.f3ah"); + assertEquals("utf-8.f3ah", t.getLookupName()); + assertEquals("utf-8_en.f3ah", t.getSourceName()); assertEquals(StandardCharsets.UTF_8, t.getActualSourceEncoding()); assertEquals("Béka", t.toString()); assertEquals( ImmutableList.of( CreateSessionEvent.INSTANCE, - new LoadEvent("utf-8_en_US.ftl", TemplateLoadingResultStatus.NOT_FOUND), - new LoadEvent("utf-8_en.ftl", TemplateLoadingResultStatus.OPENED), + new LoadEvent("utf-8_en_US.f3ah", TemplateLoadingResultStatus.NOT_FOUND), + new LoadEvent("utf-8_en.f3ah", TemplateLoadingResultStatus.OPENED), CloseSessionEvent.INSTANCE), loader.getEvents()); } @@ -316,16 +316,16 @@ public class DefaultTemplateResolverTest { { loader.clearEvents(); - Template t = cfg.getTemplate("iso-8859-1.ftl"); - assertEquals("iso-8859-1.ftl", t.getLookupName()); - assertEquals("iso-8859-1_en_US.ftl", t.getSourceName()); + Template t = cfg.getTemplate("iso-8859-1.f3ah"); + assertEquals("iso-8859-1.f3ah", t.getLookupName()); + assertEquals("iso-8859-1_en_US.f3ah", t.getSourceName()); assertEquals(StandardCharsets.ISO_8859_1, t.getActualSourceEncoding()); assertEquals("Béka", t.toString()); assertEquals( ImmutableList.of( CreateSessionEvent.INSTANCE, - new LoadEvent("iso-8859-1_en_US.ftl", TemplateLoadingResultStatus.OPENED), + new LoadEvent("iso-8859-1_en_US.f3ah", TemplateLoadingResultStatus.OPENED), CloseSessionEvent.INSTANCE), loader.getEvents()); } @@ -334,22 +334,22 @@ public class DefaultTemplateResolverTest { @Test public void testNoWrongEncodingForTemplateLoader2WithReader() throws Exception { MonitoredTemplateLoader loader = new MonitoredTemplateLoader(); - loader.putTextTemplate("foo_en.ftl", "<#ftl encoding='utf-8'>Å"); - loader.putTextTemplate("foo.ftl", "B"); + loader.putTextTemplate("foo_en.f3ah", "<#ftl encoding='utf-8'>Å"); + loader.putTextTemplate("foo.f3ah", "B"); Configuration cfg = new TestConfigurationBuilder().templateLoader(loader).build(); { - Template t = cfg.getTemplate("foo.ftl"); - assertEquals("foo.ftl", t.getLookupName()); - assertEquals("foo_en.ftl", t.getSourceName()); + Template t = cfg.getTemplate("foo.f3ah"); + assertEquals("foo.f3ah", t.getLookupName()); + assertEquals("foo_en.f3ah", t.getSourceName()); assertNull(t.getActualSourceEncoding()); assertEquals("Å", t.toString()); assertEquals( ImmutableList.of( CreateSessionEvent.INSTANCE, - new LoadEvent("foo_en_US.ftl", TemplateLoadingResultStatus.NOT_FOUND), - new LoadEvent("foo_en.ftl", TemplateLoadingResultStatus.OPENED), + new LoadEvent("foo_en_US.f3ah", TemplateLoadingResultStatus.NOT_FOUND), + new LoadEvent("foo_en.f3ah", TemplateLoadingResultStatus.OPENED), CloseSessionEvent.INSTANCE), loader.getEvents()); } http://git-wip-us.apache.org/repos/asf/freemarker/blob/7a3c4817/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/FileTemplateLoaderTest.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/FileTemplateLoaderTest.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/FileTemplateLoaderTest.java index 393dbae..9941f22 100644 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/FileTemplateLoaderTest.java +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/FileTemplateLoaderTest.java @@ -50,7 +50,7 @@ public class FileTemplateLoaderTest { if (!sub2Dir.mkdirs()) { throw new IOException("Failed to invoke subdirectories"); } - File tFile = new File(sub2Dir, "t.ftl"); + File tFile = new File(sub2Dir, "t.f3ah"); FileUtils.write(tFile, "foo"); cfg = new TestConfigurationBuilder().templateLoader(new FileTemplateLoader(templateRootDir)).build(); @@ -59,7 +59,7 @@ public class FileTemplateLoaderTest { @Test public void testSuccessful() throws Exception { for (int i = 0; i < 2; i++) { - assertEquals("foo", cfg.getTemplate("sub1/sub2/t.ftl").toString()); + assertEquals("foo", cfg.getTemplate("sub1/sub2/t.f3ah").toString()); } } @@ -68,7 +68,7 @@ public class FileTemplateLoaderTest { ((FileTemplateLoader) cfg.getTemplateLoader()).setEmulateCaseSensitiveFileSystem(true); for (int i = 0; i < 2; i++) { cfg.clearTemplateCache(); - assertEquals("foo", cfg.getTemplate("sub1/sub2/t.ftl").toString()); + assertEquals("foo", cfg.getTemplate("sub1/sub2/t.f3ah").toString()); } } @@ -77,7 +77,7 @@ public class FileTemplateLoaderTest { public void testNotFound() throws Exception { for (int i = 0; i < 2; i++) { try { - cfg.getTemplate("sub1X/sub2/t.ftl"); + cfg.getTemplate("sub1X/sub2/t.f3ah"); fail(); } catch (TemplateNotFoundException e) { assertThat(e.getMessage(), containsString("sub1X")); @@ -89,7 +89,8 @@ public class FileTemplateLoaderTest { @Test public void testCaseSensitivity() throws Exception { for (boolean emuCaseSensFS : new boolean[] { false, true }) { - for (String nameWithBadCase : new String[] { "SUB1/sub2/t.ftl", "sub1/SUB2/t.ftl", "sub1/sub2/T.FTL" }) { + for (String nameWithBadCase : new String[] { + "SUB1/sub2/t.f3ah", "sub1/SUB2/t.f3ah", "sub1/sub2/T.F3AH" }) { ((FileTemplateLoader) cfg.getTemplateLoader()).setEmulateCaseSensitiveFileSystem(emuCaseSensFS); cfg.clearTemplateCache(); http://git-wip-us.apache.org/repos/asf/freemarker/blob/7a3c4817/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/MultiTemplateLoaderTest.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/MultiTemplateLoaderTest.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/MultiTemplateLoaderTest.java index c8531c5..c6f834b 100644 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/MultiTemplateLoaderTest.java +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/MultiTemplateLoaderTest.java @@ -35,18 +35,18 @@ public class MultiTemplateLoaderTest { @Test public void testBasics() throws IOException { StringTemplateLoader stl1 = new StringTemplateLoader(); - stl1.putTemplate("1.ftl", "1"); - stl1.putTemplate("both.ftl", "both 1"); + stl1.putTemplate("1.f3ah", "1"); + stl1.putTemplate("both.f3ah", "both 1"); StringTemplateLoader stl2 = new StringTemplateLoader(); - stl2.putTemplate("2.ftl", "2"); - stl2.putTemplate("both.ftl", "both 2"); + stl2.putTemplate("2.f3ah", "2"); + stl2.putTemplate("both.f3ah", "both 2"); MultiTemplateLoader mtl = new MultiTemplateLoader(stl1, stl2); - assertEquals("1", getTemplateContent(mtl, "1.ftl")); - assertEquals("2", getTemplateContent(mtl, "2.ftl")); - assertEquals("both 1", getTemplateContent(mtl, "both.ftl")); - assertNull(getTemplateContent(mtl, "neither.ftl")); + assertEquals("1", getTemplateContent(mtl, "1.f3ah")); + assertEquals("2", getTemplateContent(mtl, "2.f3ah")); + assertEquals("both 1", getTemplateContent(mtl, "both.f3ah")); + assertNull(getTemplateContent(mtl, "neither.f3ah")); } @Test @@ -61,21 +61,21 @@ public class MultiTemplateLoaderTest { private void testStickiness(boolean sticky) throws IOException { StringTemplateLoader stl1 = new StringTemplateLoader(); - stl1.putTemplate("both.ftl", "both 1"); + stl1.putTemplate("both.f3ah", "both 1"); ByteArrayTemplateLoader stl2 = new ByteArrayTemplateLoader(); - stl2.putTemplate("both.ftl", "both 2".getBytes(StandardCharsets.UTF_8)); + stl2.putTemplate("both.f3ah", "both 2".getBytes(StandardCharsets.UTF_8)); MultiTemplateLoader mtl = new MultiTemplateLoader(stl1, stl2); mtl.setSticky(sticky); - assertEquals("both 1", getTemplateContent(mtl, "both.ftl")); - assertTrue(stl1.removeTemplate("both.ftl")); - assertEquals("both 2", getTemplateContent(mtl, "both.ftl")); - stl1.putTemplate("both.ftl", "both 1"); - assertEquals(sticky ? "both 2" : "both 1", getTemplateContent(mtl, "both.ftl")); - assertTrue(stl2.removeTemplate("both.ftl")); - assertEquals("both 1", getTemplateContent(mtl, "both.ftl")); + assertEquals("both 1", getTemplateContent(mtl, "both.f3ah")); + assertTrue(stl1.removeTemplate("both.f3ah")); + assertEquals("both 2", getTemplateContent(mtl, "both.f3ah")); + stl1.putTemplate("both.f3ah", "both 1"); + assertEquals(sticky ? "both 2" : "both 1", getTemplateContent(mtl, "both.f3ah")); + assertTrue(stl2.removeTemplate("both.f3ah")); + assertEquals("both 1", getTemplateContent(mtl, "both.f3ah")); } private String getTemplateContent(TemplateLoader tl, String name) throws IOException { http://git-wip-us.apache.org/repos/asf/freemarker/blob/7a3c4817/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/TemplateConfigurationFactoryTest.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/TemplateConfigurationFactoryTest.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/TemplateConfigurationFactoryTest.java index 8bf72dd..29d69ae 100644 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/TemplateConfigurationFactoryTest.java +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/TemplateConfigurationFactoryTest.java @@ -36,10 +36,10 @@ public class TemplateConfigurationFactoryTest { public void testCondition1() throws IOException, TemplateConfigurationFactoryException { TemplateConfiguration tc = newTemplateConfiguration(1); - TemplateConfigurationFactory tcf = new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*.ftlx"), tc); + TemplateConfigurationFactory tcf = new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*.tx"), tc); - assertNotApplicable(tcf, "x.ftl"); - assertApplicable(tcf, "x.ftlx", tc); + assertNotApplicable(tcf, "x.t"); + assertApplicable(tcf, "x.tx", tc); } @Test @@ -47,13 +47,13 @@ public class TemplateConfigurationFactoryTest { TemplateConfiguration tc = newTemplateConfiguration(1); TemplateConfigurationFactory tcf = new ConditionalTemplateConfigurationFactory( - new FileNameGlobMatcher("*.ftlx"), + new FileNameGlobMatcher("*.tx"), new ConditionalTemplateConfigurationFactory( new FileNameGlobMatcher("x.*"), tc)); - assertNotApplicable(tcf, "x.ftl"); - assertNotApplicable(tcf, "y.ftlx"); - assertApplicable(tcf, "x.ftlx", tc); + assertNotApplicable(tcf, "x.t"); + assertNotApplicable(tcf, "y.tx"); + assertApplicable(tcf, "x.tx", tc); } @Test @@ -63,20 +63,20 @@ public class TemplateConfigurationFactoryTest { TemplateConfiguration tc3 = newTemplateConfiguration(3); TemplateConfigurationFactory tcf = new MergingTemplateConfigurationFactory( - new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*.ftlx"), tc1), + new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*.tx"), tc1), new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*a*.*"), tc2), new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*b*.*"), tc3)); - assertNotApplicable(tcf, "x.ftl"); - assertApplicable(tcf, "x.ftlx", tc1); - assertApplicable(tcf, "a.ftl", tc2); - assertApplicable(tcf, "b.ftl", tc3); - assertApplicable(tcf, "a.ftlx", tc1, tc2); - assertApplicable(tcf, "b.ftlx", tc1, tc3); - assertApplicable(tcf, "ab.ftl", tc2, tc3); - assertApplicable(tcf, "ab.ftlx", tc1, tc2, tc3); + assertNotApplicable(tcf, "x.t"); + assertApplicable(tcf, "x.tx", tc1); + assertApplicable(tcf, "a.t", tc2); + assertApplicable(tcf, "b.t", tc3); + assertApplicable(tcf, "a.tx", tc1, tc2); + assertApplicable(tcf, "b.tx", tc1, tc3); + assertApplicable(tcf, "ab.t", tc2, tc3); + assertApplicable(tcf, "ab.tx", tc1, tc2, tc3); - assertNotApplicable(new MergingTemplateConfigurationFactory(), "x.ftl"); + assertNotApplicable(new MergingTemplateConfigurationFactory(), "x.t"); } @Test @@ -86,34 +86,34 @@ public class TemplateConfigurationFactoryTest { TemplateConfiguration tc3 = newTemplateConfiguration(3); FirstMatchTemplateConfigurationFactory tcf = new FirstMatchTemplateConfigurationFactory( - new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*.ftlx"), tc1), + new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*.tx"), tc1), new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*a*.*"), tc2), new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*b*.*"), tc3)); try { - assertNotApplicable(tcf, "x.ftl"); + assertNotApplicable(tcf, "x.t"); } catch (TemplateConfigurationFactoryException e) { - assertThat(e.getMessage(), containsString("x.ftl")); + assertThat(e.getMessage(), containsString("x.t")); } tcf.setNoMatchErrorDetails("Test details"); try { - assertNotApplicable(tcf, "x.ftl"); + assertNotApplicable(tcf, "x.t"); } catch (TemplateConfigurationFactoryException e) { assertThat(e.getMessage(), containsString("Test details")); } tcf.setAllowNoMatch(true); - assertNotApplicable(tcf, "x.ftl"); - assertApplicable(tcf, "x.ftlx", tc1); - assertApplicable(tcf, "a.ftl", tc2); - assertApplicable(tcf, "b.ftl", tc3); - assertApplicable(tcf, "a.ftlx", tc1); - assertApplicable(tcf, "b.ftlx", tc1); - assertApplicable(tcf, "ab.ftl", tc2); - assertApplicable(tcf, "ab.ftlx", tc1); + assertNotApplicable(tcf, "x.t"); + assertApplicable(tcf, "x.tx", tc1); + assertApplicable(tcf, "a.t", tc2); + assertApplicable(tcf, "b.T", tc3); + assertApplicable(tcf, "a.tx", tc1); + assertApplicable(tcf, "b.tx", tc1); + assertApplicable(tcf, "ab.t", tc2); + assertApplicable(tcf, "ab.tx", tc1); - assertNotApplicable(new FirstMatchTemplateConfigurationFactory().allowNoMatch(true), "x.ftl"); + assertNotApplicable(new FirstMatchTemplateConfigurationFactory().allowNoMatch(true), "x.t"); } @Test @@ -141,12 +141,12 @@ public class TemplateConfigurationFactoryTest { .allowNoMatch(true), new ConditionalTemplateConfigurationFactory(new FileNameGlobMatcher("*.nws.*"), tcNWS)); - assertNotApplicable(tcf, "x.ftl"); - assertApplicable(tcf, "b/x.ftl", tcBCommon); - assertApplicable(tcf, "b/x.s.ftl", tcBCommon, tcBSpec); - assertApplicable(tcf, "b/x.s.ftlh", tcBCommon, tcBSpec, tcHtml); - assertApplicable(tcf, "b/x.s.nws.ftlx", tcBCommon, tcBSpec, tcXml, tcNWS); - assertApplicable(tcf, "a/x.s.nws.ftlx", tcA, tcXml, tcNWS); + assertNotApplicable(tcf, "x.t"); + assertApplicable(tcf, "b/x.t", tcBCommon); + assertApplicable(tcf, "b/x.s.t", tcBCommon, tcBSpec); + assertApplicable(tcf, "b/x.s.th", tcBCommon, tcBSpec, tcHtml); + assertApplicable(tcf, "b/x.s.nws.tx", tcBCommon, tcBSpec, tcXml, tcNWS); + assertApplicable(tcf, "a/x.s.nws.tx", tcA, tcXml, tcNWS); assertApplicable(tcf, "a.hh", tcHH); assertApplicable(tcf, "a.nws.hh", tcHH, tcNWS); } http://git-wip-us.apache.org/repos/asf/freemarker/blob/7a3c4817/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/TemplateNameFormatTest.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/TemplateNameFormatTest.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/TemplateNameFormatTest.java index edbe98d..e94522a 100644 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/TemplateNameFormatTest.java +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/TemplateNameFormatTest.java @@ -219,7 +219,7 @@ public class TemplateNameFormatTest { .templateNameFormat(DefaultTemplateNameFormat.INSTANCE) .build(); try { - cfg.getTemplate("././foo\\bar.ftl", Locale.US); + cfg.getTemplate("././foo\\bar.f3ah", Locale.US); fail(); } catch (MalformedTemplateNameException e) { assertThat(e.getMessage(), containsStringIgnoringCase("backslash")); http://git-wip-us.apache.org/repos/asf/freemarker/blob/7a3c4817/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/TemplateSourceMatcherTest.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/TemplateSourceMatcherTest.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/TemplateSourceMatcherTest.java index 51273c0..838fd11 100644 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/TemplateSourceMatcherTest.java +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/TemplateSourceMatcherTest.java @@ -28,20 +28,20 @@ public class TemplateSourceMatcherTest { @Test public void testPathGlobMatcher() throws IOException { - PathGlobMatcher m = new PathGlobMatcher("**/a/?.ftl"); - assertTrue(m.matches("a/b.ftl", "dummy")); - assertTrue(m.matches("x/a/c.ftl", "dummy")); - assertFalse(m.matches("a/b.Ftl", "dummy")); - assertFalse(m.matches("b.ftl", "dummy")); - assertFalse(m.matches("a/bc.ftl", "dummy")); + PathGlobMatcher m = new PathGlobMatcher("**/a/?.f3ah"); + assertTrue(m.matches("a/b.f3ah", "dummy")); + assertTrue(m.matches("x/a/c.f3ah", "dummy")); + assertFalse(m.matches("a/b.F3ah", "dummy")); + assertFalse(m.matches("b.f3ah", "dummy")); + assertFalse(m.matches("a/bc.f3ah", "dummy")); - m = new PathGlobMatcher("**/a/?.ftl").caseInsensitive(true); - assertTrue(m.matches("A/B.FTL", "dummy")); + m = new PathGlobMatcher("**/a/?.f3ah").caseInsensitive(true); + assertTrue(m.matches("A/B.F3AH", "dummy")); m.setCaseInsensitive(false); - assertFalse(m.matches("A/B.FTL", "dummy")); + assertFalse(m.matches("A/B.F3AH", "dummy")); try { - new PathGlobMatcher("/b.ftl"); + new PathGlobMatcher("/b.f3ah"); fail(); } catch (IllegalArgumentException e) { // Expected @@ -50,24 +50,24 @@ public class TemplateSourceMatcherTest { @Test public void testFileNameGlobMatcher() throws IOException { - FileNameGlobMatcher m = new FileNameGlobMatcher("a*.ftl"); - assertTrue(m.matches("ab.ftl", "dummy")); - assertTrue(m.matches("dir/ab.ftl", "dummy")); - assertTrue(m.matches("/dir/dir/ab.ftl", "dummy")); - assertFalse(m.matches("Ab.ftl", "dummy")); - assertFalse(m.matches("bb.ftl", "dummy")); - assertFalse(m.matches("ab.ftl/x", "dummy")); + FileNameGlobMatcher m = new FileNameGlobMatcher("a*.f3ah"); + assertTrue(m.matches("ab.f3ah", "dummy")); + assertTrue(m.matches("dir/ab.f3ah", "dummy")); + assertTrue(m.matches("/dir/dir/ab.f3ah", "dummy")); + assertFalse(m.matches("Ab.f3ah", "dummy")); + assertFalse(m.matches("bb.f3ah", "dummy")); + assertFalse(m.matches("ab.f3ah/x", "dummy")); - m = new FileNameGlobMatcher("a*.ftl").caseInsensitive(true); - assertTrue(m.matches("AB.FTL", "dummy")); + m = new FileNameGlobMatcher("a*.f3ah").caseInsensitive(true); + assertTrue(m.matches("AB.F3AH", "dummy")); m.setCaseInsensitive(false); - assertFalse(m.matches("AB.FTL", "dummy")); + assertFalse(m.matches("AB.F3AH", "dummy")); - m = new FileNameGlobMatcher("\u00E1*.ftl").caseInsensitive(true); - assertTrue(m.matches("\u00C1b.ftl", "dummy")); + m = new FileNameGlobMatcher("\u00E1*.f3ah").caseInsensitive(true); + assertTrue(m.matches("\u00C1b.f3ah", "dummy")); try { - new FileNameGlobMatcher("dir/a*.ftl"); + new FileNameGlobMatcher("dir/a*.f3ah"); fail(); } catch (IllegalArgumentException e) { // Expected @@ -76,21 +76,21 @@ public class TemplateSourceMatcherTest { @Test public void testFileExtensionMatcher() throws IOException { - FileExtensionMatcher m = new FileExtensionMatcher("ftlx"); - assertTrue(m.matches("a.ftlx", "dummy")); - assertTrue(m.matches(".ftlx", "dummy")); - assertTrue(m.matches("b/a.b.ftlx", "dummy")); - assertTrue(m.matches("b/a.ftlx", "dummy")); - assertTrue(m.matches("c.b/a.ftlx", "dummy")); - assertFalse(m.matches("a.ftl", "dummy")); - assertFalse(m.matches("ftlx", "dummy")); - assertFalse(m.matches("b.ftlx/a.ftl", "dummy")); + FileExtensionMatcher m = new FileExtensionMatcher("f3ax"); + assertTrue(m.matches("a.f3ax", "dummy")); + assertTrue(m.matches(".f3ax", "dummy")); + assertTrue(m.matches("b/a.b.f3ax", "dummy")); + assertTrue(m.matches("b/a.f3ax", "dummy")); + assertTrue(m.matches("c.b/a.f3ax", "dummy")); + assertFalse(m.matches("a.f3ah", "dummy")); + assertFalse(m.matches("f3ax", "dummy")); + assertFalse(m.matches("b.f3ax/a.f3ah", "dummy")); assertTrue(m.isCaseInsensitive()); - assertTrue(m.matches("a.fTlX", "dummy")); + assertTrue(m.matches("a.f3aX", "dummy")); m.setCaseInsensitive(false); - assertFalse(m.matches("a.fTlX", "dummy")); - assertTrue(m.matches("A.ftlx", "dummy")); + assertFalse(m.matches("a.f3aX", "dummy")); + assertTrue(m.matches("A.f3ax", "dummy")); m = new FileExtensionMatcher(""); assertTrue(m.matches("a.", "dummy")); @@ -106,25 +106,25 @@ public class TemplateSourceMatcherTest { assertFalse(m.matches("a.t", "dummy")); try { - new FileExtensionMatcher("*.ftlx"); + new FileExtensionMatcher("*.f3ax"); fail(); } catch (IllegalArgumentException e) { // Expected } try { - new FileExtensionMatcher("ftl?"); + new FileExtensionMatcher("f3a?"); fail(); } catch (IllegalArgumentException e) { // Expected } try { - new FileExtensionMatcher(".ftlx"); + new FileExtensionMatcher(".f3ax"); fail(); } catch (IllegalArgumentException e) { // Expected } try { - new FileExtensionMatcher("dir/a.ftl"); + new FileExtensionMatcher("dir/a.f3ah"); fail(); } catch (IllegalArgumentException e) { // Expected @@ -133,14 +133,14 @@ public class TemplateSourceMatcherTest { @Test public void testPathRegexMatcher() throws IOException { - PathRegexMatcher m = new PathRegexMatcher("a/[a-z]+\\.ftl"); - assertTrue(m.matches("a/b.ftl", "dummy")); - assertTrue(m.matches("a/abc.ftl", "dummy")); - assertFalse(m.matches("b.ftl", "dummy")); - assertFalse(m.matches("b/b.ftl", "dummy")); + PathRegexMatcher m = new PathRegexMatcher("a/[a-z]+\\.f3ah"); + assertTrue(m.matches("a/b.f3ah", "dummy")); + assertTrue(m.matches("a/abc.f3ah", "dummy")); + assertFalse(m.matches("b.f3ah", "dummy")); + assertFalse(m.matches("b/b.f3ah", "dummy")); try { - new PathRegexMatcher("/b.ftl"); + new PathRegexMatcher("/b.f3ah"); fail(); } catch (IllegalArgumentException e) { // Expected @@ -152,7 +152,7 @@ public class TemplateSourceMatcherTest { AndMatcher m = new AndMatcher(new PathGlobMatcher("a*.*"), new PathGlobMatcher("*.t")); assertTrue(m.matches("ab.t", "dummy")); assertFalse(m.matches("bc.t", "dummy")); - assertFalse(m.matches("ab.ftl", "dummy")); + assertFalse(m.matches("ab.x", "dummy")); try { new AndMatcher(); @@ -167,8 +167,8 @@ public class TemplateSourceMatcherTest { OrMatcher m = new OrMatcher(new PathGlobMatcher("a*.*"), new PathGlobMatcher("*.t")); assertTrue(m.matches("ab.t", "dummy")); assertTrue(m.matches("bc.t", "dummy")); - assertTrue(m.matches("ab.ftl", "dummy")); - assertFalse(m.matches("bc.ftl", "dummy")); + assertTrue(m.matches("ab.x", "dummy")); + assertFalse(m.matches("bc.x", "dummy")); try { new OrMatcher(); http://git-wip-us.apache.org/repos/asf/freemarker/blob/7a3c4817/freemarker-core-test/src/test/java/org/apache/freemarker/core/util/StringUtilsTest.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/util/StringUtilsTest.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/util/StringUtilsTest.java index a4d57a8..f2a4ae6 100644 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/util/StringUtilsTest.java +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/util/StringUtilsTest.java @@ -21,6 +21,11 @@ package org.apache.freemarker.core.util; import static junit.framework.TestCase.assertNull; import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.io.IOException; import java.io.StringWriter; @@ -168,33 +173,33 @@ public class StringUtilsTest { @Test public void testGlobToRegularExpression() { - assertGlobMatches("a/b/c.ftl", "a/b/c.ftl"); - assertGlobDoesNotMatch("/a/b/cxftl", "/a/b/c.ftl", "a/b/C.ftl"); + assertGlobMatches("a/b/c.f3ah", "a/b/c.f3ah"); + assertGlobDoesNotMatch("/a/b/cxftl", "/a/b/c.f3ah", "a/b/C.f3ah"); - assertGlobMatches("a/b/*.ftl", "a/b/.ftl", "a/b/x.ftl", "a/b/xx.ftl"); - assertGlobDoesNotMatch("a/b/*.ftl", "a/c/x.ftl", "a/b/c/x.ftl", "/a/b/x.ftl", "a/b/xxftl"); + assertGlobMatches("a/b/*.f3ah", "a/b/.f3ah", "a/b/x.f3ah", "a/b/xx.f3ah"); + assertGlobDoesNotMatch("a/b/*.f3ah", "a/c/x.f3ah", "a/b/c/x.f3ah", "/a/b/x.f3ah", "a/b/xxftl"); - assertGlobMatches("a/b/?.ftl", "a/b/x.ftl"); - assertGlobDoesNotMatch("a/b/?.ftl", "a/c/x.ftl", "a/b/.ftl", "a/b/xx.ftl", "a/b/xxftl"); + assertGlobMatches("a/b/?.f3ah", "a/b/x.f3ah"); + assertGlobDoesNotMatch("a/b/?.f3ah", "a/c/x.f3ah", "a/b/.f3ah", "a/b/xx.f3ah", "a/b/xxftl"); - assertGlobMatches("a/**/c.ftl", "a/b/c.ftl", "a/c.ftl", "a/b/b2/b3/c.ftl", "a//c.ftl"); - assertGlobDoesNotMatch("a/**/c.ftl", "x/b/c.ftl", "a/b/x.ftl"); + assertGlobMatches("a/**/c.f3ah", "a/b/c.f3ah", "a/c.f3ah", "a/b/b2/b3/c.f3ah", "a//c.f3ah"); + assertGlobDoesNotMatch("a/**/c.f3ah", "x/b/c.f3ah", "a/b/x.f3ah"); - assertGlobMatches("**/c.ftl", "a/b/c.ftl", "c.ftl", "/c.ftl", "///c.ftl"); - assertGlobDoesNotMatch("**/c.ftl", "a/b/x.ftl"); + assertGlobMatches("**/c.f3ah", "a/b/c.f3ah", "c.f3ah", "/c.f3ah", "///c.f3ah"); + assertGlobDoesNotMatch("**/c.f3ah", "a/b/x.f3ah"); - assertGlobMatches("a/b/**", "a/b/c.ftl", "a/b/c2/c.ftl", "a/b/", "a/b/c/"); - assertGlobDoesNotMatch("a/b.ftl"); + assertGlobMatches("a/b/**", "a/b/c.f3ah", "a/b/c2/c.f3ah", "a/b/", "a/b/c/"); + assertGlobDoesNotMatch("a/b.f3ah"); - assertGlobMatches("**", "a/b/c.ftl", ""); + assertGlobMatches("**", "a/b/c.f3ah", ""); assertGlobMatches("\\[\\{\\*\\?\\}\\]\\\\", "[{*?}]\\"); assertGlobDoesNotMatch("\\[\\{\\*\\?\\}\\]\\\\", "[{xx}]\\"); - assertGlobMatches("a/b/\\?.ftl", "a/b/?.ftl"); - assertGlobDoesNotMatch("a/b/\\?.ftl", "a/b/x.ftl"); + assertGlobMatches("a/b/\\?.f3ah", "a/b/?.f3ah"); + assertGlobDoesNotMatch("a/b/\\?.f3ah", "a/b/x.f3ah"); - assertGlobMatches("\\?\\?.ftl", "??.ftl"); + assertGlobMatches("\\?\\?.f3ah", "??.f3ah"); assertGlobMatches("\\\\\\\\", "\\\\"); assertGlobMatches("\\\\\\\\?", "\\\\x"); assertGlobMatches("x\\", "x"); @@ -202,8 +207,8 @@ public class StringUtilsTest { assertGlobMatches("???*", "123", "1234", "12345"); assertGlobDoesNotMatch("???*", "12", "1", ""); - assertGlobMatches("**/a??/b*.ftl", "a11/b1.ftl", "x/a11/b123.ftl", "x/y/a11/b.ftl"); - assertGlobDoesNotMatch("**/a??/b*.ftl", "a1/b1.ftl", "x/a11/c123.ftl"); + assertGlobMatches("**/a??/b*.f3ah", "a11/b1.f3ah", "x/a11/b123.f3ah", "x/y/a11/b.f3ah"); + assertGlobDoesNotMatch("**/a??/b*.f3ah", "a1/b1.f3ah", "x/a11/c123.f3ah"); assertFalse(_StringUtils.globToRegularExpression("ab*").matcher("aBc").matches()); assertTrue(_StringUtils.globToRegularExpression("ab*", true).matcher("aBc").matches()); http://git-wip-us.apache.org/repos/asf/freemarker/blob/7a3c4817/freemarker-core-test/src/test/java/org/apache/freemarker/core/valueformat/NumberFormatTest.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/valueformat/NumberFormatTest.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/valueformat/NumberFormatTest.java index 3868493..2cea282 100644 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/valueformat/NumberFormatTest.java +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/valueformat/NumberFormatTest.java @@ -260,11 +260,11 @@ public class NumberFormatTest extends TemplateTest { String commonFtl = "${1?string.@f} ${1?string.@d} " + "<#setting locale='fr_FR'>${1.5?string.@d} " + "<#attempt>${10?string.@i}<#recover>E</#attempt>"; - addTemplate("t1.ftl", commonFtl); - addTemplate("t2.ftl", commonFtl); + addTemplate("t1.f3ah", commonFtl); + addTemplate("t2.f3ah", commonFtl); - assertOutputForNamed("t1.ftl", "1f 1.0 1,5 E"); - assertOutputForNamed("t2.ftl", "1f 1d 1,5d a"); + assertOutputForNamed("t1.f3ah", "1f 1.0 1,5 E"); + assertOutputForNamed("t2.f3ah", "1f 1d 1,5d a"); } @Test http://git-wip-us.apache.org/repos/asf/freemarker/blob/7a3c4817/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java b/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java index 3005979..60c372a 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java @@ -115,7 +115,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; * ... * * // Later, whenever the application needs a template (so you may do this a lot, and from multiple threads): - * {@link Template Template} myTemplate = cfg.{@link #getTemplate(String) getTemplate}("myTemplate.ftlh"); + * {@link Template Template} myTemplate = cfg.{@link #getTemplate(String) getTemplate}("myTemplate.f3ah"); * myTemplate.{@link Template#process(Object, java.io.Writer) process}(dataModel, out);</pre> * * <p>Note that you certainly want to set the {@link #getTemplateLoader templateLoader} setting, as its default @@ -1269,11 +1269,11 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc * First, the name is expected to be a hierarchical path, with path components separated by a slash * character (not with backslash!). The path (the name) given here is always interpreted relative to * the "template root directory" and must <em>not</em> begin with slash. Then, the {@code ..} and - * {@code .} path meta-elements will be resolved. For example, if the name is {@code a/../b/./c.ftl}, - * then it will be simplified to {@code b/c.ftl}. The rules regarding this are the same as with + * {@code .} path meta-elements will be resolved. For example, if the name is {@code a/../b/./c.f3ah}, + * then it will be simplified to {@code b/c.f3ah}. The rules regarding this are the same as with * conventional UN*X paths. The path must not reach outside the template root directory, that is, it - * can't be something like {@code "../templates/my.ftl"} (not even if this path happens to be - * equivalent with {@code "/my.ftl"}). Furthermore, the path is allowed to contain at most one path + * can't be something like {@code "../templates/my.f3ah"} (not even if this path happens to be + * equivalent with {@code "/my.f3ah"}). Furthermore, the path is allowed to contain at most one path * element whose name is {@code *} (asterisk). This path meta-element triggers the <i>acquisition * mechanism</i>. If the template is not found in the location described by the concatenation of the * path left to the asterisk (called base path) and the part to the right of the asterisk (called @@ -1288,12 +1288,12 @@ public final class Configuration implements TopLevelConfiguration, CustomStateSc * parameter can be {@code null} since 2.3.22, in which case it defaults to * {@link Configuration#getLocale()} (note that {@link Template#getLocale()} will give the default value, * not {@code null}). This parameter also drives localized template lookup. Assuming that you have - * specified {@code en_US} as the locale and {@code myTemplate.ftl} as the name of the template, and the + * specified {@code en_US} as the locale and {@code myTemplate.f3ah} as the name of the template, and the * default {@link TemplateLookupStrategy} is used and * {@code #setLocalizedTemplateLookup(boolean) localizedTemplateLookup} is {@code true}, FreeMarker will first try to - * retrieve {@code myTemplate_en_US.html}, then {@code myTemplate.en.ftl}, and finally - * {@code myTemplate.ftl}. Note that that the template's locale will be {@code en_US} even if it only - * finds {@code myTemplate.ftl}. Note that when the {@code locale} setting is overridden with a + * retrieve {@code myTemplate_en_US.html}, then {@code myTemplate.en.f3ah}, and finally + * {@code myTemplate.f3ah}. Note that that the template's locale will be {@code en_US} even if it only + * finds {@code myTemplate.f3ah}. Note that when the {@code locale} setting is overridden with a * {@link TemplateConfiguration} provided by {@link #getTemplateConfigurations()}, that overrides the * value specified here, but only after the localized template lookup, that is, it modifies the template * found by the localized template lookup. http://git-wip-us.apache.org/repos/asf/freemarker/blob/7a3c4817/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java b/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java index 3e55501..38a4f17 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java @@ -2667,9 +2667,9 @@ public final class Environment extends MutableProcessingConfiguration<Environmen * Converts a root based name (a name that's either relative to the root, or is absolute), which are typically used * by the API (such as for {@link Configuration#getTemplate(String)}), to an absolute name, which can be safely * passed to {@code <#include path>} and such, as it won't be misinterpreted to be relative to the directory of the - * template. For example, {@code "foo/bar.ftl"} is converted to {@code "/foo/bar.ftl"}, while {@code "/foo/bar"} or - * {@code "foo://bar/baz"} remains as is, as they are already absolute names (see {@link DefaultTemplateNameFormat} - * for more about the format of names). + * template. For example, {@code "foo/bar.f3ah"} is converted to {@code "/foo/bar.f3ah"}, while {@code "/foo/bar"} + * or {@code "foo://bar/baz"} remains as is, as they are already absolute names (see + * {@link DefaultTemplateNameFormat} for more about the format of names). * * <p> * You only need this if the template name will be passed to {@code <#include name>}, {@code <#import name>}, http://git-wip-us.apache.org/repos/asf/freemarker/blob/7a3c4817/freemarker-core/src/main/java/org/apache/freemarker/core/MutableProcessingConfiguration.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/MutableProcessingConfiguration.java b/freemarker-core/src/main/java/org/apache/freemarker/core/MutableProcessingConfiguration.java index 3d315fc..74c8692 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/MutableProcessingConfiguration.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/MutableProcessingConfiguration.java @@ -1363,12 +1363,12 @@ public abstract class MutableProcessingConfiguration<SelfT extends MutableProces * <li><p>{@code "autoImports"}: * See {@link Configuration#getAutoImports()} * <br>String value is something like: - * <br>{@code /lib/form.ftl as f, /lib/widget as w, "/lib/odd name.ftl" as odd} + * <br>{@code /lib/form.f3ah as f, /lib/widget as w, "/lib/odd name.f3ah" as odd} * * <li><p>{@code "autoInclude"}: Sets the list of auto-includes. * See {@link Configuration#getAutoIncludes()} * <br>String value is something like: - * <br>{@code /include/common.ftl, "/include/evil name.ftl"} + * <br>{@code /include/common.f3ah, "/include/evil name.f3ah"} * * <li><p>{@code "lazyAutoImports"}: * See {@link Configuration#getLazyAutoImports()}. @@ -1403,14 +1403,14 @@ public abstract class MutableProcessingConfiguration<SelfT extends MutableProces * <tr> * <td> * {@code allowedClasses: com.example.C1, com.example.C2, - * trustedTemplates: lib/*, safe.ftl} + * trustedTemplates: lib/*, safe.f3ah} * <td> * Only allow instantiating the {@code com.example.C1} and * {@code com.example.C2} classes. But, allow templates * within the {@code lib/} directory (like - * {@code lib/foo/bar.ftl}) and template {@code safe.ftl} - * (that does not match {@code foo/safe.ftl}, only - * exactly {@code safe.ftl}) to instantiate anything + * {@code lib/foo/bar.f3ah}) and template {@code safe.f3ah} + * (that does not match {@code foo/safe.f3ah}, only + * exactly {@code safe.f3ah}) to instantiate anything * that {@link TemplateClassResolver#UNRESTRICTED} allows. * <tr> * <td> @@ -1420,11 +1420,11 @@ public abstract class MutableProcessingConfiguration<SelfT extends MutableProces * trusted templates. * <tr> * <td> - {@code trustedTemplates: lib/*, safe.ftl} + {@code trustedTemplates: lib/*, safe.f3ah} * <td> * Do not allow instantiating any classes, except in * templates inside {@code lib/} or in template - * {@code safe.ftl}. + * {@code safe.f3ah}. * </table> * * <p>For more details see {@link OptInTemplateClassResolver}. http://git-wip-us.apache.org/repos/asf/freemarker/blob/7a3c4817/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java b/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java index 283f901..0907541 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java @@ -174,18 +174,18 @@ public class Template implements ProcessingConfiguration, CustomStateScope { * @param lookupName * The name (path) with which the template was get (usually via * {@link Configuration#getTemplate(String)}), after basic normalization. (Basic normalization means - * things that doesn't require accessing the backing storage, such as {@code "/a/../b/foo.ftl"} - * becomes to {@code "b/foo.ftl"}). + * things that doesn't require accessing the backing storage, such as {@code "/a/../b/foo.f3ah"} + * becomes to {@code "b/foo.f3ah"}). * This is usually the path of the template file relatively to the (virtual) directory that you use to * store the templates (except if the {@link #getSourceName()} sourceName} differs from it). * Shouldn't start with {@code '/'}. Should use {@code '/'}, not {@code '\'}. Check * {@link #getLookupName()} to see how the name will be used. The name should be independent of the actual * storage mechanism and physical location as far as possible. Even when the templates are stored * straightforwardly in real files (they often aren't; see {@link TemplateLoader}), the name shouldn't be - * an absolute file path. Like if the template is stored in {@code "/www/templates/forum/main.ftl"}, and + * an absolute file path. Like if the template is stored in {@code "/www/templates/forum/main.f3ah"}, and * you are using {@code "/www/templates/"} as the template root directory via * {@link FileTemplateLoader#FileTemplateLoader(java.io.File)}, then the template name will be - * {@code "forum/main.ftl"}. The name can be {@code null} (should be used for template made on-the-fly + * {@code "forum/main.f3ah"}. The name can be {@code null} (should be used for template made on-the-fly * instead of being loaded from somewhere), in which case relative paths in it will be relative to * the template root directory (and here again, it's the {@link TemplateLoader} that knows what that * "physically" means). @@ -678,8 +678,8 @@ public class Template implements ProcessingConfiguration, CustomStateScope { * * <p> * Relative paths to other templates in this template will be resolved relatively to the directory part of this. - * Like if the template name is {@code "foo/this.ftl"}, then {@code <#include "other.ftl">} gets the template with - * name {@code "foo/other.ftl"}. + * Like if the template name is {@code "foo/this.f3ah"}, then {@code <#include "other.f3ah">} gets the template with + * name {@code "foo/other.f3ah"}. * </p> * * <p> @@ -689,9 +689,9 @@ public class Template implements ProcessingConfiguration, CustomStateScope { * </p> * * <p> - * Some frameworks use URL-like template names like {@code "someSchema://foo/bar.ftl"}. FreeMarker understands this - * notation, so an absolute path like {@code "/baaz.ftl"} in that template will be resolved too - * {@code "someSchema://baaz.ftl"}. + * Some frameworks use URL-like template names like {@code "someSchema://foo/bar.f3ah"}. FreeMarker understands this + * notation, so an absolute path like {@code "/baaz.f3ah"} in that template will be resolved too + * {@code "someSchema://baaz.f3ah"}. */ public String getLookupName() { return lookupName; @@ -703,10 +703,10 @@ public class Template implements ProcessingConfiguration, CustomStateScope { * messages as the error location. This is usually the same as {@link #getLookupName()}, except when localized * template lookup, template acquisition ({@code *} step in the name), or other {@link TemplateLookupStrategy} * transforms the requested name ({@link #getLookupName()}) to a different final {@link TemplateLoader}-level - * name. For example, when you get a template with name {@code "foo .ftl"} then because of localized template - * lookup, it's possible that something like {@code "foo_en.ftl"} will be loaded behind the scenes. While the - * template name will be still the same as the requested template name ({@code "foo .ftl"}), errors should point - * to {@code "foo_de.ftl"}. Note that relative paths are always resolved relatively to the {@code name}, not to + * name. For example, when you get a template with name {@code "foo .f3ah"} then because of localized template + * lookup, it's possible that something like {@code "foo_en.f3ah"} will be loaded behind the scenes. While the + * template name will be still the same as the requested template name ({@code "foo .f3ah"}), errors should point + * to {@code "foo_de.f3ah"}. Note that relative paths are always resolved relatively to the {@code name}, not to * the {@code sourceName}. */ public String getSourceName() {