33import static org .junit .Assert .assertEquals ;
44import static org .junit .Assert .assertNotEquals ;
55import static org .junit .Assert .assertTrue ;
6+ import static org .junit .Assert .fail ;
67
78import org .json .JSONArray ;
89import org .json .JSONException ;
@@ -74,11 +75,11 @@ public void shouldHandleInvalidSlashInTag() {
7475 "</addresses>" ;
7576 try {
7677 XML .toJSONObject (xmlStr );
77- assertTrue ("Expecting a JSONException" , false );
78+ fail ("Expecting a JSONException" );
7879 } catch (JSONException e ) {
79- assertTrue ("Expecting an exception message" ,
80- "Misshaped tag at 176 [character 14 line 5]" .
81- equals ( e .getMessage () ));
80+ assertEquals ("Expecting an exception message" ,
81+ "Misshaped tag at 176 [character 14 line 4]" ,
82+ e .getMessage ());
8283 }
8384 }
8485
@@ -99,11 +100,11 @@ public void shouldHandleInvalidBangInTag() {
99100 "</addresses>" ;
100101 try {
101102 XML .toJSONObject (xmlStr );
102- assertTrue ("Expecting a JSONException" , false );
103+ fail ("Expecting a JSONException" );
103104 } catch (JSONException e ) {
104- assertTrue ("Expecting an exception message" ,
105- "Misshaped meta tag at 215 [character 13 line 8]" .
106- equals ( e .getMessage () ));
105+ assertEquals ("Expecting an exception message" ,
106+ "Misshaped meta tag at 215 [character 13 line 7]" ,
107+ e .getMessage ());
107108 }
108109 }
109110
@@ -124,11 +125,11 @@ public void shouldHandleInvalidBangNoCloseInTag() {
124125 "</addresses>" ;
125126 try {
126127 XML .toJSONObject (xmlStr );
127- assertTrue ("Expecting a JSONException" , false );
128+ fail ("Expecting a JSONException" );
128129 } catch (JSONException e ) {
129- assertTrue ("Expecting an exception message" ,
130- "Misshaped meta tag at 214 [character 13 line 8]" .
131- equals ( e .getMessage () ));
130+ assertEquals ("Expecting an exception message" ,
131+ "Misshaped meta tag at 214 [character 13 line 7]" ,
132+ e .getMessage ());
132133 }
133134 }
134135
@@ -149,11 +150,11 @@ public void shouldHandleNoCloseStartTag() {
149150 "</addresses>" ;
150151 try {
151152 XML .toJSONObject (xmlStr );
152- assertTrue ("Expecting a JSONException" , false );
153+ fail ("Expecting a JSONException" );
153154 } catch (JSONException e ) {
154- assertTrue ("Expecting an exception message" ,
155- "Misplaced '<' at 193 [character 4 line 7]" .
156- equals ( e .getMessage () ));
155+ assertEquals ("Expecting an exception message" ,
156+ "Misplaced '<' at 193 [character 4 line 6]" ,
157+ e .getMessage ());
157158 }
158159 }
159160
@@ -174,11 +175,11 @@ public void shouldHandleInvalidCDATABangInTag() {
174175 "</addresses>" ;
175176 try {
176177 XML .toJSONObject (xmlStr );
177- assertTrue ("Expecting a JSONException" , false );
178+ fail ("Expecting a JSONException" );
178179 } catch (JSONException e ) {
179- assertTrue ("Expecting an exception message" ,
180- "Expected 'CDATA[' at 204 [character 11 line 6]" .
181- equals ( e .getMessage () ));
180+ assertEquals ("Expecting an exception message" ,
181+ "Expected 'CDATA[' at 204 [character 11 line 5]" ,
182+ e .getMessage ());
182183 }
183184 }
184185
@@ -397,9 +398,9 @@ public void shouldHandleEmptyArray(){
397398
398399 final String expected = "<jo></jo>" ;
399400 String output1 = XML .toString (jo1 ,"jo" );
400- assertTrue ("Expected an empty root tag" , expected . equals ( output1 ) );
401+ assertEquals ("Expected an empty root tag" , expected , output1 );
401402 String output2 = XML .toString (jo2 ,"jo" );
402- assertTrue ("Expected an empty root tag" , expected . equals ( output2 ) );
403+ assertEquals ("Expected an empty root tag" , expected , output2 );
403404 }
404405
405406 /**
@@ -414,9 +415,9 @@ public void shouldHandleEmptyMultiArray(){
414415
415416 final String expected = "<jo><arr>One</arr><arr></arr><arr>Four</arr></jo>" ;
416417 String output1 = XML .toString (jo1 ,"jo" );
417- assertTrue ("Expected a matching array" , expected . equals ( output1 ) );
418+ assertEquals ("Expected a matching array" , expected , output1 );
418419 String output2 = XML .toString (jo2 ,"jo" );
419- assertTrue ("Expected a matching array" , expected . equals ( output2 ) );
420+ assertEquals ("Expected a matching array" , expected , output2 );
420421 }
421422
422423 /**
@@ -431,9 +432,9 @@ public void shouldHandleNonEmptyArray(){
431432
432433 final String expected = "<jo><arr>One</arr><arr>Two</arr><arr>Three</arr></jo>" ;
433434 String output1 = XML .toString (jo1 ,"jo" );
434- assertTrue ("Expected a non empty root tag" , expected . equals ( output1 ) );
435+ assertEquals ("Expected a non empty root tag" , expected , output1 );
435436 String output2 = XML .toString (jo2 ,"jo" );
436- assertTrue ("Expected a non empty root tag" , expected . equals ( output2 ) );
437+ assertEquals ("Expected a non empty root tag" , expected , output2 );
437438 }
438439
439440 /**
@@ -448,9 +449,9 @@ public void shouldHandleMultiArray(){
448449
449450 final String expected = "<jo><arr>One</arr><arr><array>Two</array><array>Three</array></arr><arr>Four</arr></jo>" ;
450451 String output1 = XML .toString (jo1 ,"jo" );
451- assertTrue ("Expected a matching array" , expected . equals ( output1 ) );
452+ assertEquals ("Expected a matching array" , expected , output1 );
452453 String output2 = XML .toString (jo2 ,"jo" );
453- assertTrue ("Expected a matching array" , expected . equals ( output2 ) );
454+ assertEquals ("Expected a matching array" , expected , output2 );
454455 }
455456
456457 /**
0 commit comments