mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
new test case for XML changes
This commit is contained in:
parent
474711c4ea
commit
c8563ff93d
1 changed files with 30 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue