Skip to content

Commit

Permalink
Checking for null JSON strings prior to the JSONCompare so that it do…
Browse files Browse the repository at this point in the history
…esn't throw a NullPointerException.
  • Loading branch information
AdrianAcala committed Feb 25, 2016
1 parent 8c9cf78 commit ccc44f4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/org/skyscreamer/jsonassert/JSONAssert.java
Expand Up @@ -217,6 +217,12 @@ public static void assertNotEquals(String expectedStr, String actualStr, boolean
*/
public static void assertEquals(String expectedStr, String actualStr, JSONCompareMode compareMode)
throws JSONException {
if (expectedStr==actualStr) return;
if (expectedStr==null){
throw new AssertionError("Expected string is null.");
}else if (actualStr==null){
throw new AssertionError("Actual string is null.");
}
JSONCompareResult result = JSONCompare.compareJSON(expectedStr, actualStr, compareMode);
if (result.failed()) {
throw new AssertionError(result.getMessage());
Expand Down

0 comments on commit ccc44f4

Please sign in to comment.