diff --git a/src/test/java/org/json/junit/XMLConfigurationTest.java b/src/test/java/org/json/junit/XMLConfigurationTest.java index 1ff5949..47c588c 100755 --- a/src/test/java/org/json/junit/XMLConfigurationTest.java +++ b/src/test/java/org/json/junit/XMLConfigurationTest.java @@ -907,11 +907,10 @@ public class XMLConfigurationTest { } /** - * Confirm XMLParserConfiguration functionality + * Test forceList parameter */ @Test public void testSimpleForceList() { - String xmlStr = "\n"+ "\n"+ @@ -933,6 +932,48 @@ public class XMLConfigurationTest { Util.compareActualVsExpectedJsonObjects(jsonObject, expetedJsonObject); } + @Test + public void testLongForceList() { + String xmlStr = + ""+ + ""+ + "host1"+ + "Linux"+ + ""+ + ""+ + "em0"+ + "10.0.0.1"+ + ""+ + ""+ + ""+ + ""; + + String expectedStr = + "{"+ + "\"servers\": ["+ + "{"+ + "\"server\": {"+ + "\"name\": \"host1\","+ + "\"os\": \"Linux\","+ + "\"interfaces\": ["+ + "{"+ + "\"interface\": {"+ + "\"name\": \"em0\","+ + "\"ip_address\": \"10.0.0.1\""+ + "}}]}}]}"; + + Set forceList = new HashSet(); + forceList.add("servers"); + forceList.add("interfaces"); + + XMLParserConfiguration config = + new XMLParserConfiguration() + .withForceList(forceList); + JSONObject jsonObject = XML.toJSONObject(xmlStr, config); + JSONObject expetedJsonObject = new JSONObject(expectedStr); + + Util.compareActualVsExpectedJsonObjects(jsonObject, expetedJsonObject); + } /**