1
0
Fork 0
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:
Sean Leary 2015-10-18 10:45:42 -05:00
commit 0dbd9be0f1

View file

@ -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);
} }
/** /**