jsonArrayToList(JSONArray expected) throws JSONExcept
* @param jsonArray the JSON array to get value from
* @param index index of object to retrieve
* @return value at the given index position
- * @throws JSONException JSON parsing error
*/
- public static Object getObjectOrNull(JSONArray jsonArray, int index) throws JSONException {
+ public static Object getObjectOrNull(JSONArray jsonArray, int index) {
return jsonArray.isNull(index) ? null : jsonArray.get(index);
}
@@ -143,10 +137,9 @@ public static Object getObjectOrNull(JSONArray jsonArray, int index) throws JSON
*
* @param array the JSON array to iterate through on
* @return true if all the elements in {@code array} are simple values
- * @throws JSONException JSON parsing error
* @see #isSimpleValue(Object)
*/
- public static boolean allSimpleValues(JSONArray array) throws JSONException {
+ public static boolean allSimpleValues(JSONArray array) {
for (int i = 0; i < array.length(); ++i) {
if (!array.isNull(i) && !isSimpleValue(array.get(i))) {
return false;
@@ -170,9 +163,8 @@ public static boolean isSimpleValue(Object o) {
*
* @param array the array to inspect
* @return true if all the elements in the given array are JSONObjects
- * @throws JSONException JSON parsing error
*/
- public static boolean allJSONObjects(JSONArray array) throws JSONException {
+ public static boolean allJSONObjects(JSONArray array) {
for (int i = 0; i < array.length(); ++i) {
if (!(array.get(i) instanceof JSONObject)) {
return false;
@@ -186,9 +178,8 @@ public static boolean allJSONObjects(JSONArray array) throws JSONException {
*
* @param array the array to inspect
* @return true if all the elements in the given array are JSONArrays
- * @throws JSONException JSON parsing error
*/
- public static boolean allJSONArrays(JSONArray array) throws JSONException {
+ public static boolean allJSONArrays(JSONArray array) {
for (int i = 0; i < array.length(); ++i) {
if (!(array.get(i) instanceof JSONArray)) {
return false;
diff --git a/src/site/resources/index.html b/src/site/resources/index.html
index 18028055..41f2c5ae 100644
--- a/src/site/resources/index.html
+++ b/src/site/resources/index.html
@@ -51,7 +51,7 @@ Introduction
JUnit
- The current version of JSONassert is 1.5.1
+ The current version of JSONassert is 2.0-rc1
Examples
diff --git a/src/site/resources/quickstart.html b/src/site/resources/quickstart.html
index f3cb03d7..371e3575 100644
--- a/src/site/resources/quickstart.html
+++ b/src/site/resources/quickstart.html
@@ -49,7 +49,7 @@ Quick Start
<dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
- <version>1.5.1</version>
+ <version>2.0-rc1</version>
</dependency>
diff --git a/src/test/java/org/skyscreamer/jsonassert/ArrayValueMatcherTest.java b/src/test/java/org/skyscreamer/jsonassert/ArrayValueMatcherTest.java
index b7f29e1c..fa815d3c 100644
--- a/src/test/java/org/skyscreamer/jsonassert/ArrayValueMatcherTest.java
+++ b/src/test/java/org/skyscreamer/jsonassert/ArrayValueMatcherTest.java
@@ -21,7 +21,6 @@
import java.text.MessageFormat;
import org.json.JSONArray;
-import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Test;
import org.skyscreamer.jsonassert.comparator.ArraySizeComparator;
@@ -43,12 +42,12 @@ public class ArrayValueMatcherTest {
private static final JSONComparator comparator = new DefaultComparator(JSONCompareMode.LENIENT);
private void doTest(String jsonPath, ArrayValueMatcher arrayValueMatcher, String expectedJSON,
- String actualJSON) throws JSONException {
+ String actualJSON) {
Customization customization = new Customization(jsonPath, arrayValueMatcher);
JSONAssert.assertEquals(expectedJSON, actualJSON, new CustomComparator(JSONCompareMode.LENIENT, customization));
}
- private void doFailingMatchTest(String jsonPath, ArrayValueMatcher arrayValueMatcher, String expectedJSON, String actualJSON, String expectedMessagePattern) throws JSONException {
+ private void doFailingMatchTest(String jsonPath, ArrayValueMatcher arrayValueMatcher, String expectedJSON, String actualJSON, String expectedMessagePattern) {
try {
doTest(jsonPath, arrayValueMatcher, expectedJSON, actualJSON);
}
@@ -61,12 +60,12 @@ private void doFailingMatchTest(String jsonPath, ArrayValueMatcher array
}
@Test
- public void matchesSecondElementOfJSONObjectArray() throws JSONException {
+ public void matchesSecondElementOfJSONObjectArray() {
doTest("a", new ArrayValueMatcher(comparator, 1), "{a:[{background:grey,id:2,type:row}]}", ARRAY_OF_JSONOBJECTS);
}
@Test
- public void failsWhenSecondElementOfJSONObjectArrayDoesNotMatch() throws JSONException {
+ public void failsWhenSecondElementOfJSONObjectArrayDoesNotMatch() {
doFailingMatchTest("a",
new ArrayValueMatcher(comparator, 1),
"{a:[{background:DOES_NOT_MATCH,id:2,type:row}]}",
@@ -75,7 +74,7 @@ public void failsWhenSecondElementOfJSONObjectArrayDoesNotMatch() throws JSONExc
}
@Test
- public void failsWhenThirdElementOfJSONObjectArrayDoesNotMatchInMultiplePlaces() throws JSONException {
+ public void failsWhenThirdElementOfJSONObjectArrayDoesNotMatchInMultiplePlaces() {
doFailingMatchTest("a",
new ArrayValueMatcher(comparator, 2),
"{a:[{background:DOES_NOT_MATCH,id:3,type:WRONG_TYPE}]}",
@@ -84,7 +83,7 @@ public void failsWhenThirdElementOfJSONObjectArrayDoesNotMatchInMultiplePlaces()
}
@Test
- public void failsWhenTwoElementsOfJSONObjectArrayDoNotMatch() throws JSONException {
+ public void failsWhenTwoElementsOfJSONObjectArrayDoNotMatch() {
doFailingMatchTest("a",
new ArrayValueMatcher(comparator, 1, 2),
"{a:[{background:DOES_NOT_MATCH,id:2,type:row},{background:white,id:3,type:WRONG_TYPE}]}",
@@ -93,29 +92,29 @@ public void failsWhenTwoElementsOfJSONObjectArrayDoNotMatch() throws JSONExcepti
}
@Test
- public void matchesThirdElementOfSimpleValueArray() throws JSONException {
+ public void matchesThirdElementOfSimpleValueArray() {
doTest("a", new ArrayValueMatcher(comparator, 2), "{a:[3]}", ARRAY_OF_INTEGERS);
}
@Test
- public void failsWhenTwoElementOfSimpleValueArrayDoNotMatch() throws JSONException {
+ public void failsWhenTwoElementOfSimpleValueArrayDoNotMatch() {
doFailingMatchTest("a", new ArrayValueMatcher(comparator, 3, 4), "{a:[3,4]}", ARRAY_OF_INTEGERS,
"a\\[3\\]\\s*Expected:\\s3\\s*got:\\s*4\\s*;\\s*a\\[4\\]\\s*Expected:\\s*4\\s*got:\\s*5\\s*");
}
@Test
- public void matchesFirstElementOfArrayOfJSONArrays() throws JSONException {
+ public void matchesFirstElementOfArrayOfJSONArrays() {
doTest("a", new ArrayValueMatcher(comparator, 0), "{a:[[6,7,8]]}", ARRAY_OF_JSONARRAYS);
}
@Test
- public void matchesSizeOfFirstThreeInnerArrays() throws JSONException {
+ public void matchesSizeOfFirstThreeInnerArrays() {
JSONComparator innerArraySizeComparator = new ArraySizeComparator(JSONCompareMode.STRICT_ORDER);
doTest("a", new ArrayValueMatcher(innerArraySizeComparator, 0, 2), "{a:[[3]]}", ARRAY_OF_JSONARRAYS);
}
@Test
- public void failsWhenInnerArraySizeDoesNotMatch() throws JSONException {
+ public void failsWhenInnerArraySizeDoesNotMatch() {
JSONComparator innerArraySizeComparator = new ArraySizeComparator(JSONCompareMode.STRICT_ORDER);
doFailingMatchTest("a",
new ArrayValueMatcher(innerArraySizeComparator),
@@ -125,7 +124,7 @@ public void failsWhenInnerArraySizeDoesNotMatch() throws JSONException {
}
@Test
- public void failsWhenInnerJSONObjectArrayElementDoesNotMatch() throws JSONException {
+ public void failsWhenInnerJSONObjectArrayElementDoesNotMatch() {
ArrayValueMatcher innerArrayValueMatcher = new ArrayValueMatcher(comparator, 1);
JSONComparator innerArrayComparator = new CustomComparator(
JSONCompareMode.LENIENT, new Customization("a[2]", innerArrayValueMatcher));
@@ -137,12 +136,12 @@ public void failsWhenInnerJSONObjectArrayElementDoesNotMatch() throws JSONExcept
}
@Test
- public void matchesEveryElementOfJSONObjectArray() throws JSONException {
+ public void matchesEveryElementOfJSONObjectArray() {
doTest("a", new ArrayValueMatcher(comparator), "{a:[{type:row}]}", ARRAY_OF_JSONOBJECTS);
}
@Test
- public void failsWhenNotEveryElementOfJSONObjectArrayMatches() throws JSONException {
+ public void failsWhenNotEveryElementOfJSONObjectArrayMatches() {
doFailingMatchTest("a",
new ArrayValueMatcher(comparator),
"{a:[{background:white}]}",
@@ -151,22 +150,22 @@ public void failsWhenNotEveryElementOfJSONObjectArrayMatches() throws JSONExcept
}
@Test
- public void matchesEveryElementOfJSONObjectArrayWhenRangeTooLarge() throws JSONException {
+ public void matchesEveryElementOfJSONObjectArrayWhenRangeTooLarge() {
doTest("a", new ArrayValueMatcher(comparator, 0, 500), "{a:[{type:row}]}", ARRAY_OF_JSONOBJECTS);
}
@Test
- public void matchesElementPairsStartingFromElement1OfJSONObjectArrayWhenRangeTooLarge() throws JSONException {
+ public void matchesElementPairsStartingFromElement1OfJSONObjectArrayWhenRangeTooLarge() {
doTest("a", new ArrayValueMatcher(comparator, 1, 500), "{a:[{background:grey},{background:white}]}", ARRAY_OF_JSONOBJECTS);
}
@Test
- public void matchesElementPairsStartingFromElement0OfJSONObjectArrayWhenRangeTooLarge() throws JSONException {
+ public void matchesElementPairsStartingFromElement0OfJSONObjectArrayWhenRangeTooLarge() {
doTest("a", new ArrayValueMatcher(comparator), "{a:[{background:white},{background:grey}]}", ARRAY_OF_JSONOBJECTS);
}
@Test
- public void failsWhenAppliedToNonArray() throws JSONException {
+ public void failsWhenAppliedToNonArray() {
try {
doTest("a", new ArrayValueMatcher(comparator), "{a:[{background:white}]}", "{a:{attr1:value1,attr2:value2}}");
}
@@ -185,12 +184,12 @@ public void failsWhenAppliedToNonArray() throws JSONException {
*/
@Test
- public void simpleValueMatchesSecondElementOfJSONObjectArray() throws JSONException {
+ public void simpleValueMatchesSecondElementOfJSONObjectArray() {
doTest("a", new ArrayValueMatcher(comparator, 3), "{a:4}", ARRAY_OF_INTEGERS);
}
@Test
- public void jsonObjectMatchesSecondElementOfJSONObjectArray() throws JSONException {
+ public void jsonObjectMatchesSecondElementOfJSONObjectArray() {
doTest("a", new ArrayValueMatcher(comparator, 1), "{a:{background:grey,id:2,type:row}}", ARRAY_OF_JSONOBJECTS);
}
@@ -198,35 +197,35 @@ public void jsonObjectMatchesSecondElementOfJSONObjectArray() throws JSONExcepti
* Following tests contain copies of code quoted in ArrayValueMatcher JavaDoc and are included to verify that the exact code documented works as expected.
*/
@Test
- public void verifyIdAttributeOfFirstArrayElementMatches() throws JSONException {
+ public void verifyIdAttributeOfFirstArrayElementMatches() {
JSONComparator comparator = new DefaultComparator(JSONCompareMode.LENIENT);
Customization customization = new Customization("a", new ArrayValueMatcher(comparator, 0));
JSONAssert.assertEquals("{a:[{id:1}]}", ARRAY_OF_JSONOBJECTS, new CustomComparator(JSONCompareMode.LENIENT, customization));
}
@Test
- public void verifyIdAttributeOfFirstArrayElementMatchesSimplifiedExpectedSyntax() throws JSONException {
+ public void verifyIdAttributeOfFirstArrayElementMatchesSimplifiedExpectedSyntax() {
JSONComparator comparator = new DefaultComparator(JSONCompareMode.LENIENT);
Customization customization = new Customization("a", new ArrayValueMatcher(comparator, 0));
JSONAssert.assertEquals("{a:{id:1}}", ARRAY_OF_JSONOBJECTS, new CustomComparator(JSONCompareMode.LENIENT, customization));
}
@Test
- public void verifyTypeAttributeOfSecondAndThirdElementMatchesRow() throws JSONException {
+ public void verifyTypeAttributeOfSecondAndThirdElementMatchesRow() {
JSONComparator comparator = new DefaultComparator(JSONCompareMode.LENIENT);
Customization customization = new Customization("a", new ArrayValueMatcher(comparator, 1, 2));
JSONAssert.assertEquals("{a:[{type:row}]}", ARRAY_OF_JSONOBJECTS, new CustomComparator(JSONCompareMode.LENIENT, customization));
}
@Test
- public void verifyTypeAttributeOfEveryArrayElementMatchesRow() throws JSONException {
+ public void verifyTypeAttributeOfEveryArrayElementMatchesRow() {
JSONComparator comparator = new DefaultComparator(JSONCompareMode.LENIENT);
Customization customization = new Customization("a", new ArrayValueMatcher(comparator));
JSONAssert.assertEquals("{a:[{type:row}]}", ARRAY_OF_JSONOBJECTS, new CustomComparator(JSONCompareMode.LENIENT, customization));
}
@Test
- public void verifyEveryArrayElementWithCustomComparator() throws JSONException {
+ public void verifyEveryArrayElementWithCustomComparator() {
// get length of array we will verify
int aLength = ((JSONArray)((JSONObject)JSONParser.parseJSON(ARRAY_OF_JSONOBJECTS)).get("a")).length();
// create array of customizations one for each array element
@@ -245,21 +244,21 @@ public void verifyEveryArrayElementWithCustomComparator() throws JSONException {
}
@Test
- public void verifyBackgroundAttributesOfEveryArrayElementAlternateBetweenWhiteAndGrey() throws JSONException {
+ public void verifyBackgroundAttributesOfEveryArrayElementAlternateBetweenWhiteAndGrey() {
JSONComparator comparator = new DefaultComparator(JSONCompareMode.LENIENT);
Customization customization = new Customization("a", new ArrayValueMatcher(comparator));
JSONAssert.assertEquals("{a:[{background:white},{background:grey}]}", ARRAY_OF_JSONOBJECTS, new CustomComparator(JSONCompareMode.LENIENT, customization));
}
@Test
- public void verifyEveryElementOfArrayIsJSONArrayOfLength3() throws JSONException {
+ public void verifyEveryElementOfArrayIsJSONArrayOfLength3() {
JSONComparator comparator = new ArraySizeComparator(JSONCompareMode.STRICT_ORDER);
Customization customization = new Customization("a", new ArrayValueMatcher(comparator, 0, 2));
JSONAssert.assertEquals("{a:[[3]]}", ARRAY_OF_JSONARRAYS, new CustomComparator(JSONCompareMode.LENIENT, customization));
}
@Test
- public void verifySecondElementOfArrayIsJSONArrayWhoseFirstElementIs9() throws JSONException {
+ public void verifySecondElementOfArrayIsJSONArrayWhoseFirstElementIs9() {
Customization innerCustomization = new Customization("a[1]", new ArrayValueMatcher(comparator, 0));
JSONComparator comparator = new CustomComparator(JSONCompareMode.LENIENT, innerCustomization);
Customization customization = new Customization("a", new ArrayValueMatcher(comparator, 1));
@@ -267,7 +266,7 @@ public void verifySecondElementOfArrayIsJSONArrayWhoseFirstElementIs9() throws J
}
@Test
- public void verifySecondElementOfArrayIsJSONArrayWhoseFirstElementIs9WithSimpliedExpectedString() throws JSONException {
+ public void verifySecondElementOfArrayIsJSONArrayWhoseFirstElementIs9WithSimpliedExpectedString() {
Customization innerCustomization = new Customization("a[1]", new ArrayValueMatcher(comparator, 0));
JSONComparator comparator = new CustomComparator(JSONCompareMode.LENIENT, innerCustomization);
Customization customization = new Customization("a", new ArrayValueMatcher(comparator, 1));
@@ -275,7 +274,7 @@ public void verifySecondElementOfArrayIsJSONArrayWhoseFirstElementIs9WithSimplie
}
@Test
- public void verifySecondElementOfArrayIsJSONArrayWhoseFirstElementIs9WithEvenMoreSimpliedExpectedString() throws JSONException {
+ public void verifySecondElementOfArrayIsJSONArrayWhoseFirstElementIs9WithEvenMoreSimpliedExpectedString() {
Customization innerCustomization = new Customization("a[1]", new ArrayValueMatcher(comparator, 0));
JSONComparator comparator = new CustomComparator(JSONCompareMode.LENIENT, innerCustomization);
Customization customization = new Customization("a", new ArrayValueMatcher(comparator, 1));
diff --git a/src/test/java/org/skyscreamer/jsonassert/JSONArrayWithNullTest.java b/src/test/java/org/skyscreamer/jsonassert/JSONArrayWithNullTest.java
index c5a5da5f..0bf11531 100644
--- a/src/test/java/org/skyscreamer/jsonassert/JSONArrayWithNullTest.java
+++ b/src/test/java/org/skyscreamer/jsonassert/JSONArrayWithNullTest.java
@@ -1,13 +1,12 @@
package org.skyscreamer.jsonassert;
import org.json.JSONArray;
-import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Test;
public class JSONArrayWithNullTest {
@Test
- public void testJSONArrayWithNullValue() throws JSONException {
+ public void testJSONArrayWithNullValue() {
JSONArray jsonArray1 = getJSONArray1();
JSONArray jsonArray2 = getJSONArray2();
@@ -16,7 +15,7 @@ public void testJSONArrayWithNullValue() throws JSONException {
}
@Test
- public void testJSONArrayWithNullValueAndJsonObject() throws JSONException {
+ public void testJSONArrayWithNullValueAndJsonObject() {
JSONArray jsonArray1 = getJSONArray1();
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("hey", "value");
@@ -32,7 +31,7 @@ public void testJSONArrayWithNullValueAndJsonObject() throws JSONException {
private JSONArray getJSONArray1() {
JSONArray jsonArray1 = new JSONArray();
jsonArray1.put(1);
- jsonArray1.put(null);
+ jsonArray1.put(JSONObject.NULL);
jsonArray1.put(3);
jsonArray1.put(2);
return jsonArray1;
@@ -41,7 +40,7 @@ private JSONArray getJSONArray1() {
private JSONArray getJSONArray2() {
JSONArray jsonArray1 = new JSONArray();
jsonArray1.put(1);
- jsonArray1.put(null);
+ jsonArray1.put(JSONObject.NULL);
jsonArray1.put(3);
jsonArray1.put(2);
return jsonArray1;
diff --git a/src/test/java/org/skyscreamer/jsonassert/JSONAssertTest.java b/src/test/java/org/skyscreamer/jsonassert/JSONAssertTest.java
index e39c80ba..e17f684b 100644
--- a/src/test/java/org/skyscreamer/jsonassert/JSONAssertTest.java
+++ b/src/test/java/org/skyscreamer/jsonassert/JSONAssertTest.java
@@ -24,7 +24,6 @@
import java.util.Arrays;
import org.json.JSONArray;
-import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
@@ -36,7 +35,7 @@
*/
public class JSONAssertTest {
@Test
- public void testString() throws JSONException {
+ public void testString() {
testPass("\"Joe\"", "\"Joe\"", STRICT);
testPass("\"Joe\"", "\"Joe\"", LENIENT);
testPass("\"Joe\"", "\"Joe\"", NON_EXTENSIBLE);
@@ -48,7 +47,7 @@ public void testString() throws JSONException {
}
@Test
- public void testNumber() throws JSONException {
+ public void testNumber() {
testPass("123", "123", STRICT);
testPass("123", "123", LENIENT);
testPass("123", "123", NON_EXTENSIBLE);
@@ -66,7 +65,7 @@ public void testNumber() throws JSONException {
}
@Test
- public void testSimple() throws JSONException {
+ public void testSimple() {
testPass("{id:1}", "{id:1}", STRICT);
testFail("{id:1}", "{id:2}", STRICT);
testPass("{id:1}", "{id:1}", LENIENT);
@@ -78,7 +77,7 @@ public void testSimple() throws JSONException {
}
@Test
- public void testSimpleStrict() throws JSONException {
+ public void testSimpleStrict() {
testPass("{id:1}", "{id:1,name:\"Joe\"}", LENIENT);
testFail("{id:1}", "{id:1,name:\"Joe\"}", STRICT);
testPass("{id:1}", "{id:1,name:\"Joe\"}", STRICT_ORDER);
@@ -86,7 +85,7 @@ public void testSimpleStrict() throws JSONException {
}
@Test
- public void testReversed() throws JSONException {
+ public void testReversed() {
testPass("{name:\"Joe\",id:1}", "{id:1,name:\"Joe\"}", LENIENT);
testPass("{name:\"Joe\",id:1}", "{id:1,name:\"Joe\"}", STRICT);
testPass("{name:\"Joe\",id:1}", "{id:1,name:\"Joe\"}", NON_EXTENSIBLE);
@@ -94,7 +93,7 @@ public void testReversed() throws JSONException {
}
@Test // Currently JSONAssert assumes JSONObject.
- public void testArray() throws JSONException {
+ public void testArray() {
testPass("[1,2,3]","[1,2,3]", STRICT);
testPass("[1,2,3]","[1,3,2]", LENIENT);
testFail("[1,2,3]","[1,3,2]", STRICT);
@@ -106,7 +105,7 @@ public void testArray() throws JSONException {
}
@Test
- public void testNested() throws JSONException {
+ public void testNested() {
testPass("{id:1,address:{addr1:\"123 Main\", addr2:null, city:\"Houston\", state:\"TX\"}}",
"{id:1,address:{addr1:\"123 Main\", addr2:null, city:\"Houston\", state:\"TX\"}}", STRICT);
testFail("{id:1,address:{addr1:\"123 Main\", addr2:null, city:\"Houston\", state:\"TX\"}}",
@@ -114,7 +113,7 @@ public void testNested() throws JSONException {
}
@Test
- public void testVeryNested() throws JSONException {
+ public void testVeryNested() {
testPass("{a:{b:{c:{d:{e:{f:{g:{h:{i:{j:{k:{l:{m:{n:{o:{p:\"blah\"}}}}}}}}}}}}}}}}",
"{a:{b:{c:{d:{e:{f:{g:{h:{i:{j:{k:{l:{m:{n:{o:{p:\"blah\"}}}}}}}}}}}}}}}}", STRICT);
testFail("{a:{b:{c:{d:{e:{f:{g:{h:{i:{j:{k:{l:{m:{n:{o:{p:\"blah\"}}}}}}}}}}}}}}}}",
@@ -122,7 +121,7 @@ public void testVeryNested() throws JSONException {
}
@Test
- public void testSimpleArray() throws JSONException {
+ public void testSimpleArray() {
testPass("{id:1,pets:[\"dog\",\"cat\",\"fish\"]}", // Exact to exact (strict)
"{id:1,pets:[\"dog\",\"cat\",\"fish\"]}",
STRICT);
@@ -153,40 +152,40 @@ public void testSimpleArray() throws JSONException {
}
@Test
- public void testSimpleMixedArray() throws JSONException {
+ public void testSimpleMixedArray() {
testPass("{stuff:[321, \"abc\"]}", "{stuff:[\"abc\", 321]}", LENIENT);
testFail("{stuff:[321, \"abc\"]}", "{stuff:[\"abc\", 789]}", LENIENT);
}
@Test
- public void testComplexMixedStrictArray() throws JSONException {
+ public void testComplexMixedStrictArray() {
testPass("{stuff:[{pet:\"cat\"},{car:\"Ford\"}]}", "{stuff:[{pet:\"cat\"},{car:\"Ford\"}]}", STRICT);
}
@Test
- public void testComplexMixedArray() throws JSONException {
+ public void testComplexMixedArray() {
testPass("{stuff:[{pet:\"cat\"},{car:\"Ford\"}]}", "{stuff:[{pet:\"cat\"},{car:\"Ford\"}]}", LENIENT);
}
@Test
- public void testComplexArrayNoUniqueID() throws JSONException {
+ public void testComplexArrayNoUniqueID() {
testPass("{stuff:[{address:{addr1:\"123 Main\"}}, {address:{addr1:\"234 Broad\"}}]}",
"{stuff:[{address:{addr1:\"123 Main\"}}, {address:{addr1:\"234 Broad\"}}]}",
LENIENT);
}
@Test
- public void testSimpleAndComplexStrictArray() throws JSONException {
+ public void testSimpleAndComplexStrictArray() {
testPass("{stuff:[123,{a:\"b\"}]}", "{stuff:[123,{a:\"b\"}]}", STRICT);
}
@Test
- public void testSimpleAndComplexArray() throws JSONException {
+ public void testSimpleAndComplexArray() {
testPass("{stuff:[123,{a:\"b\"}]}", "{stuff:[123,{a:\"b\"}]}", LENIENT);
}
@Test
- public void testComplexArray() throws JSONException {
+ public void testComplexArray() {
testPass("{id:1,name:\"Joe\",friends:[{id:2,name:\"Pat\",pets:[\"dog\"]},{id:3,name:\"Sue\",pets:[\"bird\",\"fish\"]}],pets:[]}",
"{id:1,name:\"Joe\",friends:[{id:2,name:\"Pat\",pets:[\"dog\"]},{id:3,name:\"Sue\",pets:[\"bird\",\"fish\"]}],pets:[]}",
STRICT); // Exact to exact (strict)
@@ -217,23 +216,23 @@ public void testComplexArray() throws JSONException {
}
@Test
- public void testArrayOfArraysStrict() throws JSONException {
+ public void testArrayOfArraysStrict() {
testPass("{id:1,stuff:[[1,2],[2,3],[],[3,4]]}", "{id:1,stuff:[[1,2],[2,3],[],[3,4]]}", STRICT);
testFail("{id:1,stuff:[[1,2],[2,3],[3,4],[]]}", "{id:1,stuff:[[1,2],[2,3],[],[3,4]]}", STRICT);
}
@Test
- public void testArrayOfArrays() throws JSONException {
+ public void testArrayOfArrays() {
testPass("{id:1,stuff:[[4,3],[3,2],[],[1,2]]}", "{id:1,stuff:[[1,2],[2,3],[],[3,4]]}", LENIENT);
}
@Test
- public void testLenientArrayRecursion() throws JSONException {
+ public void testLenientArrayRecursion() {
testPass("[{\"arr\":[5, 2, 1]}]", "[{\"b\":3, \"arr\":[1, 5, 2]}]", LENIENT);
}
@Test
- public void testFieldMismatch() throws JSONException {
+ public void testFieldMismatch() {
JSONCompareResult result = JSONCompare.compareJSON("{name:\"Pat\"}", "{name:\"Sue\"}", STRICT);
FieldComparisonFailure comparisonFailure = result.getFieldFailures().iterator().next();
Assert.assertEquals("Pat", comparisonFailure.getExpected());
@@ -242,7 +241,7 @@ public void testFieldMismatch() throws JSONException {
}
@Test
- public void testBooleanArray() throws JSONException {
+ public void testBooleanArray() {
testPass("[true, false, true, true, false]", "[true, false, true, true, false]", STRICT);
testPass("[false, true, true, false, true]", "[true, false, true, true, false]", LENIENT);
testFail("[false, true, true, false, true]", "[true, false, true, true, false]", STRICT);
@@ -251,34 +250,34 @@ public void testBooleanArray() throws JSONException {
}
@Test
- public void testNullProperty() throws JSONException {
+ public void testNullProperty() {
testFail("{id:1,name:\"Joe\"}", "{id:1,name:null}", STRICT);
testFail("{id:1,name:null}", "{id:1,name:\"Joe\"}", STRICT);
}
@Test
- public void testIncorrectTypes() throws JSONException {
+ public void testIncorrectTypes() {
testFail("{id:1,name:\"Joe\"}", "{id:1,name:[]}", STRICT);
testFail("{id:1,name:[]}", "{id:1,name:\"Joe\"}", STRICT);
}
@Test
- public void testNullEquality() throws JSONException {
+ public void testNullEquality() {
testPass("{id:1,name:null}", "{id:1,name:null}", STRICT);
}
@Test
- public void testExpectedArrayButActualObject() throws JSONException {
+ public void testExpectedArrayButActualObject() {
testFail("[1]", "{id:1}", LENIENT);
}
@Test
- public void testExpectedObjectButActualArray() throws JSONException {
+ public void testExpectedObjectButActualArray() {
testFail("{id:1}", "[1]", LENIENT);
}
@Test
- public void testEquivalentIntAndLong() throws JSONException {
+ public void testEquivalentIntAndLong() {
JSONObject expected = new JSONObject();
JSONObject actual = new JSONObject();
expected.put("id", Integer.valueOf(12345));
@@ -288,7 +287,7 @@ public void testEquivalentIntAndLong() throws JSONException {
}
@Test
- public void testEquivalentIntAndDouble() throws JSONException {
+ public void testEquivalentIntAndDouble() {
JSONObject expected = new JSONObject();
JSONObject actual = new JSONObject();
expected.put("id", Integer.valueOf(12345));
@@ -298,7 +297,7 @@ public void testEquivalentIntAndDouble() throws JSONException {
}
@Test(expected = AssertionError.class)
- public void testAssertNotEqualsWhenEqualStrict() throws JSONException {
+ public void testAssertNotEqualsWhenEqualStrict() {
JSONObject expected = new JSONObject();
JSONObject actual = new JSONObject();
expected.put("id", Integer.valueOf(12345));
@@ -307,7 +306,7 @@ public void testAssertNotEqualsWhenEqualStrict() throws JSONException {
}
@Test(expected = AssertionError.class)
- public void testAssertNotEqualsWhenEqualLenient() throws JSONException {
+ public void testAssertNotEqualsWhenEqualLenient() {
JSONObject expected = new JSONObject();
JSONObject actual = new JSONObject();
expected.put("id", Integer.valueOf(12345));
@@ -316,7 +315,7 @@ public void testAssertNotEqualsWhenEqualLenient() throws JSONException {
}
@Test()
- public void testAssertNotEqualsWhenEqualDiffObjectsStrict() throws JSONException {
+ public void testAssertNotEqualsWhenEqualDiffObjectsStrict() {
JSONObject expected = new JSONObject();
JSONObject actual = new JSONObject();
expected.put("id", Integer.valueOf(12345));
@@ -326,7 +325,7 @@ public void testAssertNotEqualsWhenEqualDiffObjectsStrict() throws JSONException
}
@Test(expected = AssertionError.class)
- public void testAssertNotEqualsWhenEqualDiffObjectsLenient() throws JSONException {
+ public void testAssertNotEqualsWhenEqualDiffObjectsLenient() {
JSONObject expected = new JSONObject();
JSONObject actual = new JSONObject();
expected.put("id", Integer.valueOf(12345));
@@ -337,7 +336,7 @@ public void testAssertNotEqualsWhenEqualDiffObjectsLenient() throws JSONExceptio
}
@Test()
- public void testAssertNotEqualsWhenDifferentStrict() throws JSONException {
+ public void testAssertNotEqualsWhenDifferentStrict() {
JSONObject expected = new JSONObject();
JSONObject actual = new JSONObject();
expected.put("id", Integer.valueOf(12345));
@@ -346,7 +345,7 @@ public void testAssertNotEqualsWhenDifferentStrict() throws JSONException {
}
@Test()
- public void testAssertNotEqualsWhenDifferentLenient() throws JSONException {
+ public void testAssertNotEqualsWhenDifferentLenient() {
JSONObject expected = new JSONObject();
JSONObject actual = new JSONObject();
expected.put("id", Integer.valueOf(12345));
@@ -355,7 +354,7 @@ public void testAssertNotEqualsWhenDifferentLenient() throws JSONException {
}
@Test()
- public void testAssertNotEqualsString() throws JSONException {
+ public void testAssertNotEqualsString() {
JSONAssert.assertNotEquals("[1,2,3]", "[1,3,2]", STRICT);
JSONAssert.assertNotEquals("[1,2,3]", "[1,2,4]", LENIENT);
JSONAssert.assertNotEquals("[1,2,3]", "[1,3,2]", true);
@@ -363,7 +362,7 @@ public void testAssertNotEqualsString() throws JSONException {
}
@Test()
- public void testAssertEqualsString() throws JSONException {
+ public void testAssertEqualsString() {
JSONAssert.assertEquals("[1,2,3]", "[1,2,3]", true);
JSONAssert.assertEquals("{id:12345}", "{id:12345}", false);
JSONAssert.assertEquals("{id:12345}", "{id:12345, name:\"john\"}", LENIENT);
@@ -372,7 +371,7 @@ public void testAssertEqualsString() throws JSONException {
}
@Test()
- public void testAssertNotEqualsStringAndJSONObject() throws JSONException {
+ public void testAssertNotEqualsStringAndJSONObject() {
JSONObject actual = new JSONObject();
actual.put("id", Double.valueOf(12345));
JSONAssert.assertEquals("{id:12345}", actual, false);
@@ -380,7 +379,7 @@ public void testAssertNotEqualsStringAndJSONObject() throws JSONException {
}
@Test()
- public void testAssertNotEqualsJSONArray() throws JSONException {
+ public void testAssertNotEqualsJSONArray() {
JSONArray actual = new JSONArray(Arrays.asList(1, 2, 3));
JSONAssert.assertEquals("[1,2,3]", actual, false);
JSONAssert.assertNotEquals("[1,2,4]", actual, false);
@@ -390,7 +389,7 @@ public void testAssertNotEqualsJSONArray() throws JSONException {
}
@Test
- public void testAssertEqualsStringJSONArrayBooleanWithMessage() throws JSONException {
+ public void testAssertEqualsStringJSONArrayBooleanWithMessage() {
JSONArray actual = new JSONArray(Arrays.asList(1, 2, 3));
JSONAssert.assertEquals("Message", "[1,2,3]", actual, false);
performAssertEqualsTestForMessageVerification("[1,2,4]", actual, false);
@@ -398,7 +397,7 @@ public void testAssertEqualsStringJSONArrayBooleanWithMessage() throws JSONExcep
}
@Test
- public void testAssertEqualsStringJSONArrayCompareModeWithMessage() throws JSONException {
+ public void testAssertEqualsStringJSONArrayCompareModeWithMessage() {
JSONArray actual = new JSONArray(Arrays.asList(1, 2, 3));
JSONAssert.assertEquals("Message", "[1,2,3]", actual, LENIENT);
performAssertEqualsTestForMessageVerification("[1,2,4]", actual, LENIENT);
@@ -406,7 +405,7 @@ public void testAssertEqualsStringJSONArrayCompareModeWithMessage() throws JSONE
}
@Test
- public void testAssertEqualsJSONArray2BooleanWithMessage() throws JSONException {
+ public void testAssertEqualsJSONArray2BooleanWithMessage() {
JSONArray actual = new JSONArray(Arrays.asList(1, 2, 3));
JSONAssert.assertEquals("Message", new JSONArray(Arrays.asList(1, 2, 3)), actual, false);
performAssertEqualsTestForMessageVerification(new JSONArray(Arrays.asList(1, 2, 4)), actual, false);
@@ -414,7 +413,7 @@ public void testAssertEqualsJSONArray2BooleanWithMessage() throws JSONException
}
@Test
- public void testAssertEqualsJSONArray2JSONCompareWithMessage() throws JSONException {
+ public void testAssertEqualsJSONArray2JSONCompareWithMessage() {
JSONArray actual = new JSONArray(Arrays.asList(1, 2, 3));
JSONAssert.assertEquals("Message", new JSONArray(Arrays.asList(1, 2, 3)), actual, LENIENT);
@@ -423,7 +422,7 @@ public void testAssertEqualsJSONArray2JSONCompareWithMessage() throws JSONExcept
}
@Test
- public void testAssertEqualsString2Boolean() throws JSONException {
+ public void testAssertEqualsString2Boolean() {
JSONAssert.assertEquals("Message", "{id:12345}", "{id:12345}", false);
JSONAssert.assertEquals("Message", "{id:12345}", "{id:12345, name:\"john\"}", false);
@@ -432,7 +431,7 @@ public void testAssertEqualsString2Boolean() throws JSONException {
}
@Test
- public void testAssertEqualsString2JSONCompare() throws JSONException {
+ public void testAssertEqualsString2JSONCompare() {
JSONAssert.assertEquals("Message", "{id:12345}", "{id:12345}", LENIENT);
JSONAssert.assertEquals("Message", "{id:12345}", "{id:12345, name:\"john\"}", LENIENT);
@@ -441,7 +440,7 @@ public void testAssertEqualsString2JSONCompare() throws JSONException {
}
@Test
- public void testAssertEqualsStringJSONObjectBoolean() throws JSONException {
+ public void testAssertEqualsStringJSONObjectBoolean() {
JSONObject actual = new JSONObject();
actual.put("id", Double.valueOf(12345));
JSONAssert.assertEquals("Message", "{id:12345}", actual, false);
@@ -450,7 +449,7 @@ public void testAssertEqualsStringJSONObjectBoolean() throws JSONException {
}
@Test
- public void testAssertEqualsStringJSONObjectJSONCompare() throws JSONException {
+ public void testAssertEqualsStringJSONObjectJSONCompare() {
JSONObject actual = new JSONObject();
actual.put("id", Double.valueOf(12345));
JSONAssert.assertEquals("Message", "{id:12345}", actual, LENIENT);
@@ -459,7 +458,7 @@ public void testAssertEqualsStringJSONObjectJSONCompare() throws JSONException {
}
@Test
- public void testAssertEqualsJSONObject2JSONCompare() throws JSONException {
+ public void testAssertEqualsJSONObject2JSONCompare() {
JSONObject expected = new JSONObject();
JSONObject actual = new JSONObject();
expected.put("id", Integer.valueOf(12345));
@@ -478,7 +477,7 @@ public void testAssertEqualsJSONObject2JSONCompare() throws JSONException {
}
@Test
- public void testAssertEqualsJSONObject2Boolean() throws JSONException {
+ public void testAssertEqualsJSONObject2Boolean() {
JSONObject expected = new JSONObject();
JSONObject actual = new JSONObject();
expected.put("id", Integer.valueOf(12345));
@@ -497,15 +496,15 @@ public void testAssertEqualsJSONObject2Boolean() throws JSONException {
}
@Test
- public void testAssertEqualsString2JsonComparator() throws IllegalArgumentException, JSONException {
- JSONAssert.assertEquals("Message", "{\"entry\":{\"id\":x}}", "{\"entry\":{\"id\":1, \"id\":2}}",
+ public void testAssertEqualsString2JsonComparator() throws IllegalArgumentException {
+ JSONAssert.assertEquals("Message", "{\"entry\":{\"id\":x}}", "{\"entry\":{\"id\":1}}",
new CustomComparator(
JSONCompareMode.STRICT,
new Customization("entry.id",
new RegularExpressionValueMatcher("\\d"))
));
- performAssertEqualsTestForMessageVerification("{\"entry\":{\"id\":x}}", "{\"entry\":{\"id\":1, \"id\":as}}",
+ performAssertEqualsTestForMessageVerification("{\"entry\":{\"id\":x}}", "{\"entry\":{\"id\":NOT_A_NUMBER}}",
new CustomComparator(
JSONCompareMode.STRICT,
new Customization("entry.id",
@@ -514,7 +513,7 @@ public void testAssertEqualsString2JsonComparator() throws IllegalArgumentExcept
}
@Test
- public void testAssertNotEqualsStringJSONArrayBooleanWithMessage() throws JSONException {
+ public void testAssertNotEqualsStringJSONArrayBooleanWithMessage() {
JSONArray actual = new JSONArray(Arrays.asList(1, 2, 3));
JSONAssert.assertNotEquals("Message", "[1,4,3]", actual, false);
JSONAssert.assertNotEquals("Message", "[1,4,3]", actual, true);
@@ -523,7 +522,7 @@ public void testAssertNotEqualsStringJSONArrayBooleanWithMessage() throws JSONEx
}
@Test
- public void testAssertNotEqualsStringJSONArrayCompareModeWithMessage() throws JSONException {
+ public void testAssertNotEqualsStringJSONArrayCompareModeWithMessage() {
JSONArray actual = new JSONArray(Arrays.asList(1, 2, 3));
JSONAssert.assertNotEquals("Message", "[1,2,4]", actual, LENIENT);
JSONAssert.assertNotEquals("Message", "[1,2,4]", actual, STRICT);
@@ -532,7 +531,7 @@ public void testAssertNotEqualsStringJSONArrayCompareModeWithMessage() throws JS
}
@Test
- public void testAssertNotEqualsJSONArray2BooleanWithMessage() throws JSONException {
+ public void testAssertNotEqualsJSONArray2BooleanWithMessage() {
JSONArray actual = new JSONArray(Arrays.asList(1, 2, 3));
JSONAssert.assertNotEquals("Message", new JSONArray(Arrays.asList(1, 4, 3)), actual, false);
performAssertNotEqualsTestForMessageVerification(new JSONArray(Arrays.asList(1, 3, 2)), actual, false);
@@ -540,7 +539,7 @@ public void testAssertNotEqualsJSONArray2BooleanWithMessage() throws JSONExcepti
}
@Test
- public void testAssertNotEqualsJSONArray2JSONCompareWithMessage() throws JSONException {
+ public void testAssertNotEqualsJSONArray2JSONCompareWithMessage() {
JSONArray actual = new JSONArray(Arrays.asList(1, 2, 3));
JSONAssert.assertNotEquals("Message", new JSONArray(Arrays.asList(1, 4, 3)), actual, LENIENT);
@@ -549,7 +548,7 @@ public void testAssertNotEqualsJSONArray2JSONCompareWithMessage() throws JSONExc
}
@Test
- public void testAssertNotEqualsString2Boolean() throws JSONException {
+ public void testAssertNotEqualsString2Boolean() {
JSONAssert.assertNotEquals("Message", "{id:12345}", "{id:45}", false);
JSONAssert.assertNotEquals("Message", "{id:12345}", "{id:345, name:\"john\"}", false);
@@ -558,7 +557,7 @@ public void testAssertNotEqualsString2Boolean() throws JSONException {
}
@Test
- public void testAssertNotEqualsString2JSONCompare() throws JSONException {
+ public void testAssertNotEqualsString2JSONCompare() {
JSONAssert.assertNotEquals("Message", "{id:12345}", "{id:123}", LENIENT);
JSONAssert.assertNotEquals("Message", "{id:12345, name:\"John\"}", "{id:12345}", LENIENT);
@@ -567,7 +566,7 @@ public void testAssertNotEqualsString2JSONCompare() throws JSONException {
}
@Test
- public void testAssertNotEqualsStringJSONObjectBoolean() throws JSONException {
+ public void testAssertNotEqualsStringJSONObjectBoolean() {
JSONObject actual = new JSONObject();
actual.put("id", Double.valueOf(12345));
JSONAssert.assertNotEquals("Message", "{id:1234}", actual, false);
@@ -576,7 +575,7 @@ public void testAssertNotEqualsStringJSONObjectBoolean() throws JSONException {
}
@Test
- public void testAssertNotEqualsStringJSONObjectJSONCompare() throws JSONException {
+ public void testAssertNotEqualsStringJSONObjectJSONCompare() {
JSONObject actual = new JSONObject();
actual.put("id", Double.valueOf(12345));
JSONAssert.assertNotEquals("Message", "{id:1234}", actual, LENIENT);
@@ -585,7 +584,7 @@ public void testAssertNotEqualsStringJSONObjectJSONCompare() throws JSONExceptio
}
@Test
- public void testAssertNtEqualsJSONObject2JSONCompare() throws JSONException {
+ public void testAssertNtEqualsJSONObject2JSONCompare() {
JSONObject expected = new JSONObject();
JSONObject actual = new JSONObject();
expected.put("id", Integer.valueOf(12345));
@@ -605,7 +604,7 @@ public void testAssertNtEqualsJSONObject2JSONCompare() throws JSONException {
}
@Test
- public void testAssertNotEqualsJSONObject2Boolean() throws JSONException {
+ public void testAssertNotEqualsJSONObject2Boolean() {
JSONObject expected = new JSONObject();
JSONObject actual = new JSONObject();
expected.put("id", Integer.valueOf(12345));
@@ -625,15 +624,15 @@ public void testAssertNotEqualsJSONObject2Boolean() throws JSONException {
}
@Test
- public void testAssertNotEqualsString2JsonComparator() throws IllegalArgumentException, JSONException {
- JSONAssert.assertNotEquals("Message", "{\"entry\":{\"id\":x}}", "{\"entry\":{\"id\":1, \"id\":hh}}",
+ public void testAssertNotEqualsString2JsonComparator() throws IllegalArgumentException {
+ JSONAssert.assertNotEquals("Message", "{\"entry\":{\"id\":x}}", "{\"entry\":{\"id\":NOT_A_NUMBER}}",
new CustomComparator(
JSONCompareMode.STRICT,
new Customization("entry.id",
new RegularExpressionValueMatcher("\\d"))
));
- performAssertNotEqualsTestForMessageVerification("{\"entry\":{\"id\":x}}", "{\"entry\":{\"id\":1, \"id\":2}}",
+ performAssertNotEqualsTestForMessageVerification("{\"entry\":{\"id\":x}}", "{\"entry\":{\"id\":1}}",
new CustomComparator(
JSONCompareMode.STRICT,
new Customization("entry.id",
@@ -642,7 +641,6 @@ public void testAssertNotEqualsString2JsonComparator() throws IllegalArgumentExc
}
private void testPass(String expected, String actual, JSONCompareMode compareMode)
- throws JSONException
{
String message = expected + " == " + actual + " (" + compareMode + ")";
JSONCompareResult result = JSONCompare.compareJSON(expected, actual, compareMode);
@@ -650,7 +648,6 @@ private void testPass(String expected, String actual, JSONCompareMode compareMod
}
private void testFail(String expected, String actual, JSONCompareMode compareMode)
- throws JSONException
{
String message = expected + " != " + actual + " (" + compareMode + ")";
JSONCompareResult result = JSONCompare.compareJSON(expected, actual, compareMode);
@@ -660,7 +657,7 @@ private void testFail(String expected, String actual, JSONCompareMode compareMod
private void performAssertEqualsTestForMessageVerification(
Object expected,
Object actual,
- Object strictMode) throws JSONException {
+ Object strictMode) {
String message = "Message";
String testShouldFailMessage = "The test should fail so that the message in AssertionError could be verified.";
@@ -754,7 +751,7 @@ private void performAssertNotEqualsTestForMessageVerification(
Object expected,
Object actual,
Object strictMode)
- throws JSONException {
+ {
String message = "Message";
String testShouldFailMessage = "The test should fail so that the message in AssertionError could be verified.";
diff --git a/src/test/java/org/skyscreamer/jsonassert/JSONCompareTest.java b/src/test/java/org/skyscreamer/jsonassert/JSONCompareTest.java
index 450adfde..3bcb7377 100644
--- a/src/test/java/org/skyscreamer/jsonassert/JSONCompareTest.java
+++ b/src/test/java/org/skyscreamer/jsonassert/JSONCompareTest.java
@@ -21,10 +21,10 @@
import static org.skyscreamer.jsonassert.JSONCompare.compareJSON;
import static org.skyscreamer.jsonassert.JSONCompareMode.LENIENT;
import static org.skyscreamer.jsonassert.JSONCompareMode.NON_EXTENSIBLE;
+import static org.skyscreamer.jsonassert.JSONCompareMode.STRICT;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
-import org.json.JSONException;
import org.junit.Test;
import org.junit.internal.matchers.TypeSafeMatcher;
@@ -33,18 +33,18 @@
*/
public class JSONCompareTest {
@Test
- public void succeedsWithEmptyArrays() throws JSONException {
+ public void succeedsWithEmptyArrays() {
assertTrue(compareJSON("[]", "[]", LENIENT).passed());
}
@Test
- public void reportsArraysOfUnequalLength() throws JSONException {
+ public void reportsArraysOfUnequalLength() {
JSONCompareResult result = compareJSON("[4]", "[]", LENIENT);
assertThat(result, failsWithMessage(equalTo("[]: Expected 1 values but got 0")));
}
@Test
- public void reportsArrayMissingExpectedElement() throws JSONException {
+ public void reportsArrayMissingExpectedElement() {
JSONCompareResult result = compareJSON("[4]", "[7]", LENIENT);
assertThat(result, failsWithMessage(equalTo("[]\nExpected: 4\n but none found\n ; []\nUnexpected: 7\n")));
assertEquals(result.getFieldMissing().size(), 1);
@@ -52,65 +52,65 @@ public void reportsArrayMissingExpectedElement() throws JSONException {
}
@Test
- public void reportsMismatchedFieldValues() throws JSONException {
+ public void reportsMismatchedFieldValues() {
JSONCompareResult result = compareJSON("{\"id\": 3}", "{\"id\": 5}", LENIENT);
assertThat(result, failsWithMessage(equalTo("id\nExpected: 3\n got: 5\n")));
assertThat(result, failsWithMessage(equalTo("id\nExpected: 3\n got: 5\n")));
}
@Test
- public void reportsMissingField() throws JSONException {
+ public void reportsMissingField() {
JSONCompareResult result = compareJSON("{\"obj\": {\"id\": 3}}", "{\"obj\": {}}", LENIENT);
assertThat(result, failsWithMessage(equalTo("obj\nExpected: id\n but none found\n")));
assertEquals(result.getFieldMissing().size(), 1);
}
@Test
- public void reportsUnexpectedArrayWhenExpectingObject() throws JSONException {
+ public void reportsUnexpectedArrayWhenExpectingObject() {
JSONCompareResult result = compareJSON("{}", "[]", LENIENT);
assertThat(result, failsWithMessage(equalTo("\nExpected: a JSON object\n got: a JSON array\n")));
}
@Test
- public void reportsUnexpectedObjectWhenExpectingArray() throws JSONException {
+ public void reportsUnexpectedObjectWhenExpectingArray() {
JSONCompareResult result = compareJSON("[]", "{}", LENIENT);
assertThat(result, failsWithMessage(equalTo("\nExpected: a JSON array\n got: a JSON object\n")));
}
@Test
- public void reportsUnexpectedNull() throws JSONException {
+ public void reportsUnexpectedNull() {
JSONCompareResult result = compareJSON("{\"id\": 3}", "{\"id\": null}", LENIENT);
assertThat(result, failsWithMessage(equalTo("id\nExpected: 3\n got: null\n")));
}
@Test
- public void reportsUnexpectedNonNull() throws JSONException {
+ public void reportsUnexpectedNonNull() {
JSONCompareResult result = compareJSON("{\"id\": null}", "{\"id\": \"abc\"}", LENIENT);
assertThat(result, failsWithMessage(equalTo("id\nExpected: null\n got: abc\n")));
}
@Test
- public void reportsUnexpectedFieldInNonExtensibleMode() throws JSONException {
+ public void reportsUnexpectedFieldInNonExtensibleMode() {
JSONCompareResult result = compareJSON("{\"obj\": {}}", "{\"obj\": {\"id\": 3}}", NON_EXTENSIBLE);
assertThat(result, failsWithMessage(equalTo("obj\nUnexpected: id\n")));
assertEquals(result.getFieldUnexpected().size(), 1);
}
@Test
- public void reportsMismatchedTypes() throws JSONException {
+ public void reportsMismatchedTypes() {
JSONCompareResult result = compareJSON("{\"arr\":[]}", "{\"arr\":{}}", LENIENT);
assertThat(result, failsWithMessage(equalTo("arr\nExpected: a JSON array\n got: a JSON object\n")));
}
@Test
- public void reportsWrongSimpleValueCountInUnorderedArray() throws JSONException {
+ public void reportsWrongSimpleValueCountInUnorderedArray() {
JSONCompareResult result = compareJSON("[5, 5]", "[5, 7]", LENIENT);
assertThat(result, failsWithMessage(equalTo("[]: Expected 2 occurrence(s) of 5 but got 1 occurrence(s) ; []\nUnexpected: 7\n")));
assertEquals(result.getFieldUnexpected().size(), 1);
}
@Test
- public void reportsMissingJSONObjectWithUniqueKeyInUnorderedArray() throws JSONException {
+ public void reportsMissingJSONObjectWithUniqueKeyInUnorderedArray() {
JSONCompareResult result = compareJSON("[{\"id\" : 3}]", "[{\"id\" : 5}]", LENIENT);
assertThat(result, failsWithMessage(equalTo("[id=3]\nExpected: a JSON object\n but none found\n ; " +
"[id=5]\nUnexpected: a JSON object\n")));
@@ -119,46 +119,72 @@ public void reportsMissingJSONObjectWithUniqueKeyInUnorderedArray() throws JSONE
}
@Test
- public void reportsUnmatchedJSONObjectInUnorderedArray() throws JSONException {
+ public void reportsUnmatchedJSONObjectInUnorderedArray() {
JSONCompareResult result = compareJSON("[{\"address\" : {\"street\" : \"Acacia Avenue\"}}]", "[{\"age\" : 23}]", LENIENT);
assertThat(result, failsWithMessage(equalTo("[0] Could not find match for element {\"address\":{\"street\":\"Acacia Avenue\"}}")));
}
@Test
- public void succeedsWithNestedJSONObjectsInUnorderedArray() throws JSONException {
+ public void succeedsWithNestedJSONObjectsInUnorderedArray() {
assertTrue(compareJSON("[{\"address\" : {\"street\" : \"Acacia Avenue\"}}, 5]", "[5, {\"address\" : {\"street\" : \"Acacia Avenue\"}}]", LENIENT).passed());
}
@Test
- public void succeedsWithJSONObjectsWithNonUniqueKeyInUnorderedArray() throws JSONException {
+ public void succeedsWithJSONObjectsWithNonUniqueKeyInUnorderedArray() {
String jsonDocument = "[{\"age\" : 43}, {\"age\" : 43}]";
assertTrue(compareJSON(jsonDocument, jsonDocument, LENIENT).passed());
}
@Test
- public void succeedsWithSomeNestedJSONObjectsInUnorderedArray() throws JSONException {
+ public void succeedsWithSomeNestedJSONObjectsInUnorderedArray() {
String jsonDocument = "[{\"age\" : 43}, {\"age\" : {\"years\" : 43}}]";
assertTrue(compareJSON(jsonDocument, jsonDocument, LENIENT).passed());
}
@Test
- public void reportsUnmatchesIntegerValueInUnorderedArrayContainingJSONObject() throws JSONException {
+ public void reportsUnmatchesIntegerValueInUnorderedArrayContainingJSONObject() {
JSONCompareResult result = compareJSON("[{\"address\" : {\"street\" : \"Acacia Avenue\"}}, 5]", "[{\"address\" : {\"street\" : \"Acacia Avenue\"}}, 2]", LENIENT);
assertThat(result, failsWithMessage(equalTo("[1] Could not find match for element 5")));
}
@Test
- public void reportsUnmatchedJSONArrayWhereOnlyExpectedContainsJSONObjectWithUniqueKey() throws JSONException {
+ public void reportsUnmatchedJSONArrayWhereOnlyExpectedContainsJSONObjectWithUniqueKey() {
JSONCompareResult result = compareJSON("[{\"id\": 3}]", "[{}]", LENIENT);
assertThat(result, failsWithMessage(equalTo("[0] Could not find match for element {\"id\":3}")));
}
@Test
- public void reportsUnmatchedJSONArrayWhereExpectedContainsJSONObjectWithUniqueKeyButActualContainsElementOfOtherType() throws JSONException {
+ public void reportsUnmatchedJSONArrayWhereExpectedContainsJSONObjectWithUniqueKeyButActualContainsElementOfOtherType() {
JSONCompareResult result = compareJSON("[{\"id\": 3}]", "[5]", LENIENT);
assertThat(result, failsWithMessage(equalTo("[0] Could not find match for element {\"id\":3}")));
}
+ @Test
+ public void reportsUnmatchedJSONArrayWhereExpectedContainsNonnullIntegerButActualContainsNullElement() {
+ JSONCompareResult result = compareJSON("[ 3 ]", "[ null ]", LENIENT);
+ assertThat(result, failsWithMessage(equalTo("[]\nExpected: 3\n but none found\n ; " +
+ "[]\nUnexpected: null\n")));
+ }
+
+ @Test
+ public void reportsUnmatchedJSONArrayWhereExpectedContainsNullElementButActualContainsNonnullInteger() {
+ JSONCompareResult result = compareJSON("[ null ]", "[ 3 ]", LENIENT);
+ assertThat(result, failsWithMessage(equalTo("[]\nExpected: null\n but none found\n ; " +
+ "[]\nUnexpected: 3\n")));
+ }
+
+ @Test
+ public void reportsStrictUnmatchedJSONArrayWhereExpectedContainsNonnullIntegerButActualContainsNullElement() {
+ JSONCompareResult result = compareJSON("[ 3 ]", "[ null ]", STRICT);
+ assertThat(result, failsWithMessage(equalTo("[0]\nExpected: 3\n got: null\n")));
+ }
+
+ @Test
+ public void reportsStrictUnmatchedJSONArrayWhereExpectedContainsNullButActualContainsNonnullInteger() {
+ JSONCompareResult result = compareJSON("[ null ]", "[ 3 ]", STRICT);
+ assertThat(result, failsWithMessage(equalTo("[0]\nExpected: null\n got: 3\n")));
+ }
+
private Matcher failsWithMessage(final Matcher expectedMessage) {
return new TypeSafeMatcher() {
@Override
diff --git a/src/test/java/org/skyscreamer/jsonassert/JSONCustomComparatorTest.java b/src/test/java/org/skyscreamer/jsonassert/JSONCustomComparatorTest.java
index 5f4c36ca..53546166 100644
--- a/src/test/java/org/skyscreamer/jsonassert/JSONCustomComparatorTest.java
+++ b/src/test/java/org/skyscreamer/jsonassert/JSONCustomComparatorTest.java
@@ -14,7 +14,6 @@
package org.skyscreamer.jsonassert;
-import org.json.JSONException;
import org.junit.Test;
import org.skyscreamer.jsonassert.comparator.CustomComparator;
import org.skyscreamer.jsonassert.comparator.JSONComparator;
@@ -128,7 +127,7 @@ public boolean equal(Object o1, Object o2) {
};
@Test
- public void whenPathMatchesInCustomizationThenCallCustomMatcher() throws JSONException {
+ public void whenPathMatchesInCustomizationThenCallCustomMatcher() {
JSONComparator jsonCmp = new CustomComparator(JSONCompareMode.STRICT, new Customization("first", comparator));
JSONCompareResult result = compareJSON(expected, actual, jsonCmp);
assertTrue(result.getMessage(), result.passed());
@@ -136,7 +135,7 @@ public void whenPathMatchesInCustomizationThenCallCustomMatcher() throws JSONExc
}
@Test
- public void whenDeepPathMatchesCallCustomMatcher() throws JSONException {
+ public void whenDeepPathMatchesCallCustomMatcher() {
JSONComparator jsonCmp = new CustomComparator(JSONCompareMode.STRICT, new Customization("outer.inner.value", comparator));
JSONCompareResult result = compareJSON(deepExpected, deepActual, jsonCmp);
assertTrue(result.getMessage(), result.passed());
@@ -144,7 +143,7 @@ public void whenDeepPathMatchesCallCustomMatcher() throws JSONException {
}
@Test
- public void whenSimpleWildcardPathMatchesCallCustomMatcher() throws JSONException {
+ public void whenSimpleWildcardPathMatchesCallCustomMatcher() {
JSONComparator jsonCmp = new CustomComparator(JSONCompareMode.STRICT, new Customization("foo.*.baz", comparator));
JSONCompareResult result = compareJSON(simpleWildcardExpected, simpleWildcardActual, jsonCmp);
assertTrue(result.getMessage(), result.passed());
@@ -152,7 +151,7 @@ public void whenSimpleWildcardPathMatchesCallCustomMatcher() throws JSONExceptio
}
@Test
- public void whenDeepWildcardPathMatchesCallCustomMatcher() throws JSONException {
+ public void whenDeepWildcardPathMatchesCallCustomMatcher() {
JSONComparator jsonCmp = new CustomComparator(JSONCompareMode.STRICT, new Customization("root.**.baz", comparator));
JSONCompareResult result = compareJSON(deepWildcardExpected, deepWildcardActual, jsonCmp);
assertTrue(result.getMessage(), result.passed());
@@ -160,7 +159,7 @@ public void whenDeepWildcardPathMatchesCallCustomMatcher() throws JSONException
}
@Test
- public void whenRootDeepWildcardPathMatchesCallCustomMatcher() throws JSONException {
+ public void whenRootDeepWildcardPathMatchesCallCustomMatcher() {
JSONComparator jsonCmp = new CustomComparator(JSONCompareMode.STRICT, new Customization("**.baz", comparator));
JSONCompareResult result = compareJSON(rootDeepWildcardExpected, rootDeepWildcardActual, jsonCmp);
assertTrue(result.getMessage(), result.passed());
diff --git a/src/test/java/org/skyscreamer/jsonassert/RegularExpressionValueMatcherTest.java b/src/test/java/org/skyscreamer/jsonassert/RegularExpressionValueMatcherTest.java
index 0e591da8..18539bc0 100644
--- a/src/test/java/org/skyscreamer/jsonassert/RegularExpressionValueMatcherTest.java
+++ b/src/test/java/org/skyscreamer/jsonassert/RegularExpressionValueMatcherTest.java
@@ -16,10 +16,7 @@
import org.junit.Assert;
-import org.json.JSONException;
import org.junit.Test;
-import org.skyscreamer.jsonassert.Customization;
-import org.skyscreamer.jsonassert.JSONCompareMode;
import org.skyscreamer.jsonassert.comparator.CustomComparator;
/**
@@ -34,52 +31,52 @@ public class RegularExpressionValueMatcherTest {
private static final String CONSTANT_URI_REGEX_EXPECTED_JSON = "{d:{results:[{__metadata:{uri:X}}]}}";
private void doTest(String jsonPath, String regex, String expectedJSON,
- String actualJSON) throws JSONException {
+ String actualJSON) {
JSONAssert.assertEquals(expectedJSON, actualJSON, new CustomComparator(
JSONCompareMode.STRICT_ORDER, new Customization(jsonPath,
new RegularExpressionValueMatcher(regex))));
}
@Test
- public void constantRegexWithSimplePathMatchsStringAttribute() throws JSONException {
+ public void constantRegexWithSimplePathMatchsStringAttribute() {
doTest("a", "v.", "{a:x}", "{a:v1}");
}
@Test
- public void constantRegexWithThreeLevelPathMatchsStringAttribute() throws JSONException {
+ public void constantRegexWithThreeLevelPathMatchsStringAttribute() {
doTest("a.b.c", ".*Is.*", "{a:{b:{c:x}}}", "{a:{b:{c:thisIsAString}}}");
}
@Test
- public void dynamicRegexWithSimplePathMatchsStringAttribute() throws JSONException {
+ public void dynamicRegexWithSimplePathMatchsStringAttribute() {
doTest("a", null, "{a:\"v.\"}", "{a:v1}");
}
@Test
- public void dynamicRegexWithThreeLevelPathMatchsStringAttribute() throws JSONException {
+ public void dynamicRegexWithThreeLevelPathMatchsStringAttribute() {
doTest("a.b.c", null, "{a:{b:{c:\".*Is.*\"}}}",
"{a:{b:{c:thisIsAString}}}");
}
@Test
- public void constantRegexMatchesStringAttributeInsideArray() throws JSONException {
+ public void constantRegexMatchesStringAttributeInsideArray() {
doTest(ARRAY_ELEMENT_PREFIX, "http://localhost:80/Person\\('\\d+'\\)", CONSTANT_URI_REGEX_EXPECTED_JSON, JSON_STRING_WITH_ARRAY);
}
@Test
- public void dynamicRegexMatchesStringAttributeInsideArray() throws JSONException {
+ public void dynamicRegexMatchesStringAttributeInsideArray() {
doTest(ARRAY_ELEMENT_PREFIX, null, "{d:{results:[{__metadata:{uri:\"http://localhost:80/Person\\\\('\\\\d+'\\\\)\"}}]}}", JSON_STRING_WITH_ARRAY);
}
@Test
- public void dynamicRegexMatchesStringAttributeInsideArrayWithNoArgConstructor() throws JSONException {
+ public void dynamicRegexMatchesStringAttributeInsideArrayWithNoArgConstructor() {
JSONAssert.assertEquals("{d:{results:[{__metadata:{uri:\"http://localhost:80/Person\\\\('\\\\d+'\\\\)\"}}]}}", JSON_STRING_WITH_ARRAY, new CustomComparator(
JSONCompareMode.STRICT_ORDER, new Customization(ARRAY_ELEMENT_PREFIX,
new RegularExpressionValueMatcher())));
}
@Test
- public void failsWhenDynamicRegexInvalid() throws JSONException {
+ public void failsWhenDynamicRegexInvalid() {
try {
doTest(ARRAY_ELEMENT_PREFIX, null, "{d:{results:[{__metadata:{uri:\"http://localhost:80/Person('\\\\d+'\\\\)\"}}]}}", JSON_STRING_WITH_ARRAY);
}
@@ -89,7 +86,7 @@ public void failsWhenDynamicRegexInvalid() throws JSONException {
}
@Test
- public void failsWhenDynamicRegexDoesNotMatchStringAttributeInsideArray() throws JSONException {
+ public void failsWhenDynamicRegexDoesNotMatchStringAttributeInsideArray() {
try {
doTest(ARRAY_ELEMENT_PREFIX, null, "{d:{results:[{__metadata:{uri:\"http://localhost:80/Person\\\\('\\\\w+'\\\\)\"}}]}}", JSON_STRING_WITH_ARRAY);
}
@@ -99,7 +96,7 @@ public void failsWhenDynamicRegexDoesNotMatchStringAttributeInsideArray() throws
}
@Test
- public void failsWhenConstantRegexInvalid() throws JSONException {
+ public void failsWhenConstantRegexInvalid() {
try {
doTest(ARRAY_ELEMENT_PREFIX, "http://localhost:80/Person\\\\['\\\\d+'\\\\)", CONSTANT_URI_REGEX_EXPECTED_JSON, JSON_STRING_WITH_ARRAY);
}
@@ -109,7 +106,7 @@ public void failsWhenConstantRegexInvalid() throws JSONException {
}
@Test
- public void failsWhenConstantRegexDoesNotMatchStringAttributeInsideArray() throws JSONException {
+ public void failsWhenConstantRegexDoesNotMatchStringAttributeInsideArray() {
try {
doTest(ARRAY_ELEMENT_PREFIX, "http://localhost:80/Person\\\\('\\\\w+'\\\\)", CONSTANT_URI_REGEX_EXPECTED_JSON, JSON_STRING_WITH_ARRAY);
}
diff --git a/src/test/java/org/skyscreamer/jsonassert/comparator/ArraySizeComparatorTest.java b/src/test/java/org/skyscreamer/jsonassert/comparator/ArraySizeComparatorTest.java
index c949e8b8..7af97ee5 100644
--- a/src/test/java/org/skyscreamer/jsonassert/comparator/ArraySizeComparatorTest.java
+++ b/src/test/java/org/skyscreamer/jsonassert/comparator/ArraySizeComparatorTest.java
@@ -19,7 +19,6 @@
import java.text.MessageFormat;
-import org.json.JSONException;
import org.junit.Test;
import org.skyscreamer.jsonassert.JSONAssert;
import org.skyscreamer.jsonassert.JSONCompareMode;
@@ -33,12 +32,12 @@
public class ArraySizeComparatorTest {
private static final String twoElementArray = "{a:[b,c]}";
- private void doTest(String expectedJSON, String actualJSON) throws JSONException
+ private void doTest(String expectedJSON, String actualJSON)
{
JSONAssert.assertEquals(expectedJSON, actualJSON, new ArraySizeComparator(JSONCompareMode.STRICT_ORDER));
}
- private void doFailingMatchTest(String expectedJSON, String actualJSON, String expectedMessagePattern) throws JSONException {
+ private void doFailingMatchTest(String expectedJSON, String actualJSON, String expectedMessagePattern) {
try {
doTest(expectedJSON, actualJSON);
}
@@ -51,77 +50,77 @@ private void doFailingMatchTest(String expectedJSON, String actualJSON, String e
}
@Test
- public void succeedsWhenExactSizeExpected() throws JSONException {
+ public void succeedsWhenExactSizeExpected() {
doTest("{a:[2]}", twoElementArray);
}
@Test
- public void succeedsWhenSizeWithinExpectedRange() throws JSONException {
+ public void succeedsWhenSizeWithinExpectedRange() {
doTest("{a:[1,3]}", twoElementArray);
}
@Test
- public void succeedsWhenSizeIsMinimumOfExpectedRange() throws JSONException {
+ public void succeedsWhenSizeIsMinimumOfExpectedRange() {
doTest("{a:[2,4]}", twoElementArray);
}
@Test
- public void succeedsWhenSizeIsMaximumOfExpectedRange() throws JSONException {
+ public void succeedsWhenSizeIsMaximumOfExpectedRange() {
doTest("{a:[1,2]}", twoElementArray);
}
@Test
- public void failsWhenExpectedArrayTooShort() throws JSONException {
+ public void failsWhenExpectedArrayTooShort() {
doFailingMatchTest("{a:[]}", twoElementArray, "a\\[\\]: invalid expectation: expected array should contain either 1 or 2 elements but contains 0 elements");
}
@Test
- public void failsWhenExpectedArrayTooLong() throws JSONException {
+ public void failsWhenExpectedArrayTooLong() {
doFailingMatchTest("{a:[1,2,3]}", twoElementArray, "a\\[\\]: invalid expectation: expected array should contain either 1 or 2 elements but contains 3 elements");
}
@Test
- public void failsWhenExpectedNotAllSimpleTypes() throws JSONException {
+ public void failsWhenExpectedNotAllSimpleTypes() {
doFailingMatchTest("{a:[{y:1},2]}", twoElementArray, "a\\[\\]: invalid expectation: minimum expected array size '\\{\"y\":1\\}' not a number");
}
@Test
- public void failsWhenExpectedMinimumTooSmall() throws JSONException {
+ public void failsWhenExpectedMinimumTooSmall() {
doFailingMatchTest("{a:[-1,6]}", twoElementArray, "a\\[\\]: invalid expectation: minimum expected array size '-1' negative");
}
@Test
- public void failsWhenExpectedMaximumTooSmall() throws JSONException {
+ public void failsWhenExpectedMaximumTooSmall() {
doFailingMatchTest("{a:[8,6]}", twoElementArray, "a\\[\\]: invalid expectation: maximum expected array size '6' less than minimum expected array size '8'");
}
@Test
- public void failsWhenExpectedArraySizeNotANumber() throws JSONException {
+ public void failsWhenExpectedArraySizeNotANumber() {
doFailingMatchTest("{a:[X]}", twoElementArray, "a\\[\\]: invalid expectation: expected array size 'X' not a number");
}
@Test
- public void failsWhenFirstExpectedArrayElementNotANumber() throws JSONException {
+ public void failsWhenFirstExpectedArrayElementNotANumber() {
doFailingMatchTest("{a:[MIN,6]}", twoElementArray, "a\\[\\]: invalid expectation: minimum expected array size 'MIN' not a number");
}
@Test
- public void failsWhenSecondExpectedArrayElementNotANumber() throws JSONException {
+ public void failsWhenSecondExpectedArrayElementNotANumber() {
doFailingMatchTest("{a:[8,MAX]}", twoElementArray, "a\\[\\]: invalid expectation: maximum expected array size 'MAX' not a number");
}
@Test
- public void failsWhenActualArrayTooShort() throws JSONException {
+ public void failsWhenActualArrayTooShort() {
doFailingMatchTest("{a:[3]}", twoElementArray, "a\\[\\]\\s*Expected:\\s*array size of 3 elements\\s*got:\\s*2 elements\\s*");
}
@Test
- public void failsWhenActualArrayLongerThanExpectedLength() throws JSONException {
+ public void failsWhenActualArrayLongerThanExpectedLength() {
doFailingMatchTest("{a:[1]}", twoElementArray, "a\\[\\]\\s*Expected:\\s*array size of 1 elements\\s*got:\\s*2 elements\\s*");
}
@Test
- public void failsWhenActualArrayLongerThanMaxOfExpectedRange() throws JSONException {
+ public void failsWhenActualArrayLongerThanMaxOfExpectedRange() {
doFailingMatchTest("{a:[0,1]}", twoElementArray, "a\\[\\]\\s*Expected:\\s*array size of 0 to 1 elements\\s*got:\\s*2 elements\\s*");
}
@@ -130,12 +129,12 @@ public void failsWhenActualArrayLongerThanMaxOfExpectedRange() throws JSONExcept
*/
@Test
- public void succeedsWhenActualArrayContainsExactly3Elements() throws JSONException {
+ public void succeedsWhenActualArrayContainsExactly3Elements() {
JSONAssert.assertEquals("{a:[3]}", "{a:[7, 8, 9]}", new ArraySizeComparator(JSONCompareMode.LENIENT));
}
@Test
- public void succeedsWhenActualArrayContainsBetween2And6Elements() throws JSONException {
+ public void succeedsWhenActualArrayContainsBetween2And6Elements() {
JSONAssert.assertEquals("{a:[2,6]}", "{a:[7, 8, 9]}", new ArraySizeComparator(JSONCompareMode.LENIENT));
}
diff --git a/src/test/java/org/skyscreamer/jsonassert/comparator/CustomComparatorTest.java b/src/test/java/org/skyscreamer/jsonassert/comparator/CustomComparatorTest.java
index 651e6a87..b48ffb59 100644
--- a/src/test/java/org/skyscreamer/jsonassert/comparator/CustomComparatorTest.java
+++ b/src/test/java/org/skyscreamer/jsonassert/comparator/CustomComparatorTest.java
@@ -16,7 +16,6 @@
import junit.framework.Assert;
import org.json.JSONArray;
-import org.json.JSONException;
import org.junit.Test;
import org.skyscreamer.jsonassert.JSONCompare;
import org.skyscreamer.jsonassert.JSONCompareMode;
@@ -34,7 +33,7 @@ public ArrayOfJsonObjectsComparator(JSONCompareMode mode) {
}
@Override
- public void compareJSONArray(String prefix, JSONArray expected, JSONArray actual, JSONCompareResult result) throws JSONException {
+ public void compareJSONArray(String prefix, JSONArray expected, JSONArray actual, JSONCompareResult result) {
compareJSONArrayOfJsonObjects(prefix, expected, actual, result);
}
}