1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-17 07:50:52 -07:00

Adds test for escaping from a JSONObject to XML

This commit is contained in:
John J. Aylward 2016-09-22 13:09:32 -04:00
parent c8563ff93d
commit 5027a283c1

View file

@ -1,6 +1,7 @@
package org.json.junit; package org.json.junit;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@ -293,7 +294,19 @@ public class XMLTest {
compareStringToJSONObject(xmlStr, expectedStr); compareStringToJSONObject(xmlStr, expectedStr);
compareReaderToJSONObject(xmlStr, expectedStr); compareReaderToJSONObject(xmlStr, expectedStr);
compareFileToJSONObject(xmlStr, expectedStr); compareFileToJSONObject(xmlStr, expectedStr);
}
/**
* Tests that certain unicode characters are escaped.
*/
@Test
public void testJsonToXmlEscape(){
JSONObject json = new JSONObject("{ \"amount\": \"10,00 €\", \"description\": \"Ação Válida\" }");
String xml = XML.toString(json);
assertFalse("Escaping € failed. Found in XML output.", xml.contains(""));
assertTrue("Escaping ç failed. Not found in XML output.", xml.contains("ç"));
assertTrue("Escaping ã failed. Not found in XML output.", xml.contains("ã"));
assertTrue("Escaping á failed. Not found in XML output.", xml.contains("á"));
} }
/** /**