4
4
5
5
import com .fasterxml .jackson .core .*;
6
6
import com .fasterxml .jackson .core .async .AsyncTestBase ;
7
+ import com .fasterxml .jackson .core .json .JsonReadFeature ;
7
8
import com .fasterxml .jackson .core .testsupport .AsyncReaderWrapper ;
8
9
9
10
public class AsyncNonStdNumbersTest extends AsyncTestBase
10
11
{
11
12
private final JsonFactory DEFAULT_F = new JsonFactory ();
12
13
14
+ @ SuppressWarnings ("deprecation" )
15
+ public void testDefaultsForAsync () throws Exception {
16
+ assertFalse (DEFAULT_F .isEnabled (JsonParser .Feature .ALLOW_NON_NUMERIC_NUMBERS ));
17
+ }
18
+
13
19
public void testDisallowNaN () throws Exception
14
20
{
15
21
final String JSON = "[ NaN]" ;
16
- assertFalse (DEFAULT_F .isEnabled (JsonParser .Feature .ALLOW_NON_NUMERIC_NUMBERS ));
17
22
18
23
// without enabling, should get an exception
19
24
AsyncReaderWrapper p = createParser (DEFAULT_F , JSON , 1 );
@@ -31,9 +36,9 @@ public void testDisallowNaN() throws Exception
31
36
public void testAllowNaN () throws Exception
32
37
{
33
38
final String JSON = "[ NaN]" ;
34
- JsonFactory f = new JsonFactory ();
35
- f . configure ( JsonParser . Feature . ALLOW_NON_NUMERIC_NUMBERS , true );
36
-
39
+ JsonFactory f = JsonFactory . builder ()
40
+ . enable ( JsonReadFeature . ALLOW_NON_NUMERIC_NUMBERS )
41
+ . build ();
37
42
_testAllowNaN (f , JSON , 99 );
38
43
_testAllowNaN (f , JSON , 5 );
39
44
_testAllowNaN (f , JSON , 3 );
@@ -62,7 +67,9 @@ private void _testAllowNaN(JsonFactory f, String doc, int readBytes) throws Exce
62
67
p .close ();
63
68
64
69
// finally, should also work with skipping
65
- f .configure (JsonParser .Feature .ALLOW_NON_NUMERIC_NUMBERS , true );
70
+ f = JsonFactory .builder ()
71
+ .configure (JsonReadFeature .ALLOW_NON_NUMERIC_NUMBERS , true )
72
+ .build ();
66
73
p = createParser (f , doc , readBytes );
67
74
assertToken (JsonToken .START_ARRAY , p .nextToken ());
68
75
assertToken (JsonToken .VALUE_NUMBER_FLOAT , p .nextToken ());
@@ -91,7 +98,6 @@ public void testDisallowInf() throws Exception
91
98
92
99
private void _testDisallowInf (JsonFactory f , String token , int readBytes ) throws Exception
93
100
{
94
- assertFalse (f .isEnabled (JsonParser .Feature .ALLOW_NON_NUMERIC_NUMBERS ));
95
101
final String JSON = String .format ("[%s]" , token );
96
102
97
103
// without enabling, should get an exception
@@ -109,9 +115,9 @@ private void _testDisallowInf(JsonFactory f, String token, int readBytes) throws
109
115
110
116
public void testAllowInf () throws Exception
111
117
{
112
- JsonFactory f = new JsonFactory ();
113
- f . configure ( JsonParser . Feature . ALLOW_NON_NUMERIC_NUMBERS , true );
114
-
118
+ JsonFactory f = JsonFactory . builder ()
119
+ . enable ( JsonReadFeature . ALLOW_NON_NUMERIC_NUMBERS )
120
+ . build ();
115
121
String JSON = "[ Infinity, +Infinity, -Infinity ]" ;
116
122
_testAllowInf (f , JSON , 99 );
117
123
_testAllowInf (f , JSON , 5 );
@@ -160,7 +166,9 @@ private void _testAllowInf(JsonFactory f, String doc, int readBytes) throws Exce
160
166
p .close ();
161
167
162
168
// finally, should also work with skipping
163
- f .configure (JsonParser .Feature .ALLOW_NON_NUMERIC_NUMBERS , true );
169
+ f = JsonFactory .builder ()
170
+ .configure (JsonReadFeature .ALLOW_NON_NUMERIC_NUMBERS , true )
171
+ .build ();
164
172
p = createParser (f , doc , readBytes );
165
173
166
174
assertToken (JsonToken .START_ARRAY , p .nextToken ());
0 commit comments