-
-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23ab583
commit 79a4b57
Showing
3 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/test/java/com/fasterxml/jackson/dataformat/xml/stream/XmlParserNextXxxTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.fasterxml.jackson.dataformat.xml.stream; | ||
|
||
import java.io.*; | ||
|
||
import com.fasterxml.jackson.core.*; | ||
|
||
import com.fasterxml.jackson.dataformat.xml.XmlFactory; | ||
import com.fasterxml.jackson.dataformat.xml.XmlTestBase; | ||
import com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser; | ||
|
||
public class XmlParserNextXxxTest extends XmlTestBase | ||
{ | ||
protected JsonFactory _jsonFactory; | ||
protected XmlFactory _xmlFactory; | ||
|
||
// let's actually reuse XmlMapper to make things bit faster | ||
@Override | ||
public void setUp() throws Exception { | ||
super.setUp(); | ||
_xmlFactory = new XmlFactory(); | ||
} | ||
|
||
/* | ||
/********************************************************** | ||
/* Unit tests | ||
/********************************************************** | ||
*/ | ||
|
||
// [dataformat-xml#204] | ||
public void testXmlAttributesWithNextTextValue() throws Exception | ||
{ | ||
final String XML = "<data max=\"7\" offset=\"9\"/>"; | ||
|
||
FromXmlParser xp = (FromXmlParser) _xmlFactory.createParser(new StringReader(XML)); | ||
|
||
// First: verify handling without forcing array handling: | ||
assertToken(JsonToken.START_OBJECT, xp.nextToken()); // <data> | ||
assertToken(JsonToken.FIELD_NAME, xp.nextToken()); // <max> | ||
assertEquals("max", xp.getCurrentName()); | ||
|
||
assertEquals("7", xp.nextTextValue()); | ||
|
||
assertToken(JsonToken.FIELD_NAME, xp.nextToken()); // <offset> | ||
assertEquals("offset", xp.getCurrentName()); | ||
|
||
assertEquals("offset", xp.getText()); | ||
|
||
assertEquals("9", xp.nextTextValue()); | ||
|
||
assertEquals("9", xp.getText()); | ||
|
||
assertToken(JsonToken.END_OBJECT, xp.nextToken()); // </data> | ||
xp.close(); | ||
} | ||
} |