@@ -919,7 +919,8 @@ public void testSimpleForceList() {
919919 " </address>\n " +
920920 "</addresses>" ;
921921
922- String expectedStr = "{\" addresses\" :[{\" address\" :{\" name\" :\" Sherlock Holmes\" }}]}" ;
922+ String expectedStr =
923+ "{\" addresses\" :[{\" address\" :{\" name\" :\" Sherlock Holmes\" }}]}" ;
923924
924925 Set <String > forceList = new HashSet <String >();
925926 forceList .add ("addresses" );
@@ -949,18 +950,18 @@ public void testLongForceList() {
949950 "</servers>" ;
950951
951952 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- "}}]}}]}" ;
953+ "{" +
954+ "\" servers\" : [" +
955+ "{" +
956+ "\" server\" : {" +
957+ "\" name\" : \" host1\" ," +
958+ "\" os\" : \" Linux\" ," +
959+ "\" interfaces\" : [" +
960+ "{" +
961+ "\" interface\" : {" +
962+ "\" name\" : \" em0\" ," +
963+ "\" ip_address\" : \" 10.0.0.1\" " +
964+ "}}]}}]}" ;
964965
965966 Set <String > forceList = new HashSet <String >();
966967 forceList .add ("servers" );
@@ -974,7 +975,25 @@ public void testLongForceList() {
974975
975976 Util .compareActualVsExpectedJsonObjects (jsonObject , expetedJsonObject );
976977 }
977-
978+ @ Test
979+ public void testEmptyForceList () {
980+ String xmlStr =
981+ "<addresses></addresses>" ;
982+
983+ String expectedStr =
984+ "{\" addresses\" :[]}" ;
985+
986+ Set <String > forceList = new HashSet <String >();
987+ forceList .add ("addresses" );
988+
989+ XMLParserConfiguration config =
990+ new XMLParserConfiguration ()
991+ .withForceList (forceList );
992+ JSONObject jsonObject = XML .toJSONObject (xmlStr , config );
993+ JSONObject expetedJsonObject = new JSONObject (expectedStr );
994+
995+ Util .compareActualVsExpectedJsonObjects (jsonObject , expetedJsonObject );
996+ }
978997
979998 /**
980999 * Convenience method, given an input string and expected result,
0 commit comments