@@ -16,6 +16,12 @@ public class LargeNameReadTest extends BaseTest
16
16
.streamReadConstraints (StreamReadConstraints .builder ().maxNameLength (100 ).build ())
17
17
.build ();
18
18
19
+ private final JsonFactory JSON_F_NAME_100_B = new JsonFactory ();
20
+ {
21
+ JSON_F_NAME_100_B .setStreamReadConstraints (StreamReadConstraints .builder ()
22
+ .maxNameLength (100 ).build ());
23
+ }
24
+
19
25
// Test name that is below default max name
20
26
public void testLargeNameBytes () throws Exception {
21
27
final String doc = generateJSON (StreamReadConstraints .defaults ().getMaxNameLength () - 100 );
@@ -31,21 +37,31 @@ public void testLargeNameChars() throws Exception {
31
37
}
32
38
}
33
39
34
- public void testLargeNameWithSmallLimitBytes () throws Exception
40
+ public void testLargeNameWithSmallLimitBytes () throws Exception {
41
+ _testLargeNameWithSmallLimitBytes (JSON_F_NAME_100 );
42
+ _testLargeNameWithSmallLimitBytes (JSON_F_NAME_100_B );
43
+ }
44
+
45
+ private void _testLargeNameWithSmallLimitBytes (JsonFactory jf ) throws Exception
35
46
{
36
47
final String doc = generateJSON (1000 );
37
- try (JsonParser p = createParserUsingStream (JSON_F_NAME_100 , doc , "UTF-8" )) {
48
+ try (JsonParser p = createParserUsingStream (jf , doc , "UTF-8" )) {
38
49
consumeTokens (p );
39
50
fail ("expected StreamConstraintsException" );
40
51
} catch (StreamConstraintsException e ) {
41
52
verifyException (e , "Name length" );
42
53
}
43
54
}
44
55
45
- public void testLargeNameWithSmallLimitChars () throws Exception
56
+ public void testLargeNameWithSmallLimitChars () throws Exception {
57
+ _testLargeNameWithSmallLimitChars (JSON_F_NAME_100 );
58
+ _testLargeNameWithSmallLimitChars (JSON_F_NAME_100_B );
59
+ }
60
+
61
+ private void _testLargeNameWithSmallLimitChars (JsonFactory jf ) throws Exception
46
62
{
47
63
final String doc = generateJSON (1000 );
48
- try (JsonParser p = createParserUsingReader (JSON_F_NAME_100 , doc )) {
64
+ try (JsonParser p = createParserUsingReader (jf , doc )) {
49
65
consumeTokens (p );
50
66
fail ("expected StreamConstraintsException" );
51
67
} catch (StreamConstraintsException e ) {
0 commit comments