Skip to content

Commit e57881f

Browse files
authored
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.
1 parent efe33a1 commit e57881f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/test/java/org/json/junit/JSONStringerTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public void missplacedArrayException() {
6060
jsonStringer.object().endObject();
6161
try {
6262
jsonStringer.array();
63+
assertTrue("Expected an exception", false);
6364
} catch (JSONException e) {
6465
assertTrue("Expected an exception message",
6566
"Misplaced array.".
@@ -77,6 +78,7 @@ public void missplacedEndArrayException() {
7778
jsonStringer.object();
7879
try {
7980
jsonStringer.endArray();
81+
assertTrue("Expected an exception", false);
8082
} catch (JSONException e) {
8183
assertTrue("Expected an exception message",
8284
"Misplaced endArray.".
@@ -94,6 +96,7 @@ public void missplacedEndObjectException() {
9496
jsonStringer.array();
9597
try {
9698
jsonStringer.endObject();
99+
assertTrue("Expected an exception", false);
97100
} catch (JSONException e) {
98101
assertTrue("Expected an exception message",
99102
"Misplaced endObject.".
@@ -111,6 +114,7 @@ public void missplacedObjectException() {
111114
jsonStringer.object().endObject();
112115
try {
113116
jsonStringer.object();
117+
assertTrue("Expected an exception", false);
114118
} catch (JSONException e) {
115119
assertTrue("Expected an exception message",
116120
"Misplaced object.".

0 commit comments

Comments
 (0)