-
-
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.
Implement #403 ("Make JsonNode work with XML")
- Loading branch information
1 parent
56d3f0c
commit 612b2ac
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/test/java/com/fasterxml/jackson/dataformat/xml/deser/JsonNodeDeser403Test.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,32 @@ | ||
package com.fasterxml.jackson.dataformat.xml.deser; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.node.JsonNodeType; | ||
import com.fasterxml.jackson.dataformat.xml.XmlTestBase; | ||
|
||
public class JsonNodeDeser403Test extends XmlTestBase | ||
{ | ||
final private ObjectMapper MAPPER = newMapper(); | ||
|
||
public void testSimpleNode() throws Exception | ||
{ | ||
JsonNode root = MAPPER.readTree("<root attr='123' />"); | ||
assertTrue(root.isObject()); | ||
assertEquals(1, root.size()); | ||
assertEquals("123", root.get("attr").textValue()); | ||
} | ||
|
||
// [dataformat-xml#403]: Allow sequences | ||
public void testRepeated() throws Exception | ||
{ | ||
JsonNode root = MAPPER.readTree("<root><value>a</value><value>b</value></root>"); | ||
assertTrue(root.isObject()); | ||
JsonNode arr = root.get("value"); | ||
assertEquals(JsonNodeType.ARRAY, arr.getNodeType()); | ||
assertTrue(arr.isArray()); | ||
assertEquals(2, arr.size()); | ||
assertEquals("a", root.at("/value/0").asText()); | ||
assertEquals("b", root.at("/value/1").asText()); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...aformat/xml/failing/ListDeser399Test.java → ...ataformat/xml/lists/ListDeser399Test.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