mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-03 11:25:30 -04:00
Added simple test case
This commit is contained in:
parent
e356739a2f
commit
fafaeb7aa6
@ -35,6 +35,8 @@ import java.io.FileWriter;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@ -903,6 +905,34 @@ public class XMLConfigurationTest {
|
|||||||
Util.compareActualVsExpectedJsonArrays(jsonArray, expectedJsonArray);
|
Util.compareActualVsExpectedJsonArrays(jsonArray, expectedJsonArray);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Confirm XMLParserConfiguration functionality
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testSimpleForceList() {
|
||||||
|
|
||||||
|
String xmlStr =
|
||||||
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
|
||||||
|
"<addresses>\n"+
|
||||||
|
" <address>\n"+
|
||||||
|
" <name>Sherlock Holmes</name>\n"+
|
||||||
|
" </address>\n"+
|
||||||
|
"</addresses>";
|
||||||
|
|
||||||
|
String expectedStr = "{\"addresses\":[{\"address\":{\"name\":\"Sherlock Holmes\"}}]}";
|
||||||
|
|
||||||
|
Set<String> forceList = new HashSet<String>();
|
||||||
|
forceList.add("addresses");
|
||||||
|
|
||||||
|
XMLParserConfiguration config =
|
||||||
|
new XMLParserConfiguration()
|
||||||
|
.withForceList(forceList);
|
||||||
|
JSONObject jsonObject = XML.toJSONObject(xmlStr, config);
|
||||||
|
JSONObject expetedJsonObject = new JSONObject(expectedStr);
|
||||||
|
|
||||||
|
Util.compareActualVsExpectedJsonObjects(jsonObject, expetedJsonObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user