File tree Expand file tree Collapse file tree
src/test/java/org/json/junit Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -907,11 +907,10 @@ public void testConfig() {
907907 }
908908
909909 /**
910- * Confirm XMLParserConfiguration functionality
910+ * Test forceList parameter
911911 */
912912 @ Test
913913 public void testSimpleForceList () {
914-
915914 String xmlStr =
916915 "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n " +
917916 "<addresses>\n " +
@@ -933,6 +932,48 @@ public void testSimpleForceList() {
933932
934933 Util .compareActualVsExpectedJsonObjects (jsonObject , expetedJsonObject );
935934 }
935+ @ Test
936+ public void testLongForceList () {
937+ String xmlStr =
938+ "<servers>" +
939+ "<server>" +
940+ "<name>host1</name>" +
941+ "<os>Linux</os>" +
942+ "<interfaces>" +
943+ "<interface>" +
944+ "<name>em0</name>" +
945+ "<ip_address>10.0.0.1</ip_address>" +
946+ "</interface>" +
947+ "</interfaces>" +
948+ "</server>" +
949+ "</servers>" ;
950+
951+ String expectedStr =
952+ "{" +
953+ "\" servers\" : [" +
954+ "{" +
955+ "\" server\" : {" +
956+ "\" name\" : \" host1\" ," +
957+ "\" os\" : \" Linux\" ," +
958+ "\" interfaces\" : [" +
959+ "{" +
960+ "\" interface\" : {" +
961+ "\" name\" : \" em0\" ," +
962+ "\" ip_address\" : \" 10.0.0.1\" " +
963+ "}}]}}]}" ;
964+
965+ Set <String > forceList = new HashSet <String >();
966+ forceList .add ("servers" );
967+ forceList .add ("interfaces" );
968+
969+ XMLParserConfiguration config =
970+ new XMLParserConfiguration ()
971+ .withForceList (forceList );
972+ JSONObject jsonObject = XML .toJSONObject (xmlStr , config );
973+ JSONObject expetedJsonObject = new JSONObject (expectedStr );
974+
975+ Util .compareActualVsExpectedJsonObjects (jsonObject , expetedJsonObject );
976+ }
936977
937978
938979 /**
You can’t perform that action at this time.
0 commit comments