Class JSONAssert

java.lang.Object
org.skyscreamer.jsonassert.JSONAssert

public class JSONAssert extends Object

A set of assertion methods useful for writing tests methods that return JSON.

There are two modes, strict and non-strict. In most cases, you will probably want to set strict to false, since that will make the tests less brittle.

Strict tests require all of the elements requested to be returned, and only those elements (ie, the tests are non-extensible). Arrays of elements must be returned in the same order as expected. For example, say I'm expecting:

{id:123,things['a','b','c']}

The following would match when doing non-strict checking, but would fail on strict checking:

{id:123,things['c','b','a'],anotherfield:'blah'}

This library uses org.json. It has fewer dependencies than other JSON libraries (like net.sf.json), making JSONassert more portable.

There are two known issues when dealing with non-strict comparisons:

  • Unless the order is strict, checking does not handle mixed types in the JSONArray (e.g. [1,2,{a:"b"}] or [{pet:"cat"},{car:"Ford"}])
  • Unless the order is strict, checking cannot handle arrays of arrays (e.g. [[1,2],[3,4]])

You do not have to worry about encountering a false positive or false negative in these two edge cases. JSONassert will identify the conditions and throw a descriptive IllegalArgumentException. These cases will be fixed in future versions.

  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    assertEquals(String expectedStr, String actualStr, boolean strict)
    Asserts that the JSONArray provided matches the expected string.
    static void
    assertEquals(String message, String expectedStr, String actualStr, boolean strict)
    Asserts that the JSONArray provided matches the expected string.
    static void
    assertEquals(String message, String expectedStr, String actualStr, JSONComparator comparator)
    Asserts that the json string provided matches the expected string.
    static void
    assertEquals(String message, String expectedStr, String actualStr, JSONCompareMode compareMode)
    Asserts that the JSONArray provided matches the expected string.
    static void
    assertEquals(String message, String expectedStr, org.json.JSONArray actual, boolean strict)
    Asserts that the JSONArray provided matches the expected string.
    static void
    assertEquals(String message, String expectedStr, org.json.JSONArray actual, JSONCompareMode compareMode)
    Asserts that the JSONArray provided matches the expected string.
    static void
    assertEquals(String message, String expectedStr, org.json.JSONObject actual, boolean strict)
    Asserts that the JSONObject provided matches the expected string.
    static void
    assertEquals(String message, String expectedStr, org.json.JSONObject actual, JSONCompareMode compareMode)
    Asserts that the JSONObject provided matches the expected string.
    static void
    assertEquals(String expectedStr, String actualStr, JSONComparator comparator)
    Asserts that the json string provided matches the expected string.
    static void
    assertEquals(String expectedStr, String actualStr, JSONCompareMode compareMode)
    Asserts that the JSONArray provided matches the expected string.
    static void
    assertEquals(String expectedStr, org.json.JSONArray actual, boolean strict)
    Asserts that the JSONArray provided matches the expected string.
    static void
    assertEquals(String message, org.json.JSONArray expected, org.json.JSONArray actual, boolean strict)
    Asserts that the JSONArray provided matches the expected JSONArray.
    static void
    assertEquals(String message, org.json.JSONArray expected, org.json.JSONArray actual, JSONCompareMode compareMode)
    Asserts that the JSONArray provided matches the expected JSONArray.
    static void
    assertEquals(String expectedStr, org.json.JSONArray actual, JSONCompareMode compareMode)
    Asserts that the JSONArray provided matches the expected string.
    static void
    assertEquals(String expectedStr, org.json.JSONObject actual, boolean strict)
    Asserts that the JSONObject provided matches the expected string.
    static void
    assertEquals(String message, org.json.JSONObject expected, org.json.JSONObject actual, boolean strict)
    Asserts that the JSONObject provided matches the expected JSONObject.
    static void
    assertEquals(String message, org.json.JSONObject expected, org.json.JSONObject actual, JSONComparator comparator)
    Asserts that the JSONObject provided matches the expected JSONObject.
    static void
    assertEquals(String message, org.json.JSONObject expected, org.json.JSONObject actual, JSONCompareMode compareMode)
    Asserts that the JSONObject provided matches the expected JSONObject.
    static void
    assertEquals(String expectedStr, org.json.JSONObject actual, JSONCompareMode compareMode)
    Asserts that the JSONObject provided matches the expected string.
    static void
    assertEquals(org.json.JSONArray expected, org.json.JSONArray actual, boolean strict)
    Asserts that the JSONArray provided matches the expected JSONArray.
    static void
    assertEquals(org.json.JSONArray expected, org.json.JSONArray actual, JSONCompareMode compareMode)
    Asserts that the JSONArray provided matches the expected JSONArray.
    static void
    assertEquals(org.json.JSONObject expected, org.json.JSONObject actual, boolean strict)
    Asserts that the JSONObject provided matches the expected JSONObject.
    static void
    assertEquals(org.json.JSONObject expected, org.json.JSONObject actual, JSONComparator comparator)
    Asserts that the JSONObject provided matches the expected JSONObject.
    static void
    assertEquals(org.json.JSONObject expected, org.json.JSONObject actual, JSONCompareMode compareMode)
    Asserts that the JSONObject provided matches the expected JSONObject.
    static void
    assertNotEquals(String expectedStr, String actualStr, boolean strict)
    Asserts that the JSONArray provided does not match the expected string.
    static void
    assertNotEquals(String message, String expectedStr, String actualStr, boolean strict)
    Asserts that the JSONArray provided does not match the expected string.
    static void
    assertNotEquals(String message, String expectedStr, String actualStr, JSONComparator comparator)
    Asserts that the json string provided does not match the expected string.
    static void
    assertNotEquals(String message, String expectedStr, String actualStr, JSONCompareMode compareMode)
    Asserts that the JSONArray provided does not match the expected string.
    static void
    assertNotEquals(String message, String expectedStr, org.json.JSONArray actual, boolean strict)
    Asserts that the JSONArray provided does not match the expected string.
    static void
    assertNotEquals(String message, String expectedStr, org.json.JSONArray actual, JSONCompareMode compareMode)
    Asserts that the JSONArray provided does not match the expected string.
    static void
    assertNotEquals(String message, String expectedStr, org.json.JSONObject actual, boolean strict)
    Asserts that the JSONObject provided does not match the expected string.
    static void
    assertNotEquals(String message, String expectedStr, org.json.JSONObject actual, JSONCompareMode compareMode)
    Asserts that the JSONObject provided does not match the expected string.
    static void
    assertNotEquals(String expectedStr, String actualStr, JSONComparator comparator)
    Asserts that the json string provided does not match the expected string.
    static void
    assertNotEquals(String expectedStr, String actualStr, JSONCompareMode compareMode)
    Asserts that the JSONArray provided does not match the expected string.
    static void
    assertNotEquals(String expectedStr, org.json.JSONArray actual, boolean strict)
    Asserts that the JSONArray provided does not match the expected string.
    static void
    assertNotEquals(String message, org.json.JSONArray expected, org.json.JSONArray actual, boolean strict)
    Asserts that the JSONArray provided does not match the expected JSONArray.
    static void
    assertNotEquals(String message, org.json.JSONArray expected, org.json.JSONArray actual, JSONCompareMode compareMode)
    Asserts that the JSONArray provided does not match the expected JSONArray.
    static void
    assertNotEquals(String expectedStr, org.json.JSONArray actual, JSONCompareMode compareMode)
    Asserts that the JSONArray provided does not match the expected string.
    static void
    assertNotEquals(String expectedStr, org.json.JSONObject actual, boolean strict)
    Asserts that the JSONObject provided does not match the expected string.
    static void
    assertNotEquals(String message, org.json.JSONObject expected, org.json.JSONObject actual, boolean strict)
    Asserts that the JSONObject provided does not match the expected JSONObject.
    static void
    assertNotEquals(String message, org.json.JSONObject expected, org.json.JSONObject actual, JSONComparator comparator)
    Asserts that the JSONObject provided does not match the expected JSONObject.
    static void
    assertNotEquals(String message, org.json.JSONObject expected, org.json.JSONObject actual, JSONCompareMode compareMode)
    Asserts that the JSONObject provided does not match the expected JSONObject.
    static void
    assertNotEquals(String expectedStr, org.json.JSONObject actual, JSONCompareMode compareMode)
    Asserts that the JSONObject provided does not match the expected string.
    static void
    assertNotEquals(org.json.JSONArray expected, org.json.JSONArray actual, boolean strict)
    Asserts that the JSONArray provided does not match the expected JSONArray.
    static void
    assertNotEquals(org.json.JSONArray expected, org.json.JSONArray actual, JSONCompareMode compareMode)
    Asserts that the JSONArray provided does not match the expected JSONArray.
    static void
    assertNotEquals(org.json.JSONObject expected, org.json.JSONObject actual, boolean strict)
    Asserts that the JSONObject provided does not match the expected JSONObject.
    static void
    assertNotEquals(org.json.JSONObject expected, org.json.JSONObject actual, JSONComparator comparator)
    Asserts that the JSONObject provided does not match the expected JSONObject.
    static void
    assertNotEquals(org.json.JSONObject expected, org.json.JSONObject actual, JSONCompareMode compareMode)
    Asserts that the JSONObject provided does not match the expected JSONObject.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • assertEquals

      public static void assertEquals(String expectedStr, org.json.JSONObject actual, boolean strict)
      Asserts that the JSONObject provided matches the expected string. If it isn't it throws an AssertionError.
      Parameters:
      expectedStr - Expected JSON string
      actual - JSONObject to compare
      strict - Enables strict checking
    • assertEquals

      public static void assertEquals(String message, String expectedStr, org.json.JSONObject actual, boolean strict)
      Asserts that the JSONObject provided matches the expected string. If it isn't it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expectedStr - Expected JSON string
      actual - JSONObject to compare
      strict - Enables strict checking
    • assertNotEquals

      public static void assertNotEquals(String expectedStr, org.json.JSONObject actual, boolean strict)
      Asserts that the JSONObject provided does not match the expected string. If it is it throws an AssertionError.
      Parameters:
      expectedStr - Expected JSON string
      actual - JSONObject to compare
      strict - Enables strict checking
      See Also:
    • assertNotEquals

      public static void assertNotEquals(String message, String expectedStr, org.json.JSONObject actual, boolean strict)
      Asserts that the JSONObject provided does not match the expected string. If it is it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expectedStr - Expected JSON string
      actual - JSONObject to compare
      strict - Enables strict checking
      See Also:
    • assertEquals

      public static void assertEquals(String expectedStr, org.json.JSONObject actual, JSONCompareMode compareMode)
      Asserts that the JSONObject provided matches the expected string. If it isn't it throws an AssertionError.
      Parameters:
      expectedStr - Expected JSON string
      actual - JSONObject to compare
      compareMode - Specifies which comparison mode to use
    • assertEquals

      public static void assertEquals(String message, String expectedStr, org.json.JSONObject actual, JSONCompareMode compareMode)
      Asserts that the JSONObject provided matches the expected string. If it isn't it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expectedStr - Expected JSON string
      actual - JSONObject to compare
      compareMode - Specifies which comparison mode to use
    • assertNotEquals

      public static void assertNotEquals(String expectedStr, org.json.JSONObject actual, JSONCompareMode compareMode)
      Asserts that the JSONObject provided does not match the expected string. If it is it throws an AssertionError.
      Parameters:
      expectedStr - Expected JSON string
      actual - JSONObject to compare
      compareMode - Specifies which comparison mode to use
      See Also:
    • assertNotEquals

      public static void assertNotEquals(String message, String expectedStr, org.json.JSONObject actual, JSONCompareMode compareMode)
      Asserts that the JSONObject provided does not match the expected string. If it is it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expectedStr - Expected JSON string
      actual - JSONObject to compare
      compareMode - Specifies which comparison mode to use
      See Also:
    • assertEquals

      public static void assertEquals(String expectedStr, org.json.JSONArray actual, boolean strict)
      Asserts that the JSONArray provided matches the expected string. If it isn't it throws an AssertionError.
      Parameters:
      expectedStr - Expected JSON string
      actual - JSONArray to compare
      strict - Enables strict checking
    • assertEquals

      public static void assertEquals(String message, String expectedStr, org.json.JSONArray actual, boolean strict)
      Asserts that the JSONArray provided matches the expected string. If it isn't it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expectedStr - Expected JSON string
      actual - JSONArray to compare
      strict - Enables strict checking
    • assertNotEquals

      public static void assertNotEquals(String expectedStr, org.json.JSONArray actual, boolean strict)
      Asserts that the JSONArray provided does not match the expected string. If it is it throws an AssertionError.
      Parameters:
      expectedStr - Expected JSON string
      actual - JSONArray to compare
      strict - Enables strict checking
    • assertNotEquals

      public static void assertNotEquals(String message, String expectedStr, org.json.JSONArray actual, boolean strict)
      Asserts that the JSONArray provided does not match the expected string. If it is it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expectedStr - Expected JSON string
      actual - JSONArray to compare
      strict - Enables strict checking
    • assertEquals

      public static void assertEquals(String expectedStr, org.json.JSONArray actual, JSONCompareMode compareMode)
      Asserts that the JSONArray provided matches the expected string. If it isn't it throws an AssertionError.
      Parameters:
      expectedStr - Expected JSON string
      actual - JSONArray to compare
      compareMode - Specifies which comparison mode to use
    • assertEquals

      public static void assertEquals(String message, String expectedStr, org.json.JSONArray actual, JSONCompareMode compareMode)
      Asserts that the JSONArray provided matches the expected string. If it isn't it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expectedStr - Expected JSON string
      actual - JSONArray to compare
      compareMode - Specifies which comparison mode to use
    • assertNotEquals

      public static void assertNotEquals(String expectedStr, org.json.JSONArray actual, JSONCompareMode compareMode)
      Asserts that the JSONArray provided does not match the expected string. If it is it throws an AssertionError.
      Parameters:
      expectedStr - Expected JSON string
      actual - JSONArray to compare
      compareMode - Specifies which comparison mode to use
    • assertNotEquals

      public static void assertNotEquals(String message, String expectedStr, org.json.JSONArray actual, JSONCompareMode compareMode)
      Asserts that the JSONArray provided does not match the expected string. If it is it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expectedStr - Expected JSON string
      actual - JSONArray to compare
      compareMode - Specifies which comparison mode to use
    • assertEquals

      public static void assertEquals(String expectedStr, String actualStr, boolean strict)
      Asserts that the JSONArray provided matches the expected string. If it isn't it throws an AssertionError.
      Parameters:
      expectedStr - Expected JSON string
      actualStr - String to compare
      strict - Enables strict checking
    • assertEquals

      public static void assertEquals(String message, String expectedStr, String actualStr, boolean strict)
      Asserts that the JSONArray provided matches the expected string. If it isn't it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expectedStr - Expected JSON string
      actualStr - String to compare
      strict - Enables strict checking
    • assertNotEquals

      public static void assertNotEquals(String expectedStr, String actualStr, boolean strict)
      Asserts that the JSONArray provided does not match the expected string. If it is it throws an AssertionError.
      Parameters:
      expectedStr - Expected JSON string
      actualStr - String to compare
      strict - Enables strict checking
    • assertNotEquals

      public static void assertNotEquals(String message, String expectedStr, String actualStr, boolean strict)
      Asserts that the JSONArray provided does not match the expected string. If it is it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expectedStr - Expected JSON string
      actualStr - String to compare
      strict - Enables strict checking
    • assertEquals

      public static void assertEquals(String expectedStr, String actualStr, JSONCompareMode compareMode)
      Asserts that the JSONArray provided matches the expected string. If it isn't it throws an AssertionError.
      Parameters:
      expectedStr - Expected JSON string
      actualStr - String to compare
      compareMode - Specifies which comparison mode to use
    • assertEquals

      public static void assertEquals(String message, String expectedStr, String actualStr, JSONCompareMode compareMode)
      Asserts that the JSONArray provided matches the expected string. If it isn't it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expectedStr - Expected JSON string
      actualStr - String to compare
      compareMode - Specifies which comparison mode to use
    • assertNotEquals

      public static void assertNotEquals(String expectedStr, String actualStr, JSONCompareMode compareMode)
      Asserts that the JSONArray provided does not match the expected string. If it is it throws an AssertionError.
      Parameters:
      expectedStr - Expected JSON string
      actualStr - String to compare
      compareMode - Specifies which comparison mode to use
    • assertNotEquals

      public static void assertNotEquals(String message, String expectedStr, String actualStr, JSONCompareMode compareMode)
      Asserts that the JSONArray provided does not match the expected string. If it is it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expectedStr - Expected JSON string
      actualStr - String to compare
      compareMode - Specifies which comparison mode to use
    • assertEquals

      public static void assertEquals(String expectedStr, String actualStr, JSONComparator comparator)
      Asserts that the json string provided matches the expected string. If it isn't it throws an AssertionError.
      Parameters:
      expectedStr - Expected JSON string
      actualStr - String to compare
      comparator - Comparator
    • assertEquals

      public static void assertEquals(String message, String expectedStr, String actualStr, JSONComparator comparator)
      Asserts that the json string provided matches the expected string. If it isn't it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expectedStr - Expected JSON string
      actualStr - String to compare
      comparator - Comparator
    • assertNotEquals

      public static void assertNotEquals(String expectedStr, String actualStr, JSONComparator comparator)
      Asserts that the json string provided does not match the expected string. If it is it throws an AssertionError.
      Parameters:
      expectedStr - Expected JSON string
      actualStr - String to compare
      comparator - Comparator
    • assertNotEquals

      public static void assertNotEquals(String message, String expectedStr, String actualStr, JSONComparator comparator)
      Asserts that the json string provided does not match the expected string. If it is it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expectedStr - Expected JSON string
      actualStr - String to compare
      comparator - Comparator
    • assertEquals

      public static void assertEquals(org.json.JSONObject expected, org.json.JSONObject actual, JSONComparator comparator)
      Asserts that the JSONObject provided matches the expected JSONObject. If it isn't it throws an AssertionError.
      Parameters:
      expected - Expected JSONObject
      actual - JSONObject to compare
      comparator - Comparator
    • assertEquals

      public static void assertEquals(String message, org.json.JSONObject expected, org.json.JSONObject actual, JSONComparator comparator)
      Asserts that the JSONObject provided matches the expected JSONObject. If it isn't it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expected - Expected JSONObject
      actual - JSONObject to compare
      comparator - Comparator
    • assertNotEquals

      public static void assertNotEquals(org.json.JSONObject expected, org.json.JSONObject actual, JSONComparator comparator)
      Asserts that the JSONObject provided does not match the expected JSONObject. If it is it throws an AssertionError.
      Parameters:
      expected - Expected JSONObject
      actual - JSONObject to compare
      comparator - Comparator
    • assertNotEquals

      public static void assertNotEquals(String message, org.json.JSONObject expected, org.json.JSONObject actual, JSONComparator comparator)
      Asserts that the JSONObject provided does not match the expected JSONObject. If it is it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expected - Expected JSONObject
      actual - JSONObject to compare
      comparator - Comparator
    • assertEquals

      public static void assertEquals(org.json.JSONObject expected, org.json.JSONObject actual, boolean strict)
      Asserts that the JSONObject provided matches the expected JSONObject. If it isn't it throws an AssertionError.
      Parameters:
      expected - Expected JSONObject
      actual - JSONObject to compare
      strict - Enables strict checking
    • assertEquals

      public static void assertEquals(String message, org.json.JSONObject expected, org.json.JSONObject actual, boolean strict)
      Asserts that the JSONObject provided matches the expected JSONObject. If it isn't it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expected - Expected JSONObject
      actual - JSONObject to compare
      strict - Enables strict checking
    • assertNotEquals

      public static void assertNotEquals(org.json.JSONObject expected, org.json.JSONObject actual, boolean strict)
      Asserts that the JSONObject provided does not match the expected JSONObject. If it is it throws an AssertionError.
      Parameters:
      expected - Expected JSONObject
      actual - JSONObject to compare
      strict - Enables strict checking
    • assertNotEquals

      public static void assertNotEquals(String message, org.json.JSONObject expected, org.json.JSONObject actual, boolean strict)
      Asserts that the JSONObject provided does not match the expected JSONObject. If it is it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expected - Expected JSONObject
      actual - JSONObject to compare
      strict - Enables strict checking
    • assertEquals

      public static void assertEquals(org.json.JSONObject expected, org.json.JSONObject actual, JSONCompareMode compareMode)
      Asserts that the JSONObject provided matches the expected JSONObject. If it isn't it throws an AssertionError.
      Parameters:
      expected - Expected JSONObject
      actual - JSONObject to compare
      compareMode - Specifies which comparison mode to use
    • assertEquals

      public static void assertEquals(String message, org.json.JSONObject expected, org.json.JSONObject actual, JSONCompareMode compareMode)
      Asserts that the JSONObject provided matches the expected JSONObject. If it isn't it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expected - Expected JSONObject
      actual - JSONObject to compare
      compareMode - Specifies which comparison mode to use
    • assertNotEquals

      public static void assertNotEquals(org.json.JSONObject expected, org.json.JSONObject actual, JSONCompareMode compareMode)
      Asserts that the JSONObject provided does not match the expected JSONObject. If it is it throws an AssertionError.
      Parameters:
      expected - Expected JSONObject
      actual - JSONObject to compare
      compareMode - Specifies which comparison mode to use
    • assertNotEquals

      public static void assertNotEquals(String message, org.json.JSONObject expected, org.json.JSONObject actual, JSONCompareMode compareMode)
      Asserts that the JSONObject provided does not match the expected JSONObject. If it is it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expected - Expected JSONObject
      actual - JSONObject to compare
      compareMode - Specifies which comparison mode to use
    • assertEquals

      public static void assertEquals(org.json.JSONArray expected, org.json.JSONArray actual, boolean strict)
      Asserts that the JSONArray provided matches the expected JSONArray. If it isn't it throws an AssertionError.
      Parameters:
      expected - Expected JSONArray
      actual - JSONArray to compare
      strict - Enables strict checking
    • assertEquals

      public static void assertEquals(String message, org.json.JSONArray expected, org.json.JSONArray actual, boolean strict)
      Asserts that the JSONArray provided matches the expected JSONArray. If it isn't it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expected - Expected JSONArray
      actual - JSONArray to compare
      strict - Enables strict checking
    • assertNotEquals

      public static void assertNotEquals(org.json.JSONArray expected, org.json.JSONArray actual, boolean strict)
      Asserts that the JSONArray provided does not match the expected JSONArray. If it is it throws an AssertionError.
      Parameters:
      expected - Expected JSONArray
      actual - JSONArray to compare
      strict - Enables strict checking
    • assertNotEquals

      public static void assertNotEquals(String message, org.json.JSONArray expected, org.json.JSONArray actual, boolean strict)
      Asserts that the JSONArray provided does not match the expected JSONArray. If it is it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expected - Expected JSONArray
      actual - JSONArray to compare
      strict - Enables strict checking
    • assertEquals

      public static void assertEquals(org.json.JSONArray expected, org.json.JSONArray actual, JSONCompareMode compareMode)
      Asserts that the JSONArray provided matches the expected JSONArray. If it isn't it throws an AssertionError.
      Parameters:
      expected - Expected JSONArray
      actual - JSONArray to compare
      compareMode - Specifies which comparison mode to use
    • assertEquals

      public static void assertEquals(String message, org.json.JSONArray expected, org.json.JSONArray actual, JSONCompareMode compareMode)
      Asserts that the JSONArray provided matches the expected JSONArray. If it isn't it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expected - Expected JSONArray
      actual - JSONArray to compare
      compareMode - Specifies which comparison mode to use
    • assertNotEquals

      public static void assertNotEquals(org.json.JSONArray expected, org.json.JSONArray actual, JSONCompareMode compareMode)
      Asserts that the JSONArray provided does not match the expected JSONArray. If it is it throws an AssertionError.
      Parameters:
      expected - Expected JSONArray
      actual - JSONArray to compare
      compareMode - Specifies which comparison mode to use
    • assertNotEquals

      public static void assertNotEquals(String message, org.json.JSONArray expected, org.json.JSONArray actual, JSONCompareMode compareMode)
      Asserts that the JSONArray provided does not match the expected JSONArray. If it is it throws an AssertionError.
      Parameters:
      message - Error message to be displayed in case of assertion failure
      expected - Expected JSONArray
      actual - JSONArray to compare
      compareMode - Specifies which comparison mode to use