2626import java .util .Set ;
2727
2828import org .apache .commons .jxpath .ri .model .NodePointer ;
29+ import org .junit .jupiter .api .BeforeEach ;
2930
30- import junit .framework .TestCase ;
31+ import static org .junit .jupiter .api .Assertions .assertEquals ;
32+ import static org .junit .jupiter .api .Assertions .assertTrue ;
3133
3234/**
3335 * Abstract superclass for various JXPath tests.
3436 */
35- public abstract class AbstractJXPathTest extends TestCase {
37+ public abstract class AbstractJXPathTest {
3638
3739 /**
3840 * Constructs a new instance of this test case.
41+ *
42+ * @throws Exception In case of errors during setup
3943 */
40- public AbstractJXPathTest () {
44+ @ BeforeEach
45+ protected void setUp () throws Exception
46+ {
4147 Locale .setDefault (Locale .US );
4248 }
4349
@@ -46,15 +52,15 @@ protected void assertXPathValue(final JXPathContext ctx,
4652 {
4753 ctx .setLenient (false );
4854 final Object actual = ctx .getValue (xpath );
49- assertEquals ("Evaluating <" + xpath + ">" , expected , actual );
55+ assertEquals (expected , actual , "Evaluating <" + xpath + ">" );
5056 }
5157
5258 protected void assertXPathValue (final JXPathContext ctx ,
5359 final String xpath , final Object expected , final Class resultType )
5460 {
5561 ctx .setLenient (false );
5662 final Object actual = ctx .getValue (xpath , resultType );
57- assertEquals ("Evaluating <" + xpath + ">" , expected , actual );
63+ assertEquals (expected , actual , "Evaluating <" + xpath + ">" );
5864 }
5965
6066 protected void assertXPathValueLenient (final JXPathContext ctx ,
@@ -63,7 +69,7 @@ protected void assertXPathValueLenient(final JXPathContext ctx,
6369 ctx .setLenient (true );
6470 final Object actual = ctx .getValue (xpath );
6571 ctx .setLenient (false );
66- assertEquals ("Evaluating lenient <" + xpath + ">" , expected , actual );
72+ assertEquals (expected , actual , "Evaluating lenient <" + xpath + ">" );
6773 }
6874
6975 protected void assertXPathSetValue (final JXPathContext ctx ,
@@ -77,37 +83,37 @@ protected void assertXPathSetValue(final JXPathContext ctx,
7783 {
7884 ctx .setValue (xpath , value );
7985 final Object actual = ctx .getValue (xpath );
80- assertEquals ("Modifying <" + xpath + ">" , expected , actual );
86+ assertEquals (expected , actual , "Modifying <" + xpath + ">" );
8187 }
8288
8389 protected void assertXPathCreatePath (final JXPathContext ctx ,
8490 final String xpath ,
8591 final Object expectedValue , final String expectedPath )
8692 {
8793 final Pointer pointer = ctx .createPath (xpath );
88- assertEquals ("Creating path <" + xpath + ">" ,
89- expectedPath , pointer . asPath () );
94+ assertEquals (expectedPath , pointer . asPath () ,
95+ "Creating path <" + xpath + ">" );
9096
91- assertEquals ("Creating path ( pointer value) <" + xpath + ">" ,
92- expectedValue , pointer . getValue () );
97+ assertEquals (expectedValue , pointer . getValue () ,
98+ "Creating path (pointer value) <" + xpath + ">" );
9399
94- assertEquals ("Creating path (context value) <" + xpath + ">" ,
95- expectedValue , ctx . getValue ( pointer . asPath ()) );
100+ assertEquals (expectedValue , ctx . getValue ( pointer . asPath ()) ,
101+ "Creating path (context value) <" + xpath + ">" );
96102 }
97103
98104 protected void assertXPathCreatePathAndSetValue (final JXPathContext ctx ,
99105 final String xpath , final Object value ,
100106 final String expectedPath )
101107 {
102108 final Pointer pointer = ctx .createPathAndSetValue (xpath , value );
103- assertEquals ("Creating path <" + xpath + ">" ,
104- expectedPath , pointer . asPath () );
109+ assertEquals (expectedPath , pointer . asPath () ,
110+ "Creating path <" + xpath + ">" );
105111
106- assertEquals ("Creating path ( pointer value) <" + xpath + ">" ,
107- value , pointer . getValue () );
112+ assertEquals (value , pointer . getValue () ,
113+ "Creating path (pointer value) <" + xpath + ">" );
108114
109- assertEquals ("Creating path (context value) <" + xpath + ">" ,
110- value , ctx . getValue ( pointer . asPath ()) );
115+ assertEquals (value , ctx . getValue ( pointer . asPath ()) ,
116+ "Creating path (context value) <" + xpath + ">" );
111117 }
112118
113119 protected void assertXPathPointer (final JXPathContext ctx ,
@@ -116,7 +122,7 @@ protected void assertXPathPointer(final JXPathContext ctx,
116122 ctx .setLenient (false );
117123 final Pointer pointer = ctx .getPointer (xpath );
118124 final String actual = pointer .toString ();
119- assertEquals ("Evaluating pointer <" + xpath + ">" , expected , actual );
125+ assertEquals (expected , actual , "Evaluating pointer <" + xpath + ">" );
120126 }
121127
122128 protected void assertXPathPointerLenient (final JXPathContext ctx ,
@@ -125,7 +131,7 @@ protected void assertXPathPointerLenient(final JXPathContext ctx,
125131 ctx .setLenient (true );
126132 final Pointer pointer = ctx .getPointer (xpath );
127133 final String actual = pointer .toString ();
128- assertEquals ("Evaluating pointer <" + xpath + ">" , expected , actual );
134+ assertEquals (expected , actual , "Evaluating pointer <" + xpath + ">" );
129135 }
130136
131137 protected void assertXPathValueAndPointer (final JXPathContext ctx ,
@@ -148,10 +154,12 @@ protected <E> void assertXPathValueIterator(final JXPathContext ctx,
148154 while (it .hasNext ()) {
149155 actual .add (it .next ());
150156 }
151- assertEquals (String .format ("[hashCode()] Evaluating value iterator <%s>, expected.class %s(%,d): %s, actual.class %s(%,d): %s" , xpath ,
152- expected .getClass (), expected .size (), expected , actual .getClass (), actual .size (), actual ), expected .hashCode (), actual .hashCode ());
153- assertEquals (String .format ("[equals()] Evaluating value iterator <%s>, expected.class %s(%,d): %s, actual.class %s(%,d): %s" , xpath ,
154- expected .getClass (), expected .size (), expected , actual .getClass (), actual .size (), actual ), expected , actual );
157+ assertEquals (expected .hashCode (), actual .hashCode (),
158+ String .format ("[hashCode()] Evaluating value iterator <%s>, expected.class %s(%,d): %s, actual.class %s(%,d): %s" , xpath ,
159+ expected .getClass (), expected .size (), expected , actual .getClass (), actual .size (), actual ));
160+ assertEquals (expected , actual ,
161+ String .format ("[equals()] Evaluating value iterator <%s>, expected.class %s(%,d): %s, actual.class %s(%,d): %s" , xpath ,
162+ expected .getClass (), expected .size (), expected , actual .getClass (), actual .size (), actual ));
155163 }
156164
157165 protected void assertXPathPointerIterator (
@@ -172,9 +180,9 @@ protected void assertXPathPointerIterator(
172180 actual .add (pointer .toString ());
173181 }
174182 assertEquals (
175- "Evaluating pointer iterator <" + xpath + ">" ,
176183 expected ,
177- actual );
184+ actual ,
185+ "Evaluating pointer iterator <" + xpath + ">" );
178186 }
179187
180188 protected void assertDocumentOrder (
@@ -193,9 +201,9 @@ else if (res > 0) {
193201 res = 1 ;
194202 }
195203 assertEquals (
196- "Comparing paths '" + path1 + "' and '" + path2 + "'" ,
197204 expected ,
198- res );
205+ res ,
206+ "Comparing paths '" + path1 + "' and '" + path2 + "'" );
199207 }
200208
201209 protected void assertXPathValueType (
@@ -205,8 +213,7 @@ protected void assertXPathValueType(
205213 {
206214 ctx .setLenient (false );
207215 final Object actual = ctx .getValue (xpath );
208- assertTrue ("Evaluating <" + xpath + "> = " + actual .getClass (),
209- clazz .isAssignableFrom (actual .getClass ()));
216+ assertTrue (clazz .isAssignableFrom (actual .getClass ()), "Evaluating <" + xpath + "> = " + actual .getClass ());
210217 }
211218
212219 protected void assertXPathNodeType (
@@ -216,8 +223,8 @@ protected void assertXPathNodeType(
216223 {
217224 ctx .setLenient (false );
218225 final Pointer actual = ctx .getPointer (xpath );
219- assertTrue ("Evaluating <" + xpath + "> = " + actual .getNode ().getClass (),
220- clazz . isAssignableFrom ( actual .getNode ().getClass () ));
226+ assertTrue (clazz . isAssignableFrom ( actual .getNode ().getClass () ),
227+ "Evaluating <" + xpath + "> = " + actual .getNode ().getClass ());
221228 }
222229
223230 protected static List list () {
0 commit comments