freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [1/2] incubator-freemarker git commit: Removed other BeansWrapper related classes that DefaultObjectWrapper doesn't use. This includes ModelCache and related classes, because DefaultObjectWrapper has only used the cache for "generic" classes (because tha
Date Wed, 01 Mar 2017 10:07:23 GMT
Repository: incubator-freemarker
Updated Branches:
  refs/heads/3 9a0a2d0bf -> 780b76a6e


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/780b76a6/src/main/java/org/apache/freemarker/core/util/_ClassUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/util/_ClassUtil.java b/src/main/java/org/apache/freemarker/core/util/_ClassUtil.java
index f97d186..26c32ec 100644
--- a/src/main/java/org/apache/freemarker/core/util/_ClassUtil.java
+++ b/src/main/java/org/apache/freemarker/core/util/_ClassUtil.java
@@ -19,7 +19,7 @@
 
 package org.apache.freemarker.core.util;
 
-import org.apache.freemarker.core.model.impl.NumberModel;
+import org.apache.freemarker.core.model.impl.BeanModel;
 
 public class _ClassUtil {
     
@@ -69,8 +69,8 @@ public class _ClassUtil {
      * 
      * @param pClass can be {@code null}, in which case the method returns {@code null}.
      * @param shortenFreeMarkerClasses if {@code true}, it will also shorten FreeMarker class
names. The exact rules
-     *     aren't specified and might change over time, but right now, {@link NumberModel}
for
-     *     example becomes to {@code f.e.b.NumberModel}. 
+     *     aren't specified and might change over time, but right now, {@link BeanModel}
for
+     *     example becomes to {@code o.a.f.c.m.BeanModel}.
      * 
      * @since 2.3.20
      */

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/780b76a6/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 72498a6..04e1d94 100644
--- a/src/manual/en_US/FM3-CHANGE-LOG.txt
+++ b/src/manual/en_US/FM3-CHANGE-LOG.txt
@@ -96,7 +96,6 @@ the FreeMarer 3 changelog here:
 - Even for setting values that are class names without following `()` or other argument list,
the INSTANCE field and
   the builder class will be searched now, and used instead of the constructor of the class.
Earlier they weren't for
   backward compatibility.
-- Removed the deprecated BeansWrapper.nullModel setting. So null is always wrapped to null
now.
 - Removed several deprecated methods and constants. Some notes:
   - strict_bean_models configuration setting was removed, as it should be set on the BeansWrapper
itself
   - .template_name now means the same as .current_template_name (it doesn't emulate 2.3 glitches
anymore)
@@ -113,8 +112,13 @@ the FreeMarer 3 changelog here:
     constructor argument anymore.)
   - When specifying the templateUpdateDelay configuration setting with a String (with Properties),
the time unit is
     required, unless the value is 0.
-- setSetting (and the like) doesn't throw ParseException (the same exception used when parsing
templates) anymore, but ConfigurationException.
-  Also, on the places where ParseException was used for other than template   parsing, o.a.f.core.util.GenericParseException
is used now instead,
-  which doesn't have the template parsing related fields that we can't fill.
-- Removed DefaultObjectWrapper settings that only exist so that you can set backward compatible
behavior instead of the
-  recommended value: useAdaptersForContainers, forceLegacyNonListCollections, iterableSupport,
simpleMapWrapper
\ No newline at end of file
+- setSetting (and the like) doesn't throw ParseException (the same exception used when parsing
templates) anymore,
+  but ConfigurationException. Also, on the places where ParseException was used for other
than template parsing,
+  o.a.f.core.util.GenericParseException is used now instead, which doesn't have the template
parsing related fields
+  that we can't fill.
+- Removed DefaultObjectWrapper settings that only exist so that you can set backward compatible
behavior instead of
+  the recommended value: useAdaptersForContainers, forceLegacyNonListCollections, iterableSupport,
simpleMapWrapper
+- Removed BeansWrapper, which was the superclass of DefaultObjectWrapper, but wasn't recommended
to be used as is.
+  Removed many BeansWrapper-related classes that DefaultObjectWrapper doesn't use. This includes
ModelCache and
+  related classes, because DefaultObjectWrapper has only used the cache for "generic" classes
(because that's where it
+  has fallen back to BeansWrapper.wrap), which is inconsistent and doesn't worth the caching
overhead and complexity.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/780b76a6/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
index a5f5a04..26329f0 100644
--- a/src/test/java/org/apache/freemarker/core/SimpleObjectWrapperTest.java
+++ b/src/test/java/org/apache/freemarker/core/SimpleObjectWrapperTest.java
@@ -19,6 +19,7 @@
 
 package org.apache.freemarker.core;
 
+import static org.apache.freemarker.test.hamcerst.Matchers.*;
 import static org.junit.Assert.*;
 
 import java.util.Collections;
@@ -66,7 +67,7 @@ public class SimpleObjectWrapperTest {
             ow.wrap(new TestBean());
             fail();
         } catch (TemplateModelException e) {
-            assertTrue(e.getMessage().contains("type"));
+            assertThat(e.getMessage(), containsStringIgnoringCase("type"));
         }
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/780b76a6/src/test/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperModelFactoryRegistrationTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperModelFactoryRegistrationTest.java
b/src/test/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperModelFactoryRegistrationTest.java
index 62e3e5f..901b017 100644
--- a/src/test/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperModelFactoryRegistrationTest.java
+++ b/src/test/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperModelFactoryRegistrationTest.java
@@ -32,19 +32,19 @@ public class DefaultObjectWrapperModelFactoryRegistrationTest {
     public void introspectionSettingChanges() {
         DefaultObjectWrapper ow = new DefaultObjectWrapper(Configuration.VERSION_3_0_0);
         ClassIntrospector ci1 = ow.getClassIntrospector();
-        checkRegisteredModelFactories(ci1, ow.getStaticModels(), ow.getEnumModels(), ow.getModelCache());
+        checkRegisteredModelFactories(ci1, ow.getStaticModels(), ow.getEnumModels());
 
         ow.setExposeFields(true);
         ClassIntrospector ci2 = ow.getClassIntrospector();
         assertNotSame(ci1, ci2);
         checkRegisteredModelFactories(ci1);
-        checkRegisteredModelFactories(ci2, ow.getStaticModels(), ow.getEnumModels(), ow.getModelCache());
+        checkRegisteredModelFactories(ci2, ow.getStaticModels(), ow.getEnumModels());
 
         ow.setExposureLevel(DefaultObjectWrapper.EXPOSE_ALL);
         ClassIntrospector ci3 = ow.getClassIntrospector();
         assertNotSame(ci2, ci3);
         checkRegisteredModelFactories(ci2);
-        checkRegisteredModelFactories(ci3, ow.getStaticModels(), ow.getEnumModels(), ow.getModelCache());
+        checkRegisteredModelFactories(ci3, ow.getStaticModels(), ow.getEnumModels());
 
         MethodAppearanceFineTuner maf = new MethodAppearanceFineTuner() {
             @Override
@@ -56,7 +56,7 @@ public class DefaultObjectWrapperModelFactoryRegistrationTest {
         ClassIntrospector ci4 = ow.getClassIntrospector();
         assertNotSame(ci3, ci4);
         checkRegisteredModelFactories(ci3);
-        checkRegisteredModelFactories(ci4, ow.getStaticModels(), ow.getEnumModels(), ow.getModelCache());
+        checkRegisteredModelFactories(ci4, ow.getStaticModels(), ow.getEnumModels());
 
         ow.setExposeFields(true);
         assertSame(ci4, ow.getClassIntrospector());
@@ -64,7 +64,7 @@ public class DefaultObjectWrapperModelFactoryRegistrationTest {
         assertSame(ci4, ow.getClassIntrospector());
         ow.setMethodAppearanceFineTuner(maf);
         assertSame(ci4, ow.getClassIntrospector());
-        checkRegisteredModelFactories(ci4, ow.getStaticModels(), ow.getEnumModels(), ow.getModelCache());
+        checkRegisteredModelFactories(ci4, ow.getStaticModels(), ow.getEnumModels());
     }
 
     private void checkRegisteredModelFactories(ClassIntrospector ci, Object... expected)
{

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/780b76a6/src/test/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperTest.java
b/src/test/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperTest.java
index 5b62a9b..9d84154 100644
--- a/src/test/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperTest.java
+++ b/src/test/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperTest.java
@@ -201,7 +201,7 @@ public class DefaultObjectWrapperTest {
         assertTrue(ow.wrap(Collections.emptyList()) instanceof DefaultListAdapter);
         assertTrue(ow.wrap(new boolean[] { }) instanceof DefaultArrayAdapter);
         assertTrue(ow.wrap(new HashSet()) instanceof DefaultNonListCollectionAdapter);
-        assertTrue(ow.wrap('c') instanceof TemplateScalarModel); // StringModel right now,
but should change later
+        assertTrue(ow.wrap('c') instanceof TemplateScalarModel); // BeanAndStringModel right
now, but should change later
         
         TemplateHashModel bean = (TemplateHashModel) ow.wrap(new TestBean());
         assertEquals(1, ow.unwrap(bean.get("x")));
@@ -824,12 +824,12 @@ public class DefaultObjectWrapperTest {
         }
         
         @Override
-        protected TemplateModel handleUnknownType(final Object obj) throws TemplateModelException
{
+        protected TemplateModel handleNonBasicTypes(final Object obj) throws TemplateModelException
{
             if (obj instanceof Tupple) {
                 return new TuppleAdapter((Tupple<?, ?>) obj, this);
             }
             
-            return super.handleUnknownType(obj);
+            return super.handleNonBasicTypes(obj);
         }
         
     }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/780b76a6/src/test/java/org/apache/freemarker/core/model/impl/ModelCacheTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/core/model/impl/ModelCacheTest.java b/src/test/java/org/apache/freemarker/core/model/impl/ModelCacheTest.java
index 4ad3c0e..5172459 100644
--- a/src/test/java/org/apache/freemarker/core/model/impl/ModelCacheTest.java
+++ b/src/test/java/org/apache/freemarker/core/model/impl/ModelCacheTest.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.*;
 
 import org.apache.freemarker.core.Configuration;
 import org.apache.freemarker.core.model.TemplateModel;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
@@ -43,6 +44,7 @@ public class ModelCacheTest {
     }
     
     @Test
+    @Ignore // ModelCache is current removed in FM3
     public void modelCacheOn() throws Exception {
         DefaultObjectWrapper ow = new DefaultObjectWrapper(Configuration.VERSION_3_0_0);
         ow.setUseModelCache(true);

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/780b76a6/src/test/java/org/apache/freemarker/test/templatesuite/TemplateTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/test/templatesuite/TemplateTestCase.java
b/src/test/java/org/apache/freemarker/test/templatesuite/TemplateTestCase.java
index cce84a4..6183170 100644
--- a/src/test/java/org/apache/freemarker/test/templatesuite/TemplateTestCase.java
+++ b/src/test/java/org/apache/freemarker/test/templatesuite/TemplateTestCase.java
@@ -54,7 +54,6 @@ import org.apache.freemarker.core.model.TemplateMethodModel;
 import org.apache.freemarker.core.model.TemplateNodeModel;
 import org.apache.freemarker.core.model.TemplateScalarModel;
 import org.apache.freemarker.core.model.TemplateSequenceModel;
-import org.apache.freemarker.core.model.impl.BooleanModel;
 import org.apache.freemarker.core.model.impl.DefaultNonListCollectionAdapter;
 import org.apache.freemarker.core.model.impl.DefaultObjectWrapper;
 import org.apache.freemarker.core.model.impl.DefaultObjectWrapperBuilder;
@@ -367,7 +366,6 @@ public class TemplateTestCase extends FileTestCase {
         } else if (simpleTestName.equals("varargs")) {
           dataModel.put("m", new VarArgTestModel());
         } else if (simpleTestName.startsWith("boolean-formatting")) {
-          dataModel.put("beansBoolean", new BooleanModel(Boolean.TRUE, (DefaultObjectWrapper)
conf.getObjectWrapper()));
           dataModel.put("booleanAndString", new BooleanAndStringTemplateModel());
           dataModel.put("booleanVsStringMethods", new BooleanVsStringMethods());
         } else if (simpleTestName.startsWith("number-math-builtins")) {

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/780b76a6/src/test/resources/org/apache/freemarker/test/templatesuite/expected/boolean-formatting.txt
----------------------------------------------------------------------
diff --git a/src/test/resources/org/apache/freemarker/test/templatesuite/expected/boolean-formatting.txt
b/src/test/resources/org/apache/freemarker/test/templatesuite/expected/boolean-formatting.txt
index d736687..73b0788 100644
--- a/src/test/resources/org/apache/freemarker/test/templatesuite/expected/boolean-formatting.txt
+++ b/src/test/resources/org/apache/freemarker/test/templatesuite/expected/boolean-formatting.txt
@@ -24,7 +24,6 @@ y y y
 n n n
 str:n str:n
 nein ja
-y y
 theStringValue theStringValue
 
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/780b76a6/src/test/resources/org/apache/freemarker/test/templatesuite/templates/boolean-formatting.ftl
----------------------------------------------------------------------
diff --git a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/boolean-formatting.ftl
b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/boolean-formatting.ftl
index 6ccc6ca..80c968c 100644
--- a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/boolean-formatting.ftl
+++ b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/boolean-formatting.ftl
@@ -69,7 +69,6 @@
 <#assign x = false>${x} ${false} ${false?string}
 ${'str:' + x} ${'str:' + false}
 ${x?string('ja', 'nein')} ${true?string('ja', 'nein')}
-${beansBoolean} ${beansBoolean?string}
 ${booleanAndString} ${booleanAndString?string}
 
 <#setting boolean_format = 'y,n'>


Mime
View raw message