mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
in progress
This commit is contained in:
parent
2df27fc6e7
commit
a18e9f7a25
1 changed files with 20 additions and 4 deletions
24
XMLTest.java
24
XMLTest.java
|
@ -28,15 +28,30 @@ public class XMLTest {
|
||||||
String xmlStr = XML.toString(jsonObject);
|
String xmlStr = XML.toString(jsonObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected=JSONException.class)
|
||||||
public void shouldHandleInvalidCDATA() {
|
public void shouldHandleInvalidBangInTag() {
|
||||||
String xmlStr =
|
String xmlStr =
|
||||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
|
||||||
"<addresses xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""+
|
"<addresses xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""+
|
||||||
" xsi:noNamespaceSchemaLocation='test.xsd'>\n"+
|
" xsi:noNamespaceSchemaLocation='test.xsd'>\n"+
|
||||||
" <address>\n"+
|
" <address>\n"+
|
||||||
" <name>Joe Tester</name>\n"+
|
" <name>Joe Tester</name>\n"+
|
||||||
" <street>![Baker street 5</street>\n"+
|
" <!street>abc street</street>\n"+
|
||||||
|
" </address>\n"+
|
||||||
|
"</addresses>";
|
||||||
|
JSONObject jsonObject = XML.toJSONObject(xmlStr);
|
||||||
|
assertTrue(jsonObject == null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected=JSONException.class)
|
||||||
|
public void shouldHandleInvalidSlashInTag() {
|
||||||
|
String xmlStr =
|
||||||
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
|
||||||
|
"<addresses xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""+
|
||||||
|
" xsi:noNamespaceSchemaLocation='test.xsd'>\n"+
|
||||||
|
" <address>\n"+
|
||||||
|
" <name/x>\n"+
|
||||||
|
" <street>abc street</street>\n"+
|
||||||
" </address>\n"+
|
" </address>\n"+
|
||||||
"</addresses>";
|
"</addresses>";
|
||||||
JSONObject jsonObject = XML.toJSONObject(xmlStr);
|
JSONObject jsonObject = XML.toJSONObject(xmlStr);
|
||||||
|
@ -66,12 +81,13 @@ public class XMLTest {
|
||||||
" <address>\n"+
|
" <address>\n"+
|
||||||
" <name>Joe Tester</name>\n"+
|
" <name>Joe Tester</name>\n"+
|
||||||
" <street>[CDATA[Baker street 5]</street>\n"+
|
" <street>[CDATA[Baker street 5]</street>\n"+
|
||||||
|
" <NothingHere/>\n"+
|
||||||
" </address>\n"+
|
" </address>\n"+
|
||||||
"</addresses>";
|
"</addresses>";
|
||||||
|
|
||||||
String expectedStr =
|
String expectedStr =
|
||||||
"{\"addresses\":{\"address\":{\"street\":\"[CDATA[Baker street 5]\","+
|
"{\"addresses\":{\"address\":{\"street\":\"[CDATA[Baker street 5]\","+
|
||||||
"\"name\":\"Joe Tester\"},\"xsi:noNamespaceSchemaLocation\":"+
|
"\"name\":\"Joe Tester\",\"NothingHere\":\"\"},\"xsi:noNamespaceSchemaLocation\":"+
|
||||||
"\"test.xsd\",\"xmlns:xsi\":\"http://www.w3.org/2001/"+
|
"\"test.xsd\",\"xmlns:xsi\":\"http://www.w3.org/2001/"+
|
||||||
"XMLSchema-instance\"}}";
|
"XMLSchema-instance\"}}";
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue