freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [1/2] freemarker git commit: (Removed .java file from src/test/resources, merged it into the similar test in src/test/java)
Date Sat, 22 Sep 2018 22:42:59 GMT
Repository: freemarker
Updated Branches:
  refs/heads/2.3-gae 25361d786 -> 683a0ab06


(Removed .java file from src/test/resources, merged it into the similar test in src/test/java)


Project: http://git-wip-us.apache.org/repos/asf/freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/freemarker/commit/4534050e
Tree: http://git-wip-us.apache.org/repos/asf/freemarker/tree/4534050e
Diff: http://git-wip-us.apache.org/repos/asf/freemarker/diff/4534050e

Branch: refs/heads/2.3-gae
Commit: 4534050e1b84006b8fee0961370e50ca33e7b90c
Parents: 25361d7
Author: ddekany <ddekany@apache.org>
Authored: Sat Sep 22 19:39:53 2018 +0200
Committer: ddekany <ddekany@apache.org>
Committed: Sat Sep 22 19:39:53 2018 +0200

----------------------------------------------------------------------
 .../template/SimpleObjectWrapperTest.java       | 144 +++++++++++++++++++
 .../template/SimpleObjetWrapperTest.java        | 103 -------------
 .../template/SimpleObjectWrapperTest.java       |  72 ----------
 3 files changed, 144 insertions(+), 175 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/freemarker/blob/4534050e/src/test/java/freemarker/template/SimpleObjectWrapperTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/template/SimpleObjectWrapperTest.java b/src/test/java/freemarker/template/SimpleObjectWrapperTest.java
new file mode 100644
index 0000000..39c9fcf
--- /dev/null
+++ b/src/test/java/freemarker/template/SimpleObjectWrapperTest.java
@@ -0,0 +1,144 @@
+/*
+ * 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 freemarker.template;
+
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+
+import freemarker.template.DefaultObjectWrapperTest.TestBean;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class SimpleObjectWrapperTest {
+    
+    @Test
+    public void testDoesNotAllowAPIBuiltin() throws TemplateModelException {
+        SimpleObjectWrapper sow = new SimpleObjectWrapper(Configuration.VERSION_2_3_22);
+        
+        TemplateModelWithAPISupport map = (TemplateModelWithAPISupport) sow.wrap(new HashMap());
+        try {
+            map.getAPI();
+            fail();
+        } catch (TemplateException e) {
+            assertThat(e.getMessage(), containsString("?api"));
+        }
+    }
+
+    @SuppressWarnings("boxing")
+    @Test
+    public void testCanWrapBasicTypes() throws TemplateModelException {
+        for (Version version : new Version[] { Configuration.VERSION_2_3_0, Configuration.VERSION_2_3_22
}) {
+            SimpleObjectWrapper sow = new SimpleObjectWrapper(version);
+            assertTrue(sow.wrap("s") instanceof TemplateScalarModel);
+            assertTrue(sow.wrap(1) instanceof TemplateNumberModel);
+            assertTrue(sow.wrap(true) instanceof TemplateBooleanModel);
+            assertTrue(sow.wrap(new Date()) instanceof TemplateDateModel);
+            assertTrue(sow.wrap(new ArrayList()) instanceof TemplateSequenceModel);
+            assertTrue(sow.wrap(new String[0]) instanceof TemplateSequenceModel);
+            assertTrue(sow.wrap(new ArrayList().iterator()) instanceof TemplateCollectionModel);
+            assertTrue(sow.wrap(new HashSet()) instanceof TemplateSequenceModel);
+            assertTrue(sow.wrap(new HashMap()) instanceof TemplateHashModelEx);
+            assertNull(sow.wrap(null));
+        }
+    }
+    
+    @Test
+    public void testWontWrapDOM() throws SAXException, IOException, ParserConfigurationException,
+            TemplateModelException {
+        DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+        InputSource is = new InputSource();
+        is.setCharacterStream(new StringReader("<doc><sub a='1' /></doc>"));
+        Document doc = db.parse(is);
+        
+        SimpleObjectWrapper sow = new SimpleObjectWrapper(Configuration.VERSION_2_3_22);
+        try {
+            sow.wrap(doc);
+            fail();
+        } catch (TemplateModelException e) {
+            assertThat(e.getMessage(), containsString("won't wrap"));
+        }
+    }
+    
+    @Test
+    public void testWontWrapGenericObjects() {
+        SimpleObjectWrapper sow = new SimpleObjectWrapper(Configuration.VERSION_2_3_22);
+        try {
+            sow.wrap(new File("/x"));
+            fail();
+        } catch (TemplateModelException e) {
+            assertThat(e.getMessage(), containsString("won't wrap"));
+        }
+    }
+
+    @Test
+    public void testIncompatibleImprovements() throws TemplateModelException {
+        {
+            SimpleObjectWrapper ow = new SimpleObjectWrapper(Configuration.VERSION_2_3_22);
+            testIncompatibleImprovementsIndependentPart(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
+        }
+        
+        {
+            SimpleObjectWrapper ow = new SimpleObjectWrapper(Configuration.VERSION_2_3_21);
+            testIncompatibleImprovementsIndependentPart(ow);
+            assertTrue(ow.wrap(Collections.emptyMap()) instanceof SimpleHash);
+            assertTrue(ow.wrap(Collections.emptyList()) instanceof SimpleSequence);
+            assertTrue(ow.wrap(new boolean[] { }) instanceof SimpleSequence);
+            assertTrue(ow.wrap(new HashSet()) instanceof SimpleSequence);
+        }
+    }
+
+    @SuppressWarnings("boxing")
+    private void testIncompatibleImprovementsIndependentPart(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/freemarker/blob/4534050e/src/test/java/freemarker/template/SimpleObjetWrapperTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/template/SimpleObjetWrapperTest.java b/src/test/java/freemarker/template/SimpleObjetWrapperTest.java
deleted file mode 100644
index 4af7f2f..0000000
--- a/src/test/java/freemarker/template/SimpleObjetWrapperTest.java
+++ /dev/null
@@ -1,103 +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 freemarker.template;
-
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.junit.Test;
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-public class SimpleObjetWrapperTest {
-    
-    @Test
-    public void testDoesNotAllowAPIBuiltin() throws TemplateModelException {
-        SimpleObjectWrapper sow = new SimpleObjectWrapper(Configuration.VERSION_2_3_22);
-        
-        TemplateModelWithAPISupport map = (TemplateModelWithAPISupport) sow.wrap(new HashMap());
-        try {
-            map.getAPI();
-            fail();
-        } catch (TemplateException e) {
-            assertThat(e.getMessage(), containsString("?api"));
-        }
-    }
-
-    @SuppressWarnings("boxing")
-    @Test
-    public void testCanWrapBasicTypes() throws TemplateModelException {
-        for (Version version : new Version[] { Configuration.VERSION_2_3_0, Configuration.VERSION_2_3_22
}) {
-            SimpleObjectWrapper sow = new SimpleObjectWrapper(version);
-            assertTrue(sow.wrap("s") instanceof TemplateScalarModel);
-            assertTrue(sow.wrap(1) instanceof TemplateNumberModel);
-            assertTrue(sow.wrap(true) instanceof TemplateBooleanModel);
-            assertTrue(sow.wrap(new Date()) instanceof TemplateDateModel);
-            assertTrue(sow.wrap(new ArrayList()) instanceof TemplateSequenceModel);
-            assertTrue(sow.wrap(new String[0]) instanceof TemplateSequenceModel);
-            assertTrue(sow.wrap(new ArrayList().iterator()) instanceof TemplateCollectionModel);
-            assertTrue(sow.wrap(new HashSet()) instanceof TemplateSequenceModel);
-            assertTrue(sow.wrap(new HashMap()) instanceof TemplateHashModelEx);
-            assertNull(sow.wrap(null));
-        }
-    }
-    
-    @Test
-    public void testWontWrapDOM() throws SAXException, IOException, ParserConfigurationException,
-            TemplateModelException {
-        DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
-        InputSource is = new InputSource();
-        is.setCharacterStream(new StringReader("<doc><sub a='1' /></doc>"));
-        Document doc = db.parse(is);
-        
-        SimpleObjectWrapper sow = new SimpleObjectWrapper(Configuration.VERSION_2_3_22);
-        try {
-            sow.wrap(doc);
-            fail();
-        } catch (TemplateModelException e) {
-            assertThat(e.getMessage(), containsString("won't wrap"));
-        }
-    }
-    
-    @Test
-    public void testWontWrapGenericObjects() {
-        SimpleObjectWrapper sow = new SimpleObjectWrapper(Configuration.VERSION_2_3_22);
-        try {
-            sow.wrap(new File("/x"));
-            fail();
-        } catch (TemplateModelException e) {
-            assertThat(e.getMessage(), containsString("won't wrap"));
-        }
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/freemarker/blob/4534050e/src/test/resources/freemarker/template/SimpleObjectWrapperTest.java
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/template/SimpleObjectWrapperTest.java b/src/test/resources/freemarker/template/SimpleObjectWrapperTest.java
deleted file mode 100644
index 798bcca..0000000
--- a/src/test/resources/freemarker/template/SimpleObjectWrapperTest.java
+++ /dev/null
@@ -1,72 +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 freemarker.template;
-
-import static org.junit.Assert.*;
-
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashSet;
-
-import org.junit.Test;
-
-import freemarker.template.DefaultObjectWrapperTest.TestBean;
-
-public class SimpleObjectWrapperTest {
-    
-    @Test
-    public void testBasics() throws TemplateModelException {
-        {
-            SimpleObjectWrapper ow = new SimpleObjectWrapper(Configuration.VERSION_2_3_22);
-            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
-        }
-        
-        {
-            SimpleObjectWrapper ow = new SimpleObjectWrapper(Configuration.VERSION_2_3_21);
-            testCustomizationCommonPart(ow);
-            assertTrue(ow.wrap(Collections.emptyMap()) instanceof SimpleHash);
-            assertTrue(ow.wrap(Collections.emptyList()) instanceof SimpleSequence);
-            assertTrue(ow.wrap(new boolean[] { }) instanceof SimpleSequence);
-            assertTrue(ow.wrap(new HashSet()) instanceof SimpleSequence);
-        }
-    }
-
-    @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"));
-        }
-    }
-    
-}


Mime
View raw message