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

Fixes for failing tests due to android integration

This commit is contained in:
John J. Aylward 2017-06-21 14:59:42 -04:00
parent 441fec7498
commit 3081b4bd96
2 changed files with 61 additions and 60 deletions

View file

@ -42,11 +42,11 @@ public class JSONMLTest {
String xmlStr = ""; String xmlStr = "";
try { try {
JSONML.toJSONArray(xmlStr); JSONML.toJSONArray(xmlStr);
assertTrue("Expecting an exception", false); fail("Expecting an exception");
} catch (JSONException e) { } catch (JSONException e) {
assertTrue("Expecting an exception message", assertEquals("Expecting an exception message",
"Bad XML at 1 [character 2 line 1]". "Bad XML at 0 [character 1 line 1]",
equals(e.getMessage())); e.getMessage());
} }
} }
@ -95,11 +95,11 @@ public class JSONMLTest {
String xmlStr = "{ \"this is\": \"not xml\"}"; String xmlStr = "{ \"this is\": \"not xml\"}";
try { try {
JSONML.toJSONArray(xmlStr); JSONML.toJSONArray(xmlStr);
assertTrue("Expecting an exception", false); fail("Expecting an exception");
} catch (JSONException e) { } catch (JSONException e) {
assertTrue("Expecting an exception message", assertEquals("Expecting an exception message",
"Bad XML at 25 [character 26 line 1]". "Bad XML at 23 [character 24 line 1]",
equals(e.getMessage())); e.getMessage());
} }
} }
@ -198,11 +198,11 @@ public class JSONMLTest {
"</addresses>"; "</addresses>";
try { try {
JSONML.toJSONArray(xmlStr); JSONML.toJSONArray(xmlStr);
assertTrue("Expecting an exception", false); fail("Expecting an exception");
} catch (JSONException e) { } catch (JSONException e) {
assertTrue("Expecting an exception message", assertEquals("Expecting an exception message",
"Misshaped tag at 176 [character 14 line 7]". "Misshaped tag at 176 [character 14 line 4]",
equals(e.getMessage())); e.getMessage());
} }
} }
@ -223,11 +223,11 @@ public class JSONMLTest {
"</addresses>"; "</addresses>";
try { try {
JSONML.toJSONArray(xmlStr); JSONML.toJSONArray(xmlStr);
assertTrue("Expecting an exception", false); fail("Expecting an exception");
} catch (JSONException e) { } catch (JSONException e) {
assertTrue("Expecting an exception message", assertEquals("Expecting an exception message",
"Misshaped meta tag at 216 [character 13 line 11]". "Misshaped meta tag at 216 [character 13 line 7]",
equals(e.getMessage())); e.getMessage());
} }
} }
@ -253,11 +253,11 @@ public class JSONMLTest {
"</addresses>"; "</addresses>";
try { try {
JSONML.toJSONArray(xmlStr); JSONML.toJSONArray(xmlStr);
assertTrue("Expecting an exception", false); fail("Expecting an exception");
} catch (JSONException e) { } catch (JSONException e) {
assertTrue("Expecting an exception message", assertEquals("Expecting an exception message",
"Misshaped meta tag at 215 [character 13 line 11]". "Misshaped meta tag at 215 [character 13 line 7]",
equals(e.getMessage())); e.getMessage());
} }
} }
@ -283,11 +283,11 @@ public class JSONMLTest {
"</addresses>"; "</addresses>";
try { try {
JSONML.toJSONArray(xmlStr); JSONML.toJSONArray(xmlStr);
assertTrue("Expecting an exception", false); fail("Expecting an exception");
} catch (JSONException e) { } catch (JSONException e) {
assertTrue("Expecting an exception message", assertEquals("Expecting an exception message",
"Misplaced '<' at 194 [character 5 line 10]". "Misplaced '<' at 194 [character 5 line 6]",
equals(e.getMessage())); e.getMessage());
} }
} }
@ -343,11 +343,11 @@ public class JSONMLTest {
"</addresses>"; "</addresses>";
try { try {
JSONML.toJSONArray(xmlStr); JSONML.toJSONArray(xmlStr);
assertTrue("Expecting an exception", false); fail("Expecting an exception");
} catch (JSONException e) { } catch (JSONException e) {
assertTrue("Expecting an exception message", assertEquals("Expecting an exception message",
"Misplaced '<' at 206 [character 1 line 12]". "Misplaced '<' at 206 [character 1 line 7]",
equals(e.getMessage())); e.getMessage());
} }
} }
@ -373,11 +373,11 @@ public class JSONMLTest {
"</addresses>"; "</addresses>";
try { try {
JSONML.toJSONArray(xmlStr); JSONML.toJSONArray(xmlStr);
assertTrue("Expecting an exception", false); fail("Expecting an exception");
} catch (JSONException e) { } catch (JSONException e) {
assertTrue("Expecting an exception message", assertEquals("Expecting an exception message",
"Expected 'CDATA[' at 204 [character 11 line 9]". "Expected 'CDATA[' at 204 [character 11 line 5]",
equals(e.getMessage())); e.getMessage());
} }
} }

View file

@ -3,6 +3,7 @@ package org.json.junit;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
@ -74,11 +75,11 @@ public class XMLTest {
"</addresses>"; "</addresses>";
try { try {
XML.toJSONObject(xmlStr); XML.toJSONObject(xmlStr);
assertTrue("Expecting a JSONException", false); fail("Expecting a JSONException");
} catch (JSONException e) { } catch (JSONException e) {
assertTrue("Expecting an exception message", assertEquals("Expecting an exception message",
"Misshaped tag at 176 [character 14 line 5]". "Misshaped tag at 176 [character 14 line 4]",
equals(e.getMessage())); e.getMessage());
} }
} }
@ -99,11 +100,11 @@ public class XMLTest {
"</addresses>"; "</addresses>";
try { try {
XML.toJSONObject(xmlStr); XML.toJSONObject(xmlStr);
assertTrue("Expecting a JSONException", false); fail("Expecting a JSONException");
} catch (JSONException e) { } catch (JSONException e) {
assertTrue("Expecting an exception message", assertEquals("Expecting an exception message",
"Misshaped meta tag at 215 [character 13 line 8]". "Misshaped meta tag at 215 [character 13 line 7]",
equals(e.getMessage())); e.getMessage());
} }
} }
@ -124,11 +125,11 @@ public class XMLTest {
"</addresses>"; "</addresses>";
try { try {
XML.toJSONObject(xmlStr); XML.toJSONObject(xmlStr);
assertTrue("Expecting a JSONException", false); fail("Expecting a JSONException");
} catch (JSONException e) { } catch (JSONException e) {
assertTrue("Expecting an exception message", assertEquals("Expecting an exception message",
"Misshaped meta tag at 214 [character 13 line 8]". "Misshaped meta tag at 214 [character 13 line 7]",
equals(e.getMessage())); e.getMessage());
} }
} }
@ -149,11 +150,11 @@ public class XMLTest {
"</addresses>"; "</addresses>";
try { try {
XML.toJSONObject(xmlStr); XML.toJSONObject(xmlStr);
assertTrue("Expecting a JSONException", false); fail("Expecting a JSONException");
} catch (JSONException e) { } catch (JSONException e) {
assertTrue("Expecting an exception message", assertEquals("Expecting an exception message",
"Misplaced '<' at 193 [character 4 line 7]". "Misplaced '<' at 193 [character 4 line 6]",
equals(e.getMessage())); e.getMessage());
} }
} }
@ -174,11 +175,11 @@ public class XMLTest {
"</addresses>"; "</addresses>";
try { try {
XML.toJSONObject(xmlStr); XML.toJSONObject(xmlStr);
assertTrue("Expecting a JSONException", false); fail("Expecting a JSONException");
} catch (JSONException e) { } catch (JSONException e) {
assertTrue("Expecting an exception message", assertEquals("Expecting an exception message",
"Expected 'CDATA[' at 204 [character 11 line 6]". "Expected 'CDATA[' at 204 [character 11 line 5]",
equals(e.getMessage())); e.getMessage());
} }
} }
@ -397,9 +398,9 @@ public class XMLTest {
final String expected = "<jo></jo>"; final String expected = "<jo></jo>";
String output1 = XML.toString(jo1,"jo"); String output1 = XML.toString(jo1,"jo");
assertTrue("Expected an empty root tag", expected.equals(output1)); assertEquals("Expected an empty root tag", expected, output1);
String output2 = XML.toString(jo2,"jo"); String output2 = XML.toString(jo2,"jo");
assertTrue("Expected an empty root tag", expected.equals(output2)); assertEquals("Expected an empty root tag", expected, output2);
} }
/** /**
@ -414,9 +415,9 @@ public class XMLTest {
final String expected = "<jo><arr>One</arr><arr></arr><arr>Four</arr></jo>"; final String expected = "<jo><arr>One</arr><arr></arr><arr>Four</arr></jo>";
String output1 = XML.toString(jo1,"jo"); String output1 = XML.toString(jo1,"jo");
assertTrue("Expected a matching array", expected.equals(output1)); assertEquals("Expected a matching array", expected, output1);
String output2 = XML.toString(jo2,"jo"); String output2 = XML.toString(jo2,"jo");
assertTrue("Expected a matching array", expected.equals(output2)); assertEquals("Expected a matching array", expected, output2);
} }
/** /**
@ -431,9 +432,9 @@ public class XMLTest {
final String expected = "<jo><arr>One</arr><arr>Two</arr><arr>Three</arr></jo>"; final String expected = "<jo><arr>One</arr><arr>Two</arr><arr>Three</arr></jo>";
String output1 = XML.toString(jo1,"jo"); String output1 = XML.toString(jo1,"jo");
assertTrue("Expected a non empty root tag", expected.equals(output1)); assertEquals("Expected a non empty root tag", expected, output1);
String output2 = XML.toString(jo2,"jo"); String output2 = XML.toString(jo2,"jo");
assertTrue("Expected a non empty root tag", expected.equals(output2)); assertEquals("Expected a non empty root tag", expected, output2);
} }
/** /**
@ -448,9 +449,9 @@ public class XMLTest {
final String expected = "<jo><arr>One</arr><arr><array>Two</array><array>Three</array></arr><arr>Four</arr></jo>"; final String expected = "<jo><arr>One</arr><arr><array>Two</array><array>Three</array></arr><arr>Four</arr></jo>";
String output1 = XML.toString(jo1,"jo"); String output1 = XML.toString(jo1,"jo");
assertTrue("Expected a matching array", expected.equals(output1)); assertEquals("Expected a matching array", expected, output1);
String output2 = XML.toString(jo2,"jo"); String output2 = XML.toString(jo2,"jo");
assertTrue("Expected a matching array", expected.equals(output2)); assertEquals("Expected a matching array", expected, output2);
} }
/** /**