mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
Merge pull request #26 from johnjaylward/FixXMLNPE
Fixes NPE in XML for pull request #160 in the json-java project
This commit is contained in:
commit
0dbd9be0f1
1 changed files with 13 additions and 8 deletions
21
XMLTest.java
21
XMLTest.java
|
@ -1,12 +1,17 @@
|
||||||
package org.json.junit;
|
package org.json.junit;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.json.*;
|
import org.json.JSONArray;
|
||||||
import org.junit.*;
|
import org.json.JSONException;
|
||||||
import org.junit.rules.*;
|
import org.json.JSONObject;
|
||||||
|
import org.json.XML;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -180,12 +185,12 @@ public class XMLTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Null JSONObject in XML.toString()
|
* Null JSONObject in XML.toString()
|
||||||
* Expects NullPointerException
|
|
||||||
*/
|
*/
|
||||||
@Test(expected=NullPointerException.class)
|
@Test
|
||||||
public void shouldHandleNullJSONXML() {
|
public void shouldHandleNullJSONXML() {
|
||||||
JSONObject jsonObject= null;
|
JSONObject jsonObject= null;
|
||||||
XML.toString(jsonObject);
|
String actualXml=XML.toString(jsonObject);
|
||||||
|
assertEquals("generated XML does not equal expected XML","\"null\"",actualXml);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue