2424import java .util .Iterator ;
2525import java .util .Set ;
2626
27- import junit .framework .TestCase ;
2827import org .codehaus .plexus .util .StringUtils ;
28+ import org .junit .jupiter .api .Test ;
2929
30- public class PathSetTest extends TestCase {
30+ import static org .junit .jupiter .api .Assertions .assertEquals ;
31+ import static org .junit .jupiter .api .Assertions .assertFalse ;
32+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
33+ import static org .junit .jupiter .api .Assertions .assertTrue ;
34+
35+ public class PathSetTest {
3136
3237 /* --------------- Normalization tests --------------*/
3338
3439 /**
3540 * Test method for 'org.apache.maven.plugin.war.PathSet.normalizeSubPath(String)'
3641 */
42+ @ Test
3743 public void testNormalizeSubPath () {
38- assertEquals ("Normalized path error " , "" , PathSet .normalizeSubPath ("" ));
39- assertEquals ("Normalized path error " , "" , PathSet .normalizeSubPath ("/" ));
40- assertEquals ("Normalized path error " , "" , PathSet .normalizeSubPath ("////" ));
41- assertEquals ("Normalized path error " , "" , PathSet .normalizeSubPath ("\\ " ));
42- assertEquals ("Normalized path error " , "" , PathSet .normalizeSubPath ("\\ \\ \\ \\ " ));
43-
44- assertEquals ("Normalized path error" , " abc" , PathSet .normalizeSubPath ("abc" ));
45- assertEquals ("Normalized path error" , " abc" , PathSet .normalizeSubPath ("/abc" ));
46- assertEquals ("Normalized path error" , " abc" , PathSet .normalizeSubPath ("////abc" ));
47- assertEquals ("Normalized path error" , " abc" , PathSet .normalizeSubPath ("\\ abc" ));
48- assertEquals ("Normalized path error" , " abc" , PathSet .normalizeSubPath ("\\ \\ \\ \\ abc" ));
49-
50- assertEquals ("Normalized path error" , " abc/def/xyz" , PathSet .normalizeSubPath ("abc/def\\ xyz\\ " ));
51- assertEquals ("Normalized path error" , " abc/def/xyz" , PathSet .normalizeSubPath ("/abc/def/xyz/" ));
52- assertEquals ("Normalized path error" , " abc/def/xyz" , PathSet .normalizeSubPath ("////abc/def/xyz/" ));
53- assertEquals ("Normalized path error" , " abc/def/xyz" , PathSet .normalizeSubPath ("\\ abc/def/xyz/" ));
54- assertEquals ("Normalized path error" , " abc/def/xyz" , PathSet .normalizeSubPath ("\\ \\ \\ \\ abc/def/xyz/" ));
44+ assertEquals ("" , PathSet .normalizeSubPath ("" ), "Normalized path error" );
45+ assertEquals ("" , PathSet .normalizeSubPath ("/" ), "Normalized path error" );
46+ assertEquals ("" , PathSet .normalizeSubPath ("////" ), "Normalized path error" );
47+ assertEquals ("" , PathSet .normalizeSubPath ("\\ " ), "Normalized path error" );
48+ assertEquals ("" , PathSet .normalizeSubPath ("\\ \\ \\ \\ " ), "Normalized path error" );
49+
50+ assertEquals ("abc" , PathSet .normalizeSubPath ("abc" ), "Normalized path error" );
51+ assertEquals ("abc" , PathSet .normalizeSubPath ("/abc" ), "Normalized path error" );
52+ assertEquals ("abc" , PathSet .normalizeSubPath ("////abc" ), "Normalized path error" );
53+ assertEquals ("abc" , PathSet .normalizeSubPath ("\\ abc" ), "Normalized path error" );
54+ assertEquals ("abc" , PathSet .normalizeSubPath ("\\ \\ \\ \\ abc" ), "Normalized path error" );
55+
56+ assertEquals ("abc/def/xyz" , PathSet .normalizeSubPath ("abc/def\\ xyz\\ " ), "Normalized path error" );
57+ assertEquals ("abc/def/xyz" , PathSet .normalizeSubPath ("/abc/def/xyz/" ), "Normalized path error" );
58+ assertEquals ("abc/def/xyz" , PathSet .normalizeSubPath ("////abc/def/xyz/" ), "Normalized path error" );
59+ assertEquals ("abc/def/xyz" , PathSet .normalizeSubPath ("\\ abc/def/xyz/" ), "Normalized path error" );
60+ assertEquals ("abc/def/xyz" , PathSet .normalizeSubPath ("\\ \\ \\ \\ abc/def/xyz/" ), "Normalized path error" );
5561 // MWAR-371
56- assertEquals ("Normalized path error" , " abc/def/ghi" , PathSet .normalizeSubPath ("///abc/////def////ghi//" ));
62+ assertEquals ("abc/def/ghi" , PathSet .normalizeSubPath ("///abc/////def////ghi//" ), "Normalized path error" );
5763 }
5864
5965 /* -------------- Operations tests ------------------*/
@@ -70,26 +76,27 @@ public void testNormalizeSubPath() {
7076 * <li>org.apache.maven.plugin.war.PathSet.addPrefix(String)</li>
7177 * </ul>
7278 */
79+ @ Test
7380 public void testPathsSetBasic () {
7481 PathSet ps = new PathSet ();
75- assertEquals ("Unexpected PathSet size" , ps .size (), 0 );
82+ assertEquals (0 , ps .size (), "Unexpected PathSet size" );
7683 Iterator <String > iter = ps .iterator ();
77- assertNotNull ("Iterator is null" , iter );
78- assertFalse ("Can iterate on empty set" , iter . hasNext () );
84+ assertNotNull (iter , "Iterator is null" );
85+ assertFalse (iter . hasNext (), "Can iterate on empty set" );
7986
8087 ps .add ("abc" );
81- assertEquals ("Unexpected PathSet size" , ps .size (), 1 );
88+ assertEquals (1 , ps .size (), "Unexpected PathSet size" );
8289 ps .add ("abc" );
83- assertEquals ("Unexpected PathSet size" , ps .size (), 1 );
90+ assertEquals (1 , ps .size (), "Unexpected PathSet size" );
8491 ps .add ("xyz/abc" );
85- assertEquals ("Unexpected PathSet size" , ps .size (), 2 );
92+ assertEquals (2 , ps .size (), "Unexpected PathSet size" );
8693 ps .add ("///abc" );
87- assertEquals ("Unexpected PathSet size" , ps .size (), 2 );
94+ assertEquals (2 , ps .size (), "Unexpected PathSet size" );
8895 ps .add ("///xyz\\ abc" );
89- assertEquals ("Unexpected PathSet size" , ps .size (), 2 );
96+ assertEquals (2 , ps .size (), "Unexpected PathSet size" );
9097
9198 ps .addAll (ps );
92- assertEquals ("Unexpected PathSet size" , ps .size (), 2 );
99+ assertEquals (2 , ps .size (), "Unexpected PathSet size" );
93100
94101 int i = 0 ;
95102 for (String pathstr : ps ) {
@@ -100,7 +107,7 @@ public void testPathsSetBasic() {
100107 assertFalse (ps .contains ("/" + StringUtils .replace (pathstr , '/' , '\\' ) + "/a" ));
101108 assertFalse (ps .contains ("/a/" + StringUtils .replace (pathstr , '/' , '\\' )));
102109 }
103- assertEquals ("Wrong count of iterations" , 2 , i );
110+ assertEquals (2 , i , "Wrong count of iterations" );
104111
105112 ps .addPrefix ("/ab/c/" );
106113 i = 0 ;
@@ -114,7 +121,7 @@ public void testPathsSetBasic() {
114121 assertFalse (ps .contains ("/" + StringUtils .replace (pathstr , '/' , '\\' ) + "/a" ));
115122 assertFalse (ps .contains ("/ab/" + StringUtils .replace (pathstr , '/' , '\\' )));
116123 }
117- assertEquals ("Wrong count of iterations" , 2 , i );
124+ assertEquals (2 , i , "Wrong count of iterations" );
118125 }
119126
120127 /**
@@ -127,6 +134,7 @@ public void testPathsSetBasic() {
127134 * <li>org.apache.maven.plugin.war.PathSet.AddAll(Collection,String)</li>
128135 * </ul>
129136 */
137+ @ Test
130138 public void testPathsSetAddAlls () {
131139 Set <String > s1set = new HashSet <>();
132140 s1set .add ("/a/b" );
@@ -137,19 +145,19 @@ public void testPathsSetAddAlls() {
137145 String [] s2ar = new String [] {"/a/b" , "a2/b2/c2" , "a2\\ b2/c2" , "//21//22\23 a" };
138146
139147 PathSet ps1 = new PathSet (s1set );
140- assertEquals ("Unexpected PathSet size" , 3 , ps1 .size ());
148+ assertEquals (3 , ps1 .size (), "Unexpected PathSet size" );
141149
142150 PathSet ps2 = new PathSet (s2ar );
143- assertEquals ("Unexpected PathSet size" , 3 , ps2 .size ());
151+ assertEquals (3 , ps2 .size (), "Unexpected PathSet size" );
144152
145153 ps1 .addAll (s2ar );
146- assertEquals ("Unexpected PathSet size" , 5 , ps1 .size ());
154+ assertEquals (5 , ps1 .size (), "Unexpected PathSet size" );
147155
148156 ps2 .addAll (s1set );
149- assertEquals ("Unexpected PathSet size" , 5 , ps2 .size ());
157+ assertEquals (5 , ps2 .size (), "Unexpected PathSet size" );
150158
151159 for (String str : ps1 ) {
152- assertTrue (str , ps2 .contains (str ));
160+ assertTrue (ps2 .contains (str ), str );
153161 assertTrue (ps2 .contains ("/" + str ));
154162 assertTrue (ps1 .contains (str ));
155163 assertTrue (ps1 .contains ("/" + str ));
@@ -163,13 +171,13 @@ public void testPathsSetAddAlls() {
163171 }
164172
165173 ps1 .addAll (s2ar , "/pref/" );
166- assertEquals ("Unexpected PathSet size" , 8 , ps1 .size ());
174+ assertEquals (8 , ps1 .size (), "Unexpected PathSet size" );
167175
168176 ps2 .addAll (s2ar , "/pref/" );
169- assertEquals ("Unexpected PathSet size" , 8 , ps2 .size ());
177+ assertEquals (8 , ps2 .size (), "Unexpected PathSet size" );
170178
171179 for (String str : ps1 ) {
172- assertTrue (str , ps2 .contains (str ));
180+ assertTrue (ps2 .contains (str ), str );
173181 assertTrue (ps2 .contains ("/" + str ));
174182 assertTrue (ps1 .contains (str ));
175183 assertTrue (ps1 .contains ("/" + str ));
@@ -184,14 +192,15 @@ public void testPathsSetAddAlls() {
184192
185193 PathSet ps3 = new PathSet ();
186194 ps3 .addAll (new String [] {"a/b/c" }, "d" );
187- assertTrue ("Unexpected PathSet path" , ps3 .contains ("d/a/b/c" ));
195+ assertTrue (ps3 .contains ("d/a/b/c" ), "Unexpected PathSet path" );
188196 }
189197
190198 /**
191199 * Test method for 'org.apache.maven.plugin.war.PathSet.addAllFilesInDirectory(File, String)'
192200 *
193201 * @throws IOException if an io error occurred
194202 */
203+ @ Test
195204 public void testAddAllFilesInDirectory () throws IOException {
196205 PathSet ps = new PathSet ();
197206
@@ -213,11 +222,11 @@ public void testAddAllFilesInDirectory() throws IOException {
213222 d1d2f2 .createNewFile ();
214223
215224 ps .addAllFilesInDirectory (new File ("target/testAddAllFilesInDirectory" ), "123/" );
216- assertEquals ("Unexpected PathSet size" , 4 , ps .size ());
225+ assertEquals (4 , ps .size (), "Unexpected PathSet size" );
217226
218227 /*No changes after adding duplicates*/
219228 ps .addAllFilesInDirectory (new File ("target/testAddAllFilesInDirectory" ), "123/" );
220- assertEquals ("Unexpected PathSet size" , 4 , ps .size ());
229+ assertEquals (4 , ps .size (), "Unexpected PathSet size" );
221230
222231 /*Cleanup*/
223232
@@ -226,7 +235,7 @@ public void testAddAllFilesInDirectory() throws IOException {
226235
227236 /*No changes after adding a subset of files*/
228237 ps .addAllFilesInDirectory (new File ("target/testAddAllFilesInDirectory" ), "123/" );
229- assertEquals ("Unexpected PathSet size" , 4 , ps .size ());
238+ assertEquals (4 , ps .size (), "Unexpected PathSet size" );
230239
231240 d1d2f1 .delete ();
232241 d1d2f2 .delete ();
0 commit comments