From e57881f8fa9d81ccda83e17d2379f3597b0af213 Mon Sep 17 00:00:00 2001 From: run2000 Date: Mon, 25 Jul 2016 09:44:43 +1000 Subject: [PATCH] Fail when exceptions are not thrown as expected The idiom was started in the first few methods, but not continued further down where JSONException was expected. False success may have resulted. --- src/test/java/org/json/junit/JSONStringerTest.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/java/org/json/junit/JSONStringerTest.java b/src/test/java/org/json/junit/JSONStringerTest.java index d4376df..99cdd6f 100644 --- a/src/test/java/org/json/junit/JSONStringerTest.java +++ b/src/test/java/org/json/junit/JSONStringerTest.java @@ -60,6 +60,7 @@ public class JSONStringerTest { jsonStringer.object().endObject(); try { jsonStringer.array(); + assertTrue("Expected an exception", false); } catch (JSONException e) { assertTrue("Expected an exception message", "Misplaced array.". @@ -77,6 +78,7 @@ public class JSONStringerTest { jsonStringer.object(); try { jsonStringer.endArray(); + assertTrue("Expected an exception", false); } catch (JSONException e) { assertTrue("Expected an exception message", "Misplaced endArray.". @@ -94,6 +96,7 @@ public class JSONStringerTest { jsonStringer.array(); try { jsonStringer.endObject(); + assertTrue("Expected an exception", false); } catch (JSONException e) { assertTrue("Expected an exception message", "Misplaced endObject.". @@ -111,6 +114,7 @@ public class JSONStringerTest { jsonStringer.object().endObject(); try { jsonStringer.object(); + assertTrue("Expected an exception", false); } catch (JSONException e) { assertTrue("Expected an exception message", "Misplaced object.".