@@ -26,6 +26,12 @@ static class POJO {
26
26
public Map <String , Object > name ;
27
27
}
28
28
29
+ /*
30
+ /**********************************************************
31
+ /* Test methods, simple read/write with defaults
32
+ /**********************************************************
33
+ */
34
+
29
35
public void testSimpleViaParser () throws Exception
30
36
{
31
37
final String JSON = "[1]" ;
@@ -89,6 +95,22 @@ public void testReaderForMapOf() throws Exception
89
95
assertEquals (Collections .singletonMap ("key" , ABC .B ), value );
90
96
}
91
97
98
+ public void testNodeHandling () throws Exception
99
+ {
100
+ JsonNodeFactory nodes = new JsonNodeFactory (true );
101
+ ObjectReader r = MAPPER .reader ().with (nodes );
102
+ // but also no further changes if attempting again
103
+ assertSame (r , r .with (nodes ));
104
+ assertTrue (r .createArrayNode ().isArray ());
105
+ assertTrue (r .createObjectNode ().isObject ());
106
+ }
107
+
108
+ /*
109
+ /**********************************************************
110
+ /* Test methods, some alternative JSON settings
111
+ /**********************************************************
112
+ */
113
+
92
114
public void testParserFeaturesComments () throws Exception
93
115
{
94
116
final String JSON = "[ /* foo */ 7 ]" ;
@@ -140,15 +162,11 @@ public void testParserFeaturesCtrlChars() throws Exception
140
162
assertEquals (1 , result .size ());
141
163
}
142
164
143
- public void testNodeHandling () throws Exception
144
- {
145
- JsonNodeFactory nodes = new JsonNodeFactory (true );
146
- ObjectReader r = MAPPER .reader ().with (nodes );
147
- // but also no further changes if attempting again
148
- assertSame (r , r .with (nodes ));
149
- assertTrue (r .createArrayNode ().isArray ());
150
- assertTrue (r .createObjectNode ().isObject ());
151
- }
165
+ /*
166
+ /**********************************************************
167
+ /* Test methods, config setting verification
168
+ /**********************************************************
169
+ */
152
170
153
171
public void testFeatureSettings () throws Exception
154
172
{
@@ -268,6 +286,31 @@ public void testGetValueType() throws Exception
268
286
assertEquals (MAPPER .constructType (String .class ), r .getValueType ());
269
287
}
270
288
289
+ public void testParserConfigViaMapper () throws Exception
290
+ {
291
+ try (JsonParser p = MAPPER .reader ()
292
+ .with (StreamReadFeature .STRICT_DUPLICATE_DETECTION )
293
+ .createParser ("[ ]" )) {
294
+ assertTrue (p .isEnabled (StreamReadFeature .STRICT_DUPLICATE_DETECTION ));
295
+ }
296
+
297
+ try (JsonParser p = MAPPER .reader ()
298
+ .with (JsonReadFeature .ALLOW_JAVA_COMMENTS )
299
+ .createParser ("[ ]" )) {
300
+ assertTrue (p .isEnabled (JsonReadFeature .ALLOW_JAVA_COMMENTS .mappedFeature ()));
301
+ }
302
+ }
303
+
304
+ public void testGeneratorConfigViaMapper () throws Exception
305
+ {
306
+ StringWriter sw = new StringWriter ();
307
+ try (JsonGenerator g = MAPPER .writer ()
308
+ .with (StreamWriteFeature .IGNORE_UNKNOWN )
309
+ .createGenerator (sw )) {
310
+ assertTrue (g .isEnabled (StreamWriteFeature .IGNORE_UNKNOWN ));
311
+ }
312
+ }
313
+
271
314
/*
272
315
/**********************************************************
273
316
/* Test methods, JsonPointer
0 commit comments