Repository: incubator-freemarker Updated Branches: refs/heads/3 d74ccf3cc -> 6dc991876
(Misplaced task class) Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/6dc99187 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/6dc99187 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/6dc99187 Branch: refs/heads/3 Commit: 6dc991876b4cb08590e8450ef3bef793dd68c2b8 Parents: d74ccf3 Author: ddekany <[email protected]> Authored: Sun Feb 26 02:36:04 2017 +0100 Committer: ddekany <[email protected]> Committed: Sun Feb 26 02:36:04 2017 +0100 ---------------------------------------------------------------------- .../core/SimpleObjectWrapperTest.java | 73 ++++++++++++++++++++ .../core/SimpleObjectWrapperTest.java | 73 -------------------- 2 files changed, 73 insertions(+), 73 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/6dc99187/src/test/java/org/apache/freemarker/core/SimpleObjectWrapperTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/freemarker/core/SimpleObjectWrapperTest.java b/src/test/java/org/apache/freemarker/core/SimpleObjectWrapperTest.java new file mode 100644 index 0000000..924e170 --- /dev/null +++ b/src/test/java/org/apache/freemarker/core/SimpleObjectWrapperTest.java @@ -0,0 +1,73 @@ +/* + * 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; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.util.Collections; +import java.util.Date; +import java.util.HashSet; + +import org.apache.freemarker.core.model.TemplateBooleanModel; +import org.apache.freemarker.core.model.TemplateModelException; +import org.apache.freemarker.core.model.impl.DefaultArrayAdapter; +import org.apache.freemarker.core.model.impl.DefaultListAdapter; +import org.apache.freemarker.core.model.impl.DefaultMapAdapter; +import org.apache.freemarker.core.model.impl.DefaultObjectWrapperTest.TestBean; +import org.apache.freemarker.core.model.impl.SimpleDate; +import org.apache.freemarker.core.model.impl.SimpleNumber; +import org.apache.freemarker.core.model.impl.SimpleObjectWrapper; +import org.apache.freemarker.core.model.impl.SimpleScalar; +import org.apache.freemarker.core.model.impl.SimpleSequence; +import org.junit.Test; + +public class SimpleObjectWrapperTest { + + @Test + public void testBasics() throws TemplateModelException { + SimpleObjectWrapper ow = new SimpleObjectWrapper(Configuration.VERSION_3_0_0); + testCustomizationCommonPart(ow); + assertTrue(ow.wrap(Collections.emptyMap()) instanceof DefaultMapAdapter); + assertTrue(ow.wrap(Collections.emptyList()) instanceof DefaultListAdapter); + assertTrue(ow.wrap(new boolean[] { }) instanceof DefaultArrayAdapter); + assertTrue(ow.wrap(new HashSet()) instanceof SimpleSequence); // at least until IcI 2.4 + } + + @SuppressWarnings("boxing") + private void testCustomizationCommonPart(SimpleObjectWrapper ow) throws TemplateModelException { + assertFalse(ow.isWriteProtected()); + + assertTrue(ow.wrap("x") instanceof SimpleScalar); + assertTrue(ow.wrap(1.5) instanceof SimpleNumber); + assertTrue(ow.wrap(new Date()) instanceof SimpleDate); + assertEquals(TemplateBooleanModel.TRUE, ow.wrap(true)); + + try { + ow.wrap(new TestBean()); + fail(); + } catch (TemplateModelException e) { + assertTrue(e.getMessage().contains("type")); + } + } + +} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/6dc99187/src/test/resources/org/apache/freemarker/core/SimpleObjectWrapperTest.java ---------------------------------------------------------------------- diff --git a/src/test/resources/org/apache/freemarker/core/SimpleObjectWrapperTest.java b/src/test/resources/org/apache/freemarker/core/SimpleObjectWrapperTest.java deleted file mode 100644 index 924e170..0000000 --- a/src/test/resources/org/apache/freemarker/core/SimpleObjectWrapperTest.java +++ /dev/null @@ -1,73 +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.core; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.Collections; -import java.util.Date; -import java.util.HashSet; - -import org.apache.freemarker.core.model.TemplateBooleanModel; -import org.apache.freemarker.core.model.TemplateModelException; -import org.apache.freemarker.core.model.impl.DefaultArrayAdapter; -import org.apache.freemarker.core.model.impl.DefaultListAdapter; -import org.apache.freemarker.core.model.impl.DefaultMapAdapter; -import org.apache.freemarker.core.model.impl.DefaultObjectWrapperTest.TestBean; -import org.apache.freemarker.core.model.impl.SimpleDate; -import org.apache.freemarker.core.model.impl.SimpleNumber; -import org.apache.freemarker.core.model.impl.SimpleObjectWrapper; -import org.apache.freemarker.core.model.impl.SimpleScalar; -import org.apache.freemarker.core.model.impl.SimpleSequence; -import org.junit.Test; - -public class SimpleObjectWrapperTest { - - @Test - public void testBasics() throws TemplateModelException { - SimpleObjectWrapper ow = new SimpleObjectWrapper(Configuration.VERSION_3_0_0); - testCustomizationCommonPart(ow); - assertTrue(ow.wrap(Collections.emptyMap()) instanceof DefaultMapAdapter); - assertTrue(ow.wrap(Collections.emptyList()) instanceof DefaultListAdapter); - assertTrue(ow.wrap(new boolean[] { }) instanceof DefaultArrayAdapter); - assertTrue(ow.wrap(new HashSet()) instanceof SimpleSequence); // at least until IcI 2.4 - } - - @SuppressWarnings("boxing") - private void testCustomizationCommonPart(SimpleObjectWrapper ow) throws TemplateModelException { - assertFalse(ow.isWriteProtected()); - - assertTrue(ow.wrap("x") instanceof SimpleScalar); - assertTrue(ow.wrap(1.5) instanceof SimpleNumber); - assertTrue(ow.wrap(new Date()) instanceof SimpleDate); - assertEquals(TemplateBooleanModel.TRUE, ow.wrap(true)); - - try { - ow.wrap(new TestBean()); - fail(); - } catch (TemplateModelException e) { - assertTrue(e.getMessage().contains("type")); - } - } - -}
