diff --git a/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java b/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java index e342d1cb0..2eefd7228 100644 --- a/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java +++ b/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java @@ -20,12 +20,17 @@ package org.apache.struts2.views.freemarker; import com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory; import freemarker.template.Configuration; +import freemarker.template.Template; import freemarker.template.Version; import org.apache.commons.io.FileUtils; import org.apache.struts2.StrutsInternalTestCase; import org.apache.struts2.views.jsp.StrutsMockServletContext; import javax.servlet.ServletContext; +import java.io.StringWriter; +import java.io.Writer; +import java.util.HashMap; +import java.util.Map; /** * Test case for FreemarkerManager @@ -77,6 +82,24 @@ public class FreemarkerManagerTest extends StrutsInternalTestCase { assertEquals(Configuration.VERSION_2_3_0, manager.config.getIncompatibleImprovements()); } + public void testIncompatibleImprovementsWithTemplate() throws Exception { + // given + FreemarkerManager manager = new FreemarkerManager(); + container.inject(manager); + Configuration configuration = manager.getConfiguration(servletContext); + Template tpl = configuration.getTemplate("org/apache/struts2/views/freemarker/incompatible-improvements.ftl"); + + // when + Writer out = new StringWriter(); + Map model = new HashMap<>(); + model.put("error", "It's an error message"); + + tpl.process(model, out); + + // then + assertEquals("", out.toString()); + } + public void testIncompatibleImprovementsByServletContext() throws Exception { // given servletContext.setInitParameter("freemarker.incompatible_improvements", "2.3.0"); diff --git a/core/src/test/resources/org/apache/struts2/views/freemarker/incompatible-improvements.ftl b/core/src/test/resources/org/apache/struts2/views/freemarker/incompatible-improvements.ftl new file mode 100644 index 000000000..99d929d68 --- /dev/null +++ b/core/src/test/resources/org/apache/struts2/views/freemarker/incompatible-improvements.ftl @@ -0,0 +1,23 @@ +<#-- +/* + * $Id: someFreeMarkerFile.ftl 590812 2007-10-31 20:32:54Z apetrelli $ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +--> + \ No newline at end of file