Skip to content

Commit

Permalink
Add minimal testing of (now-)deprecated JsonParser/YAMLParser methods
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Dec 14, 2023
1 parent 0613698 commit 8c7c55f
Showing 1 changed file with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Unit tests for checking functioning of the underlying
* parser implementation.
*/
public class StreamingParseTest extends ModuleTestBase
public class StreamingYAMLParseTest extends ModuleTestBase
{
private final YAMLFactory YAML_F = new YAMLFactory();

Expand Down Expand Up @@ -75,6 +75,50 @@ public void testBasic() throws Exception
p.close();
}

// @since 2.17
@SuppressWarnings("deprecation")
public void testDeprecatedMethods() throws Exception
{
final String YAML =
"string: 'text'\n"
+"bool: true\n"
;
try (JsonParser p = YAML_F.createParser(YAML)) {
assertToken(JsonToken.START_OBJECT, p.nextToken());
assertNull("string", p.getCurrentName());
assertNull("string", p.currentName());
assertNull(p.getCurrentValue());

assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertEquals("string", p.getCurrentName());
assertEquals("string", p.currentName());
assertNull(p.getCurrentValue());

assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals("text", p.getText());
assertEquals("string", p.getCurrentName());
assertEquals("string", p.currentName());
assertNull(p.getCurrentValue());
JsonLocation loc = p.getTokenLocation();
assertEquals(1, loc.getLineNr());
assertEquals(9, loc.getColumnNr());
assertEquals(8, loc.getCharOffset());
assertEquals(-1, loc.getByteOffset());
loc = p.getCurrentLocation();
assertEquals(1, loc.getLineNr());
assertEquals(15, loc.getColumnNr());
assertEquals(14, loc.getCharOffset());
assertEquals(-1, loc.getByteOffset());

assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertToken(JsonToken.VALUE_TRUE, p.nextToken());
assertEquals("true", p.getText());

assertToken(JsonToken.END_OBJECT, p.nextToken());
assertNull(p.nextToken());
}
}

// Parsing large numbers around the transition from int->long and long->BigInteger
public void testIntParsingWithLimits() throws Exception
{
Expand Down

0 comments on commit 8c7c55f

Please sign in to comment.