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
4fbe651e57
commit
4c6da0e6f9
1 changed files with 23 additions and 5 deletions
28
XMLTest.java
28
XMLTest.java
|
@ -21,6 +21,24 @@ public class XMLTest {
|
||||||
assertTrue("jsonObject should be empty", jsonObject.length() == 0);
|
assertTrue("jsonObject should be empty", jsonObject.length() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldHandleCommentsInXML() {
|
||||||
|
|
||||||
|
String xmlStr =
|
||||||
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
|
||||||
|
"<!-- this is a comment -->\n"+
|
||||||
|
"<addresses>\n"+
|
||||||
|
" <address>\n"+
|
||||||
|
" <!-- this is another comment -->\n"+
|
||||||
|
" <name>Joe Tester</name>\n"+
|
||||||
|
" <!-- this is a multi line \n"+
|
||||||
|
" comment -->\n"+
|
||||||
|
" <street>Baker street 5</street>\n"+
|
||||||
|
" </address>\n"+
|
||||||
|
"</addresses>";
|
||||||
|
JSONObject jsonObject = XML.toJSONObject(xmlStr);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldHandleEmptyXML() {
|
public void shouldHandleEmptyXML() {
|
||||||
|
|
||||||
|
@ -69,17 +87,17 @@ public class XMLTest {
|
||||||
public void shouldHandleToString() {
|
public void shouldHandleToString() {
|
||||||
String xmlStr =
|
String xmlStr =
|
||||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
|
||||||
"<addr&esses 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>[CDATA[Joe Tester]]</name>\n"+
|
" <name>[CDATA[Joe & T > e < s " t ' er]]</name>\n"+
|
||||||
" <street>Baker street 5</street>\n"+
|
" <street>Baker street 5</street>\n"+
|
||||||
" </address>\n"+
|
" </address>\n"+
|
||||||
"</addr&esses>";
|
"</addresses>";
|
||||||
|
|
||||||
String expectedStr =
|
String expectedStr =
|
||||||
"{\"addr&esses\":{\"address\":{\"street\":\"Baker street 5\","+
|
"{\"addresses\":{\"address\":{\"street\":\"Baker street 5\","+
|
||||||
"\"name\":\"[CDATA[Joe Tester]]\"},\"xsi:noNamespaceSchemaLocation\":"+
|
"\"name\":\"[CDATA[Joe & T > e < s \\\" t \\\' er]]\"},\"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