Skip to content

Commit

Permalink
Merge pull request stleary#26 from johnjaylward/FixXMLNPE
Browse files Browse the repository at this point in the history
Fixes NPE in XML for pull request stleary#160 in the json-java project
  • Loading branch information
stleary committed Oct 18, 2015
2 parents 1a5718d + cb63a96 commit 0dbd9be
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions XMLTest.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
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.junit.*;
import org.junit.rules.*;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.XML;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;


/**
Expand Down Expand Up @@ -180,12 +185,12 @@ public void shouldHandleInvalidCDATABangInTag() {

/**
* Null JSONObject in XML.toString()
* Expects NullPointerException
*/
@Test(expected=NullPointerException.class)
@Test
public void shouldHandleNullJSONXML() {
JSONObject jsonObject= null;
XML.toString(jsonObject);
String actualXml=XML.toString(jsonObject);
assertEquals("generated XML does not equal expected XML","\"null\"",actualXml);
}

/**
Expand Down

0 comments on commit 0dbd9be

Please sign in to comment.