Skip to content

Commit 09d6cfb

Browse files
committed
[FREEMARKER-234] Fixed a unit test. Improved Configuration.incompatibleImprovements javadoc.
1 parent 6c2b018 commit 09d6cfb

2 files changed

Lines changed: 46 additions & 113 deletions

File tree

freemarker-core/src/main/java/freemarker/template/Configuration.java

Lines changed: 27 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -19,89 +19,26 @@
1919

2020
package freemarker.template;
2121

22+
import freemarker.cache.*;
23+
import freemarker.cache.TemplateCache.MaybeMissingTemplate;
24+
import freemarker.core.*;
25+
import freemarker.ext.beans.BeansWrapper;
26+
import freemarker.ext.beans.BeansWrapperBuilder;
27+
import freemarker.log.Logger;
28+
import freemarker.template.utility.*;
29+
2230
import java.io.File;
2331
import java.io.IOException;
2432
import java.io.Writer;
2533
import java.lang.reflect.InvocationTargetException;
2634
import java.net.URLConnection;
2735
import java.text.Collator;
2836
import java.text.DecimalFormat;
29-
import java.util.Collection;
30-
import java.util.Collections;
31-
import java.util.HashMap;
32-
import java.util.HashSet;
33-
import java.util.Iterator;
34-
import java.util.LinkedHashMap;
35-
import java.util.List;
36-
import java.util.Locale;
37-
import java.util.Map;
37+
import java.util.*;
3838
import java.util.Map.Entry;
39-
import java.util.Properties;
40-
import java.util.Set;
41-
import java.util.TimeZone;
42-
import java.util.TreeSet;
4339
import java.util.concurrent.ConcurrentHashMap;
4440
import java.util.concurrent.ConcurrentMap;
4541

46-
import freemarker.cache.CacheStorage;
47-
import freemarker.cache.ClassTemplateLoader;
48-
import freemarker.cache.FileTemplateLoader;
49-
import freemarker.cache.MruCacheStorage;
50-
import freemarker.cache.MultiTemplateLoader;
51-
import freemarker.cache.SoftCacheStorage;
52-
import freemarker.cache.TemplateCache;
53-
import freemarker.cache.TemplateCache.MaybeMissingTemplate;
54-
import freemarker.cache.TemplateConfigurationFactory;
55-
import freemarker.cache.TemplateLoader;
56-
import freemarker.cache.TemplateLookupContext;
57-
import freemarker.cache.TemplateLookupStrategy;
58-
import freemarker.cache.TemplateNameFormat;
59-
import freemarker.cache.URLTemplateLoader;
60-
import freemarker.core.BugException;
61-
import freemarker.core.CFormat;
62-
import freemarker.core.CSSOutputFormat;
63-
import freemarker.core.CombinedMarkupOutputFormat;
64-
import freemarker.core.Configurable;
65-
import freemarker.core.Environment;
66-
import freemarker.core.HTMLOutputFormat;
67-
import freemarker.core.JSONOutputFormat;
68-
import freemarker.core.JavaScriptOrJSONCFormat;
69-
import freemarker.core.JavaScriptOutputFormat;
70-
import freemarker.core.LegacyCFormat;
71-
import freemarker.core.MarkupOutputFormat;
72-
import freemarker.core.OutputFormat;
73-
import freemarker.core.ParseException;
74-
import freemarker.core.ParserConfiguration;
75-
import freemarker.core.PlainTextOutputFormat;
76-
import freemarker.core.RTFOutputFormat;
77-
import freemarker.core.TemplateConfiguration;
78-
import freemarker.core.TemplateMarkupOutputModel;
79-
import freemarker.core.UndefinedOutputFormat;
80-
import freemarker.core.UnregisteredOutputFormatException;
81-
import freemarker.core.XHTMLOutputFormat;
82-
import freemarker.core.XMLOutputFormat;
83-
import freemarker.core.XSCFormat;
84-
import freemarker.core._CoreAPI;
85-
import freemarker.core._DelayedJQuote;
86-
import freemarker.core._MiscTemplateException;
87-
import freemarker.core._ObjectBuilderSettingEvaluator;
88-
import freemarker.core._SettingEvaluationEnvironment;
89-
import freemarker.core._SortedArraySet;
90-
import freemarker.core._UnmodifiableCompositeSet;
91-
import freemarker.ext.beans.BeansWrapper;
92-
import freemarker.ext.beans.BeansWrapperBuilder;
93-
import freemarker.log.Logger;
94-
import freemarker.template.utility.CaptureOutput;
95-
import freemarker.template.utility.ClassUtil;
96-
import freemarker.template.utility.Constants;
97-
import freemarker.template.utility.HtmlEscape;
98-
import freemarker.template.utility.NormalizeNewlines;
99-
import freemarker.template.utility.NullArgumentException;
100-
import freemarker.template.utility.SecurityUtilities;
101-
import freemarker.template.utility.StandardCompress;
102-
import freemarker.template.utility.StringUtil;
103-
import freemarker.template.utility.XmlEscape;
104-
10542
/**
10643
* <b>The main entry point into the FreeMarker API</b>; encapsulates the configuration settings of FreeMarker,
10744
* also serves as a central template-loading and caching service.
@@ -877,7 +814,7 @@ public Configuration() {
877814
* <li><p>
878815
* {@link DefaultObjectWrapper} has some minor changes with {@code incompatibleImprovements} 2.3.24;
879816
* check them out at {@link DefaultObjectWrapper#DefaultObjectWrapper(Version)}. It's important to know
880-
* that if you set the {@code object_wrapper} setting (to an other value than {@code "default"}), rather
817+
* that if you set the {@code object_wrapper} setting (to another value than {@code "default"}), rather
881818
* than leaving it on its default value, the {@code object_wrapper} won't inherit the
882819
* {@code incompatibleImprovements} of the {@link Configuration}. In that case, if you want the 2.3.24
883820
* improvements of {@link DefaultObjectWrapper}, you have to set it in the {@link DefaultObjectWrapper}
@@ -938,7 +875,7 @@ public Configuration() {
938875
* exception (though almost all implementation does), you couldn't use said directives inside the
939876
* transformed block. It's very unlikely that user code is affected by this, partially because these aren't
940877
* commonly implemented interfaces (especially not {@link TransformControl}), and because it's unlikely
941-
* that templates utilize the the bug that's not fixed.
878+
* that templates utilize the bug that's not fixed.
942879
* </ul>
943880
* </li>
944881
* <li><p>
@@ -997,7 +934,7 @@ public Configuration() {
997934
* <p>
998935
* 2.3.33 (or higher):
999936
* <ul>
1000-
* <li><p>Comparing strings is now way faster. If your template does lot of string comparisons, this can
937+
* <li><p>Comparing strings is now way faster. If your template does a lot of string comparisons, this can
1001938
* mean very significant speedup. We now use a simpler way of comparing strings, and because templates
1002939
* were only ever allowed equality comparisons between strings (not less-than, or greater-than), it's very
1003940
* unlikely to change the behavior of your templates. (Technically, what changes is that instead of using
@@ -1008,8 +945,8 @@ public Configuration() {
1008945
* normalization, so combining characters won't break your comparisons.)</p></li>
1009946
* <li><p>
1010947
* The default {@link Configuration#setObjectWrapper(ObjectWrapper) object_wrapper} now exposes Java
1011-
* records public methods with 0-arguments and non-void return type are now exposed both as properties,
1012-
* and as methods; see {@link BeansWrapper#BeansWrapper(Version)}.
948+
* records public methods with 0-arguments and non-void return type both as properties and as methods;
949+
* see {@link BeansWrapper#BeansWrapper(Version)}.
1013950
* </ul>
1014951
* </li>
1015952
* <li>
@@ -1025,6 +962,19 @@ public Configuration() {
1025962
* text, just as it's done for any other FTL tags.
1026963
* </ul>
1027964
* </li>
965+
* <li>
966+
* <p>
967+
* 2.3.35 (or higher):
968+
* <ul>
969+
* <li><p>
970+
* The default {@link Configuration#setObjectWrapper(ObjectWrapper) object_wrapper} now exposes "is"
971+
* methods (like {@code isExpired()}) as a JavaBeans property (like {@code obj.expirted}) even if the
972+
* return type is not primitive {@code boolean}, but {@code Boolean}. The method will be still also be
973+
* exposed as a plain method ({@code obj.isExpirted()}), so this is a mostly backward compatible change.
974+
* see {@link BeansWrapper#BeansWrapper(Version)}.
975+
* </li>
976+
* </ul>
977+
* </li>
1028978
* </ul>
1029979
*
1030980
* @throws IllegalArgumentException

freemarker-jython25/src/test/java/freemarker/template/DefaultObjectWrapperTest.java

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,49 +19,32 @@
1919

2020
package freemarker.template;
2121

22-
import static freemarker.test.hamcerst.Matchers.*;
23-
import static org.hamcrest.Matchers.*;
24-
import static org.junit.Assert.*;
25-
26-
import java.io.IOException;
27-
import java.io.StringReader;
28-
import java.io.StringWriter;
29-
import java.util.ArrayList;
30-
import java.util.Arrays;
31-
import java.util.Collections;
32-
import java.util.Date;
33-
import java.util.HashMap;
34-
import java.util.HashSet;
35-
import java.util.Iterator;
36-
import java.util.LinkedHashMap;
37-
import java.util.LinkedList;
38-
import java.util.List;
39-
import java.util.Map;
40-
import java.util.Set;
41-
import java.util.TreeMap;
42-
import java.util.TreeSet;
43-
import java.util.Vector;
44-
45-
import javax.xml.parsers.DocumentBuilder;
46-
import javax.xml.parsers.DocumentBuilderFactory;
47-
import javax.xml.parsers.ParserConfigurationException;
48-
49-
import org.hamcrest.Matchers;
50-
import org.junit.Test;
51-
import org.python.core.PyString;
52-
import org.w3c.dom.Document;
53-
import org.xml.sax.InputSource;
54-
import org.xml.sax.SAXException;
55-
5622
import com.google.common.collect.ImmutableList;
5723
import com.google.common.collect.ImmutableMap;
58-
5924
import freemarker.ext.beans.BeansWrapper;
6025
import freemarker.ext.beans.EnumerationModel;
6126
import freemarker.ext.beans.HashAdapter;
6227
import freemarker.ext.beans.WhitelistMemberAccessPolicy;
6328
import freemarker.ext.jython.JythonSequenceModel;
6429
import freemarker.ext.util.WrapperTemplateModel;
30+
import org.hamcrest.Matchers;
31+
import org.junit.Test;
32+
import org.python.core.PyString;
33+
import org.w3c.dom.Document;
34+
import org.xml.sax.InputSource;
35+
import org.xml.sax.SAXException;
36+
37+
import javax.xml.parsers.DocumentBuilder;
38+
import javax.xml.parsers.DocumentBuilderFactory;
39+
import javax.xml.parsers.ParserConfigurationException;
40+
import java.io.IOException;
41+
import java.io.StringReader;
42+
import java.io.StringWriter;
43+
import java.util.*;
44+
45+
import static freemarker.test.hamcerst.Matchers.containsStringIgnoringCase;
46+
import static org.hamcrest.Matchers.*;
47+
import static org.junit.Assert.*;
6548

6649
public class DefaultObjectWrapperTest {
6750

@@ -106,7 +89,7 @@ public void testIncompatibleImprovementsVersionBreakPoints() throws Exception {
10689
expected.add(Configuration.VERSION_2_3_27); // no non-BC change in 2.3.32
10790
expected.add(Configuration.VERSION_2_3_33);
10891
expected.add(Configuration.VERSION_2_3_33); // no non-BC change in 2.3.34
109-
expected.add(Configuration.VERSION_2_3_33); // no non-BC change in 2.3.35
92+
expected.add(Configuration.VERSION_2_3_35); // no non-BC change in 2.3.35
11093

11194
List<Version> actual = new ArrayList<>();
11295
for (int i = _VersionInts.V_2_3_0; i <= Configuration.getVersion().intValue(); i++) {

0 commit comments

Comments
 (0)