mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-03 19:35:31 -04:00
new test case for XML changes
This commit is contained in:
parent
474711c4ea
commit
c8563ff93d
@ -267,6 +267,35 @@ public class XMLTest {
|
||||
compareFileToJSONObject(xmlStr, expectedStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests to verify that supported escapes in XML are converted to actual values.
|
||||
*/
|
||||
@Test
|
||||
public void testXmlEscapeToJson(){
|
||||
String xmlStr =
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
|
||||
"<root>"+
|
||||
"<rawQuote>\"</rawQuote>"+
|
||||
"<euro>A €33</euro>"+
|
||||
"<euroX>A €22€</euroX>"+
|
||||
"<unknown>some text ©</unknown>"+
|
||||
"<known>" " & ' < ></known>"+
|
||||
"</root>";
|
||||
String expectedStr =
|
||||
"{\"root\":{" +
|
||||
"\"rawQuote\":\"\\\"\"," +
|
||||
"\"euro\":\"A €33\"," +
|
||||
"\"euroX\":\"A €22€\"," +
|
||||
"\"unknown\":\"some text ©\"," +
|
||||
"\"known\":\"\\\" \\\" & ' < >\"" +
|
||||
"}}";
|
||||
|
||||
compareStringToJSONObject(xmlStr, expectedStr);
|
||||
compareReaderToJSONObject(xmlStr, expectedStr);
|
||||
compareFileToJSONObject(xmlStr, expectedStr);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Valid XML with comments to JSONObject
|
||||
*/
|
||||
@ -675,8 +704,8 @@ public class XMLTest {
|
||||
* @param expectedStr the expected JSON string
|
||||
*/
|
||||
private void compareStringToJSONObject(String xmlStr, String expectedStr) {
|
||||
JSONObject expectedJsonObject = new JSONObject(expectedStr);
|
||||
JSONObject jsonObject = XML.toJSONObject(xmlStr);
|
||||
JSONObject expectedJsonObject = new JSONObject(expectedStr);
|
||||
Util.compareActualVsExpectedJsonObjects(jsonObject,expectedJsonObject);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user