@@ -77,21 +77,25 @@ public void testJavaType() throws Exception
77
77
public void testTokenBufferWithSample () throws Exception
78
78
{
79
79
// First, try standard sample doc:
80
- TokenBuffer result = MAPPER .readValue (SAMPLE_DOC_JSON_SPEC , TokenBuffer .class );
81
- verifyJsonSpecSampleDoc (result .asParser (), true );
82
- result . close ();
80
+ try ( TokenBuffer result = MAPPER .readValue (SAMPLE_DOC_JSON_SPEC , TokenBuffer .class )) {
81
+ verifyJsonSpecSampleDoc (result .asParser (), true );
82
+ }
83
83
}
84
84
85
85
@ SuppressWarnings ("resource" )
86
86
@ Test
87
87
public void testTokenBufferWithSequence () throws Exception
88
88
{
89
+ final ObjectMapper mapper = jsonMapperBuilder ()
90
+ .disable (DeserializationFeature .FAIL_ON_TRAILING_TOKENS )
91
+ .build ();
92
+
89
93
// and then sequence of other things
90
- JsonParser jp = MAPPER .createParser ("[ 32, [ 1 ], \" abc\" , { \" a\" : true } ]" );
91
- assertToken (JsonToken .START_ARRAY , jp .nextToken ());
94
+ JsonParser p = mapper .createParser ("[ 32, [ 1 ], \" abc\" , { \" a\" : true } ]" );
95
+ assertToken (JsonToken .START_ARRAY , p .nextToken ());
92
96
93
- assertToken (JsonToken .VALUE_NUMBER_INT , jp .nextToken ());
94
- TokenBuffer buf = MAPPER .readValue (jp , TokenBuffer .class );
97
+ assertToken (JsonToken .VALUE_NUMBER_INT , p .nextToken ());
98
+ TokenBuffer buf = mapper .readValue (p , TokenBuffer .class );
95
99
96
100
// check manually...
97
101
JsonParser bufParser = buf .asParser ();
@@ -100,7 +104,7 @@ public void testTokenBufferWithSequence() throws Exception
100
104
assertNull (bufParser .nextToken ());
101
105
102
106
// then bind to another
103
- buf = MAPPER .readValue (jp , TokenBuffer .class );
107
+ buf = mapper .readValue (p , TokenBuffer .class );
104
108
bufParser = buf .asParser ();
105
109
assertToken (JsonToken .START_ARRAY , bufParser .nextToken ());
106
110
assertToken (JsonToken .VALUE_NUMBER_INT , bufParser .nextToken ());
@@ -109,18 +113,18 @@ public void testTokenBufferWithSequence() throws Exception
109
113
assertNull (bufParser .nextToken ());
110
114
111
115
// third one, with automatic binding
112
- buf = MAPPER .readValue (jp , TokenBuffer .class );
113
- String str = MAPPER .readValue (buf .asParser (), String .class );
116
+ buf = mapper .readValue (p , TokenBuffer .class );
117
+ String str = mapper .readValue (buf .asParser (), String .class );
114
118
assertEquals ("abc" , str );
115
119
116
120
// and ditto for last one
117
- buf = MAPPER .readValue (jp , TokenBuffer .class );
118
- Map <?,?> map = MAPPER .readValue (buf .asParser (), Map .class );
121
+ buf = mapper .readValue (p , TokenBuffer .class );
122
+ Map <?,?> map = mapper .readValue (buf .asParser (), Map .class );
119
123
assertEquals (1 , map .size ());
120
124
assertEquals (Boolean .TRUE , map .get ("a" ));
121
125
122
- assertEquals (JsonToken .END_ARRAY , jp .nextToken ());
123
- assertNull (jp .nextToken ());
126
+ assertEquals (JsonToken .END_ARRAY , p .nextToken ());
127
+ assertNull (p .nextToken ());
124
128
}
125
129
126
130
// 10k does it, 5k not, but use bit higher values just in case
0 commit comments