You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by dd...@apache.org on 2017/05/15 21:23:23 UTC
[07/51] [abbrv] [partial] incubator-freemarker git commit:
Restructured project so that freemarker-test-utils depends on freemarker-core
(and hence can provide common classes for testing templates,
and can use utility classes defined in the core). As a c
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/TemplateTestSuite.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/TemplateTestSuite.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/TemplateTestSuite.java
deleted file mode 100644
index 0edae99..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/TemplateTestSuite.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.freemarker.core.Configuration;
-import org.apache.freemarker.core.Version;
-import org.apache.freemarker.core.util._StringUtil;
-import org.apache.freemarker.dom.NodeModel;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-import junit.framework.TestSuite;
-
-/**
- * Test suite where the test cases are defined in testcases.xml, and usually process
- * templates and compare their output with the expected output.
- *
- * If you only want to run certain tests, you can specify a regular expression for
- * the test name in the {@link #TEST_FILTER_PROPERTY_NAME} system property.
- */
-public class TemplateTestSuite extends TestSuite {
-
- private static final String ELEM_TEST_CASE = "testCase";
-
- private static final String ELEM_SETTING = "setting";
-
- private static final String ATTR_NO_OUTPUT = "noOutput";
-
- private static final String ATTR_EXPECTED = "expected";
-
- private static final String ATTR_TEMPLATE = "template";
-
- private static final String END_TEMPLATE_NAME_MARK = "[#endTN]";
-
- public static final String CONFIGURATION_XML_FILE_NAME = "testcases.xml";
-
- /**
- * When setting this system property, only the tests whose name matches the
- * given regular expression will be executed.
- */
- public static final String TEST_FILTER_PROPERTY_NAME = "freemareker.templateTestSuite.testFilter";
-
- /**
- * Comma separated list of "incompatible improvements" versions to run the test cases with.
- */
- public static final String INCOMPATIBLE_IMPROVEMENTS_PROPERTY_NAME
- = "freemareker.templateTestSuite.incompatibleImprovements";
-
- private final Map<String, String> testSuiteSettings = new LinkedHashMap<>();
-
- private final ArrayList<Version> testSuiteIcis;
-
- private final Pattern testCaseNameFilter;
-
- public static TestSuite suite() throws Exception {
- return new TemplateTestSuite();
- }
-
- public TemplateTestSuite() throws Exception {
- NodeModel.useJaxenXPathSupport();
-
- String filterStr = System.getProperty(TEST_FILTER_PROPERTY_NAME);
- testCaseNameFilter = filterStr != null ? Pattern.compile(filterStr) : null;
- if (testCaseNameFilter != null) {
- System.out.println("Note: " + TEST_FILTER_PROPERTY_NAME + " is " + _StringUtil.jQuote(testCaseNameFilter));
- }
-
- testSuiteIcis = new ArrayList<>();
- String testedIcIsStr = System.getProperty(INCOMPATIBLE_IMPROVEMENTS_PROPERTY_NAME);
- if (testedIcIsStr != null) {
- for (String iciStr : testedIcIsStr.split(",")) {
- iciStr = iciStr.trim();
- if (iciStr.length() != 0) {
- testSuiteIcis.add(new Version(iciStr));
- }
- }
- }
- if (testSuiteIcis.isEmpty()) {
- testSuiteIcis.add(getMinIcIVersion());
- testSuiteIcis.add(getMaxIcIVersion());
- }
-
- java.net.URL url = TemplateTestSuite.class.getResource(CONFIGURATION_XML_FILE_NAME);
- if (url == null) {
- throw new IOException("Resource not found: "
- + TemplateTestSuite.class.getName() + ", " + CONFIGURATION_XML_FILE_NAME);
- }
- processConfigXML(url.toURI());
- }
-
- /**
- * Read the test case configurations file and build up the test suite.
- */
- public void processConfigXML(URI uri) throws Exception {
- Element testCasesElem = loadXMLFromURL(uri);
-
- NodeList children = testCasesElem.getChildNodes();
- for (int childIdx = 0; childIdx < children.getLength(); childIdx++) {
- Node n = children.item(childIdx);
- if (n.getNodeType() == Node.ELEMENT_NODE) {
- final String nodeName = n.getNodeName();
- if (nodeName.equals(ELEM_SETTING)) {
- NamedNodeMap attrs = n.getAttributes();
- for (int attrIdx = 0; attrIdx < attrs.getLength(); attrIdx++) {
- Attr attr = (Attr) attrs.item(attrIdx);
- testSuiteSettings.put(attr.getName(), attr.getValue());
- }
- } else if (nodeName.equals(ELEM_TEST_CASE)) {
- for (TemplateTestCase testCase : createTestCasesFromElement((Element) n)) {
- addTest(testCase);
- }
- }
- }
- }
- }
-
- private Element loadXMLFromURL(URI uri) throws ParserConfigurationException, SAXException, IOException {
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- // dbf.setValidating(true);
- DocumentBuilder db = dbf.newDocumentBuilder();
- Document d = db.parse(uri.toString());
- return d.getDocumentElement();
- }
-
- String getTextInElement(Element e) {
- StringBuilder buf = new StringBuilder();
- NodeList children = e.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- Node n = children.item(i);
- short type = n.getNodeType();
- if (type == Node.TEXT_NODE || type == Node.CDATA_SECTION_NODE) {
- buf.append(n.getNodeValue());
- }
- }
- return buf.toString();
- }
-
- /**
- * Returns the list of test cases generated from the {@link #ELEM_TEST_CASE} element.
- * There can be multiple generated test cases because of "incompatible improvements" variations, or none because
- * of the {@code nameFilter}.
- */
- private List<TemplateTestCase> createTestCasesFromElement(Element testCaseElem)
- throws Exception {
- final String caseName = _StringUtil.emptyToNull(testCaseElem.getAttribute("name"));
- if (caseName == null) throw new Exception("Invalid XML: the \"name\" attribute is mandatory.");
-
- if (testCaseNameFilter != null
- && !testCaseNameFilter.matcher(caseName).matches()) {
- return Collections.emptyList();
- }
-
- final String templateName;
- final String expectedFileName;
- {
- final String beforeEndTN;
- final String afterEndTN;
- {
- int tBNameSep = caseName.indexOf(END_TEMPLATE_NAME_MARK);
- beforeEndTN = tBNameSep == -1 ? caseName : caseName.substring(0, tBNameSep);
- afterEndTN = tBNameSep == -1
- ? "" : caseName.substring(tBNameSep + END_TEMPLATE_NAME_MARK.length());
- }
-
- {
- String s = _StringUtil.emptyToNull(testCaseElem.getAttribute(ATTR_TEMPLATE));
- templateName = s != null ? s : beforeEndTN + ".ftl";
- }
-
- {
- String s = _StringUtil.emptyToNull(testCaseElem.getAttribute(ATTR_EXPECTED));
- expectedFileName = s != null ? s : beforeEndTN + afterEndTN + ".txt";
- }
- }
-
- final boolean noOutput;
- {
- String s = _StringUtil.emptyToNull(testCaseElem.getAttribute(ATTR_NO_OUTPUT));
- noOutput = s != null && _StringUtil.getYesNo(s);
- }
-
- final Map<String, String> testCaseSettings = getCaseFMSettings(testCaseElem);
-
- final List<Version> icisToTest;
- {
- final String testCaseIcis = testCaseSettings.get(Configuration.ExtendableBuilder.INCOMPATIBLE_IMPROVEMENTS_KEY);
-
- icisToTest = testCaseIcis != null ? parseVersionList(testCaseIcis) : testSuiteIcis;
- if (icisToTest.isEmpty()) {
- throw new Exception("The incompatible_improvement list was empty");
- }
- }
-
- List<TemplateTestCase> result = new ArrayList<>();
- for (Version iciToTest : icisToTest) {
- TemplateTestCase testCase = new TemplateTestCase(
- caseName + "(ici=" + iciToTest + ")", caseName,
- templateName, expectedFileName, noOutput, iciToTest);
- for (Map.Entry<String, String> setting : testSuiteSettings.entrySet()) {
- testCase.setSetting(setting.getKey(), setting.getValue());
- }
- for (Map.Entry<String, String> setting : testCaseSettings.entrySet()) {
- testCase.setSetting(setting.getKey(), setting.getValue());
- }
-
- result.add(testCase);
- }
-
- return result;
- }
-
- private List<Version> parseVersionList(String versionsStr) {
- List<Version> versions = new ArrayList<>();
- for (String versionStr : versionsStr.split(",")) {
- versionStr = versionStr.trim();
- if (versionStr.length() != 0) {
- final Version v;
- if ("min".equals(versionStr)) {
- v = getMinIcIVersion();
- } else if ("max".equals(versionStr)) {
- v = getMaxIcIVersion();
- } else {
- v = new Version(versionStr);
- }
- if (!versions.contains(v)) {
- versions.add(v);
- }
- }
- }
- return versions;
- }
-
- private Version getMaxIcIVersion() {
- Version v = Configuration.getVersion();
- // Remove nightly, RC and such:
- return new Version(v.getMajor(), v.getMinor(), v.getMicro());
- }
-
- private Version getMinIcIVersion() {
- return Configuration.VERSION_3_0_0;
- }
-
- private Map<String, String> getCaseFMSettings(Element e) {
- final Map<String, String> caseFMSettings;
- caseFMSettings = new LinkedHashMap<>();
- NodeList settingElems = e.getElementsByTagName(ELEM_SETTING);
- for (int elemIdx = 0; elemIdx < settingElems.getLength(); elemIdx++) {
- NamedNodeMap attrs = settingElems.item(elemIdx).getAttributes();
- for (int attrIdx = 0; attrIdx < attrs.getLength(); attrIdx++) {
- Attr attr = (Attr) attrs.item(attrIdx);
-
- final String settingName = attr.getName();
- caseFMSettings.put(settingName, attr.getValue());
- }
- }
- return caseFMSettings;
- }
-
- public static void main (String[] args) throws Exception {
- junit.textui.TestRunner.run(new TemplateTestSuite());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/AllTemplateModels.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/AllTemplateModels.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/AllTemplateModels.java
deleted file mode 100644
index 974b3f9..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/AllTemplateModels.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-import java.util.Date;
-
-import org.apache.freemarker.core.model.TemplateBooleanModel;
-import org.apache.freemarker.core.model.TemplateCollectionModel;
-import org.apache.freemarker.core.model.TemplateDateModel;
-import org.apache.freemarker.core.model.TemplateHashModelEx;
-import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
-import org.apache.freemarker.core.model.TemplateModelIterator;
-import org.apache.freemarker.core.model.TemplateNumberModel;
-import org.apache.freemarker.core.model.TemplateScalarModel;
-import org.apache.freemarker.core.model.TemplateSequenceModel;
-import org.apache.freemarker.core.model.impl.SimpleScalar;
-
-/**
- * Implements all template models that are interesting when calling overloaded Java methods.
- */
-public class AllTemplateModels implements
- TemplateScalarModel, TemplateNumberModel, TemplateDateModel, TemplateBooleanModel,
- TemplateHashModelEx, TemplateSequenceModel, TemplateCollectionModel {
-
- public static final AllTemplateModels INSTANCE = new AllTemplateModels();
-
- private final TemplateModelIterator EMPTY_ITERATOR = new TemplateModelIterator() {
-
- @Override
- public TemplateModel next() throws TemplateModelException {
- return null;
- }
-
- @Override
- public boolean hasNext() throws TemplateModelException {
- return false;
- }
-
- };
-
- private final TemplateCollectionModel EMPTY_COLLECTION = new TemplateCollectionModel() {
-
- @Override
- public TemplateModelIterator iterator() throws TemplateModelException {
- return EMPTY_ITERATOR;
- }
- };
-
- @Override
- public TemplateModel get(String key) throws TemplateModelException {
- return new SimpleScalar("value for key " + key);
- }
-
- @Override
- public boolean isEmpty() throws TemplateModelException {
- return true;
- }
-
- @Override
- public TemplateModelIterator iterator() throws TemplateModelException {
- return EMPTY_ITERATOR;
- }
-
- @Override
- public TemplateModel get(int index) throws TemplateModelException {
- return null;
- }
-
- @Override
- public int size() throws TemplateModelException {
- return 0;
- }
-
- @Override
- public TemplateCollectionModel keys() throws TemplateModelException {
- return EMPTY_COLLECTION;
- }
-
- @Override
- public TemplateCollectionModel values() throws TemplateModelException {
- return EMPTY_COLLECTION;
- }
-
- @Override
- public boolean getAsBoolean() throws TemplateModelException {
- return true;
- }
-
- @Override
- public Date getAsDate() throws TemplateModelException {
- return new Date(0);
- }
-
- @Override
- public int getDateType() {
- return TemplateDateModel.DATETIME;
- }
-
- @Override
- @SuppressWarnings("boxing")
- public Number getAsNumber() throws TemplateModelException {
- return 1;
- }
-
- @Override
- public String getAsString() throws TemplateModelException {
- return "s";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BeanTestClass.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BeanTestClass.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BeanTestClass.java
deleted file mode 100644
index 7e7fa82..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BeanTestClass.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-/**
- */
-public class BeanTestClass extends BeanTestSuperclass implements BeanTestInterface<Integer> {
- public static final String STATIC_FINAL_FIELD = "static-final-field";
- public static String STATIC_FIELD = "static-field";
-
- public String getFoo() {
- return "foo-value";
- }
-
- public String getBar(int index) {
- return "bar-value-" + index;
- }
-
- public String[] getBar() {
- return new String[] { "bar-value-0", "bar-value-1", "bar-value-2" };
- }
-
- public String overloaded(int i) {
- return "overloaded-int-" + i;
- }
-
- public String overloaded(String s) {
- return "overloaded-String-" + s;
- }
-
- public static String staticMethod() {
- return "static-method";
- }
-
- public static String staticOverloaded(int i) {
- return "static-overloaded-int-" + i;
- }
-
- public static String staticOverloaded(String s) {
- return "static-overloaded-String-" + s;
- }
-
- public PrivateInner getPrivateInner() {
- return new PrivateInner();
- }
-
- public PublicInner getPublicInner() {
- return new PublicInner();
- }
-
- public class PublicInner {
-
- public int getX() {
- return 1;
- }
-
- public String m() {
- return "m";
- }
-
- }
-
- @SuppressWarnings("unused")
- private class PrivateInner {
-
- public int getX() {
- return 2;
- }
-
- public String m() {
- return "M";
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BeanTestInterface.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BeanTestInterface.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BeanTestInterface.java
deleted file mode 100644
index 6737b87..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BeanTestInterface.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-public interface BeanTestInterface<T> {
- T getSomething();
- void setSomething(T s);
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BeanTestSuperclass.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BeanTestSuperclass.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BeanTestSuperclass.java
deleted file mode 100644
index b462e9a..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BeanTestSuperclass.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-public class BeanTestSuperclass {
- public Integer getSomething() {
- return 42;
- }
-
- public void setSomething(Integer x) {
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanAndScalarModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanAndScalarModel.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanAndScalarModel.java
deleted file mode 100644
index 4af030e..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanAndScalarModel.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-import org.apache.freemarker.core.model.TemplateBooleanModel;
-import org.apache.freemarker.core.model.TemplateModelException;
-import org.apache.freemarker.core.model.TemplateScalarModel;
-
-public class BooleanAndScalarModel implements TemplateBooleanModel, TemplateScalarModel {
-
- public static final BooleanAndScalarModel INSTANCE = new BooleanAndScalarModel();
-
- @Override
- public String getAsString() throws TemplateModelException {
- return "s";
- }
-
- @Override
- public boolean getAsBoolean() throws TemplateModelException {
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanAndStringTemplateModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanAndStringTemplateModel.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanAndStringTemplateModel.java
deleted file mode 100644
index d87b65c..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanAndStringTemplateModel.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-import org.apache.freemarker.core.model.TemplateBooleanModel;
-import org.apache.freemarker.core.model.TemplateModelException;
-import org.apache.freemarker.core.model.TemplateScalarModel;
-
-public class BooleanAndStringTemplateModel implements TemplateBooleanModel, TemplateScalarModel {
-
- @Override
- public String getAsString() throws TemplateModelException {
- return "theStringValue";
- }
-
- @Override
- public boolean getAsBoolean() throws TemplateModelException {
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanHash1.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanHash1.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanHash1.java
deleted file mode 100644
index 524d003..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanHash1.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-import org.apache.freemarker.core.model.TemplateBooleanModel;
-import org.apache.freemarker.core.model.TemplateHashModel;
-import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.impl.SimpleScalar;
-
-/**
- * Tests the impact that the isEmpty() has on template hash models.
- */
-public class BooleanHash1 implements TemplateHashModel {
-
- /**
- * Gets a <tt>TemplateModel</tt> from the hash.
- *
- * @param key the name by which the <tt>TemplateModel</tt>
- * is identified in the template.
- * @return the <tt>TemplateModel</tt> referred to by the key,
- * or null if not found.
- */
- @Override
- public TemplateModel get(String key) {
- if ( key.equals( "temp" )) {
- return new SimpleScalar( "Hello, world." );
- } else if ( key.equals( "boolean" )) {
- return TemplateBooleanModel.FALSE;
- } else {
- return new SimpleScalar( "Just another key..." );
- }
- }
-
- /**
- * @return true if this object is empty.
- */
- @Override
- public boolean isEmpty() {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanHash2.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanHash2.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanHash2.java
deleted file mode 100644
index 8bae7ab..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanHash2.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-import org.apache.freemarker.core.model.TemplateHashModel;
-import org.apache.freemarker.core.model.TemplateModel;
-
-/**
- * Tests the impact that the isEmpty() has on template hash models.
- */
-public class BooleanHash2 implements TemplateHashModel {
-
- /**
- * Gets a <tt>TemplateModel</tt> from the hash.
- *
- * @param key the name by which the <tt>TemplateModel</tt>
- * is identified in the template.
- * @return the <tt>TemplateModel</tt> referred to by the key,
- * or null if not found.
- */
- @Override
- public TemplateModel get(String key) {
- return null;
- }
-
- /**
- * @return true if this object is empty.
- */
- @Override
- public boolean isEmpty() {
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanList1.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanList1.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanList1.java
deleted file mode 100644
index 3e0a69c..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanList1.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-import org.apache.freemarker.core.model.ObjectWrapper;
-import org.apache.freemarker.core.model.TemplateBooleanModel;
-import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
-import org.apache.freemarker.core.model.TemplateSequenceModel;
-import org.apache.freemarker.core.model.impl.SimpleSequence;
-
-/**
- * Model for testing the impact of isEmpty() on template list models. Every
- * other method simply delegates to a SimpleList model.
- */
-public class BooleanList1 implements TemplateSequenceModel {
-
- private SimpleSequence cList;
-
- /** Creates new BooleanList1 */
- public BooleanList1(ObjectWrapper ow) {
- cList = new SimpleSequence(ow);
- cList.add( "false" );
- cList.add( "0" );
- cList.add(TemplateBooleanModel.FALSE);
- cList.add(TemplateBooleanModel.TRUE);
- cList.add(TemplateBooleanModel.TRUE);
- cList.add(TemplateBooleanModel.TRUE);
- cList.add(TemplateBooleanModel.FALSE);
- }
-
- /**
- * @return the specified index in the list
- */
- @Override
- public TemplateModel get(int i) throws TemplateModelException {
- return cList.get(i);
- }
-
- @Override
- public int size() {
- return cList.size();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanList2.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanList2.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanList2.java
deleted file mode 100644
index 939fb5f..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanList2.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-import org.apache.freemarker.core.model.ObjectWrapper;
-import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
-import org.apache.freemarker.core.model.TemplateSequenceModel;
-import org.apache.freemarker.core.model.impl.SimpleSequence;
-
-/**
- * Model for testing list models. Every
- * other method simply delegates to a SimpleList model.
- */
-public class BooleanList2 implements TemplateSequenceModel {
-
- private SimpleSequence cList;
-
- /** Creates new BooleanList2 */
- public BooleanList2(ObjectWrapper ow) {
- cList = new SimpleSequence(ow);
- }
-
- /**
- * @return the specified index in the list
- */
- @Override
- public TemplateModel get(int i) throws TemplateModelException {
- return cList.get(i);
- }
-
- @Override
- public int size() {
- return cList.size();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanVsStringMethods.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanVsStringMethods.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanVsStringMethods.java
deleted file mode 100644
index 3e13623..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/BooleanVsStringMethods.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-public class BooleanVsStringMethods {
-
- public String expectsString(String s) {
- return s;
- }
-
- public boolean expectsBoolean(boolean b) {
- return b;
- }
-
- public String overloaded(String s) {
- return "String " + s;
- }
-
- public String overloaded(boolean s) {
- return "boolean " + s;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/EnumTestClass.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/EnumTestClass.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/EnumTestClass.java
deleted file mode 100644
index 359e4a4..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/EnumTestClass.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-/**
- */
-public enum EnumTestClass
-{
- ONE,
- TWO,
- THREE;
-
- @Override
- public String toString() {
- return name() + "x";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/ExceptionModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/ExceptionModel.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/ExceptionModel.java
deleted file mode 100644
index ca0f9be..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/ExceptionModel.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-import org.apache.freemarker.core.model.TemplateModelException;
-import org.apache.freemarker.core.model.TemplateScalarModel;
-
-/**
- * A template that always throws an exception whenever we call getAsString()
- */
-public class ExceptionModel implements TemplateScalarModel {
-
- /**
- * Returns the scalar's value as a String.
- *
- * @return the String value of this scalar.
- */
- @Override
- public String getAsString () throws TemplateModelException {
- throw new TemplateModelException( "Throwing from ExceptionModel!" );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/HashAndScalarModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/HashAndScalarModel.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/HashAndScalarModel.java
deleted file mode 100644
index 70ea42a..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/HashAndScalarModel.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-import org.apache.freemarker.core.model.TemplateCollectionModel;
-import org.apache.freemarker.core.model.TemplateHashModelEx;
-import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
-import org.apache.freemarker.core.model.TemplateModelIterator;
-import org.apache.freemarker.core.model.TemplateScalarModel;
-import org.apache.freemarker.core.model.impl.SimpleScalar;
-
-public class HashAndScalarModel implements TemplateHashModelEx, TemplateScalarModel {
-
- public static final HashAndScalarModel INSTANCE = new HashAndScalarModel();
-
- private final TemplateCollectionModel EMPTY_COLLECTION = new TemplateCollectionModel() {
-
- @Override
- public TemplateModelIterator iterator() throws TemplateModelException {
- return new TemplateModelIterator() {
-
- @Override
- public TemplateModel next() throws TemplateModelException {
- return null;
- }
-
- @Override
- public boolean hasNext() throws TemplateModelException {
- return false;
- }
-
- };
- }
- };
-
- @Override
- public String getAsString() throws TemplateModelException {
- return "scalarValue";
- }
-
- @Override
- public TemplateModel get(String key) throws TemplateModelException {
- return new SimpleScalar("mapValue for " + key);
- }
-
- @Override
- public boolean isEmpty() throws TemplateModelException {
- return true;
- }
-
- @Override
- public int size() throws TemplateModelException {
- return 0;
- }
-
- @Override
- public TemplateCollectionModel keys() throws TemplateModelException {
- return EMPTY_COLLECTION;
- }
-
- @Override
- public TemplateCollectionModel values() throws TemplateModelException {
- return EMPTY_COLLECTION;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/JavaObjectInfo.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/JavaObjectInfo.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/JavaObjectInfo.java
deleted file mode 100644
index 4673b09..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/JavaObjectInfo.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-import org.apache.freemarker.core.util._StringUtil;
-
-public class JavaObjectInfo {
-
- public static final Object INSTANCE = new JavaObjectInfo();
-
- private JavaObjectInfo() { }
-
- public String info(Object o) {
- if (o == null) return "null";
- return o.getClass().getName() + " " + _StringUtil.jQuote(o.toString());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/Listables.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/Listables.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/Listables.java
deleted file mode 100644
index c2d7c90..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/Listables.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * 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.
- */
-package org.apache.freemarker.test.templatesuite.models;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.apache.freemarker.core.Configuration;
-import org.apache.freemarker.core.model.ObjectWrapper;
-import org.apache.freemarker.core.model.TemplateCollectionModel;
-import org.apache.freemarker.core.model.TemplateHashModelEx;
-import org.apache.freemarker.core.model.TemplateHashModelEx2;
-import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
-import org.apache.freemarker.core.model.WrappingTemplateModel;
-import org.apache.freemarker.core.model.impl.DefaultMapAdapter;
-import org.apache.freemarker.core.model.impl.DefaultObjectWrapper;
-import org.apache.freemarker.core.model.impl.SimpleCollection;
-import org.apache.freemarker.core.model.impl.SimpleHash;
-
-import com.google.common.collect.ImmutableMap;
-
-@SuppressWarnings("boxing")
-public class Listables {
-
- private static final List<Integer> LIST;
- static {
- List<Integer> list = new ArrayList<>();
- list.add(11);
- list.add(22);
- list.add(33);
- LIST = list;
- }
-
- private static final List<Integer> LINKED_LIST;
- static {
- List<Integer> list = new LinkedList<>();
- list.add(11);
- list.add(22);
- list.add(33);
- LINKED_LIST = list;
- }
-
- private static final List<Integer> EMPTY_LINKED_LIST = new LinkedList<>();
-
- private static final Set<Integer> SET;
- static {
- Set<Integer> set = new TreeSet<>();
- set.add(11);
- set.add(22);
- set.add(33);
- SET = set;
- }
-
- public List<Integer> getList() {
- return LIST;
- }
-
- public List<Integer> getLinkedList() {
- return LINKED_LIST;
- }
-
- public Set<Integer> getSet() {
- return SET;
- }
-
- public Iterator<Integer> getIterator() {
- return SET.iterator();
- }
-
- public List<Integer> getEmptyList() {
- return Collections.emptyList();
- }
-
- public List<Integer> getEmptyLinkedList() {
- return Collections.emptyList();
- }
-
- public Set<Integer> getEmptySet() {
- return Collections.emptySet();
- }
-
- public Iterator<Integer> getEmptyIterator() {
- return Collections.<Integer>emptySet().iterator();
- }
-
- public List<TemplateHashModelEx2> getHashEx2s() throws TemplateModelException {
- Map<Object, Object> map;
- map = new LinkedHashMap<>();
- map.put("k1", "v1");
- map.put(2, "v2");
- map.put("k3", "v3");
- map.put(null, "v4");
- map.put(true, "v5");
- map.put(false, null);
-
- return getMapsWrappedAsEx2(map);
- }
-
- public List<? extends TemplateHashModelEx> getEmptyHashes() throws TemplateModelException {
- List<TemplateHashModelEx> emptyMaps = new ArrayList<>();
- emptyMaps.addAll(getMapsWrappedAsEx2(Collections.emptyMap()));
- emptyMaps.add((TemplateHashModelEx) new DefaultObjectWrapper.Builder(Configuration.VERSION_3_0_0).build()
- .wrap(Collections.emptyMap()));
- return emptyMaps;
- }
-
- /**
- * Returns the map wrapped on various ways.
- */
- private List<TemplateHashModelEx2> getMapsWrappedAsEx2(Map<?, ?> map) throws TemplateModelException {
- List<TemplateHashModelEx2> maps = new ArrayList<>();
-
- DefaultObjectWrapper ow = new DefaultObjectWrapper.Builder(Configuration.VERSION_3_0_0).build();
- maps.add(new SimpleHash(map, ow));
- maps.add((DefaultMapAdapter) ow.wrap(map));
-
- return maps;
- }
-
- public TemplateHashModelEx getHashNonEx2() {
- return new NonEx2MapAdapter(ImmutableMap.of("k1", 11, "k2", 22),
- new DefaultObjectWrapper.Builder(Configuration.VERSION_3_0_0).build());
- }
-
- public static class NonEx2MapAdapter extends WrappingTemplateModel implements TemplateHashModelEx {
-
- private final Map<?, ?> map;
-
- public NonEx2MapAdapter(Map<?, ?> map, ObjectWrapper wrapper) {
- super(wrapper);
- this.map = map;
- }
-
- @Override
- public TemplateModel get(String key) throws TemplateModelException {
- return wrap(map.get(key));
- }
-
- @Override
- public boolean isEmpty() {
- return map.isEmpty();
- }
-
- @Override
- public int size() {
- return map.size();
- }
-
- @Override
- public TemplateCollectionModel keys() {
- return new SimpleCollection(map.keySet(), getObjectWrapper());
- }
-
- @Override
- public TemplateCollectionModel values() {
- return new SimpleCollection(map.values(), getObjectWrapper());
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/MultiModel1.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/MultiModel1.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/MultiModel1.java
deleted file mode 100644
index 66a0ffe..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/MultiModel1.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-import org.apache.freemarker.core.Configuration;
-import org.apache.freemarker.core.model.ObjectWrapper;
-import org.apache.freemarker.core.model.TemplateHashModel;
-import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
-import org.apache.freemarker.core.model.TemplateScalarModel;
-import org.apache.freemarker.core.model.TemplateSequenceModel;
-import org.apache.freemarker.core.model.impl.DefaultObjectWrapper;
-import org.apache.freemarker.core.model.impl.SimpleHash;
-import org.apache.freemarker.core.model.impl.SimpleScalar;
-import org.apache.freemarker.core.model.impl.SimpleSequence;
-
-/**
- * Testcase to see how FreeMarker deals with multiple Template models.
- */
-public class MultiModel1 implements TemplateHashModel,
- TemplateSequenceModel, TemplateScalarModel {
-
- private ObjectWrapper ow = new DefaultObjectWrapper.Builder(Configuration.VERSION_3_0_0).build();
-
- private TemplateModel m_cSubModel = new MultiModel2();
- private TemplateModel m_cListHashModel1 = new MultiModel4(ow);
- private TemplateModel m_cListHashModel2 = new MultiModel5(ow);
- private TemplateSequenceModel m_cListModel = new SimpleSequence(ow);
- private TemplateHashModel m_cHashModel = new SimpleHash(ow);
-
- /** Creates new MultiModel1 */
- public MultiModel1() {
- for ( int i = 0; i < 10; i++ ) {
- ((SimpleSequence) m_cListModel).add( "Model1 value: " + Integer.toString( i ));
- }
- ((SimpleSequence) m_cListModel).add( new MultiModel3() );
- ((SimpleHash) m_cHashModel).put( "nested", new MultiModel3() );
- }
-
- /**
- * Gets a <tt>TemplateModel</tt> from the hash.
- *
- * @param key the name by which the <tt>TemplateModel</tt>
- * is identified in the template.
- * @return the <tt>TemplateModel</tt> referred to by the key,
- * or null if not found.
- */
- @Override
- public TemplateModel get(String key) {
- if ( key.equals( "model2" )) {
- return m_cSubModel;
- } else if ( key.equals( "modellist" )) {
- return m_cListModel;
- } else if ( key.equals( "selftest" )) {
- return new SimpleScalar( "Selftest of a hash from MultiModel1" );
- } else if ( key.equals( "one" )) {
- return m_cListHashModel1;
- } else if ( key.equals( "two" )) {
- return m_cListHashModel2;
- } else if ( key.equals( "size" )) {
- return new SimpleScalar( "Nasty!" );
- } else if ( key.equals( "nesting1" )) {
- return m_cHashModel;
- } else {
- return null;
- }
- }
-
- /**
- * @return true if this object is empty.
- */
- @Override
- public boolean isEmpty() {
- return false;
- }
-
- /**
- * @return the specified index in the list
- */
- @Override
- public TemplateModel get(int i) throws TemplateModelException {
- return m_cListModel.get( i );
- }
-
- /**
- * Returns the scalar's value as a String.
- *
- * @return the String value of this scalar.
- */
- @Override
- public String getAsString() {
- return "MultiModel1 as a string!";
- }
-
- @Override
- public int size() throws TemplateModelException {
- return m_cListModel.size();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/MultiModel2.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/MultiModel2.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/MultiModel2.java
deleted file mode 100644
index a7a75b5..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/MultiModel2.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.freemarker.core.model.TemplateMethodModel;
-import org.apache.freemarker.core.model.TemplateScalarModel;
-import org.apache.freemarker.core.model.impl.SimpleScalar;
-
-/**
- * Testcase to see how FreeMarker deals with multiple Template models.
- */
-public class MultiModel2 implements TemplateScalarModel, TemplateMethodModel {
-
- /**
- * Returns the scalar's value as a String.
- *
- * @return the String value of this scalar.
- */
- @Override
- public String getAsString() {
- return "Model2 is alive!";
- }
-
- /**
- * Executes a method call.
- *
- * @param arguments a <tt>List</tt> of <tt>String</tt> objects containing the values
- * of the arguments passed to the method.
- * @return the <tt>TemplateModel</tt> produced by the method, or null.
- */
- @Override
- public Object exec(List arguments) {
- StringBuilder aResults = new StringBuilder( "Arguments are:<br />" );
- Iterator iList = arguments.iterator();
-
- while ( iList.hasNext() ) {
- aResults.append( (String) iList.next() );
- aResults.append( "<br />" );
- }
-
- return new SimpleScalar( aResults.toString() );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/MultiModel3.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/MultiModel3.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/MultiModel3.java
deleted file mode 100644
index 4434afc..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/MultiModel3.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-import org.apache.freemarker.core.model.TemplateHashModel;
-import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateScalarModel;
-import org.apache.freemarker.core.model.impl.SimpleScalar;
-
-/**
- * Testcase to see how FreeMarker deals with multiple Template models.
- */
-public class MultiModel3 implements TemplateScalarModel, TemplateHashModel {
-
- /**
- * Returns the scalar's value as a String.
- *
- * @return the String value of this scalar.
- */
- @Override
- public String getAsString() {
- return "Model3 is alive!";
- }
-
- /**
- * @return true if this object is empty.
- */
- @Override
- public boolean isEmpty() {
- return false;
- }
-
- /**
- * Gets a <tt>TemplateModel</tt> from the hash.
- *
- * @param key the name by which the <tt>TemplateModel</tt>
- * is identified in the template.
- * @return the <tt>TemplateModel</tt> referred to by the key,
- * or null if not found.
- */
- @Override
- public TemplateModel get(String key) {
- if ( key.equals( "selftest" )) {
- return new SimpleScalar( "Selftest from MultiModel3!" );
- } else if ( key.equals( "message" )) {
- return new SimpleScalar( "Hello world from MultiModel3!" );
- } else {
- return null;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/MultiModel4.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/MultiModel4.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/MultiModel4.java
deleted file mode 100644
index bdd11fc..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/MultiModel4.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-import org.apache.freemarker.core.model.ObjectWrapper;
-import org.apache.freemarker.core.model.TemplateHashModel;
-import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
-import org.apache.freemarker.core.model.TemplateSequenceModel;
-import org.apache.freemarker.core.model.impl.SimpleScalar;
-import org.apache.freemarker.core.model.impl.SimpleSequence;
-
-/**
- * Testcase to see how FreeMarker deals with multiple Template models.
- */
-public class MultiModel4 implements TemplateSequenceModel, TemplateHashModel {
-
- private final SimpleSequence m_cList;
-
- public MultiModel4(ObjectWrapper ow) {
- this.m_cList = new SimpleSequence(ow);
- }
-
- /**
- * @return the specified index in the list
- */
- @Override
- public TemplateModel get(int i) throws TemplateModelException {
- return m_cList.get( i );
- }
-
- /**
- * Gets a <tt>TemplateModel</tt> from the hash.
- *
- * @param key the name by which the <tt>TemplateModel</tt>
- * is identified in the template.
- * @return the <tt>TemplateModel</tt> referred to by the key,
- * or null if not found.
- */
- @Override
- public TemplateModel get(String key) {
- if ( key.equals( "size" )) {
- return new SimpleScalar( "Key size, not the listSize method." );
- } else {
- return null;
- }
- }
-
-
- @Override
- public int size() {
- return m_cList.size();
- }
-
- @Override
- public boolean isEmpty() {
- return size() == 0;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/MultiModel5.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/MultiModel5.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/MultiModel5.java
deleted file mode 100644
index 01f7a3e..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/MultiModel5.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-import org.apache.freemarker.core.model.ObjectWrapper;
-import org.apache.freemarker.core.model.TemplateHashModel;
-import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
-import org.apache.freemarker.core.model.TemplateSequenceModel;
-import org.apache.freemarker.core.model.impl.SimpleScalar;
-import org.apache.freemarker.core.model.impl.SimpleSequence;
-
-/**
- * Testcase to see how FreeMarker deals with multiple Template models.
- */
-public class MultiModel5 implements TemplateSequenceModel, TemplateHashModel {
-
- private final SimpleSequence m_cList;
-
- /** Creates new MultiModel5 */
- public MultiModel5(ObjectWrapper ow) {
- this.m_cList = new SimpleSequence(ow);
- m_cList.add( new SimpleScalar( "Dummy to make list non-empty" ));
- }
-
- /**
- * @return the specified index in the list
- */
- @Override
- public TemplateModel get(int i) throws TemplateModelException {
- return m_cList.get( i );
- }
-
- /**
- * @return true if this object is empty.
- */
- @Override
- public boolean isEmpty() {
- return false;
- }
-
- @Override
- public int size() {
- return m_cList.size();
- }
-
- /**
- * Gets a <tt>TemplateModel</tt> from the hash.
- *
- * @param key the name by which the <tt>TemplateModel</tt>
- * is identified in the template.
- * @return the <tt>TemplateModel</tt> referred to by the key,
- * or null if not found.
- */
- @Override
- public TemplateModel get(String key) {
- if ( key.equals( "empty" )) {
- return new SimpleScalar( "Dummy hash value, for test purposes." );
- } else {
- return null;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/NewTestModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/NewTestModel.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/NewTestModel.java
deleted file mode 100644
index 9f51458..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/NewTestModel.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-import org.apache.freemarker.core.model.TemplateScalarModel;
-
-/**
- * Testcase to see how FreeMarker's ?new built-in deals with constructors.
- */
-public class NewTestModel
-implements
- TemplateScalarModel {
- private final String string;
-
- public NewTestModel() {
- string = "default constructor";
- }
-
- public NewTestModel(String str) {
- string = str;
- }
-
- public NewTestModel(long i) {
- string = Long.toString(i);
- }
-
- public NewTestModel(Object o1, java.io.Serializable o2) {
- string = o1 + ":" + o2;
- }
-
- @Override
- public String getAsString() {
- return string;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/NewTestModel2.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/NewTestModel2.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/NewTestModel2.java
deleted file mode 100644
index 420b4fa..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/NewTestModel2.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-import org.apache.freemarker.core.model.TemplateScalarModel;
-
-/**
- * Testcase to see how FreeMarker's ?new built-in deals with constructors.
- */
-public class NewTestModel2
-implements
- TemplateScalarModel {
- private final String string;
-
- public NewTestModel2() {
- string = "default constructor";
- }
-
- public NewTestModel2(String str) {
- string = str;
- }
-
- public NewTestModel2(long i) {
- string = Long.toString(i);
- }
-
- public NewTestModel2(Object o1, java.io.Serializable o2) {
- string = o1 + ":" + o2;
- }
-
- @Override
- public String getAsString() {
- return string;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/NumberAndStringModel.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/NumberAndStringModel.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/NumberAndStringModel.java
deleted file mode 100644
index 5c8e7db..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/NumberAndStringModel.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-import org.apache.freemarker.core.model.TemplateModelException;
-import org.apache.freemarker.core.model.TemplateNumberModel;
-import org.apache.freemarker.core.model.TemplateScalarModel;
-
-public class NumberAndStringModel implements TemplateNumberModel,
- TemplateScalarModel {
-
- private final String s;
-
- public NumberAndStringModel(String s) {
- super();
- this.s = s;
- }
-
- @Override
- public String getAsString() throws TemplateModelException {
- return s;
- }
-
- @Override
- @SuppressWarnings("boxing")
- public Number getAsNumber() throws TemplateModelException {
- return s.length();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/OverloadedConstructor.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/OverloadedConstructor.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/OverloadedConstructor.java
deleted file mode 100644
index 6e09053..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/OverloadedConstructor.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-import org.apache.freemarker.core.model.TemplateModelException;
-import org.apache.freemarker.core.model.TemplateScalarModel;
-
-public class OverloadedConstructor implements TemplateScalarModel {
-
- String value;
-
- public OverloadedConstructor(int i) {
- value = "int " + i;
- }
-
- public OverloadedConstructor(String s) {
- value = "String " + s;
- }
-
- public OverloadedConstructor(CharSequence s) {
- value = "CharSequence " + s;
- }
-
- @Override
- public String getAsString() throws TemplateModelException {
- return value;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/OverloadedMethods.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/OverloadedMethods.java b/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/OverloadedMethods.java
deleted file mode 100644
index ebd505a..0000000
--- a/freemarker-core/src/test/java/org/apache/freemarker/test/templatesuite/models/OverloadedMethods.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.freemarker.test.templatesuite.models;
-
-import java.math.BigDecimal;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.freemarker.core.util.FTLUtil;
-
-/**
- * For testing overloaded method selection.
- */
-public class OverloadedMethods {
-
- public String oneArg(Object a1) {
- return methodCallToStr("oneArg<Object>", a1);
- }
-
- public String oneArg(String a1) {
- return methodCallToStr("oneArg<String>", a1);
- }
-
- public String oneArg(Boolean a1) {
- return methodCallToStr("oneArg<Boolean>", a1);
- }
-
- public String oneArg(boolean a1) {
- return methodCallToStr("oneArg<boolean>", Boolean.valueOf(a1));
- }
-
- public String oneArg(List a1) {
- return methodCallToStr("oneArg<List>", a1);
- }
-
- public String oneArg(Map a1) {
- return methodCallToStr("oneArg<Map>", a1);
- }
-
- public String oneArg2(Map a1) {
- return methodCallToStr("oneArg2<Map>", a1);
- }
-
- public String oneArg2(List a1) {
- return methodCallToStr("oneArg2<List>", a1);
- }
-
- public String oneArg3(List a1, List a2) {
- return methodCallToStr("oneArg3<List, List>", a1, a2);
- }
-
- public String oneArg3(List a1) {
- return methodCallToStr("oneArg3<List>", a1);
- }
-
- public String oneArg4(Integer a1) {
- return methodCallToStr("oneArg4<Integer>", a1);
- }
-
- public String oneArg4(int a1) {
- return methodCallToStr("oneArg4<int>", Integer.valueOf(a1));
- }
-
- public String notOverloaded(List a1) {
- return methodCallToStr("notOverloaded<List>", a1);
- }
-
- public String varargsIssue1(Map a1, List a2) {
- return methodCallToStr("varargsIssue1<Map, List>", a1, a2);
- }
-
- public String varargsIssue1(Object... a1) {
- return methodCallToStr("varargsIssue1<Object...>", a1);
- }
-
- public String varargsIssue2(String a1, List a2) {
- return methodCallToStr("varargsIssue2<String, List>", a1, a2);
- }
-
- public String varargsIssue2(String a1, Map a2) {
- return methodCallToStr("varargsIssue2<String, Map>", a1, a2);
- }
-
- public String varargsIssue2(Object... a1) {
- return methodCallToStr("varargsIssue2<Object...>", a1);
- }
-
- public String numberIssue1(int a1) {
- return methodCallToStr("numberIssue1<int>", a1);
- }
-
- public String numberIssue1(float a1) {
- return methodCallToStr("numberIssue1<float>", a1);
- }
-
- public String numberIssue2(int a1) {
- return methodCallToStr("numberIssue2<int>", a1);
- }
-
- public String numberIssue2(BigDecimal a1) {
- return methodCallToStr("numberIssue2<BigDecimal>", a1);
- }
-
- public String numberIssue3(int a1) {
- return methodCallToStr("numberIssue3<int>", a1);
- }
-
- public String numberIssue3(double a1) {
- return methodCallToStr("numberIssue3<double>", a1);
- }
-
- private String methodCallToStr(String methodName, Object... args) {
- StringBuilder sb = new StringBuilder();
-
- sb.append(methodName);
- sb.append('(');
- boolean hadItems = false;
- for (Object arg : args) {
- if (hadItems) sb.append(", ");
- sb.append(valueToStr(arg));
- hadItems = true;
- }
- sb.append(')');
-
- return sb.toString();
- }
-
- private String valueToStr(Object value) {
- if (value == null) {
- return "null";
- } else if (value instanceof Character) {
- return "'" + FTLUtil.escapeStringLiteralPart(value.toString()) + "'";
- } else if (value instanceof String) {
- return "\"" + FTLUtil.escapeStringLiteralPart((String) value) + "\"";
- } else if (value instanceof Map) {
- StringBuilder sb = new StringBuilder();
- sb.append("{");
- boolean hadItems = false;
- for (Map.Entry<?, ?> ent : ((Map<?, ?>) value).entrySet()) {
- if (hadItems) sb.append(", ");
- sb.append(valueToStr(ent.getKey()));
- sb.append(": ");
- sb.append(valueToStr(ent.getValue()));
- hadItems = true;
- }
- sb.append("}");
- return sb.toString();
- } else if (value instanceof Collection || value.getClass().isArray()) {
- StringBuilder sb = new StringBuilder();
-
- if (value.getClass().isArray()) {
- value = Arrays.asList(value);
- sb.append("array");
- } else if (value instanceof Set) {
- sb.append("set");
- }
- sb.append("[");
- boolean hadItems = false;
- for (Object i : (Collection) value) {
- if (hadItems) sb.append(", ");
- sb.append(i);
- hadItems = true;
- }
- sb.append("]");
- return sb.toString();
- } else {
- return value.toString();
- }
- }
-
-}