Moving TemplateTestSuite to freemarker-test-utils, so that it can be used from multiple modules. It had to be generalized for this a bit, as now it has a CoreTemplateTestSuite subclass in freemarker-core-test.
Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/4b75ea93 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/4b75ea93 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/4b75ea93 Branch: refs/heads/3 Commit: 4b75ea930f8b4894298c19e60915950ce4443995 Parents: bb9acc9 Author: ddekany <[email protected]> Authored: Tue May 16 11:21:14 2017 +0200 Committer: ddekany <[email protected]> Committed: Tue May 16 18:08:45 2017 +0200 ---------------------------------------------------------------------- build.gradle | 2 +- freemarker-core-test/build.gradle | 7 + .../apache/freemarker/core/ListErrorsTest.java | 2 +- .../core/NewBiObjectWrapperRestrictionTest.java | 4 +- .../templatesuite/CoreTemplateTestSuite.java | 282 +++++ .../templatesuite/models/AllTemplateModels.java | 128 ++ .../templatesuite/models/BeanTestClass.java | 93 ++ .../templatesuite/models/BeanTestInterface.java | 25 + .../models/BeanTestSuperclass.java | 30 + .../models/BooleanAndScalarModel.java | 40 + .../models/BooleanAndStringTemplateModel.java | 38 + .../core/templatesuite/models/BooleanHash1.java | 58 + .../core/templatesuite/models/BooleanHash2.java | 50 + .../core/templatesuite/models/BooleanList1.java | 62 + .../core/templatesuite/models/BooleanList2.java | 53 + .../models/BooleanVsStringMethods.java | 40 + .../templatesuite/models/EnumTestClass.java | 34 + .../templatesuite/models/ExceptionModel.java | 39 + .../models/HashAndScalarModel.java | 84 ++ .../templatesuite/models/JavaObjectInfo.java | 35 + .../core/templatesuite/models/Listables.java | 185 +++ .../core/templatesuite/models/MultiModel1.java | 116 ++ .../core/templatesuite/models/MultiModel2.java | 63 + .../core/templatesuite/models/MultiModel3.java | 69 ++ .../core/templatesuite/models/MultiModel4.java | 77 ++ .../core/templatesuite/models/MultiModel5.java | 81 ++ .../core/templatesuite/models/NewTestModel.java | 52 + .../templatesuite/models/NewTestModel2.java | 52 + .../models/NumberAndStringModel.java | 47 + .../models/OverloadedConstructor.java | 46 + .../templatesuite/models/OverloadedMethods.java | 191 +++ .../models/OverloadedMethods2.java | 1110 ++++++++++++++++++ .../SimpleMapAndCollectionObjectWrapper.java | 60 + .../templatesuite/models/SimpleTestMethod.java | 49 + .../core/templatesuite/models/TestBean.java | 17 + .../core/templatesuite/models/TestBoolean.java | 16 + .../core/templatesuite/models/TestMethod.java | 12 + .../core/templatesuite/models/TestNode.java | 32 + .../models/TransformHashWrapper.java | 79 ++ .../models/TransformMethodWrapper1.java | 49 + .../models/TransformMethodWrapper2.java | 64 + .../templatesuite/models/TransformModel1.java | 175 +++ .../templatesuite/models/VarArgTestModel.java | 63 + .../test/templatesuite/TemplateTestCase.java | 515 -------- .../test/templatesuite/TemplateTestSuite.java | 298 ----- .../templatesuite/models/AllTemplateModels.java | 128 -- .../templatesuite/models/BeanTestClass.java | 93 -- .../templatesuite/models/BeanTestInterface.java | 25 - .../models/BeanTestSuperclass.java | 30 - .../models/BooleanAndScalarModel.java | 40 - .../models/BooleanAndStringTemplateModel.java | 38 - .../test/templatesuite/models/BooleanHash1.java | 58 - .../test/templatesuite/models/BooleanHash2.java | 50 - .../test/templatesuite/models/BooleanList1.java | 62 - .../test/templatesuite/models/BooleanList2.java | 53 - .../models/BooleanVsStringMethods.java | 40 - .../templatesuite/models/EnumTestClass.java | 34 - .../templatesuite/models/ExceptionModel.java | 39 - .../models/HashAndScalarModel.java | 84 -- .../templatesuite/models/JavaObjectInfo.java | 35 - .../test/templatesuite/models/Listables.java | 185 --- .../test/templatesuite/models/MultiModel1.java | 116 -- .../test/templatesuite/models/MultiModel2.java | 63 - .../test/templatesuite/models/MultiModel3.java | 69 -- .../test/templatesuite/models/MultiModel4.java | 77 -- .../test/templatesuite/models/MultiModel5.java | 81 -- .../test/templatesuite/models/NewTestModel.java | 52 - .../templatesuite/models/NewTestModel2.java | 52 - .../models/NumberAndStringModel.java | 47 - .../models/OverloadedConstructor.java | 46 - .../templatesuite/models/OverloadedMethods.java | 191 --- .../models/OverloadedMethods2.java | 1110 ------------------ .../SimpleMapAndCollectionObjectWrapper.java | 60 - .../templatesuite/models/SimpleTestMethod.java | 49 - .../models/TransformHashWrapper.java | 79 -- .../models/TransformMethodWrapper1.java | 49 - .../models/TransformMethodWrapper2.java | 64 - .../templatesuite/models/TransformModel1.java | 175 --- .../templatesuite/models/VarArgTestModel.java | 63 - .../freemarker/test/templatesuite/package.html | 42 - .../core/templatesuite/expected/arithmetic.txt | 46 + .../expected/boolean-formatting.txt | 31 + .../core/templatesuite/expected/boolean.txt | 102 ++ .../expected/charset-in-header.txt | 26 + .../core/templatesuite/expected/comment.txt | 34 + .../core/templatesuite/expected/comparisons.txt | 93 ++ .../core/templatesuite/expected/compress.txt | 40 + .../templatesuite/expected/dateformat-java.txt | 55 + .../expected/default-object-wrapper.txt | 55 + .../templatesuite/expected/default-xmlns.txt | 25 + .../core/templatesuite/expected/default.txt | 26 + .../expected/encoding-builtins.txt | 44 + .../core/templatesuite/expected/escapes.txt | 49 + .../core/templatesuite/expected/exception.txt | 43 + .../core/templatesuite/expected/exception2.txt | 47 + .../core/templatesuite/expected/exception3.txt | 21 + .../core/templatesuite/expected/exthash.txt | 76 ++ .../core/templatesuite/expected/hashconcat.txt | 138 +++ .../core/templatesuite/expected/hashliteral.txt | 74 ++ .../core/templatesuite/expected/helloworld.txt | 31 + .../expected/identifier-escaping.txt | 57 + .../expected/identifier-non-ascii.txt | 19 + .../core/templatesuite/expected/if.txt | 104 ++ .../core/templatesuite/expected/import.txt | 40 + .../core/templatesuite/expected/include.txt | 67 ++ .../core/templatesuite/expected/include2.txt | 28 + .../core/templatesuite/expected/interpret.txt | 23 + .../core/templatesuite/expected/iterators.txt | 84 ++ .../templatesuite/expected/lastcharacter.txt | 31 + .../core/templatesuite/expected/list-bis.txt | 51 + .../core/templatesuite/expected/list.txt | 51 + .../core/templatesuite/expected/list2.txt | 211 ++++ .../core/templatesuite/expected/list3.txt | 57 + .../core/templatesuite/expected/listhash.txt | 157 +++ .../templatesuite/expected/listhashliteral.txt | 36 + .../core/templatesuite/expected/listliteral.txt | 75 ++ .../templatesuite/expected/localization.txt | 32 + .../core/templatesuite/expected/logging.txt | 27 + .../templatesuite/expected/loopvariable.txt | 54 + .../templatesuite/expected/macros-return.txt | 23 + .../core/templatesuite/expected/macros.txt | 67 ++ .../core/templatesuite/expected/macros2.txt | 22 + .../core/templatesuite/expected/multimodels.txt | 93 ++ .../core/templatesuite/expected/nested.txt | 25 + .../expected/new-allowsnothing.txt | 19 + .../expected/new-defaultresolver.txt | 19 + .../core/templatesuite/expected/new-optin.txt | 32 + .../core/templatesuite/expected/newlines1.txt | 29 + .../core/templatesuite/expected/newlines2.txt | 30 + .../core/templatesuite/expected/noparse.txt | 54 + .../templatesuite/expected/number-format.txt | 33 + .../templatesuite/expected/number-literal.txt | 79 ++ .../templatesuite/expected/number-to-date.txt | 31 + .../templatesuite/expected/numerical-cast.txt | 462 ++++++++ .../templatesuite/expected/output-encoding1.txt | 27 + .../templatesuite/expected/output-encoding2.txt | Bin 0 -> 1972 bytes .../templatesuite/expected/output-encoding3.txt | 26 + .../core/templatesuite/expected/precedence.txt | 48 + .../core/templatesuite/expected/recover.txt | 26 + .../core/templatesuite/expected/root.txt | 44 + .../expected/sequence-builtins.txt | 404 +++++++ .../core/templatesuite/expected/specialvars.txt | 25 + .../string-builtins-regexps-matches.txt | 99 ++ .../expected/string-builtins-regexps.txt | 112 ++ .../templatesuite/expected/string-builtins1.txt | 112 ++ .../templatesuite/expected/string-builtins2.txt | 135 +++ .../templatesuite/expected/stringbimethods.txt | 29 + .../templatesuite/expected/stringliteral.txt | Bin 0 -> 1550 bytes .../core/templatesuite/expected/switch.txt | 80 ++ .../core/templatesuite/expected/transforms.txt | 68 ++ .../templatesuite/expected/type-builtins.txt | 33 + .../core/templatesuite/expected/var-layers.txt | 37 + .../core/templatesuite/expected/varargs.txt | 44 + .../core/templatesuite/expected/variables.txt | 62 + .../templatesuite/expected/whitespace-trim.txt | 60 + .../templatesuite/expected/wstrip-in-header.txt | 23 + .../core/templatesuite/expected/wstripping.txt | 39 + .../templatesuite/expected/xml-fragment.txt | 25 + .../expected/xml-ns_prefix-scope.txt | 29 + .../core/templatesuite/expected/xml.txt | 65 + .../core/templatesuite/expected/xmlns1.txt | 63 + .../core/templatesuite/expected/xmlns3.txt | 47 + .../core/templatesuite/expected/xmlns4.txt | 47 + .../core/templatesuite/expected/xmlns5.txt | 26 + .../models/BeansTestResources.properties | 19 + .../core/templatesuite/models/defaultxmlns1.xml | 24 + .../models/xml-ns_prefix-scope.xml | 26 + .../core/templatesuite/models/xml.xml | 31 + .../core/templatesuite/models/xmlfragment.xml | 19 + .../core/templatesuite/models/xmlns.xml | 32 + .../core/templatesuite/models/xmlns2.xml | 32 + .../core/templatesuite/models/xmlns3.xml | 32 + .../templatesuite/templates/api-builtins.ftl | 40 + .../core/templatesuite/templates/arithmetic.ftl | 50 + .../templatesuite/templates/assignments.ftl | 108 ++ .../templates/boolean-formatting.ftl | 82 ++ .../core/templatesuite/templates/boolean.ftl | 142 +++ .../templates/charset-in-header.ftl | 27 + .../templates/charset-in-header_inc1.ftl | 20 + .../templates/charset-in-header_inc2.ftl | 19 + .../core/templatesuite/templates/comment.ftl | 50 + .../templatesuite/templates/comparisons.ftl | 218 ++++ .../core/templatesuite/templates/compress.ftl | 59 + .../templates/date-type-builtins.ftl | 47 + .../templates/dateformat-iso-bi.ftl | 163 +++ .../templates/dateformat-iso-like.ftl | 155 +++ .../templatesuite/templates/dateformat-java.ftl | 71 ++ .../templatesuite/templates/dateparsing.ftl | 84 ++ .../templates/default-object-wrapper.ftl | 59 + .../templatesuite/templates/default-xmlns.ftl | 28 + .../core/templatesuite/templates/default.ftl | 34 + .../templates/encoding-builtins.ftl | 52 + .../core/templatesuite/templates/escapes.ftl | 79 ++ .../core/templatesuite/templates/exception.ftl | 31 + .../core/templatesuite/templates/exception2.ftl | 31 + .../core/templatesuite/templates/exception3.ftl | 31 + .../templates/existence-operators.ftl | 141 +++ .../core/templatesuite/templates/hashconcat.ftl | 60 + .../templatesuite/templates/hashliteral.ftl | 100 ++ .../core/templatesuite/templates/helloworld.ftl | 30 + .../templates/identifier-escaping.ftl | 81 ++ .../templates/identifier-non-ascii.ftl | 21 + .../core/templatesuite/templates/if.ftl | 109 ++ .../core/templatesuite/templates/import.ftl | 45 + .../core/templatesuite/templates/import_lib.ftl | 31 + .../core/templatesuite/templates/include.ftl | 47 + .../templates/include2-included.ftl | 19 + .../core/templatesuite/templates/include2.ftl | 32 + .../core/templatesuite/templates/included.ftl | 30 + .../core/templatesuite/templates/interpret.ftl | 25 + .../core/templatesuite/templates/iterators.ftl | 71 ++ .../templatesuite/templates/lastcharacter.ftl | 31 + .../core/templatesuite/templates/list-bis.ftl | 48 + .../core/templatesuite/templates/list.ftl | 44 + .../core/templatesuite/templates/list2.ftl | 90 ++ .../core/templatesuite/templates/list3.ftl | 70 ++ .../core/templatesuite/templates/listhash.ftl | 70 ++ .../templatesuite/templates/listhashliteral.ftl | 35 + .../templatesuite/templates/listliteral.ftl | 84 ++ .../templatesuite/templates/localization.ftl | 32 + .../templatesuite/templates/localization_en.ftl | 32 + .../templates/localization_en_AU.ftl | 32 + .../core/templatesuite/templates/logging.ftl | 42 + .../templatesuite/templates/loopvariable.ftl | 49 + .../templatesuite/templates/macros-return.ftl | 34 + .../core/templatesuite/templates/macros.ftl | 101 ++ .../core/templatesuite/templates/macros2.ftl | 35 + .../templatesuite/templates/multimodels.ftl | 84 ++ .../core/templatesuite/templates/nested.ftl | 29 + .../templatesuite/templates/nestedinclude.ftl | 21 + .../templates/new-defaultresolver.ftl | 23 + .../core/templatesuite/templates/new-optin.ftl | 30 + .../core/templatesuite/templates/newlines1.ftl | 29 + .../core/templatesuite/templates/newlines2.ftl | 33 + .../core/templatesuite/templates/noparse.ftl | 62 + .../templatesuite/templates/number-format.ftl | 42 + .../templatesuite/templates/number-literal.ftl | 133 +++ .../templates/number-math-builtins.ftl | 78 ++ .../templatesuite/templates/number-to-date.ftl | 35 + .../templatesuite/templates/numerical-cast.ftl | 82 ++ .../templates/output-encoding1.ftl | 30 + .../templates/output-encoding2.ftl | 28 + .../templates/output-encoding3.ftl | 28 + .../templates/overloaded-methods.ftl | 411 +++++++ .../core/templatesuite/templates/precedence.ftl | 61 + .../templatesuite/templates/range-common.ftl | 314 +++++ .../core/templatesuite/templates/range.ftl | 50 + .../core/templatesuite/templates/recover.ftl | 47 + .../core/templatesuite/templates/root.ftl | 47 + .../templates/sequence-builtins.ftl | 360 ++++++ .../core/templatesuite/templates/setting.ftl | 53 + .../templates/simplehash-char-key.ftl | 44 + .../templatesuite/templates/specialvars.ftl | 38 + .../templates/string-builtin-coercion.ftl | 34 + .../string-builtins-regexps-matches.ftl | 118 ++ .../templates/string-builtins-regexps.ftl | 136 +++ .../templates/string-builtins1.ftl | 129 ++ .../templates/string-builtins2.ftl | 135 +++ .../templates/string-builtins3.ftl | 225 ++++ .../templatesuite/templates/stringbimethods.ftl | 36 + .../templatesuite/templates/stringliteral.ftl | 69 ++ .../templates/subdir/include-subdir.ftl | 27 + .../templates/subdir/include-subdir2.ftl | 19 + .../templates/subdir/new-optin-2.ftl | 24 + .../templates/subdir/new-optin.ftl | 26 + .../templates/subdir/subsub/new-optin.ftl | 24 + .../templatesuite/templates/switch-builtin.ftl | 54 + .../core/templatesuite/templates/switch.ftl | 139 +++ .../templatesuite/templates/then-builtin.ftl | 53 + .../core/templatesuite/templates/transforms.ftl | 100 ++ .../templatesuite/templates/type-builtins.ftl | 44 + .../core/templatesuite/templates/undefined.ftl | 19 + .../core/templatesuite/templates/url.ftl | 24 + .../core/templatesuite/templates/var-layers.ftl | 39 + .../core/templatesuite/templates/varargs.ftl | 45 + .../core/templatesuite/templates/variables.ftl | 70 ++ .../templatesuite/templates/varlayers_lib.ftl | 28 + .../templatesuite/templates/whitespace-trim.ftl | 102 ++ .../templates/wsstripinheader_inc.ftl | 22 + .../templates/wstrip-in-header.ftl | 26 + .../templatesuite/templates/xml-fragment.ftl | 26 + .../templates/xml-ns_prefix-scope-lib.ftl | 23 + .../templates/xml-ns_prefix-scope-main.ftl | 36 + .../core/templatesuite/templates/xml.ftl | 47 + .../core/templatesuite/templates/xmlns1.ftl | 53 + .../core/templatesuite/templates/xmlns3.ftl | 70 ++ .../core/templatesuite/templates/xmlns4.ftl | 70 ++ .../core/templatesuite/templates/xmlns5.ftl | 28 + .../freemarker/core/templatesuite/testcases.xml | 211 ++++ .../test/templatesuite/expected/arithmetic.txt | 46 - .../expected/boolean-formatting.txt | 31 - .../test/templatesuite/expected/boolean.txt | 102 -- .../expected/charset-in-header.txt | 26 - .../test/templatesuite/expected/comment.txt | 34 - .../test/templatesuite/expected/comparisons.txt | 93 -- .../test/templatesuite/expected/compress.txt | 40 - .../templatesuite/expected/dateformat-java.txt | 55 - .../expected/default-object-wrapper.txt | 55 - .../templatesuite/expected/default-xmlns.txt | 25 - .../test/templatesuite/expected/default.txt | 26 - .../expected/encoding-builtins.txt | 44 - .../test/templatesuite/expected/escapes.txt | 49 - .../test/templatesuite/expected/exception.txt | 43 - .../test/templatesuite/expected/exception2.txt | 47 - .../test/templatesuite/expected/exception3.txt | 21 - .../test/templatesuite/expected/exthash.txt | 76 -- .../test/templatesuite/expected/hashconcat.txt | 138 --- .../test/templatesuite/expected/hashliteral.txt | 74 -- .../test/templatesuite/expected/helloworld.txt | 31 - .../expected/identifier-escaping.txt | 57 - .../expected/identifier-non-ascii.txt | 19 - .../test/templatesuite/expected/if.txt | 104 -- .../test/templatesuite/expected/import.txt | 40 - .../test/templatesuite/expected/include.txt | 67 -- .../test/templatesuite/expected/include2.txt | 28 - .../test/templatesuite/expected/interpret.txt | 23 - .../test/templatesuite/expected/iterators.txt | 84 -- .../templatesuite/expected/lastcharacter.txt | 31 - .../test/templatesuite/expected/list-bis.txt | 51 - .../test/templatesuite/expected/list.txt | 51 - .../test/templatesuite/expected/list2.txt | 211 ---- .../test/templatesuite/expected/list3.txt | 57 - .../test/templatesuite/expected/listhash.txt | 157 --- .../templatesuite/expected/listhashliteral.txt | 36 - .../test/templatesuite/expected/listliteral.txt | 75 -- .../templatesuite/expected/localization.txt | 32 - .../test/templatesuite/expected/logging.txt | 27 - .../templatesuite/expected/loopvariable.txt | 54 - .../templatesuite/expected/macros-return.txt | 23 - .../test/templatesuite/expected/macros.txt | 67 -- .../test/templatesuite/expected/macros2.txt | 22 - .../test/templatesuite/expected/multimodels.txt | 93 -- .../test/templatesuite/expected/nested.txt | 25 - .../expected/new-allowsnothing.txt | 19 - .../expected/new-defaultresolver.txt | 19 - .../test/templatesuite/expected/new-optin.txt | 32 - .../test/templatesuite/expected/newlines1.txt | 29 - .../test/templatesuite/expected/newlines2.txt | 30 - .../test/templatesuite/expected/noparse.txt | 54 - .../templatesuite/expected/number-format.txt | 33 - .../templatesuite/expected/number-literal.txt | 79 -- .../templatesuite/expected/number-to-date.txt | 31 - .../templatesuite/expected/numerical-cast.txt | 462 -------- .../templatesuite/expected/output-encoding1.txt | 27 - .../templatesuite/expected/output-encoding2.txt | Bin 1972 -> 0 bytes .../templatesuite/expected/output-encoding3.txt | 26 - .../test/templatesuite/expected/precedence.txt | 48 - .../test/templatesuite/expected/recover.txt | 26 - .../test/templatesuite/expected/root.txt | 44 - .../expected/sequence-builtins.txt | 404 ------- .../test/templatesuite/expected/specialvars.txt | 25 - .../string-builtins-regexps-matches.txt | 99 -- .../expected/string-builtins-regexps.txt | 112 -- .../templatesuite/expected/string-builtins1.txt | 112 -- .../templatesuite/expected/string-builtins2.txt | 135 --- .../templatesuite/expected/stringbimethods.txt | 29 - .../templatesuite/expected/stringliteral.txt | Bin 1550 -> 0 bytes .../test/templatesuite/expected/switch.txt | 80 -- .../test/templatesuite/expected/transforms.txt | 68 -- .../templatesuite/expected/type-builtins.txt | 33 - .../test/templatesuite/expected/var-layers.txt | 37 - .../test/templatesuite/expected/varargs.txt | 44 - .../test/templatesuite/expected/variables.txt | 62 - .../templatesuite/expected/whitespace-trim.txt | 60 - .../templatesuite/expected/wstrip-in-header.txt | 23 - .../test/templatesuite/expected/wstripping.txt | 39 - .../templatesuite/expected/xml-fragment.txt | 25 - .../expected/xml-ns_prefix-scope.txt | 29 - .../test/templatesuite/expected/xml.txt | 65 - .../test/templatesuite/expected/xmlns1.txt | 63 - .../test/templatesuite/expected/xmlns3.txt | 47 - .../test/templatesuite/expected/xmlns4.txt | 47 - .../test/templatesuite/expected/xmlns5.txt | 26 - .../models/BeansTestResources.properties | 19 - .../test/templatesuite/models/defaultxmlns1.xml | 24 - .../models/xml-ns_prefix-scope.xml | 26 - .../test/templatesuite/models/xml.xml | 31 - .../test/templatesuite/models/xmlfragment.xml | 19 - .../test/templatesuite/models/xmlns.xml | 32 - .../test/templatesuite/models/xmlns2.xml | 32 - .../test/templatesuite/models/xmlns3.xml | 32 - .../templatesuite/templates/api-builtins.ftl | 40 - .../test/templatesuite/templates/arithmetic.ftl | 50 - .../templatesuite/templates/assignments.ftl | 108 -- .../templates/boolean-formatting.ftl | 82 -- .../test/templatesuite/templates/boolean.ftl | 142 --- .../templates/charset-in-header.ftl | 27 - .../templates/charset-in-header_inc1.ftl | 20 - .../templates/charset-in-header_inc2.ftl | 19 - .../test/templatesuite/templates/comment.ftl | 50 - .../templatesuite/templates/comparisons.ftl | 218 ---- .../test/templatesuite/templates/compress.ftl | 59 - .../templates/date-type-builtins.ftl | 47 - .../templates/dateformat-iso-bi.ftl | 163 --- .../templates/dateformat-iso-like.ftl | 155 --- .../templatesuite/templates/dateformat-java.ftl | 71 -- .../templatesuite/templates/dateparsing.ftl | 84 -- .../templates/default-object-wrapper.ftl | 59 - .../templatesuite/templates/default-xmlns.ftl | 28 - .../test/templatesuite/templates/default.ftl | 34 - .../templates/encoding-builtins.ftl | 52 - .../test/templatesuite/templates/escapes.ftl | 79 -- .../test/templatesuite/templates/exception.ftl | 31 - .../test/templatesuite/templates/exception2.ftl | 31 - .../test/templatesuite/templates/exception3.ftl | 31 - .../templates/existence-operators.ftl | 141 --- .../test/templatesuite/templates/hashconcat.ftl | 60 - .../templatesuite/templates/hashliteral.ftl | 100 -- .../test/templatesuite/templates/helloworld.ftl | 30 - .../templates/identifier-escaping.ftl | 81 -- .../templates/identifier-non-ascii.ftl | 21 - .../test/templatesuite/templates/if.ftl | 109 -- .../test/templatesuite/templates/import.ftl | 45 - .../test/templatesuite/templates/import_lib.ftl | 31 - .../test/templatesuite/templates/include.ftl | 47 - .../templates/include2-included.ftl | 19 - .../test/templatesuite/templates/include2.ftl | 32 - .../test/templatesuite/templates/included.ftl | 30 - .../test/templatesuite/templates/interpret.ftl | 25 - .../test/templatesuite/templates/iterators.ftl | 71 -- .../templatesuite/templates/lastcharacter.ftl | 31 - .../test/templatesuite/templates/list-bis.ftl | 48 - .../test/templatesuite/templates/list.ftl | 44 - .../test/templatesuite/templates/list2.ftl | 90 -- .../test/templatesuite/templates/list3.ftl | 70 -- .../test/templatesuite/templates/listhash.ftl | 70 -- .../templatesuite/templates/listhashliteral.ftl | 35 - .../templatesuite/templates/listliteral.ftl | 84 -- .../templatesuite/templates/localization.ftl | 32 - .../templatesuite/templates/localization_en.ftl | 32 - .../templates/localization_en_AU.ftl | 32 - .../test/templatesuite/templates/logging.ftl | 42 - .../templatesuite/templates/loopvariable.ftl | 49 - .../templatesuite/templates/macros-return.ftl | 34 - .../test/templatesuite/templates/macros.ftl | 101 -- .../test/templatesuite/templates/macros2.ftl | 35 - .../templatesuite/templates/multimodels.ftl | 84 -- .../test/templatesuite/templates/nested.ftl | 29 - .../templatesuite/templates/nestedinclude.ftl | 21 - .../templates/new-defaultresolver.ftl | 23 - .../test/templatesuite/templates/new-optin.ftl | 30 - .../test/templatesuite/templates/newlines1.ftl | 29 - .../test/templatesuite/templates/newlines2.ftl | 33 - .../test/templatesuite/templates/noparse.ftl | 62 - .../templatesuite/templates/number-format.ftl | 42 - .../templatesuite/templates/number-literal.ftl | 133 --- .../templates/number-math-builtins.ftl | 78 -- .../templatesuite/templates/number-to-date.ftl | 35 - .../templatesuite/templates/numerical-cast.ftl | 82 -- .../templates/output-encoding1.ftl | 30 - .../templates/output-encoding2.ftl | 28 - .../templates/output-encoding3.ftl | 28 - .../templates/overloaded-methods.ftl | 411 ------- .../test/templatesuite/templates/precedence.ftl | 61 - .../templatesuite/templates/range-common.ftl | 314 ----- .../test/templatesuite/templates/range.ftl | 50 - .../test/templatesuite/templates/recover.ftl | 47 - .../test/templatesuite/templates/root.ftl | 47 - .../templates/sequence-builtins.ftl | 360 ------ .../test/templatesuite/templates/setting.ftl | 53 - .../templates/simplehash-char-key.ftl | 44 - .../templatesuite/templates/specialvars.ftl | 38 - .../templates/string-builtin-coercion.ftl | 34 - .../string-builtins-regexps-matches.ftl | 118 -- .../templates/string-builtins-regexps.ftl | 136 --- .../templates/string-builtins1.ftl | 129 -- .../templates/string-builtins2.ftl | 135 --- .../templates/string-builtins3.ftl | 225 ---- .../templatesuite/templates/stringbimethods.ftl | 36 - .../templatesuite/templates/stringliteral.ftl | 69 -- .../templates/subdir/include-subdir.ftl | 27 - .../templates/subdir/include-subdir2.ftl | 19 - .../templates/subdir/new-optin-2.ftl | 24 - .../templates/subdir/new-optin.ftl | 26 - .../templates/subdir/subsub/new-optin.ftl | 24 - .../templatesuite/templates/switch-builtin.ftl | 54 - .../test/templatesuite/templates/switch.ftl | 139 --- .../templatesuite/templates/then-builtin.ftl | 53 - .../test/templatesuite/templates/transforms.ftl | 100 -- .../templatesuite/templates/type-builtins.ftl | 44 - .../test/templatesuite/templates/undefined.ftl | 19 - .../test/templatesuite/templates/url.ftl | 24 - .../test/templatesuite/templates/var-layers.ftl | 39 - .../test/templatesuite/templates/varargs.ftl | 45 - .../test/templatesuite/templates/variables.ftl | 70 -- .../templatesuite/templates/varlayers_lib.ftl | 28 - .../templatesuite/templates/whitespace-trim.ftl | 102 -- .../templates/wsstripinheader_inc.ftl | 22 - .../templates/wstrip-in-header.ftl | 26 - .../templatesuite/templates/xml-fragment.ftl | 26 - .../templates/xml-ns_prefix-scope-lib.ftl | 23 - .../templates/xml-ns_prefix-scope-main.ftl | 36 - .../test/templatesuite/templates/xml.ftl | 47 - .../test/templatesuite/templates/xmlns1.ftl | 53 - .../test/templatesuite/templates/xmlns3.ftl | 70 -- .../test/templatesuite/templates/xmlns4.ftl | 70 -- .../test/templatesuite/templates/xmlns5.ftl | 28 - .../freemarker/test/templatesuite/testcases.xml | 211 ---- freemarker-core/build.gradle | 8 - .../freemarker/test/TemplateTestCase.java | 194 +++ .../freemarker/test/TemplateTestSuite.java | 332 ++++++ 501 files changed, 17535 insertions(+), 17506 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/build.gradle ---------------------------------------------------------------------- diff --git a/build.gradle b/build.gradle index d9d7f7f..33fe1bf 100644 --- a/build.gradle +++ b/build.gradle @@ -276,4 +276,4 @@ subprojects { } } -} // end subprojects \ No newline at end of file +} // end subprojects http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/build.gradle ---------------------------------------------------------------------- diff --git a/freemarker-core-test/build.gradle b/freemarker-core-test/build.gradle index 411f6ea..1edfe8f 100644 --- a/freemarker-core-test/build.gradle +++ b/freemarker-core-test/build.gradle @@ -5,6 +5,13 @@ through freemarker-test-utils, they had to be moved into a separate project.""" dependencies { compile project(":freemarker-core") compile project(":freemarker-test-utils") + + testRuntime "jaxen:jaxen:1.0-FCS" + testRuntime "saxpath:saxpath:1.0-FCS" + testRuntime("xalan:xalan:2.7.0") { + // xml-apis is part of Java SE since version 1.4: + exclude group: "xml-apis", module: "xml-apis" + } } // We have nothing to put into the jar, as we have test classes only http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/java/org/apache/freemarker/core/ListErrorsTest.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/ListErrorsTest.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/ListErrorsTest.java index 05bac4f..67d8f59 100644 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/ListErrorsTest.java +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/ListErrorsTest.java @@ -23,7 +23,7 @@ import java.io.IOException; import org.apache.freemarker.core.model.impl.DefaultObjectWrapper; import org.apache.freemarker.test.TemplateTest; -import org.apache.freemarker.test.templatesuite.models.Listables; +import org.apache.freemarker.core.templatesuite.models.Listables; import org.junit.Test; import com.google.common.collect.ImmutableMap; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/java/org/apache/freemarker/core/NewBiObjectWrapperRestrictionTest.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/NewBiObjectWrapperRestrictionTest.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/NewBiObjectWrapperRestrictionTest.java index 506101d..a90e28b 100644 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/NewBiObjectWrapperRestrictionTest.java +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/NewBiObjectWrapperRestrictionTest.java @@ -50,14 +50,14 @@ public class NewBiObjectWrapperRestrictionTest extends TemplateTest { @Test public void testPositive() throws IOException, TemplateException { assertOutput( - "${'org.apache.freemarker.test.templatesuite.models.NewTestModel'?new()}", + "${'org.apache.freemarker.core.templatesuite.models.NewTestModel'?new()}", "default constructor"); } @Test public void testNegative() { assertErrorContains( - "${'org.apache.freemarker.test.templatesuite.models.NewTestModel'?new('s')}", + "${'org.apache.freemarker.core.templatesuite.models.NewTestModel'?new('s')}", "only supports 0 argument"); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/CoreTemplateTestSuite.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/CoreTemplateTestSuite.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/CoreTemplateTestSuite.java new file mode 100644 index 0000000..b49c213 --- /dev/null +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/CoreTemplateTestSuite.java @@ -0,0 +1,282 @@ +package org.apache.freemarker.core.templatesuite; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.Set; +import java.util.TimeZone; +import java.util.TreeSet; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.apache.freemarker.core.ASTPrinter; +import org.apache.freemarker.core.Configuration; +import org.apache.freemarker.core.Template; +import org.apache.freemarker.core.model.TemplateBooleanModel; +import org.apache.freemarker.core.model.TemplateDateModel; +import org.apache.freemarker.core.model.impl.DefaultNonListCollectionAdapter; +import org.apache.freemarker.core.model.impl.DefaultObjectWrapper; +import org.apache.freemarker.core.model.impl.ResourceBundleModel; +import org.apache.freemarker.core.model.impl.SimpleCollection; +import org.apache.freemarker.core.model.impl.SimpleDate; +import org.apache.freemarker.core.model.impl.SimpleNumber; +import org.apache.freemarker.core.templatesuite.models.BooleanAndStringTemplateModel; +import org.apache.freemarker.core.templatesuite.models.BooleanHash1; +import org.apache.freemarker.core.templatesuite.models.BooleanHash2; +import org.apache.freemarker.core.templatesuite.models.BooleanList1; +import org.apache.freemarker.core.templatesuite.models.BooleanList2; +import org.apache.freemarker.core.templatesuite.models.BooleanVsStringMethods; +import org.apache.freemarker.core.templatesuite.models.JavaObjectInfo; +import org.apache.freemarker.core.templatesuite.models.Listables; +import org.apache.freemarker.core.templatesuite.models.MultiModel1; +import org.apache.freemarker.core.templatesuite.models.OverloadedMethods2; +import org.apache.freemarker.core.templatesuite.models.TestBean; +import org.apache.freemarker.core.templatesuite.models.TestBoolean; +import org.apache.freemarker.core.templatesuite.models.TestMethod; +import org.apache.freemarker.core.templatesuite.models.TestNode; +import org.apache.freemarker.core.templatesuite.models.VarArgTestModel; +import org.apache.freemarker.dom.NodeModel; +import org.apache.freemarker.test.TemplateTestSuite; +import org.apache.freemarker.test.XMLLoader; +import org.xml.sax.InputSource; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; + +import junit.framework.TestSuite; + +public class CoreTemplateTestSuite extends TemplateTestSuite { + + private final DefaultObjectWrapper dow = new DefaultObjectWrapper.Builder(Configuration.VERSION_3_0_0).build(); + + /** + * Required for the suite to be detected and run by build tools and IDE-s. + */ + public static TestSuite suite() { + return new CoreTemplateTestSuite(); + } + + @Override + protected void setUpTestCase(String simpleTestName, Map<String, Object> dataModel, + Configuration.ExtendableBuilder<?> confB) throws Exception { + dataModel.put("message", "Hello, world!"); + dataModel.put("javaObjectInfo", JavaObjectInfo.INSTANCE); + + if (simpleTestName.startsWith("api-builtin")) { + dataModel.put("map", ImmutableMap.of(1, "a", 2, "b", 3, "c")); + dataModel.put("list", ImmutableList.of(1, 2, 3)); + dataModel.put("set", ImmutableSet.of("a", "b", "c")); + dataModel.put("s", "test"); + } else if (simpleTestName.equals("default-object-wrapper")) { + dataModel.put("array", new String[] { "array-0", "array-1"}); + dataModel.put("list", Arrays.asList("list-0", "list-1", "list-2")); + Map<Object, Object> tmap = new HashMap<>(); + tmap.put("key", "value"); + Object objKey = new Object(); + tmap.put(objKey, "objValue"); + dataModel.put("map", tmap); + dataModel.put("objKey", objKey); + dataModel.put("obj", new org.apache.freemarker.core.templatesuite.models.BeanTestClass()); + dataModel.put("resourceBundle", + new ResourceBundleModel(ResourceBundle.getBundle( + "org.apache.freemarker.core.templatesuite.models.BeansTestResources"), dow)); + dataModel.put("date", new GregorianCalendar(1974, 10, 14).getTime()); + dataModel.put("statics", dow.getStaticModels()); + dataModel.put("enums", dow.getEnumModels()); + } else if (simpleTestName.equals("boolean")) { + dataModel.put( "boolean1", TemplateBooleanModel.FALSE); + dataModel.put( "boolean2", TemplateBooleanModel.TRUE); + dataModel.put( "boolean3", TemplateBooleanModel.TRUE); + dataModel.put( "boolean4", TemplateBooleanModel.TRUE); + dataModel.put( "boolean5", TemplateBooleanModel.FALSE); + + dataModel.put( "list1", new BooleanList1(dow) ); + dataModel.put( "list2", new BooleanList2(dow) ); + + dataModel.put( "hash1", new BooleanHash1() ); + dataModel.put( "hash2", new BooleanHash2() ); + } else if (simpleTestName.startsWith("dateformat")) { + GregorianCalendar cal = new GregorianCalendar(2002, 10, 15, 14, 54, 13); + cal.setTimeZone(TimeZone.getTimeZone("GMT")); + dataModel.put("date", new SimpleDate(cal.getTime(), TemplateDateModel.DATETIME)); + dataModel.put("unknownDate", new SimpleDate(cal.getTime(), TemplateDateModel.UNKNOWN)); + dataModel.put("javaGMT02", TimeZone.getTimeZone("GMT+02")); + dataModel.put("javaUTC", TimeZone.getTimeZone("UTC")); + dataModel.put("adaptedToStringScalar", new Object() { + @Override + public String toString() { + return "GMT+02"; + } + }); + dataModel.put("sqlDate", new java.sql.Date(1273955885023L)); + dataModel.put("sqlTime", new java.sql.Time(74285023L)); + } else if (simpleTestName.startsWith("list-") || simpleTestName.startsWith("list[") + || simpleTestName.startsWith("list2[") || simpleTestName.startsWith("list3[") + || simpleTestName.equals("listhash")) { + dataModel.put("listables", new Listables()); + } else if (simpleTestName.startsWith("number-format")) { + dataModel.put("int", new SimpleNumber(Integer.valueOf(1))); + dataModel.put("double", new SimpleNumber(Double.valueOf(1.0))); + dataModel.put("double2", new SimpleNumber(Double.valueOf(1 + 1e-15))); + dataModel.put("double3", new SimpleNumber(Double.valueOf(1e-16))); + dataModel.put("double4", new SimpleNumber(Double.valueOf(-1e-16))); + dataModel.put("bigDecimal", new SimpleNumber(java.math.BigDecimal.valueOf(1))); + dataModel.put("bigDecimal2", new SimpleNumber(java.math.BigDecimal.valueOf(1, 16))); + } else if (simpleTestName.equals("simplehash-char-key")) { + HashMap<String, String> mStringC = new HashMap<>(); + mStringC.put("c", "string"); + dataModel.put("mStringC", mStringC); + + HashMap<String, String> mStringCNull = new HashMap<>(); + mStringCNull.put("c", null); + dataModel.put("mStringCNull", mStringCNull); + + HashMap<Character, String> mCharC = new HashMap<>(); + mCharC.put(Character.valueOf('c'), "char"); + dataModel.put("mCharC", mCharC); + + HashMap<String, String> mCharCNull = new HashMap<>(); + mCharCNull.put("c", null); + dataModel.put("mCharCNull", mCharCNull); + + HashMap<Object, String> mMixed = new HashMap<>(); + mMixed.put(Character.valueOf('c'), "char"); + mMixed.put("s", "string"); + mMixed.put("s2", "string2"); + mMixed.put("s2n", null); + dataModel.put("mMixed", mMixed); + } else if (simpleTestName.equals("default-xmlns")) { + InputSource is = new InputSource(getClass().getResourceAsStream("models/defaultxmlns1.xml")); + NodeModel nm = XMLLoader.toModel(is); + dataModel.put("doc", nm); + } else if (simpleTestName.equals("multimodels")) { + dataModel.put("test", "selftest"); + dataModel.put("self", "self"); + dataModel.put("zero", Integer.valueOf(0)); + dataModel.put("data", new MultiModel1()); + } else if (simpleTestName.equals("stringbimethods")) { + dataModel.put("multi", new TestBoolean()); + } else if (simpleTestName.startsWith("type-builtins")) { + dataModel.put("testmethod", new TestMethod()); + dataModel.put("testnode", new TestNode()); + dataModel.put("testcollection", new SimpleCollection(new ArrayList<>(), dow)); + dataModel.put("testcollectionEx", DefaultNonListCollectionAdapter.adapt(new HashSet<>(), dow)); + dataModel.put("bean", new TestBean()); + } else if (simpleTestName.equals("date-type-builtins")) { + GregorianCalendar cal = new GregorianCalendar(2003, 4 - 1, 5, 6, 7, 8); + cal.setTimeZone(TimeZone.getTimeZone("UTC")); + Date d = cal.getTime(); + dataModel.put("unknown", d); + dataModel.put("timeOnly", new java.sql.Time(d.getTime())); + dataModel.put("dateOnly", new java.sql.Date(d.getTime())); + dataModel.put("dateTime", new java.sql.Timestamp(d.getTime())); + } else if (simpleTestName.equals("var-layers")) { + dataModel.put("x", Integer.valueOf(4)); + dataModel.put("z", Integer.valueOf(4)); + confB.setSharedVariable("y", Integer.valueOf(7)); + } else if (simpleTestName.equals("xml-fragment")) { + DocumentBuilderFactory f = DocumentBuilderFactory.newInstance(); + f.setNamespaceAware(true); + DocumentBuilder db = f.newDocumentBuilder(); + org.w3c.dom.Document doc = db.parse(new InputSource(getClass().getResourceAsStream("models/xmlfragment.xml"))); + NodeModel.simplify(doc); + dataModel.put("node", NodeModel.wrap(doc.getDocumentElement().getFirstChild().getFirstChild())); + } else if (simpleTestName.equals("xmlns1")) { + InputSource is = new InputSource(getClass().getResourceAsStream("models/xmlns.xml")); + NodeModel nm = XMLLoader.toModel(is); + dataModel.put("doc", nm); + } else if (simpleTestName.equals("xmlns2")) { + InputSource is = new InputSource(getClass().getResourceAsStream("models/xmlns2.xml")); + NodeModel nm = XMLLoader.toModel(is); + dataModel.put("doc", nm); + } else if (simpleTestName.equals("xmlns3") || simpleTestName.equals("xmlns4")) { + InputSource is = new InputSource(getClass().getResourceAsStream("models/xmlns3.xml")); + NodeModel nm = XMLLoader.toModel(is); + dataModel.put("doc", nm); + } else if (simpleTestName.equals("xmlns5")) { + InputSource is = new InputSource(getClass().getResourceAsStream("models/defaultxmlns1.xml")); + NodeModel nm = XMLLoader.toModel(is); + dataModel.put("doc", nm); + } else if (simpleTestName.equals("xml-ns_prefix-scope")) { + InputSource is = new InputSource(getClass().getResourceAsStream("models/xml-ns_prefix-scope.xml")); + NodeModel nm = XMLLoader.toModel(is); + dataModel.put("doc", nm); + } else if (simpleTestName.startsWith("sequence-builtins")) { + Set<String> abcSet = new TreeSet<>(); + abcSet.add("a"); + abcSet.add("b"); + abcSet.add("c"); + dataModel.put("abcSet", abcSet); + dataModel.put("abcSetNonSeq", DefaultNonListCollectionAdapter.adapt(abcSet, dow)); + + List<String> listWithNull = new ArrayList<>(); + listWithNull.add("a"); + listWithNull.add(null); + listWithNull.add("c"); + dataModel.put("listWithNull", listWithNull); + + List<String> listWithNullsOnly = new ArrayList<>(); + listWithNull.add(null); + listWithNull.add(null); + listWithNull.add(null); + dataModel.put("listWithNullsOnly", listWithNullsOnly); + + dataModel.put("abcCollection", new SimpleCollection(abcSet, dow)); + + Set<String> set = new HashSet<>(); + set.add("a"); + set.add("b"); + set.add("c"); + dataModel.put("set", set); + } else if (simpleTestName.equals("number-to-date")) { + dataModel.put("bigInteger", new BigInteger("1305575275540")); + dataModel.put("bigDecimal", new BigDecimal("1305575275539.5")); + } else if (simpleTestName.equals("varargs")) { + dataModel.put("m", new VarArgTestModel()); + } else if (simpleTestName.startsWith("boolean-formatting")) { + dataModel.put("booleanAndString", new BooleanAndStringTemplateModel()); + dataModel.put("booleanVsStringMethods", new BooleanVsStringMethods()); + } else if (simpleTestName.startsWith("number-math-builtins")) { + dataModel.put("fNan", Float.valueOf(Float.NaN)); + dataModel.put("dNan", Double.valueOf(Double.NaN)); + dataModel.put("fNinf", Float.valueOf(Float.NEGATIVE_INFINITY)); + dataModel.put("dPinf", Double.valueOf(Double.POSITIVE_INFINITY)); + + dataModel.put("fn", Float.valueOf(-0.05f)); + dataModel.put("dn", Double.valueOf(-0.05)); + dataModel.put("ineg", Integer.valueOf(-5)); + dataModel.put("ln", Long.valueOf(-5)); + dataModel.put("sn", Short.valueOf((short) -5)); + dataModel.put("bn", Byte.valueOf((byte) -5)); + dataModel.put("bin", BigInteger.valueOf(5)); + dataModel.put("bdn", BigDecimal.valueOf(-0.05)); + + dataModel.put("fp", Float.valueOf(0.05f)); + dataModel.put("dp", Double.valueOf(0.05)); + dataModel.put("ip", Integer.valueOf(5)); + dataModel.put("lp", Long.valueOf(5)); + dataModel.put("sp", Short.valueOf((short) 5)); + dataModel.put("bp", Byte.valueOf((byte) 5)); + dataModel.put("bip", BigInteger.valueOf(5)); + dataModel.put("bdp", BigDecimal.valueOf(0.05)); + } else if (simpleTestName.startsWith("overloaded-methods")) { + dataModel.put("obj", new OverloadedMethods2()); + } + } + + @Override + protected void validateTemplate(Template template) { + ASTPrinter.validateAST(template); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/AllTemplateModels.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/AllTemplateModels.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/AllTemplateModels.java new file mode 100644 index 0000000..d656a6b --- /dev/null +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/AllTemplateModels.java @@ -0,0 +1,128 @@ +/* + * 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.core.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/4b75ea93/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BeanTestClass.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BeanTestClass.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BeanTestClass.java new file mode 100644 index 0000000..88541ae --- /dev/null +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BeanTestClass.java @@ -0,0 +1,93 @@ +/* + * 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.core.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/4b75ea93/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BeanTestInterface.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BeanTestInterface.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BeanTestInterface.java new file mode 100644 index 0000000..291b0cd --- /dev/null +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BeanTestInterface.java @@ -0,0 +1,25 @@ +/* + * 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.core.templatesuite.models; + +public interface BeanTestInterface<T> { + T getSomething(); + void setSomething(T s); +} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BeanTestSuperclass.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BeanTestSuperclass.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BeanTestSuperclass.java new file mode 100644 index 0000000..1a689ab --- /dev/null +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BeanTestSuperclass.java @@ -0,0 +1,30 @@ +/* + * 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.core.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/4b75ea93/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanAndScalarModel.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanAndScalarModel.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanAndScalarModel.java new file mode 100644 index 0000000..12e5f3d --- /dev/null +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanAndScalarModel.java @@ -0,0 +1,40 @@ +/* + * 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.core.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/4b75ea93/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanAndStringTemplateModel.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanAndStringTemplateModel.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanAndStringTemplateModel.java new file mode 100644 index 0000000..accf649 --- /dev/null +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanAndStringTemplateModel.java @@ -0,0 +1,38 @@ +/* + * 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.core.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/4b75ea93/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanHash1.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanHash1.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanHash1.java new file mode 100644 index 0000000..a143cbc --- /dev/null +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanHash1.java @@ -0,0 +1,58 @@ +/* + * 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.core.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/4b75ea93/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanHash2.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanHash2.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanHash2.java new file mode 100644 index 0000000..070b3e2 --- /dev/null +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanHash2.java @@ -0,0 +1,50 @@ +/* + * 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.core.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/4b75ea93/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanList1.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanList1.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanList1.java new file mode 100644 index 0000000..5022f68 --- /dev/null +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanList1.java @@ -0,0 +1,62 @@ +/* + * 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.core.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/4b75ea93/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanList2.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanList2.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanList2.java new file mode 100644 index 0000000..2d7667e --- /dev/null +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanList2.java @@ -0,0 +1,53 @@ +/* + * 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.core.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/4b75ea93/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanVsStringMethods.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanVsStringMethods.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanVsStringMethods.java new file mode 100644 index 0000000..45c0542 --- /dev/null +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/BooleanVsStringMethods.java @@ -0,0 +1,40 @@ +/* + * 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.core.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/4b75ea93/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/EnumTestClass.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/EnumTestClass.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/EnumTestClass.java new file mode 100644 index 0000000..5ad85f5 --- /dev/null +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/EnumTestClass.java @@ -0,0 +1,34 @@ +/* + * 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.core.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/4b75ea93/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/ExceptionModel.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/ExceptionModel.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/ExceptionModel.java new file mode 100644 index 0000000..940579a --- /dev/null +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/ExceptionModel.java @@ -0,0 +1,39 @@ +/* + * 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.core.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/4b75ea93/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/HashAndScalarModel.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/HashAndScalarModel.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/HashAndScalarModel.java new file mode 100644 index 0000000..a5869a2 --- /dev/null +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/HashAndScalarModel.java @@ -0,0 +1,84 @@ +/* + * 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.core.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/4b75ea93/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/JavaObjectInfo.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/JavaObjectInfo.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/JavaObjectInfo.java new file mode 100644 index 0000000..aa6d618 --- /dev/null +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templatesuite/models/JavaObjectInfo.java @@ -0,0 +1,35 @@ +/* + * 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.core.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()); + } + +}
