fix(#887): unit tests, uncommented tests after fix

This commit is contained in:
rikkarth 2024-04-28 23:52:53 +01:00
parent 1ae43bdb90
commit 48dfeb84b0
No known key found for this signature in database
GPG Key ID: 11E5F28B0AED6AC7

View File

@ -294,10 +294,7 @@ public class XMLTest {
"<euro>A &#8364;33</euro>"+ "<euro>A &#8364;33</euro>"+
"<euroX>A &#x20ac;22&#x20AC;</euroX>"+ "<euroX>A &#x20ac;22&#x20AC;</euroX>"+
"<unknown>some text &copy;</unknown>"+ "<unknown>some text &copy;</unknown>"+
// TODO: Looks like a strictMode regression where embedded single quotes are not handled correctly "<known>&#x0022; &quot; &amp; &apos; &lt; &gt;</known>"+
// Should be fixed.
// "<known>&#x0022; &quot; &amp; &apos; &lt; &gt;</known>"+
"<known>&#x0022; &quot; &amp; &lt; &gt;</known>"+
"<high>&#x1D122; &#x10165;</high>" + "<high>&#x1D122; &#x10165;</high>" +
"</root>"; "</root>";
String expectedStr = String expectedStr =
@ -306,10 +303,7 @@ public class XMLTest {
"\"euro\":\"A €33\"," + "\"euro\":\"A €33\"," +
"\"euroX\":\"A €22€\"," + "\"euroX\":\"A €22€\"," +
"\"unknown\":\"some text &copy;\"," + "\"unknown\":\"some text &copy;\"," +
// TODO: Looks like a strictMode regression where embedded single quotes are not handled correctly "\"known\":\"\\\" \\\" & ' < >\"," +
// Should be fixed.
// "\"known\":\"\\\" \\\" & ' < >\"," +
"\"known\":\"\\\" \\\" & < >\"," +
"\"high\":\"𝄢 𐅥\""+ "\"high\":\"𝄢 𐅥\""+
"}}"; "}}";
@ -323,12 +317,9 @@ public class XMLTest {
*/ */
@Test @Test
public void testJsonToXmlEscape(){ public void testJsonToXmlEscape(){
// TODO: Looks like a strictMode regression where embedded single quotes are not handled correctly
// Should be fixed.
final String jsonSrc = "{\"amount\":\"10,00 €\"," final String jsonSrc = "{\"amount\":\"10,00 €\","
+ "\"description\":\"Ação Válida\u0085\"," + "\"description\":\"Ação Válida\u0085\","
// + "\"xmlEntities\":\"\\\" ' & < >\"" + "\"xmlEntities\":\"\\\" ' & < >\""
+ "\"xmlEntities\":\"\\\" & < >\""
+ "}"; + "}";
JSONObject json = new JSONObject(jsonSrc); JSONObject json = new JSONObject(jsonSrc);
String xml = XML.toString(json); String xml = XML.toString(json);
@ -342,8 +333,7 @@ public class XMLTest {
assertTrue("Escaping á failed. Not found in XML output.", xml.contains("á")); assertTrue("Escaping á failed. Not found in XML output.", xml.contains("á"));
// test XML Entities converted // test XML Entities converted
assertTrue("Escaping \" failed. Not found in XML output.", xml.contains("&quot;")); assertTrue("Escaping \" failed. Not found in XML output.", xml.contains("&quot;"));
// TODO: restore when the regression is fixed assertTrue("Escaping ' failed. Not found in XML output.", xml.contains("&apos;"));
// assertTrue("Escaping ' failed. Not found in XML output.", xml.contains("&apos;"));
assertTrue("Escaping & failed. Not found in XML output.", xml.contains("&amp;")); assertTrue("Escaping & failed. Not found in XML output.", xml.contains("&amp;"));
assertTrue("Escaping < failed. Not found in XML output.", xml.contains("&lt;")); assertTrue("Escaping < failed. Not found in XML output.", xml.contains("&lt;"));
assertTrue("Escaping > failed. Not found in XML output.", xml.contains("&gt;")); assertTrue("Escaping > failed. Not found in XML output.", xml.contains("&gt;"));