diff --git a/.github/workflows/deploy-website.yml b/.github/workflows/deploy-website.yml
new file mode 100644
index 00000000..fb527d76
--- /dev/null
+++ b/.github/workflows/deploy-website.yml
@@ -0,0 +1,50 @@
+# Simple workflow for deploying static content to GitHub Pages
+name: Deploy static content to Pages
+
+on:
+ # Runs on pushes targeting the default branch - disabled, manual only
+ #push:
+ # branches: ["master"]
+
+ # Allows you to run this workflow manually from the Actions tab
+ workflow_dispatch:
+
+# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
+permissions:
+ contents: read
+ pages: write
+ id-token: write
+
+# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
+# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
+concurrency:
+ group: "pages"
+ cancel-in-progress: false
+
+jobs:
+ # Single deploy job since we're just deploying
+ deploy:
+ environment:
+ name: github-pages
+ url: ${{ steps.deployment.outputs.page_url }}
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ - name: Setup Pages
+ uses: actions/configure-pages@v5
+ - uses: actions/setup-java@v4
+ with:
+ java-version: '17'
+ distribution: 'temurin'
+ cache: maven
+ - name: Run the Maven javadoc command
+ run: mvn javadoc:aggregate -DreportOutputDirectory=src/site/resources/apidocs
+ - name: Upload artifact
+ uses: actions/upload-pages-artifact@v3
+ with:
+ # Upload entire repository
+ path: './src/site/resources'
+ - name: Deploy to GitHub Pages
+ id: deployment
+ uses: actions/deploy-pages@v4
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..ec376bb8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+.idea
+target
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0c9fef76..1b33ee64 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,34 @@
Changelog
=========
+Version 2.0-rc1 - 7/28/2024
+-------------------
+ - Release candidate
+ - ** Switches JSON implementation to use org.json:json:20240303 **
+ - Deployment still built with Java version 8 to maximize compatibility
+ - Cannot insert null directly into JSONArray without casting. Recommend to use JSONObject.Null
+ - JSONException is now a RuntimeException. Is not defined as thrown in method signatures anynmore.
+
+Version 1.5.3 - 6/28/2024
+-------------------------
+ - Revert Java release version from 21 to 8 due to breaking older compilers.
+
+Version 1.5.2 - 6/14/2024
+-------------------------
+ - Fix CVE-2020-15250 JUnit vulnerability (https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-15250). Bump
+ dependencies.
+ - Add gitIgnore file
+ - README syntax error fix
+ - Accidentally upgraded release to Java version 21
+
+Version 1.5.1 - 7/4/2022
+------------------------
+Going to try to catch up on some ancient PRs, mainly around security and cleanup. Starting with accepted PRs that
+didn't get released yet. To be followed hopefully shortly with another release.
+ - Added convenience methods for JSONObject comparison using a custom JSONComparator (thanks jakob-o@!)
+ - Fix issue #105: Issue when comparing JSONArray if any value is null (thanks suraj1291993@!)
+ - Fixes security vulnerability associated with older version of junit
+
Version 1.5.0 - 3/19/2017
-------------------------
- JSONassert now supports user-supplied error messages (thanks yasin3061@!)
@@ -16,12 +44,12 @@ Version 1.4.0 - 10/30/2016
Version 1.3.0 - 12/16/2015
--------------------------
- - Fix & improve ArrayValueMatcher JavaDoc (thanks dmackinder!)
+ - Fix & improve ArrayValueMatcher JavaDoc (thanks dmackinder@!)
Fix final JavaDoc example and add new example showing how to verify
every array element using a custom comparator
- - Fix URL in pom.xml (aukevanleeuwen)
- - Update JSONCompareResult.java adding 2 new lists for missing and unexpected fileds (thanks riccorazza!)
- - Includes missing imports in test class (thanks javierseixas!)
+ - Fix URL in pom.xml (aukevanleeuwen@)
+ - Update JSONCompareResult.java adding 2 new lists for missing and unexpected fileds (thanks riccorazza@!)
+ - Includes missing imports in test class (thanks javierseixas@!)
Version 1.2.3 - 2/5/2014
------------------------
@@ -38,7 +66,8 @@ Version 1.2.2 - 12/31/2013
Version 1.2.1 - 10/24/2013
--------------------------
- Remove commons-collection dependency
- - Updated Customization class to allow path-matching, and matching of expected and actual values with user-provided EqualityComparator.
+ - Updated Customization class to allow path-matching, and matching of expected and actual values with user-provided
+ EqualityComparator.
- Added AssertNotEquals
Version 1.2.0 - 3/17/2013
diff --git a/README.md b/README.md
index c28ba6de..871b1e19 100644
--- a/README.md
+++ b/README.md
@@ -29,22 +29,23 @@ Assert.assertTrue(data.has("friends"));
Object friendsObject = data.get("friends");
Assert.assertTrue(friendsObject instanceof JSONArray);
JSONArray friends = (JSONArray) friendsObject;
-Assert.assertEquals(2, data.length());
-JSONObject friend1Obj = friends.getJSONObject(data.get(0));
-Assert.true(friend1Obj.has("id"));
-Assert.true(friend1Obj.has("name"));
-JSONObject friend2Obj = friends.getJSONObject(data.get(1));
-Assert.true(friend2Obj.has("id"));
-Assert.true(friend2Obj.has("name"));
+Assert.assertEquals(2, friends.length());
+JSONObject friend1Obj = friends.getJSONObject(0);
+Assert.assertTrue(friend1Obj.has("id"));
+Assert.assertTrue(friend1Obj.has("name"));
+JSONObject friend2Obj = friends.getJSONObject(1);
+Assert.assertTrue(friend2Obj.has("id"));
+Assert.assertTrue(friend2Obj.has("name"));
+
if ("Carter Page".equals(friend1Obj.getString("name"))) {
- Assert.assertEquals(123, friend1Obj.getInt("id"));
+ Assert.assertEquals(456, friend1Obj.getInt("id"));
Assert.assertEquals("Corby Page", friend2Obj.getString("name"));
- Assert.assertEquals(456, friend2Obj.getInt("id"));
+ Assert.assertEquals(123, friend2Obj.getInt("id"));
}
else if ("Corby Page".equals(friend1Obj.getString("name"))) {
- Assert.assertEquals(456, friend1Obj.getInt("id"));
+ Assert.assertEquals(123, friend1Obj.getInt("id"));
Assert.assertEquals("Carter Page", friend2Obj.getString("name"));
- Assert.assertEquals(123, friend2Obj.getInt("id"));
+ Assert.assertEquals(456, friend2Obj.getInt("id"));
}
else {
Assert.fail("Expected either Carter or Corby, Got: " + friend1Obj.getString("name"));
@@ -76,8 +77,8 @@ To use, [download the JAR](https://github.com/skyscreamer/JSONassert/releases) o
org.skyscreamerjsonassert
- 1.5.0
- test
+ 2.0-rc1
+ test
Write tests like this:
@@ -96,16 +97,15 @@ Who uses JSONassert?
+ [GroupDocs](http://groupdocs.com/)
+ [Shazam](http://www.shazam.com/)
+ [Thucydides](http://thucydides.net/)
+ + [and over a thousand more](https://mvnrepository.com/artifact/org.skyscreamer/jsonassert)...
* * *
org.json
--------
-This implementation uses a clean-room implementation of the org.json
-library implemented for the Android system, released under the Apache 2.0 license. See
-[com.vaadin.external.google:android-json](http://search.maven.org/#artifactdetails%7Ccom.vaadin.external.google%7Candroid-json%7C0.0.20131108.vaadin1%7Cjar)
-That jar does **not** include the org.json.JSONString interface, so a new implementation of that interface is added to this source.
+As of v2, JSONAssert uses @stleary's [JSON-java](https://github.com/stleary/JSON-java) implementation of org.json, the
+most commonly used reference implementation for JSON in Java.
Resources
---------
diff --git a/pom.xml b/pom.xml
index 70a0456a..86738534 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,21 +2,19 @@
4.0.0
-
- org.sonatype.oss
- oss-parent
- 7
-
-
org.skyscreamerjsonassert
- 1.5.1-SNAPSHOT
+ 2.0-rc1jarJSONassert
- A library to develop RESTful but flexible APIs
+ Write JSON unit tests in less code. Great for testing REST interfaces.https://github.com/skyscreamer/JSONassert
+
+ 8
+
+
The Apache Software License, Version 2.0
@@ -36,28 +34,28 @@
carter@skyscreamer.org
- cepage
- Corby Page
- corby@skyscreamer.org
-
-
- sduskis
- Solomon Duskis
- solomon@skyscreamer.org
+ hertzsprung
+ James Shaw
- com.vaadin.external.google
- android-json
- 0.0.20131108.vaadin1
+ org.json
+ json
+ 20240303junitjunit
- 4.10
+ 4.13.2
+ test
+
+
+ org.hamcrest
+ hamcrest
+ 2.2test
@@ -67,44 +65,27 @@
org.apache.maven.pluginsmaven-compiler-plugin
- 2.3.1
-
- 1.6
- 1.6
-
+ 3.11.0
- org.apache.maven.plugins
- maven-site-plugin
- 3.3
+ org.sonatype.plugins
+ nexus-staging-maven-plugin
+ 1.6.7
+ true
-
-
- org.codehaus.mojo
- cobertura-maven-plugin
- 2.5.1
-
-
+ ossrh
+ https://oss.sonatype.org/
+ false
+
+
+ com.thoughtworks.xstream
+ xstream
+ 1.4.15
+
+
-
-
- org.apache.maven.scm
- maven-scm-provider-gitexe
- 1.3
-
-
- org.apache.maven.scm
- maven-scm-manager-plexus
- 1.3
-
-
- org.kathrynhuxtable.maven.wagon
- wagon-gitsite
- 0.3.1
-
-
@@ -112,23 +93,51 @@
github-project-sitegitsite:git@github.com/skyscreamer/JSONassert.git
+
+ ossrh
+ https://oss.sonatype.org/content/repositories/snapshots
+
- release-sign-artifacts
-
-
- performRelease
- true
-
-
+ deploy
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 2.2.1
+
+
+ attach-sources
+
+ jar-no-fork
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 2.9.1
+
+
+ attach-javadocs
+
+ jar
+
+
+
+
+ ${java.home}/bin/javadoc
+ ${maven.compiler.release}
+
+ org.apache.maven.pluginsmaven-gpg-plugin
- 1.1
+ 1.5sign-artifacts
diff --git a/src/main/java/org/json/JSONString.java b/src/main/java/org/json/JSONString.java
deleted file mode 100644
index 7360ddd3..00000000
--- a/src/main/java/org/json/JSONString.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.json;
-
-/**
- * The JSONString interface allows a toJSONString() method so that a class can change
- * the behavior of JSONObject.toString(), JSONArray.toString(), and JSONWriter.value(Object).
- * The toJSONString method will be used instead of the default behavior of using the
- * Object's toString() method and quoting the result.
- *
- * @author sasdjb
- *
- */
-public interface JSONString {
-
- /**
- * The toJSONString method allows a class to produce its own JSON
- * serialization.
- *
- * @return String representation of JSON object
- * */
- String toJSONString();
-
-}
diff --git a/src/main/java/org/skyscreamer/jsonassert/ArrayValueMatcher.java b/src/main/java/org/skyscreamer/jsonassert/ArrayValueMatcher.java
index ea3ebaf8..2d4dd8ec 100644
--- a/src/main/java/org/skyscreamer/jsonassert/ArrayValueMatcher.java
+++ b/src/main/java/org/skyscreamer/jsonassert/ArrayValueMatcher.java
@@ -133,7 +133,7 @@
*
To simplify complexity of expected JSON string, the value "{a:[[9]]}" may be replaced by "{a:[9]}" or "{a:9}"
*
* @author Duncan Mackinder
- *
+ * @param Array Type
*/
public class ArrayValueMatcher implements LocationAwareValueMatcher {
private final JSONComparator comparator;
diff --git a/src/main/java/org/skyscreamer/jsonassert/JSONAssert.java b/src/main/java/org/skyscreamer/jsonassert/JSONAssert.java
index d2a31cd1..5a2eec18 100644
--- a/src/main/java/org/skyscreamer/jsonassert/JSONAssert.java
+++ b/src/main/java/org/skyscreamer/jsonassert/JSONAssert.java
@@ -15,7 +15,6 @@
package org.skyscreamer.jsonassert;
import org.json.JSONArray;
-import org.json.JSONException;
import org.json.JSONObject;
import org.skyscreamer.jsonassert.comparator.JSONComparator;
@@ -59,10 +58,8 @@ private JSONAssert() {}
* @param expectedStr Expected JSON string
* @param actual JSONObject to compare
* @param strict Enables strict checking
- * @throws JSONException JSON parsing error
*/
- public static void assertEquals(String expectedStr, JSONObject actual, boolean strict)
- throws JSONException {
+ public static void assertEquals(String expectedStr, JSONObject actual, boolean strict) {
assertEquals(expectedStr, actual, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
}
@@ -74,10 +71,8 @@ public static void assertEquals(String expectedStr, JSONObject actual, boolean s
* @param expectedStr Expected JSON string
* @param actual JSONObject to compare
* @param strict Enables strict checking
- * @throws JSONException JSON parsing error
*/
- public static void assertEquals(String message, String expectedStr, JSONObject actual, boolean strict)
- throws JSONException {
+ public static void assertEquals(String message, String expectedStr, JSONObject actual, boolean strict) {
assertEquals(message, expectedStr, actual, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
}
@@ -90,10 +85,8 @@ public static void assertEquals(String message, String expectedStr, JSONObject a
* @param expectedStr Expected JSON string
* @param actual JSONObject to compare
* @param strict Enables strict checking
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(String expectedStr, JSONObject actual, boolean strict)
- throws JSONException {
+ public static void assertNotEquals(String expectedStr, JSONObject actual, boolean strict) {
assertNotEquals(expectedStr, actual, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
}
@@ -107,10 +100,8 @@ public static void assertNotEquals(String expectedStr, JSONObject actual, boolea
* @param expectedStr Expected JSON string
* @param actual JSONObject to compare
* @param strict Enables strict checking
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(String message, String expectedStr, JSONObject actual, boolean strict)
- throws JSONException {
+ public static void assertNotEquals(String message, String expectedStr, JSONObject actual, boolean strict) {
assertNotEquals(message, expectedStr, actual, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
}
@@ -121,10 +112,8 @@ public static void assertNotEquals(String message, String expectedStr, JSONObjec
* @param expectedStr Expected JSON string
* @param actual JSONObject to compare
* @param compareMode Specifies which comparison mode to use
- * @throws JSONException JSON parsing error
*/
- public static void assertEquals(String expectedStr, JSONObject actual, JSONCompareMode compareMode)
- throws JSONException {
+ public static void assertEquals(String expectedStr, JSONObject actual, JSONCompareMode compareMode) {
assertEquals("", expectedStr, actual, compareMode);
}
@@ -136,10 +125,9 @@ public static void assertEquals(String expectedStr, JSONObject actual, JSONCompa
* @param expectedStr Expected JSON string
* @param actual JSONObject to compare
* @param compareMode Specifies which comparison mode to use
- * @throws JSONException JSON parsing error
*/
public static void assertEquals(String message, String expectedStr, JSONObject actual, JSONCompareMode compareMode)
- throws JSONException {
+ {
Object expected = JSONParser.parseJSON(expectedStr);
if (expected instanceof JSONObject) {
assertEquals(message, (JSONObject)expected, actual, compareMode);
@@ -158,10 +146,8 @@ public static void assertEquals(String message, String expectedStr, JSONObject a
* @param expectedStr Expected JSON string
* @param actual JSONObject to compare
* @param compareMode Specifies which comparison mode to use
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(String expectedStr, JSONObject actual, JSONCompareMode compareMode)
- throws JSONException {
+ public static void assertNotEquals(String expectedStr, JSONObject actual, JSONCompareMode compareMode) {
assertNotEquals("", expectedStr, actual, compareMode);
}
@@ -175,10 +161,9 @@ public static void assertNotEquals(String expectedStr, JSONObject actual, JSONCo
* @param expectedStr Expected JSON string
* @param actual JSONObject to compare
* @param compareMode Specifies which comparison mode to use
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(String message, String expectedStr, JSONObject actual, JSONCompareMode compareMode)
- throws JSONException {
+ public static void assertNotEquals(String message, String expectedStr, JSONObject actual,
+ JSONCompareMode compareMode) {
Object expected = JSONParser.parseJSON(expectedStr);
if (expected instanceof JSONObject) {
assertNotEquals(message, (JSONObject) expected, actual, compareMode);
@@ -195,10 +180,8 @@ public static void assertNotEquals(String message, String expectedStr, JSONObjec
* @param expectedStr Expected JSON string
* @param actual JSONArray to compare
* @param strict Enables strict checking
- * @throws JSONException JSON parsing error
*/
- public static void assertEquals(String expectedStr, JSONArray actual, boolean strict)
- throws JSONException {
+ public static void assertEquals(String expectedStr, JSONArray actual, boolean strict) {
assertEquals(expectedStr, actual, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
}
@@ -210,10 +193,8 @@ public static void assertEquals(String expectedStr, JSONArray actual, boolean st
* @param expectedStr Expected JSON string
* @param actual JSONArray to compare
* @param strict Enables strict checking
- * @throws JSONException JSON parsing error
*/
- public static void assertEquals(String message, String expectedStr, JSONArray actual, boolean strict)
- throws JSONException {
+ public static void assertEquals(String message, String expectedStr, JSONArray actual, boolean strict) {
assertEquals(message, expectedStr, actual, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
}
@@ -224,10 +205,8 @@ public static void assertEquals(String message, String expectedStr, JSONArray ac
* @param expectedStr Expected JSON string
* @param actual JSONArray to compare
* @param strict Enables strict checking
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(String expectedStr, JSONArray actual, boolean strict)
- throws JSONException {
+ public static void assertNotEquals(String expectedStr, JSONArray actual, boolean strict) {
assertNotEquals(expectedStr, actual, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
}
@@ -239,10 +218,8 @@ public static void assertNotEquals(String expectedStr, JSONArray actual, boolean
* @param expectedStr Expected JSON string
* @param actual JSONArray to compare
* @param strict Enables strict checking
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(String message, String expectedStr, JSONArray actual, boolean strict)
- throws JSONException {
+ public static void assertNotEquals(String message, String expectedStr, JSONArray actual, boolean strict) {
assertNotEquals(message, expectedStr, actual, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
}
@@ -253,10 +230,8 @@ public static void assertNotEquals(String message, String expectedStr, JSONArray
* @param expectedStr Expected JSON string
* @param actual JSONArray to compare
* @param compareMode Specifies which comparison mode to use
- * @throws JSONException JSON parsing error
*/
- public static void assertEquals(String expectedStr, JSONArray actual, JSONCompareMode compareMode)
- throws JSONException {
+ public static void assertEquals(String expectedStr, JSONArray actual, JSONCompareMode compareMode) {
assertEquals("", expectedStr, actual, compareMode);
}
@@ -268,10 +243,8 @@ public static void assertEquals(String expectedStr, JSONArray actual, JSONCompar
* @param expectedStr Expected JSON string
* @param actual JSONArray to compare
* @param compareMode Specifies which comparison mode to use
- * @throws JSONException JSON parsing error
*/
- public static void assertEquals(String message, String expectedStr, JSONArray actual, JSONCompareMode compareMode)
- throws JSONException {
+ public static void assertEquals(String message, String expectedStr, JSONArray actual, JSONCompareMode compareMode) {
Object expected = JSONParser.parseJSON(expectedStr);
if (expected instanceof JSONArray) {
assertEquals(message, (JSONArray) expected, actual, compareMode);
@@ -288,10 +261,8 @@ public static void assertEquals(String message, String expectedStr, JSONArray ac
* @param expectedStr Expected JSON string
* @param actual JSONArray to compare
* @param compareMode Specifies which comparison mode to use
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(String expectedStr, JSONArray actual, JSONCompareMode compareMode)
- throws JSONException {
+ public static void assertNotEquals(String expectedStr, JSONArray actual, JSONCompareMode compareMode) {
Object expected = JSONParser.parseJSON(expectedStr);
if (expected instanceof JSONArray) {
assertNotEquals((JSONArray) expected, actual, compareMode);
@@ -309,10 +280,9 @@ public static void assertNotEquals(String expectedStr, JSONArray actual, JSONCom
* @param expectedStr Expected JSON string
* @param actual JSONArray to compare
* @param compareMode Specifies which comparison mode to use
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(String message, String expectedStr, JSONArray actual, JSONCompareMode compareMode)
- throws JSONException {
+ public static void assertNotEquals(String message, String expectedStr, JSONArray actual,
+ JSONCompareMode compareMode) {
Object expected = JSONParser.parseJSON(expectedStr);
if (expected instanceof JSONArray) {
assertNotEquals(message, (JSONArray) expected, actual, compareMode);
@@ -329,10 +299,8 @@ public static void assertNotEquals(String message, String expectedStr, JSONArray
* @param expectedStr Expected JSON string
* @param actualStr String to compare
* @param strict Enables strict checking
- * @throws JSONException JSON parsing error
*/
- public static void assertEquals(String expectedStr, String actualStr, boolean strict)
- throws JSONException {
+ public static void assertEquals(String expectedStr, String actualStr, boolean strict) {
assertEquals(expectedStr, actualStr, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
}
@@ -344,10 +312,8 @@ public static void assertEquals(String expectedStr, String actualStr, boolean st
* @param expectedStr Expected JSON string
* @param actualStr String to compare
* @param strict Enables strict checking
- * @throws JSONException JSON parsing error
*/
- public static void assertEquals(String message, String expectedStr, String actualStr, boolean strict)
- throws JSONException {
+ public static void assertEquals(String message, String expectedStr, String actualStr, boolean strict) {
assertEquals(message, expectedStr, actualStr, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
}
@@ -358,10 +324,8 @@ public static void assertEquals(String message, String expectedStr, String actua
* @param expectedStr Expected JSON string
* @param actualStr String to compare
* @param strict Enables strict checking
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(String expectedStr, String actualStr, boolean strict)
- throws JSONException {
+ public static void assertNotEquals(String expectedStr, String actualStr, boolean strict) {
assertNotEquals(expectedStr, actualStr, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
}
@@ -373,10 +337,8 @@ public static void assertNotEquals(String expectedStr, String actualStr, boolean
* @param expectedStr Expected JSON string
* @param actualStr String to compare
* @param strict Enables strict checking
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(String message, String expectedStr, String actualStr, boolean strict)
- throws JSONException {
+ public static void assertNotEquals(String message, String expectedStr, String actualStr, boolean strict) {
assertNotEquals(message, expectedStr, actualStr, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
}
@@ -387,10 +349,8 @@ public static void assertNotEquals(String message, String expectedStr, String ac
* @param expectedStr Expected JSON string
* @param actualStr String to compare
* @param compareMode Specifies which comparison mode to use
- * @throws JSONException JSON parsing error
*/
- public static void assertEquals(String expectedStr, String actualStr, JSONCompareMode compareMode)
- throws JSONException {
+ public static void assertEquals(String expectedStr, String actualStr, JSONCompareMode compareMode) {
assertEquals("", expectedStr, actualStr, compareMode);
}
@@ -402,10 +362,8 @@ public static void assertEquals(String expectedStr, String actualStr, JSONCompar
* @param expectedStr Expected JSON string
* @param actualStr String to compare
* @param compareMode Specifies which comparison mode to use
- * @throws JSONException JSON parsing error
*/
- public static void assertEquals(String message, String expectedStr, String actualStr, JSONCompareMode compareMode)
- throws JSONException {
+ public static void assertEquals(String message, String expectedStr, String actualStr, JSONCompareMode compareMode) {
if (expectedStr==actualStr) return;
if (expectedStr==null){
throw new AssertionError("Expected string is null.");
@@ -425,10 +383,8 @@ public static void assertEquals(String message, String expectedStr, String actua
* @param expectedStr Expected JSON string
* @param actualStr String to compare
* @param compareMode Specifies which comparison mode to use
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(String expectedStr, String actualStr, JSONCompareMode compareMode)
- throws JSONException {
+ public static void assertNotEquals(String expectedStr, String actualStr, JSONCompareMode compareMode) {
assertNotEquals("", expectedStr, actualStr, compareMode);
}
@@ -440,10 +396,9 @@ public static void assertNotEquals(String expectedStr, String actualStr, JSONCom
* @param expectedStr Expected JSON string
* @param actualStr String to compare
* @param compareMode Specifies which comparison mode to use
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(String message, String expectedStr, String actualStr, JSONCompareMode compareMode)
- throws JSONException {
+ public static void assertNotEquals(String message, String expectedStr, String actualStr,
+ JSONCompareMode compareMode) {
JSONCompareResult result = JSONCompare.compareJSON(expectedStr, actualStr, compareMode);
if (result.passed()) {
throw new AssertionError(getCombinedMessage(message, result.getMessage()));
@@ -457,10 +412,8 @@ public static void assertNotEquals(String message, String expectedStr, String ac
* @param expectedStr Expected JSON string
* @param actualStr String to compare
* @param comparator Comparator
- * @throws JSONException JSON parsing error
*/
- public static void assertEquals(String expectedStr, String actualStr, JSONComparator comparator)
- throws JSONException {
+ public static void assertEquals(String expectedStr, String actualStr, JSONComparator comparator) {
assertEquals("", expectedStr, actualStr, comparator);
}
@@ -473,10 +426,8 @@ public static void assertEquals(String expectedStr, String actualStr, JSONCompar
* @param expectedStr Expected JSON string
* @param actualStr String to compare
* @param comparator Comparator
- * @throws JSONException JSON parsing error
*/
- public static void assertEquals(String message, String expectedStr, String actualStr, JSONComparator comparator)
- throws JSONException {
+ public static void assertEquals(String message, String expectedStr, String actualStr, JSONComparator comparator) {
JSONCompareResult result = JSONCompare.compareJSON(expectedStr, actualStr, comparator);
if (result.failed()) {
throw new AssertionError(getCombinedMessage(message, result.getMessage()));
@@ -490,10 +441,8 @@ public static void assertEquals(String message, String expectedStr, String actua
* @param expectedStr Expected JSON string
* @param actualStr String to compare
* @param comparator Comparator
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(String expectedStr, String actualStr, JSONComparator comparator)
- throws JSONException {
+ public static void assertNotEquals(String expectedStr, String actualStr, JSONComparator comparator) {
assertNotEquals("", expectedStr, actualStr, comparator);
}
@@ -505,16 +454,72 @@ public static void assertNotEquals(String expectedStr, String actualStr, JSONCom
* @param expectedStr Expected JSON string
* @param actualStr String to compare
* @param comparator Comparator
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(String message, String expectedStr, String actualStr, JSONComparator comparator)
- throws JSONException {
+ public static void assertNotEquals(String message, String expectedStr, String actualStr,
+ JSONComparator comparator) {
JSONCompareResult result = JSONCompare.compareJSON(expectedStr, actualStr, comparator);
if (result.passed()) {
throw new AssertionError(getCombinedMessage(message, result.getMessage()));
}
}
+ /**
+ * Asserts that the JSONObject provided matches the expected JSONObject. If it isn't it throws an
+ * {@link AssertionError}.
+ *
+ * @param expected Expected JSONObject
+ * @param actual JSONObject to compare
+ * @param comparator Comparator
+ */
+ public static void assertEquals(JSONObject expected, JSONObject actual, JSONComparator comparator) {
+ assertEquals("", expected, actual, comparator);
+ }
+
+ /**
+ * Asserts that the JSONObject provided matches the expected JSONObject. If it isn't it throws an
+ * {@link AssertionError}.
+ *
+ * @param message Error message to be displayed in case of assertion failure
+ * @param expected Expected JSONObject
+ * @param actual JSONObject to compare
+ * @param comparator Comparator
+ */
+ public static void assertEquals(String message, JSONObject expected, JSONObject actual, JSONComparator comparator) {
+ JSONCompareResult result = JSONCompare.compareJSON(expected, actual, comparator);
+ if (result.failed()) {
+ throw new AssertionError(getCombinedMessage(message, result.getMessage()));
+ }
+ }
+
+ /**
+ * Asserts that the JSONObject provided does not match the expected JSONObject. If it is it throws an
+ * {@link AssertionError}.
+ *
+ * @param expected Expected JSONObject
+ * @param actual JSONObject to compare
+ * @param comparator Comparator
+ */
+ public static void assertNotEquals(JSONObject expected, JSONObject actual, JSONComparator comparator) {
+ assertNotEquals("", expected, actual, comparator);
+ }
+
+ /**
+ * Asserts that the JSONObject provided does not match the expected JSONObject. If it is it throws an
+ * {@link AssertionError}.
+ *
+ * @param message Error message to be displayed in case of assertion failure
+ * @param expected Expected JSONObject
+ * @param actual JSONObject to compare
+ * @param comparator Comparator
+ */
+ public static void assertNotEquals(String message, JSONObject expected, JSONObject actual,
+ JSONComparator comparator) {
+ JSONCompareResult result = JSONCompare.compareJSON(expected, actual, comparator);
+ if (result.passed()) {
+ throw new AssertionError(getCombinedMessage(message, result.getMessage()));
+ }
+ }
+
/**
* Asserts that the JSONObject provided matches the expected JSONObject. If it isn't it throws an
* {@link AssertionError}.
@@ -522,10 +527,8 @@ public static void assertNotEquals(String message, String expectedStr, String ac
* @param expected Expected JSONObject
* @param actual JSONObject to compare
* @param strict Enables strict checking
- * @throws JSONException JSON parsing error
*/
- public static void assertEquals(JSONObject expected, JSONObject actual, boolean strict)
- throws JSONException {
+ public static void assertEquals(JSONObject expected, JSONObject actual, boolean strict) {
assertEquals(expected, actual, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
}
@@ -537,10 +540,8 @@ public static void assertEquals(JSONObject expected, JSONObject actual, boolean
* @param expected Expected JSONObject
* @param actual JSONObject to compare
* @param strict Enables strict checking
- * @throws JSONException JSON parsing error
*/
- public static void assertEquals(String message, JSONObject expected, JSONObject actual, boolean strict)
- throws JSONException {
+ public static void assertEquals(String message, JSONObject expected, JSONObject actual, boolean strict) {
assertEquals(message, expected, actual, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
}
@@ -551,10 +552,8 @@ public static void assertEquals(String message, JSONObject expected, JSONObject
* @param expected Expected JSONObject
* @param actual JSONObject to compare
* @param strict Enables strict checking
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(JSONObject expected, JSONObject actual, boolean strict)
- throws JSONException {
+ public static void assertNotEquals(JSONObject expected, JSONObject actual, boolean strict) {
assertNotEquals(expected, actual, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
}
@@ -566,10 +565,8 @@ public static void assertNotEquals(JSONObject expected, JSONObject actual, boole
* @param expected Expected JSONObject
* @param actual JSONObject to compare
* @param strict Enables strict checking
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(String message, JSONObject expected, JSONObject actual, boolean strict)
- throws JSONException {
+ public static void assertNotEquals(String message, JSONObject expected, JSONObject actual, boolean strict) {
assertNotEquals(message, expected, actual, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
}
@@ -580,10 +577,8 @@ public static void assertNotEquals(String message, JSONObject expected, JSONObje
* @param expected Expected JSONObject
* @param actual JSONObject to compare
* @param compareMode Specifies which comparison mode to use
- * @throws JSONException JSON parsing error
*/
- public static void assertEquals(JSONObject expected, JSONObject actual, JSONCompareMode compareMode)
- throws JSONException {
+ public static void assertEquals(JSONObject expected, JSONObject actual, JSONCompareMode compareMode) {
assertEquals("", expected, actual, compareMode);
}
@@ -595,10 +590,9 @@ public static void assertEquals(JSONObject expected, JSONObject actual, JSONComp
* @param expected Expected JSONObject
* @param actual JSONObject to compare
* @param compareMode Specifies which comparison mode to use
- * @throws JSONException JSON parsing error
*/
- public static void assertEquals(String message, JSONObject expected, JSONObject actual, JSONCompareMode compareMode)
- throws JSONException {
+ public static void assertEquals(String message, JSONObject expected, JSONObject actual,
+ JSONCompareMode compareMode) {
JSONCompareResult result = JSONCompare.compareJSON(expected, actual, compareMode);
if (result.failed()) {
throw new AssertionError(getCombinedMessage(message, result.getMessage()));
@@ -612,10 +606,8 @@ public static void assertEquals(String message, JSONObject expected, JSONObject
* @param expected Expected JSONObject
* @param actual JSONObject to compare
* @param compareMode Specifies which comparison mode to use
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(JSONObject expected, JSONObject actual, JSONCompareMode compareMode)
- throws JSONException {
+ public static void assertNotEquals(JSONObject expected, JSONObject actual, JSONCompareMode compareMode) {
assertNotEquals("", expected, actual, compareMode);
}
@@ -627,10 +619,9 @@ public static void assertNotEquals(JSONObject expected, JSONObject actual, JSONC
* @param expected Expected JSONObject
* @param actual JSONObject to compare
* @param compareMode Specifies which comparison mode to use
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(String message, JSONObject expected, JSONObject actual, JSONCompareMode compareMode)
- throws JSONException {
+ public static void assertNotEquals(String message, JSONObject expected, JSONObject actual,
+ JSONCompareMode compareMode) {
JSONCompareResult result = JSONCompare.compareJSON(expected, actual, compareMode);
if (result.passed()) {
throw new AssertionError(getCombinedMessage(message, result.getMessage()));
@@ -644,10 +635,8 @@ public static void assertNotEquals(String message, JSONObject expected, JSONObje
* @param expected Expected JSONArray
* @param actual JSONArray to compare
* @param strict Enables strict checking
- * @throws JSONException JSON parsing error
*/
- public static void assertEquals(JSONArray expected, JSONArray actual, boolean strict)
- throws JSONException {
+ public static void assertEquals(JSONArray expected, JSONArray actual, boolean strict) {
assertEquals("", expected, actual, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
}
@@ -659,10 +648,8 @@ public static void assertEquals(JSONArray expected, JSONArray actual, boolean st
* @param expected Expected JSONArray
* @param actual JSONArray to compare
* @param strict Enables strict checking
- * @throws JSONException JSON parsing error
*/
- public static void assertEquals(String message, JSONArray expected, JSONArray actual, boolean strict)
- throws JSONException {
+ public static void assertEquals(String message, JSONArray expected, JSONArray actual, boolean strict) {
assertEquals(message, expected, actual, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
}
@@ -673,10 +660,8 @@ public static void assertEquals(String message, JSONArray expected, JSONArray ac
* @param expected Expected JSONArray
* @param actual JSONArray to compare
* @param strict Enables strict checking
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(JSONArray expected, JSONArray actual, boolean strict)
- throws JSONException {
+ public static void assertNotEquals(JSONArray expected, JSONArray actual, boolean strict) {
assertNotEquals(expected, actual, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
}
@@ -688,10 +673,8 @@ public static void assertNotEquals(JSONArray expected, JSONArray actual, boolean
* @param expected Expected JSONArray
* @param actual JSONArray to compare
* @param strict Enables strict checking
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(String message, JSONArray expected, JSONArray actual, boolean strict)
- throws JSONException {
+ public static void assertNotEquals(String message, JSONArray expected, JSONArray actual, boolean strict) {
assertNotEquals(message, expected, actual, strict ? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
}
@@ -702,10 +685,8 @@ public static void assertNotEquals(String message, JSONArray expected, JSONArray
* @param expected Expected JSONArray
* @param actual JSONArray to compare
* @param compareMode Specifies which comparison mode to use
- * @throws JSONException JSON parsing error
*/
- public static void assertEquals(JSONArray expected, JSONArray actual, JSONCompareMode compareMode)
- throws JSONException {
+ public static void assertEquals(JSONArray expected, JSONArray actual, JSONCompareMode compareMode) {
assertEquals("", expected, actual, compareMode);
}
@@ -717,10 +698,8 @@ public static void assertEquals(JSONArray expected, JSONArray actual, JSONCompar
* @param expected Expected JSONArray
* @param actual JSONArray to compare
* @param compareMode Specifies which comparison mode to use
- * @throws JSONException JSON parsing error
*/
- public static void assertEquals(String message, JSONArray expected, JSONArray actual, JSONCompareMode compareMode)
- throws JSONException {
+ public static void assertEquals(String message, JSONArray expected, JSONArray actual, JSONCompareMode compareMode) {
JSONCompareResult result = JSONCompare.compareJSON(expected, actual, compareMode);
if (result.failed()) {
throw new AssertionError(getCombinedMessage(message, result.getMessage()));
@@ -734,10 +713,8 @@ public static void assertEquals(String message, JSONArray expected, JSONArray ac
* @param expected Expected JSONArray
* @param actual JSONArray to compare
* @param compareMode Specifies which comparison mode to use
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(JSONArray expected, JSONArray actual, JSONCompareMode compareMode)
- throws JSONException {
+ public static void assertNotEquals(JSONArray expected, JSONArray actual, JSONCompareMode compareMode) {
assertNotEquals("", expected, actual, compareMode);
}
@@ -749,10 +726,9 @@ public static void assertNotEquals(JSONArray expected, JSONArray actual, JSONCom
* @param expected Expected JSONArray
* @param actual JSONArray to compare
* @param compareMode Specifies which comparison mode to use
- * @throws JSONException JSON parsing error
*/
- public static void assertNotEquals(String message, JSONArray expected, JSONArray actual, JSONCompareMode compareMode)
- throws JSONException {
+ public static void assertNotEquals(String message, JSONArray expected, JSONArray actual,
+ JSONCompareMode compareMode) {
JSONCompareResult result = JSONCompare.compareJSON(expected, actual, compareMode);
if (result.passed()) {
throw new AssertionError(getCombinedMessage(message, result.getMessage()));
diff --git a/src/main/java/org/skyscreamer/jsonassert/JSONCompare.java b/src/main/java/org/skyscreamer/jsonassert/JSONCompare.java
index b963be9f..c17115df 100644
--- a/src/main/java/org/skyscreamer/jsonassert/JSONCompare.java
+++ b/src/main/java/org/skyscreamer/jsonassert/JSONCompare.java
@@ -15,7 +15,6 @@
package org.skyscreamer.jsonassert;
import org.json.JSONArray;
-import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONString;
import org.skyscreamer.jsonassert.comparator.DefaultComparator;
@@ -41,11 +40,9 @@ private static JSONComparator getComparatorForMode(JSONCompareMode mode) {
* @param actualStr JSON string to compare
* @param comparator Comparator to use
* @return result of the comparison
- * @throws JSONException JSON parsing error
* @throws IllegalArgumentException when type of expectedStr doesn't match the type of actualStr
*/
- public static JSONCompareResult compareJSON(String expectedStr, String actualStr, JSONComparator comparator)
- throws JSONException {
+ public static JSONCompareResult compareJSON(String expectedStr, String actualStr, JSONComparator comparator) {
Object expected = JSONParser.parseJSON(expectedStr);
Object actual = JSONParser.parseJSON(actualStr);
if ((expected instanceof JSONObject) && (actual instanceof JSONObject)) {
@@ -72,10 +69,8 @@ else if (expected instanceof JSONObject) {
* @param actual actual json object
* @param comparator comparator to use
* @return result of the comparison
- * @throws JSONException JSON parsing error
*/
- public static JSONCompareResult compareJSON(JSONObject expected, JSONObject actual, JSONComparator comparator)
- throws JSONException {
+ public static JSONCompareResult compareJSON(JSONObject expected, JSONObject actual, JSONComparator comparator) {
return comparator.compareJSON(expected, actual);
}
@@ -86,10 +81,8 @@ public static JSONCompareResult compareJSON(JSONObject expected, JSONObject actu
* @param actual actual json array
* @param comparator comparator to use
* @return result of the comparison
- * @throws JSONException JSON parsing error
*/
- public static JSONCompareResult compareJSON(JSONArray expected, JSONArray actual, JSONComparator comparator)
- throws JSONException {
+ public static JSONCompareResult compareJSON(JSONArray expected, JSONArray actual, JSONComparator comparator) {
return comparator.compareJSON(expected, actual);
}
@@ -118,10 +111,8 @@ public static JSONCompareResult compareJson(final JSONString expected, final JSO
* @param actualStr JSON string to compare
* @param mode Defines comparison behavior
* @return result of the comparison
- * @throws JSONException JSON parsing error
*/
- public static JSONCompareResult compareJSON(String expectedStr, String actualStr, JSONCompareMode mode)
- throws JSONException {
+ public static JSONCompareResult compareJSON(String expectedStr, String actualStr, JSONCompareMode mode) {
return compareJSON(expectedStr, actualStr, getComparatorForMode(mode));
}
@@ -132,10 +123,8 @@ public static JSONCompareResult compareJSON(String expectedStr, String actualStr
* @param actual JSONObject to compare
* @param mode Defines comparison behavior
* @return result of the comparison
- * @throws JSONException JSON parsing error
*/
- public static JSONCompareResult compareJSON(JSONObject expected, JSONObject actual, JSONCompareMode mode)
- throws JSONException {
+ public static JSONCompareResult compareJSON(JSONObject expected, JSONObject actual, JSONCompareMode mode) {
return compareJSON(expected, actual, getComparatorForMode(mode));
}
@@ -147,10 +136,8 @@ public static JSONCompareResult compareJSON(JSONObject expected, JSONObject actu
* @param actual JSONArray to compare
* @param mode Defines comparison behavior
* @return result of the comparison
- * @throws JSONException JSON parsing error
*/
- public static JSONCompareResult compareJSON(JSONArray expected, JSONArray actual, JSONCompareMode mode)
- throws JSONException {
+ public static JSONCompareResult compareJSON(JSONArray expected, JSONArray actual, JSONCompareMode mode) {
return compareJSON(expected, actual, getComparatorForMode(mode));
}
diff --git a/src/main/java/org/skyscreamer/jsonassert/JSONCompareMode.java b/src/main/java/org/skyscreamer/jsonassert/JSONCompareMode.java
index d676be45..8185b065 100644
--- a/src/main/java/org/skyscreamer/jsonassert/JSONCompareMode.java
+++ b/src/main/java/org/skyscreamer/jsonassert/JSONCompareMode.java
@@ -18,7 +18,10 @@
*
These different modes define different behavior for the comparison of JSON for testing.
* Each mode encapsulates two underlying behaviors: extensibility and strict ordering.
*
- *
+ *
+ *
+ * Behavior of JSONCompareMode
+ *
*
Extensible
Strict Ordering
*
STRICT
no
yes
*
LENIENT
yes
no
diff --git a/src/main/java/org/skyscreamer/jsonassert/JSONCompareResult.java b/src/main/java/org/skyscreamer/jsonassert/JSONCompareResult.java
index 28406fbe..55672099 100644
--- a/src/main/java/org/skyscreamer/jsonassert/JSONCompareResult.java
+++ b/src/main/java/org/skyscreamer/jsonassert/JSONCompareResult.java
@@ -245,7 +245,7 @@ private static String describe(Object value) {
} else if (value instanceof JSONObject) {
return "a JSON object";
} else {
- return value.toString();
+ return String.valueOf(value);
}
}
diff --git a/src/main/java/org/skyscreamer/jsonassert/JSONParser.java b/src/main/java/org/skyscreamer/jsonassert/JSONParser.java
index 882d25da..a70af96c 100644
--- a/src/main/java/org/skyscreamer/jsonassert/JSONParser.java
+++ b/src/main/java/org/skyscreamer/jsonassert/JSONParser.java
@@ -36,9 +36,8 @@ private JSONParser() {}
*
* @param s Raw JSON string to be parsed
* @return JSONObject or JSONArray
- * @throws JSONException JSON parsing error
*/
- public static Object parseJSON(final String s) throws JSONException {
+ public static Object parseJSON(final String s) {
if (s.trim().startsWith("{")) {
return new JSONObject(s);
}
diff --git a/src/main/java/org/skyscreamer/jsonassert/LocationAwareValueMatcher.java b/src/main/java/org/skyscreamer/jsonassert/LocationAwareValueMatcher.java
index 32891b62..cc2b7449 100644
--- a/src/main/java/org/skyscreamer/jsonassert/LocationAwareValueMatcher.java
+++ b/src/main/java/org/skyscreamer/jsonassert/LocationAwareValueMatcher.java
@@ -21,7 +21,7 @@
* A ValueMatcher extension that provides location in form of prefix to the equals method.
*
* @author Duncan Mackinder
- *
+ * @param Generic Type
*/
public interface LocationAwareValueMatcher extends ValueMatcher {
diff --git a/src/main/java/org/skyscreamer/jsonassert/RegularExpressionValueMatcher.java b/src/main/java/org/skyscreamer/jsonassert/RegularExpressionValueMatcher.java
index 2a9efa54..19a4ef1d 100644
--- a/src/main/java/org/skyscreamer/jsonassert/RegularExpressionValueMatcher.java
+++ b/src/main/java/org/skyscreamer/jsonassert/RegularExpressionValueMatcher.java
@@ -28,7 +28,7 @@
* specify regular expression pattern that actual value must match.
*
* @author Duncan Mackinder
- *
+ * @param Generic Type
*/
public class RegularExpressionValueMatcher implements ValueMatcher {
diff --git a/src/main/java/org/skyscreamer/jsonassert/comparator/AbstractComparator.java b/src/main/java/org/skyscreamer/jsonassert/comparator/AbstractComparator.java
index 41b0ea0f..190e47ea 100644
--- a/src/main/java/org/skyscreamer/jsonassert/comparator/AbstractComparator.java
+++ b/src/main/java/org/skyscreamer/jsonassert/comparator/AbstractComparator.java
@@ -15,7 +15,6 @@
package org.skyscreamer.jsonassert.comparator;
import org.json.JSONArray;
-import org.json.JSONException;
import org.json.JSONObject;
import org.skyscreamer.jsonassert.JSONCompareResult;
@@ -26,18 +25,25 @@
/**
* This class provides a skeletal implementation of the {@link JSONComparator}
* interface, to minimize the effort required to implement this interface.
+ *
+ *
*/
public abstract class AbstractComparator implements JSONComparator {
+ /**
+ * Default constructor
+ */
+ public AbstractComparator() {
+ }
+
/**
* Compares JSONObject provided to the expected JSONObject, and returns the results of the comparison.
*
* @param expected Expected JSONObject
* @param actual JSONObject to compare
- * @throws JSONException JSON parsing error
*/
@Override
- public final JSONCompareResult compareJSON(JSONObject expected, JSONObject actual) throws JSONException {
+ public final JSONCompareResult compareJSON(JSONObject expected, JSONObject actual) {
JSONCompareResult result = new JSONCompareResult();
compareJSON("", expected, actual, result);
return result;
@@ -48,15 +54,20 @@ public final JSONCompareResult compareJSON(JSONObject expected, JSONObject actua
*
* @param expected Expected JSONArray
* @param actual JSONArray to compare
- * @throws JSONException JSON parsing error
*/
@Override
- public final JSONCompareResult compareJSON(JSONArray expected, JSONArray actual) throws JSONException {
+ public final JSONCompareResult compareJSON(JSONArray expected, JSONArray actual) {
JSONCompareResult result = new JSONCompareResult();
compareJSONArray("", expected, actual, result);
return result;
}
+ /**
+ * @param prefix
+ * @param expected
+ * @param actual
+ * @param result
+ */
protected void checkJsonObjectKeysActualInExpected(String prefix, JSONObject expected, JSONObject actual, JSONCompareResult result) {
Set actualKeys = getKeys(actual);
for (String key : actualKeys) {
@@ -66,7 +77,14 @@ protected void checkJsonObjectKeysActualInExpected(String prefix, JSONObject exp
}
}
- protected void checkJsonObjectKeysExpectedInActual(String prefix, JSONObject expected, JSONObject actual, JSONCompareResult result) throws JSONException {
+ /**
+ *
+ * @param prefix
+ * @param expected
+ * @param actual
+ * @param result
+ */
+ protected void checkJsonObjectKeysExpectedInActual(String prefix, JSONObject expected, JSONObject actual, JSONCompareResult result) {
Set expectedKeys = getKeys(expected);
for (String key : expectedKeys) {
Object expectedValue = expected.get(key);
@@ -79,7 +97,7 @@ protected void checkJsonObjectKeysExpectedInActual(String prefix, JSONObject exp
}
}
- protected void compareJSONArrayOfJsonObjects(String key, JSONArray expected, JSONArray actual, JSONCompareResult result) throws JSONException {
+ protected void compareJSONArrayOfJsonObjects(String key, JSONArray expected, JSONArray actual, JSONCompareResult result) {
String uniqueKey = findUniqueKey(expected);
if (uniqueKey == null || !isUsableAsUniqueKey(uniqueKey, actual)) {
// An expensive last resort
@@ -104,7 +122,7 @@ protected void compareJSONArrayOfJsonObjects(String key, JSONArray expected, JSO
}
}
- protected void compareJSONArrayOfSimpleValues(String key, JSONArray expected, JSONArray actual, JSONCompareResult result) throws JSONException {
+ protected void compareJSONArrayOfSimpleValues(String key, JSONArray expected, JSONArray actual, JSONCompareResult result) {
Map