3
3
import java .io .*;
4
4
5
5
import com .fasterxml .jackson .core .*;
6
+ import com .fasterxml .jackson .core .json .JsonReadFeature ;
6
7
7
8
/**
8
9
* Unit tests for verifying that support for (non-standard) comments
@@ -29,6 +30,7 @@ public class CommentParsingTest
29
30
* Unit test for verifying that by default comments are not
30
31
* recognized.
31
32
*/
33
+ @ SuppressWarnings ("deprecation" )
32
34
public void testDefaultSettings () throws Exception
33
35
{
34
36
JsonFactory jf = new JsonFactory ();
@@ -72,8 +74,9 @@ public void testCommentsWithUTF8() throws Exception
72
74
}
73
75
74
76
public void testYAMLCommentsBytes () throws Exception {
75
- JsonFactory f = new JsonFactory ();
76
- f .configure (JsonParser .Feature .ALLOW_YAML_COMMENTS , true );
77
+ final JsonFactory f = JsonFactory .builder ()
78
+ .enable (JsonReadFeature .ALLOW_YAML_COMMENTS )
79
+ .build ();
77
80
78
81
_testYAMLComments (f , MODE_INPUT_STREAM );
79
82
_testCommentsBeforePropValue (f , MODE_INPUT_STREAM , "# foo\n " );
@@ -84,42 +87,47 @@ public void testYAMLCommentsBytes() throws Exception {
84
87
}
85
88
86
89
public void testYAMLCommentsChars () throws Exception {
87
- JsonFactory f = new JsonFactory ();
88
- f .configure (JsonParser .Feature .ALLOW_YAML_COMMENTS , true );
90
+ final JsonFactory f = JsonFactory .builder ()
91
+ .enable (JsonReadFeature .ALLOW_YAML_COMMENTS )
92
+ .build ();
89
93
_testYAMLComments (f , MODE_READER );
90
94
final String COMMENT = "# foo\n " ;
91
95
_testCommentsBeforePropValue (f , MODE_READER , COMMENT );
92
96
_testCommentsBetweenArrayValues (f , MODE_READER , COMMENT );
93
97
}
94
98
95
99
public void testCCommentsBytes () throws Exception {
96
- JsonFactory f = new JsonFactory ();
97
- f .configure (JsonParser .Feature .ALLOW_COMMENTS , true );
100
+ final JsonFactory f = JsonFactory .builder ()
101
+ .enable (JsonReadFeature .ALLOW_JAVA_COMMENTS )
102
+ .build ();
98
103
final String COMMENT = "/* foo */\n " ;
99
104
_testCommentsBeforePropValue (f , MODE_INPUT_STREAM , COMMENT );
100
105
_testCommentsBeforePropValue (f , MODE_INPUT_STREAM_THROTTLED , COMMENT );
101
106
_testCommentsBeforePropValue (f , MODE_DATA_INPUT , COMMENT );
102
107
}
103
108
104
109
public void testCCommentsChars () throws Exception {
105
- JsonFactory f = new JsonFactory ();
106
- f .configure (JsonParser .Feature .ALLOW_COMMENTS , true );
110
+ final JsonFactory f = JsonFactory .builder ()
111
+ .enable (JsonReadFeature .ALLOW_JAVA_COMMENTS )
112
+ .build ();
107
113
final String COMMENT = "/* foo */\n " ;
108
114
_testCommentsBeforePropValue (f , MODE_READER , COMMENT );
109
115
}
110
116
111
117
public void testCppCommentsBytes () throws Exception {
112
- JsonFactory f = new JsonFactory ();
113
- f .configure (JsonParser .Feature .ALLOW_COMMENTS , true );
118
+ final JsonFactory f = JsonFactory .builder ()
119
+ .enable (JsonReadFeature .ALLOW_JAVA_COMMENTS )
120
+ .build ();
114
121
final String COMMENT = "// foo\n " ;
115
122
_testCommentsBeforePropValue (f , MODE_INPUT_STREAM , COMMENT );
116
123
_testCommentsBeforePropValue (f , MODE_INPUT_STREAM_THROTTLED , COMMENT );
117
124
_testCommentsBeforePropValue (f , MODE_DATA_INPUT , COMMENT );
118
125
}
119
126
120
127
public void testCppCommentsChars () throws Exception {
121
- JsonFactory f = new JsonFactory ();
122
- f .configure (JsonParser .Feature .ALLOW_COMMENTS , true );
128
+ final JsonFactory f = JsonFactory .builder ()
129
+ .enable (JsonReadFeature .ALLOW_JAVA_COMMENTS )
130
+ .build ();
123
131
final String COMMENT = "// foo \n " ;
124
132
_testCommentsBeforePropValue (f , MODE_READER , COMMENT );
125
133
}
@@ -277,8 +285,9 @@ private void _testEnabled(String doc, int mode) throws IOException
277
285
private JsonParser _createParser (String doc , int mode , boolean enabled )
278
286
throws IOException
279
287
{
280
- JsonFactory f = new JsonFactory ();
281
- f .configure (JsonParser .Feature .ALLOW_COMMENTS , enabled );
288
+ final JsonFactory f = JsonFactory .builder ()
289
+ .configure (JsonReadFeature .ALLOW_JAVA_COMMENTS , enabled )
290
+ .build ();
282
291
JsonParser p = createParser (f , mode , doc );
283
292
assertToken (JsonToken .START_ARRAY , p .nextToken ());
284
293
return p ;
0 commit comments