From 5eadebb797c761d58ebf73d337566cd3745995e8 Mon Sep 17 00:00:00 2001 From: JaXt0r Date: Sun, 19 Jul 2015 14:24:06 +0200 Subject: [PATCH] Showing issue of illegal node names with possible underscore-replacement. (Will currently assterted to an Exception). --- XMLTest.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/XMLTest.java b/XMLTest.java index 0c86eeb..1c04c1b 100644 --- a/XMLTest.java +++ b/XMLTest.java @@ -294,4 +294,25 @@ public class XMLTest { JSONObject expectedJsonObject = XML.toJSONObject(expectedStr); Util.compareActualVsExpectedJsonObjects(finalJsonObject,expectedJsonObject); } + + + /** + * Illegal node-names must be converted to legal XML-node-names. + * The given example shows 2 nodes which are valid for JSON, but not for XML. + * Therefore illegal arguments should be converted to e.g. an underscore (_). + * + */ + @Test + public void shouldHandleIllegalJSONNodeNames() + { + JSONObject inputJSON = new JSONObject(); + inputJSON.append("123IllegalNode", "someValue1"); + inputJSON.append("Illegal@node", "someValue2"); + + String result = XML.toString(inputJSON); + + String expected = "<___IllegalNode>someValue1someValue3"; + + assertEquals(expected, result); + } }