Skip to content

Commit 0dbd9be

Browse files
committed
Merge pull request stleary#26 from johnjaylward/FixXMLNPE
Fixes NPE in XML for pull request stleary#160 in the json-java project
2 parents 1a5718d + cb63a96 commit 0dbd9be

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

XMLTest.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
package org.json.junit;
22

3-
import static org.junit.Assert.*;
3+
import static org.junit.Assert.assertEquals;
4+
import static org.junit.Assert.assertTrue;
45

5-
import java.io.*;
6+
import java.io.IOException;
67

7-
import org.json.*;
8-
import org.junit.*;
9-
import org.junit.rules.*;
8+
import org.json.JSONArray;
9+
import org.json.JSONException;
10+
import org.json.JSONObject;
11+
import org.json.XML;
12+
import org.junit.Rule;
13+
import org.junit.Test;
14+
import org.junit.rules.TemporaryFolder;
1015

1116

1217
/**
@@ -180,12 +185,12 @@ public void shouldHandleInvalidCDATABangInTag() {
180185

181186
/**
182187
* Null JSONObject in XML.toString()
183-
* Expects NullPointerException
184188
*/
185-
@Test(expected=NullPointerException.class)
189+
@Test
186190
public void shouldHandleNullJSONXML() {
187191
JSONObject jsonObject= null;
188-
XML.toString(jsonObject);
192+
String actualXml=XML.toString(jsonObject);
193+
assertEquals("generated XML does not equal expected XML","\"null\"",actualXml);
189194
}
190195

191196
/**

0 commit comments

Comments
 (0)