mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-03 11:25:30 -04:00
longer forcelist tests
This commit is contained in:
parent
a0f90b776d
commit
3f9b53fee4
@ -907,11 +907,10 @@ public class XMLConfigurationTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm XMLParserConfiguration functionality
|
||||
* Test forceList parameter
|
||||
*/
|
||||
@Test
|
||||
public void testSimpleForceList() {
|
||||
|
||||
String xmlStr =
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
|
||||
"<addresses>\n"+
|
||||
@ -933,6 +932,48 @@ public class XMLConfigurationTest {
|
||||
|
||||
Util.compareActualVsExpectedJsonObjects(jsonObject, expetedJsonObject);
|
||||
}
|
||||
@Test
|
||||
public void testLongForceList() {
|
||||
String xmlStr =
|
||||
"<servers>"+
|
||||
"<server>"+
|
||||
"<name>host1</name>"+
|
||||
"<os>Linux</os>"+
|
||||
"<interfaces>"+
|
||||
"<interface>"+
|
||||
"<name>em0</name>"+
|
||||
"<ip_address>10.0.0.1</ip_address>"+
|
||||
"</interface>"+
|
||||
"</interfaces>"+
|
||||
"</server>"+
|
||||
"</servers>";
|
||||
|
||||
String expectedStr =
|
||||
"{"+
|
||||
"\"servers\": ["+
|
||||
"{"+
|
||||
"\"server\": {"+
|
||||
"\"name\": \"host1\","+
|
||||
"\"os\": \"Linux\","+
|
||||
"\"interfaces\": ["+
|
||||
"{"+
|
||||
"\"interface\": {"+
|
||||
"\"name\": \"em0\","+
|
||||
"\"ip_address\": \"10.0.0.1\""+
|
||||
"}}]}}]}";
|
||||
|
||||
Set<String> forceList = new HashSet<String>();
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user