freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject incubator-freemarker git commit: SimpleObjectWrapper was renamed to RestrictedObjectWrapper, also the "simple" setting value was rename to "restricted".
Date Wed, 01 Mar 2017 15:49:10 GMT
Repository: incubator-freemarker
Updated Branches:
  refs/heads/3 f0ec63c2d -> 079ff48a7


SimpleObjectWrapper was renamed to RestrictedObjectWrapper, also the "simple" setting value
was rename to "restricted".


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

Branch: refs/heads/3
Commit: 079ff48a7f4cb097f05195ac3df1118bc6d85c69
Parents: f0ec63c
Author: ddekany <ddekany@apache.org>
Authored: Wed Mar 1 16:48:57 2017 +0100
Committer: ddekany <ddekany@apache.org>
Committed: Wed Mar 1 16:48:57 2017 +0100

----------------------------------------------------------------------
 .../apache/freemarker/core/Configurable.java    | 12 ++--
 .../core/_ObjectBuilderSettingEvaluator.java    |  5 +-
 .../model/impl/RestrictedObjectWrapper.java     | 58 +++++++++++++++
 .../core/model/impl/SimpleObjectWrapper.java    | 58 ---------------
 .../core/model/impl/_StaticObjectWrappers.java  |  6 +-
 .../freemarker/servlet/FreemarkerServlet.java   |  6 +-
 src/manual/en_US/FM3-CHANGE-LOG.txt             |  4 +-
 .../freemarker/core/ConfigurationTest.java      |  8 +--
 .../core/RestrictedObjectWrapperTest.java       | 74 ++++++++++++++++++++
 .../core/SimpleObjectWrapperTest.java           | 74 --------------------
 .../freemarker/core/SimpleObjetWrapperTest.java | 10 +--
 .../core/TemplateConfigurationTest.java         |  4 +-
 .../DefaultObjectWrapperSingletonsTest.java     |  4 +-
 .../servlet/jsp/RealServletContainertTest.java  |  6 +-
 14 files changed, 165 insertions(+), 164 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/079ff48a/src/main/java/org/apache/freemarker/core/Configurable.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/Configurable.java b/src/main/java/org/apache/freemarker/core/Configurable.java
index d5d2c89..a750e3d 100644
--- a/src/main/java/org/apache/freemarker/core/Configurable.java
+++ b/src/main/java/org/apache/freemarker/core/Configurable.java
@@ -46,7 +46,7 @@ import org.apache.freemarker.core.model.ObjectWrapper;
 import org.apache.freemarker.core.model.TemplateModel;
 import org.apache.freemarker.core.model.impl.DefaultObjectWrapper;
 import org.apache.freemarker.core.model.impl.DefaultObjectWrapperBuilder;
-import org.apache.freemarker.core.model.impl.SimpleObjectWrapper;
+import org.apache.freemarker.core.model.impl.RestrictedObjectWrapper;
 import org.apache.freemarker.core.model.impl._StaticObjectWrappers;
 import org.apache.freemarker.core.outputformat.OutputFormat;
 import org.apache.freemarker.core.outputformat.impl.HTMLOutputFormat;
@@ -1805,7 +1805,7 @@ public class Configurable {
      *       See {@link #setObjectWrapper(ObjectWrapper)}.
      *       <br>String value: If the value contains dot, then it's interpreted as
an <a href="#fm_obe">object builder
      *       expression</a>, with the addition that {@link DefaultObjectWrapper}, {@link
DefaultObjectWrapper} and
-     *       {@link SimpleObjectWrapper} can be referred without package name. For example,
these strings are valid
+     *       {@link RestrictedObjectWrapper} can be referred without package name. For example,
these strings are valid
      *       values: {@code "DefaultObjectWrapper(3.0.0)"},
      *       {@code "DefaultObjectWrapper(2.3.21, simpleMapWrapper=true)"}.
      *       <br>If the value does not contain dot, then it must be one of these special
values (case insensitive):
@@ -1813,7 +1813,7 @@ public class Configurable {
      *       {@code Configuration#Configuration(Version) incompatible_improvements}, but
a bug existed in 2.3.21 where
      *       that was ignored),
      *       {@code "default_2_3_0"} (means {@link _StaticObjectWrappers#DEFAULT_OBJECT_WRAPPER})
-     *       {@code "simple"} (means the deprecated {@link _StaticObjectWrappers#SIMPLE_OBJECT_WRAPPER}
+     *       {@code "restricted"} (means the deprecated {@link _StaticObjectWrappers#RESTRICTED_OBJECT_WRAPPER}
      *
      *   <li><p>{@code "number_format"}: See {@link #setNumberFormat(String)}.
      *   
@@ -2114,7 +2114,7 @@ public class Configurable {
      *   </li>
      *   <li>
      *     <p>The following classes can be referred to with simple (unqualified) name
instead of fully qualified name:
-     *     {@link DefaultObjectWrapper}, {@link DefaultObjectWrapper}, {@link SimpleObjectWrapper},
{@link Locale},
+     *     {@link DefaultObjectWrapper}, {@link DefaultObjectWrapper}, {@link RestrictedObjectWrapper},
{@link Locale},
      *     {@link TemplateConfiguration}, {@link PathGlobMatcher}, {@link FileNameGlobMatcher},
{@link PathRegexMatcher},
      *     {@link AndMatcher}, {@link OrMatcher}, {@link NotMatcher}, {@link ConditionalTemplateConfigurationFactory},
      *     {@link MergingTemplateConfigurationFactory}, {@link FirstMatchTemplateConfigurationFactory},
@@ -2212,8 +2212,8 @@ public class Configurable {
                     } else {
                         setObjectWrapper(Configuration.getDefaultObjectWrapper(Configuration.VERSION_3_0_0));
                     }
-                } else if ("simple".equalsIgnoreCase(value)) {
-                    setObjectWrapper(_StaticObjectWrappers.SIMPLE_OBJECT_WRAPPER);
+                } else if ("restricted".equalsIgnoreCase(value)) {
+                    setObjectWrapper(_StaticObjectWrappers.RESTRICTED_OBJECT_WRAPPER);
                 } else {
                     setObjectWrapper((ObjectWrapper) _ObjectBuilderSettingEvaluator.eval(
                                     value, ObjectWrapper.class, false, _SettingEvaluationEnvironment.getCurrent()));

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/079ff48a/src/main/java/org/apache/freemarker/core/_ObjectBuilderSettingEvaluator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/_ObjectBuilderSettingEvaluator.java
b/src/main/java/org/apache/freemarker/core/_ObjectBuilderSettingEvaluator.java
index 38e269a..e98c104 100644
--- a/src/main/java/org/apache/freemarker/core/_ObjectBuilderSettingEvaluator.java
+++ b/src/main/java/org/apache/freemarker/core/_ObjectBuilderSettingEvaluator.java
@@ -40,8 +40,7 @@ import org.apache.freemarker.core.model.TemplateMethodModelEx;
 import org.apache.freemarker.core.model.TemplateModel;
 import org.apache.freemarker.core.model.TemplateModelException;
 import org.apache.freemarker.core.model.impl.DefaultObjectWrapper;
-import org.apache.freemarker.core.model.impl.SimpleObjectWrapper;
-import org.apache.freemarker.core.model.impl.DefaultObjectWrapper;
+import org.apache.freemarker.core.model.impl.RestrictedObjectWrapper;
 import org.apache.freemarker.core.outputformat.impl.HTMLOutputFormat;
 import org.apache.freemarker.core.outputformat.impl.PlainTextOutputFormat;
 import org.apache.freemarker.core.outputformat.impl.RTFOutputFormat;
@@ -659,7 +658,7 @@ public class _ObjectBuilderSettingEvaluator {
             
             addWithSimpleName(SHORTHANDS, DefaultObjectWrapper.class);
             addWithSimpleName(SHORTHANDS, DefaultObjectWrapper.class);
-            addWithSimpleName(SHORTHANDS, SimpleObjectWrapper.class);
+            addWithSimpleName(SHORTHANDS, RestrictedObjectWrapper.class);
 
             addWithSimpleName(SHORTHANDS, TemplateConfiguration.class);
             

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/079ff48a/src/main/java/org/apache/freemarker/core/model/impl/RestrictedObjectWrapper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/model/impl/RestrictedObjectWrapper.java
b/src/main/java/org/apache/freemarker/core/model/impl/RestrictedObjectWrapper.java
new file mode 100644
index 0000000..2e738a0
--- /dev/null
+++ b/src/main/java/org/apache/freemarker/core/model/impl/RestrictedObjectWrapper.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.model.impl;
+
+import org.apache.freemarker.core.Version;
+import org.apache.freemarker.core.model.TemplateHashModel;
+import org.apache.freemarker.core.model.TemplateModel;
+import org.apache.freemarker.core.model.TemplateModelException;
+
+/**
+ * A restricted version of {@link DefaultObjectWrapper} that doesn't expose arbitrary object,
just those that directly
+ * correspond to the {@link TemplateModel} sub-interfaces ({@code String}, {@code Map} and
such). If it had to wrap
+ * other kind of objects, it will throw exception. It will also block {@code ?api} calls
on the values it wraps.
+ */
+public class RestrictedObjectWrapper extends DefaultObjectWrapper {
+
+    /**
+     * @param incompatibleImprovements see in {@link DefaultObjectWrapper#DefaultObjectWrapper(Version)}.
+     * 
+     * @since 2.3.21
+     */
+    public RestrictedObjectWrapper(Version incompatibleImprovements) {
+        super(incompatibleImprovements);
+    }
+
+    /**
+     * Called if a type other than the simple ones we know about is passed in. 
+     * In this implementation, this just throws an exception.
+     */
+    @Override
+    protected TemplateModel handleNonBasicTypes(Object obj) throws TemplateModelException
{
+        throw new TemplateModelException("RestrictedObjectWrapper deliberately won't wrap
this type: "
+                + obj.getClass().getName());
+    }
+
+    @Override
+    public TemplateHashModel wrapAsAPI(Object obj) throws TemplateModelException {
+        throw new TemplateModelException("RestrictedObjectWrapper deliberately doesn't allow
?api.");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/079ff48a/src/main/java/org/apache/freemarker/core/model/impl/SimpleObjectWrapper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/model/impl/SimpleObjectWrapper.java
b/src/main/java/org/apache/freemarker/core/model/impl/SimpleObjectWrapper.java
deleted file mode 100644
index 9acd2b6..0000000
--- a/src/main/java/org/apache/freemarker/core/model/impl/SimpleObjectWrapper.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.freemarker.core.model.impl;
-
-import org.apache.freemarker.core.Version;
-import org.apache.freemarker.core.model.TemplateHashModel;
-import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
-
-/**
- * A restricted object wrapper that will not expose arbitrary object, just those that directly
correspond to the
- * {@link TemplateModel} sub-interfaces ({@code String}, {@code Map} and such). If it had
to wrap other kind of objects,
- * it will throw exception. It will also block {@code ?api} calls on the values it wraps.
- */
-public class SimpleObjectWrapper extends DefaultObjectWrapper {
-
-    /**
-     * @param incompatibleImprovements see in {@link DefaultObjectWrapper#DefaultObjectWrapper(Version)}.
-     * 
-     * @since 2.3.21
-     */
-    public SimpleObjectWrapper(Version incompatibleImprovements) {
-        super(incompatibleImprovements);
-    }
-
-    /**
-     * Called if a type other than the simple ones we know about is passed in. 
-     * In this implementation, this just throws an exception.
-     */
-    @Override
-    protected TemplateModel handleNonBasicTypes(Object obj) throws TemplateModelException
{
-        throw new TemplateModelException("SimpleObjectWrapper deliberately won't wrap this
type: "
-                + obj.getClass().getName());
-    }
-
-    @Override
-    public TemplateHashModel wrapAsAPI(Object obj) throws TemplateModelException {
-        throw new TemplateModelException("SimpleObjectWrapper deliberately doesn't allow
?api.");
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/079ff48a/src/main/java/org/apache/freemarker/core/model/impl/_StaticObjectWrappers.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/model/impl/_StaticObjectWrappers.java
b/src/main/java/org/apache/freemarker/core/model/impl/_StaticObjectWrappers.java
index 18e39b6..3be2da5 100644
--- a/src/main/java/org/apache/freemarker/core/model/impl/_StaticObjectWrappers.java
+++ b/src/main/java/org/apache/freemarker/core/model/impl/_StaticObjectWrappers.java
@@ -34,9 +34,9 @@ public final class _StaticObjectWrappers {
     public static final DefaultObjectWrapper DEFAULT_OBJECT_WRAPPER
             = new DefaultObjectWrapperBuilder(Configuration.VERSION_3_0_0).build();
 
-    public static final SimpleObjectWrapper SIMPLE_OBJECT_WRAPPER
-            = new SimpleObjectWrapper(Configuration.VERSION_3_0_0);
+    public static final RestrictedObjectWrapper RESTRICTED_OBJECT_WRAPPER
+            = new RestrictedObjectWrapper(Configuration.VERSION_3_0_0);
     {
-        SIMPLE_OBJECT_WRAPPER.writeProtect();
+        RESTRICTED_OBJECT_WRAPPER.writeProtect();
     }    
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/079ff48a/src/main/java/org/apache/freemarker/servlet/FreemarkerServlet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/servlet/FreemarkerServlet.java b/src/main/java/org/apache/freemarker/servlet/FreemarkerServlet.java
index b050d7a..9dbc701 100644
--- a/src/main/java/org/apache/freemarker/servlet/FreemarkerServlet.java
+++ b/src/main/java/org/apache/freemarker/servlet/FreemarkerServlet.java
@@ -410,7 +410,7 @@ public class FreemarkerServlet extends HttpServlet {
     private static final String DEPR_INITPARAM_TEMPLATE_DELAY = "TemplateDelay";
     private static final String DEPR_INITPARAM_ENCODING = "DefaultEncoding";
     private static final String DEPR_INITPARAM_OBJECT_WRAPPER = "ObjectWrapper";
-    private static final String DEPR_INITPARAM_WRAPPER_SIMPLE = "simple";
+    private static final String DEPR_INITPARAM_WRAPPER_RESTRICTED = "restricted";
     private static final String DEPR_INITPARAM_TEMPLATE_EXCEPTION_HANDLER = "TemplateExceptionHandler";
     private static final String DEPR_INITPARAM_TEMPLATE_EXCEPTION_HANDLER_RETHROW = "rethrow";
     private static final String DEPR_INITPARAM_TEMPLATE_EXCEPTION_HANDLER_DEBUG = "debug";
@@ -1297,8 +1297,8 @@ public class FreemarkerServlet extends HttpServlet {
                         + Configurable.OBJECT_WRAPPER_KEY + " and "
                         + DEPR_INITPARAM_OBJECT_WRAPPER);
             }
-            if (DEPR_INITPARAM_WRAPPER_SIMPLE.equals(wrapper)) {
-                return _StaticObjectWrappers.SIMPLE_OBJECT_WRAPPER;
+            if (DEPR_INITPARAM_WRAPPER_RESTRICTED.equals(wrapper)) {
+                return _StaticObjectWrappers.RESTRICTED_OBJECT_WRAPPER;
             }
             return createDefaultObjectWrapper();
         } else {

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/079ff48a/src/manual/en_US/FM3-CHANGE-LOG.txt
----------------------------------------------------------------------
diff --git a/src/manual/en_US/FM3-CHANGE-LOG.txt b/src/manual/en_US/FM3-CHANGE-LOG.txt
index 93f092b..bb16fb8 100644
--- a/src/manual/en_US/FM3-CHANGE-LOG.txt
+++ b/src/manual/en_US/FM3-CHANGE-LOG.txt
@@ -124,4 +124,6 @@ the FreeMarer 3 changelog here:
   has fallen back to BeansWrapper.wrap), which is inconsistent and doesn't worth the caching
overhead and complexity.
 - Java methods (when using DefaultObjectWrapper) won't be accessible as sequences anyore.
That is, earlier, instead of
   obj.m(1), you could write obj.m[1]. This strange feature has led to some tricky cases,
while almost nobody has
-  utilized it.
\ No newline at end of file
+  utilized it.
+- SimpleObjectWrapper was renamed to RestrictedObjectWrapper, also the "simple" setting value
was rename to
+  "restricted".
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/079ff48a/src/test/java/org/apache/freemarker/core/ConfigurationTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/core/ConfigurationTest.java b/src/test/java/org/apache/freemarker/core/ConfigurationTest.java
index 77e5cd3..6889f8c 100644
--- a/src/test/java/org/apache/freemarker/core/ConfigurationTest.java
+++ b/src/test/java/org/apache/freemarker/core/ConfigurationTest.java
@@ -109,9 +109,9 @@ public class ConfigurationTest extends TestCase {
         assertFalse(cfg.isObjectWrapperExplicitlySet());
         assertSame(_StaticObjectWrappers.DEFAULT_OBJECT_WRAPPER, cfg.getObjectWrapper());
         //
-        cfg.setObjectWrapper(_StaticObjectWrappers.SIMPLE_OBJECT_WRAPPER);
+        cfg.setObjectWrapper(_StaticObjectWrappers.RESTRICTED_OBJECT_WRAPPER);
         assertTrue(cfg.isObjectWrapperExplicitlySet());
-        assertSame(_StaticObjectWrappers.SIMPLE_OBJECT_WRAPPER, cfg.getObjectWrapper());
+        assertSame(_StaticObjectWrappers.RESTRICTED_OBJECT_WRAPPER, cfg.getObjectWrapper());
         //
         for (int i = 0; i < 2; i++) {
             cfg.unsetObjectWrapper();
@@ -647,8 +647,8 @@ public class ConfigurationTest extends TestCase {
         }
         
         {
-            cfg.setSetting(Configurable.OBJECT_WRAPPER_KEY, "simple");
-            assertSame(_StaticObjectWrappers.SIMPLE_OBJECT_WRAPPER, cfg.getObjectWrapper());
+            cfg.setSetting(Configurable.OBJECT_WRAPPER_KEY, "restricted");
+            assertSame(_StaticObjectWrappers.RESTRICTED_OBJECT_WRAPPER, cfg.getObjectWrapper());
         }
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/079ff48a/src/test/java/org/apache/freemarker/core/RestrictedObjectWrapperTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/core/RestrictedObjectWrapperTest.java b/src/test/java/org/apache/freemarker/core/RestrictedObjectWrapperTest.java
new file mode 100644
index 0000000..d76a31e
--- /dev/null
+++ b/src/test/java/org/apache/freemarker/core/RestrictedObjectWrapperTest.java
@@ -0,0 +1,74 @@
+/*
+ * 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.apache.freemarker.test.hamcerst.Matchers.*;
+import static org.junit.Assert.*;
+
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+
+import javax.annotation.PostConstruct;
+
+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.DefaultNonListCollectionAdapter;
+import org.apache.freemarker.core.model.impl.DefaultObjectWrapperTest.TestBean;
+import org.apache.freemarker.core.model.impl.RestrictedObjectWrapper;
+import org.apache.freemarker.core.model.impl.SimpleDate;
+import org.apache.freemarker.core.model.impl.SimpleNumber;
+import org.apache.freemarker.core.model.impl.SimpleScalar;
+import org.junit.Test;
+
+public class RestrictedObjectWrapperTest {
+
+    @Test
+    public void testBasics() throws TemplateModelException {
+        PostConstruct.class.toString();
+        RestrictedObjectWrapper ow = new RestrictedObjectWrapper(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 DefaultNonListCollectionAdapter);
+    }
+
+    @SuppressWarnings("boxing")
+    private void testCustomizationCommonPart(RestrictedObjectWrapper 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) {
+            assertThat(e.getMessage(), containsStringIgnoringCase("type"));
+        }
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/079ff48a/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
deleted file mode 100644
index 94d1833..0000000
--- a/src/test/java/org/apache/freemarker/core/SimpleObjectWrapperTest.java
+++ /dev/null
@@ -1,74 +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.apache.freemarker.test.hamcerst.Matchers.*;
-import static org.junit.Assert.*;
-
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashSet;
-
-import javax.annotation.PostConstruct;
-
-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.DefaultNonListCollectionAdapter;
-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.junit.Test;
-
-public class SimpleObjectWrapperTest {
-
-    @Test
-    public void testBasics() throws TemplateModelException {
-        PostConstruct.class.toString();
-        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 DefaultNonListCollectionAdapter);
-    }
-
-    @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) {
-            assertThat(e.getMessage(), containsStringIgnoringCase("type"));
-        }
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/079ff48a/src/test/java/org/apache/freemarker/core/SimpleObjetWrapperTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/core/SimpleObjetWrapperTest.java b/src/test/java/org/apache/freemarker/core/SimpleObjetWrapperTest.java
index e41203b..040695d 100644
--- a/src/test/java/org/apache/freemarker/core/SimpleObjetWrapperTest.java
+++ b/src/test/java/org/apache/freemarker/core/SimpleObjetWrapperTest.java
@@ -44,7 +44,7 @@ import org.apache.freemarker.core.model.TemplateModelWithAPISupport;
 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.SimpleObjectWrapper;
+import org.apache.freemarker.core.model.impl.RestrictedObjectWrapper;
 import org.junit.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
@@ -54,7 +54,7 @@ public class SimpleObjetWrapperTest {
     
     @Test
     public void testDoesNotAllowAPIBuiltin() throws TemplateModelException {
-        SimpleObjectWrapper sow = new SimpleObjectWrapper(Configuration.VERSION_3_0_0);
+        RestrictedObjectWrapper sow = new RestrictedObjectWrapper(Configuration.VERSION_3_0_0);
         
         TemplateModelWithAPISupport map = (TemplateModelWithAPISupport) sow.wrap(new HashMap());
         try {
@@ -68,7 +68,7 @@ public class SimpleObjetWrapperTest {
     @SuppressWarnings("boxing")
     @Test
     public void testCanWrapBasicTypes() throws TemplateModelException {
-        SimpleObjectWrapper sow = new SimpleObjectWrapper(Configuration.VERSION_3_0_0);
+        RestrictedObjectWrapper sow = new RestrictedObjectWrapper(Configuration.VERSION_3_0_0);
         assertTrue(sow.wrap("s") instanceof TemplateScalarModel);
         assertTrue(sow.wrap(1) instanceof TemplateNumberModel);
         assertTrue(sow.wrap(true) instanceof TemplateBooleanModel);
@@ -89,7 +89,7 @@ public class SimpleObjetWrapperTest {
         is.setCharacterStream(new StringReader("<doc><sub a='1' /></doc>"));
         Document doc = db.parse(is);
         
-        SimpleObjectWrapper sow = new SimpleObjectWrapper(Configuration.VERSION_3_0_0);
+        RestrictedObjectWrapper sow = new RestrictedObjectWrapper(Configuration.VERSION_3_0_0);
         try {
             sow.wrap(doc);
             fail();
@@ -100,7 +100,7 @@ public class SimpleObjetWrapperTest {
     
     @Test
     public void testWontWrapGenericObjects() {
-        SimpleObjectWrapper sow = new SimpleObjectWrapper(Configuration.VERSION_3_0_0);
+        RestrictedObjectWrapper sow = new RestrictedObjectWrapper(Configuration.VERSION_3_0_0);
         try {
             sow.wrap(new File("/x"));
             fail();

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/079ff48a/src/test/java/org/apache/freemarker/core/TemplateConfigurationTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/core/TemplateConfigurationTest.java b/src/test/java/org/apache/freemarker/core/TemplateConfigurationTest.java
index 4a22ba4..bf3587e 100644
--- a/src/test/java/org/apache/freemarker/core/TemplateConfigurationTest.java
+++ b/src/test/java/org/apache/freemarker/core/TemplateConfigurationTest.java
@@ -44,7 +44,7 @@ import java.util.TimeZone;
 import org.apache.commons.collections.ListUtils;
 import org.apache.freemarker.core.arithmetic.ArithmeticEngine;
 import org.apache.freemarker.core.arithmetic.impl.ConservativeArithmeticEngine;
-import org.apache.freemarker.core.model.impl.SimpleObjectWrapper;
+import org.apache.freemarker.core.model.impl.RestrictedObjectWrapper;
 import org.apache.freemarker.core.outputformat.impl.HTMLOutputFormat;
 import org.apache.freemarker.core.outputformat.impl.UndefinedOutputFormat;
 import org.apache.freemarker.core.outputformat.impl.XMLOutputFormat;
@@ -172,7 +172,7 @@ public class TemplateConfigurationTest {
         SETTING_ASSIGNMENTS.put("logTemplateExceptions", true);
         SETTING_ASSIGNMENTS.put("newBuiltinClassResolver", TemplateClassResolver.ALLOWS_NOTHING_RESOLVER);
         SETTING_ASSIGNMENTS.put("numberFormat", "0.0000");
-        SETTING_ASSIGNMENTS.put("objectWrapper", new SimpleObjectWrapper(ICI));
+        SETTING_ASSIGNMENTS.put("objectWrapper", new RestrictedObjectWrapper(ICI));
         SETTING_ASSIGNMENTS.put("outputEncoding", "utf-16");
         SETTING_ASSIGNMENTS.put("showErrorTips", false);
         SETTING_ASSIGNMENTS.put("templateExceptionHandler", TemplateExceptionHandler.IGNORE_HANDLER);

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/079ff48a/src/test/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperSingletonsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperSingletonsTest.java
b/src/test/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperSingletonsTest.java
index cccae37..485ef45 100644
--- a/src/test/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperSingletonsTest.java
+++ b/src/test/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperSingletonsTest.java
@@ -208,12 +208,12 @@ public class DefaultObjectWrapperSingletonsTest extends TestCase {
             DefaultObjectWrapperBuilder factory = new DefaultObjectWrapperBuilder(Configuration.VERSION_3_0_0);
             factory.setStrict(true);
             factory.setDefaultDateType(TemplateDateModel.DATETIME);
-            factory.setOuterIdentity(new SimpleObjectWrapper(Configuration.VERSION_3_0_0));
+            factory.setOuterIdentity(new RestrictedObjectWrapper(Configuration.VERSION_3_0_0));
             DefaultObjectWrapper ow = factory.build();
             assertEquals(5, getDefaultObjectWrapperInstanceCacheSize());
             assertTrue(ow.isStrict());
             assertEquals(TemplateDateModel.DATETIME, ow.getDefaultDateType());
-            assertSame(SimpleObjectWrapper.class, ow.getOuterIdentity().getClass());
+            assertSame(RestrictedObjectWrapper.class, ow.getOuterIdentity().getClass());
             
             hardReferences.add(ow);
         }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/079ff48a/src/test/java/org/apache/freemarker/servlet/jsp/RealServletContainertTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/servlet/jsp/RealServletContainertTest.java
b/src/test/java/org/apache/freemarker/servlet/jsp/RealServletContainertTest.java
index bc5e152..d3c1a14 100644
--- a/src/test/java/org/apache/freemarker/servlet/jsp/RealServletContainertTest.java
+++ b/src/test/java/org/apache/freemarker/servlet/jsp/RealServletContainertTest.java
@@ -42,7 +42,7 @@ import org.apache.freemarker.core.TemplateExceptionHandler;
 import org.apache.freemarker.core.model.ObjectWrapper;
 import org.apache.freemarker.core.model.impl.DefaultObjectWrapper;
 import org.apache.freemarker.core.model.impl.DefaultObjectWrapperBuilder;
-import org.apache.freemarker.core.model.impl.SimpleObjectWrapper;
+import org.apache.freemarker.core.model.impl.RestrictedObjectWrapper;
 import org.apache.freemarker.core.templateresolver.TemplateLoader;
 import org.apache.freemarker.core.templateresolver.impl.ClassTemplateLoader;
 import org.apache.freemarker.servlet.FreemarkerServlet;
@@ -466,14 +466,14 @@ public class RealServletContainertTest extends WebAppTestCase {
         @Override
         protected Configuration createConfiguration() {
             Configuration cfg = new Configuration(Configuration.VERSION_3_0_0);
-            cfg.setObjectWrapper(new SimpleObjectWrapper(Configuration.VERSION_3_0_0));
+            cfg.setObjectWrapper(new RestrictedObjectWrapper(Configuration.VERSION_3_0_0));
             return cfg;
         }
         
         @Override
         protected void doAssertions(Configuration cfg) throws Exception {
             ObjectWrapper ow = cfg.getObjectWrapper();
-            assertSame(SimpleObjectWrapper.class, ow.getClass());
+            assertSame(RestrictedObjectWrapper.class, ow.getClass());
             assertEquals(Configuration.VERSION_3_0_0, ((DefaultObjectWrapper) ow).getIncompatibleImprovements());
         }
         


Mime
View raw message