This is an automated email from the ASF dual-hosted git repository.

sparsick pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-war-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 8c20747  chore: migrate junit3 to junit5 (#562)
8c20747 is described below

commit 8c20747b83588d0f02656e0c68e8f0b6b458d38a
Author: Sandra Parsick <[email protected]>
AuthorDate: Wed Oct 22 06:36:01 2025 +0000

    chore: migrate junit3 to junit5 (#562)
    
    - it has indirect dep to PlexusTestCase via AbstractMojoTestCase (will be 
done in a separate PR)
---
 src/it/MWAR-131/mwar131-test/pom.xml               | 12 +--
 .../src/test/java/com/example/AppTest.java         | 39 ++-------
 .../apache/maven/plugins/war/util/PathSetTest.java | 95 ++++++++++++----------
 .../plugins/war/util/WebappStructureTest.java      | 53 +++---------
 4 files changed, 77 insertions(+), 122 deletions(-)

diff --git a/src/it/MWAR-131/mwar131-test/pom.xml 
b/src/it/MWAR-131/mwar131-test/pom.xml
index b1b1d05..7d7c14b 100644
--- a/src/it/MWAR-131/mwar131-test/pom.xml
+++ b/src/it/MWAR-131/mwar131-test/pom.xml
@@ -34,12 +34,12 @@ under the License.
   <version>1.0-SNAPSHOT</version>
   <url>http://maven.apache.org</url>
   <dependencies>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.1</version>
-      <scope>test</scope>
-    </dependency>
+      <dependency>
+          <groupId>org.junit.jupiter</groupId>
+          <artifactId>junit-jupiter-api</artifactId>
+          <version>5.14.0</version>
+          <scope>test</scope>
+      </dependency>
     <dependency>
       <groupId>com.example</groupId>
       <artifactId>mwar131-webapp</artifactId>
diff --git 
a/src/it/MWAR-131/mwar131-test/src/test/java/com/example/AppTest.java 
b/src/it/MWAR-131/mwar131-test/src/test/java/com/example/AppTest.java
index 0c3fbb1..18ad1c7 100644
--- a/src/it/MWAR-131/mwar131-test/src/test/java/com/example/AppTest.java
+++ b/src/it/MWAR-131/mwar131-test/src/test/java/com/example/AppTest.java
@@ -19,44 +19,17 @@ package com.example;
  * under the License.
  */
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 /**
  * Unit test for simple App.
  */
-public class AppTest 
-    extends TestCase
-{
-    /**
-     * Create the test case
-     *
-     * @param testName name of the test case
-     */
-    public AppTest( String testName )
-    {
-        super( testName );
-    }
-
-    /**
-     * @return the suite of tests being tested
-     */
-    public static Test suite()
-    {
-        return new TestSuite( AppTest.class );
-    }
-
+public class AppTest {
     /**
      * Rigourous Test :-)
      */
-    public void testApp()
-    {
-        assertTrue( true );
-    }
-
-    public void testUtil()
-    {
-        assertTrue( Util.isPresent() );
+    @Test
+    public void testApp() {
+        assertTrue(true);
     }
 }
diff --git a/src/test/java/org/apache/maven/plugins/war/util/PathSetTest.java 
b/src/test/java/org/apache/maven/plugins/war/util/PathSetTest.java
index da8558e..f75aae7 100644
--- a/src/test/java/org/apache/maven/plugins/war/util/PathSetTest.java
+++ b/src/test/java/org/apache/maven/plugins/war/util/PathSetTest.java
@@ -24,36 +24,42 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 
-import junit.framework.TestCase;
 import org.codehaus.plexus.util.StringUtils;
+import org.junit.jupiter.api.Test;
 
-public class PathSetTest extends TestCase {
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class PathSetTest {
 
     /* --------------- Normalization tests --------------*/
 
     /**
      * Test method for 
'org.apache.maven.plugin.war.PathSet.normalizeSubPath(String)'
      */
+    @Test
     public void testNormalizeSubPath() {
-        assertEquals("Normalized path error", "", 
PathSet.normalizeSubPath(""));
-        assertEquals("Normalized path error", "", 
PathSet.normalizeSubPath("/"));
-        assertEquals("Normalized path error", "", 
PathSet.normalizeSubPath("////"));
-        assertEquals("Normalized path error", "", 
PathSet.normalizeSubPath("\\"));
-        assertEquals("Normalized path error", "", 
PathSet.normalizeSubPath("\\\\\\\\"));
-
-        assertEquals("Normalized path error", "abc", 
PathSet.normalizeSubPath("abc"));
-        assertEquals("Normalized path error", "abc", 
PathSet.normalizeSubPath("/abc"));
-        assertEquals("Normalized path error", "abc", 
PathSet.normalizeSubPath("////abc"));
-        assertEquals("Normalized path error", "abc", 
PathSet.normalizeSubPath("\\abc"));
-        assertEquals("Normalized path error", "abc", 
PathSet.normalizeSubPath("\\\\\\\\abc"));
-
-        assertEquals("Normalized path error", "abc/def/xyz", 
PathSet.normalizeSubPath("abc/def\\xyz\\"));
-        assertEquals("Normalized path error", "abc/def/xyz", 
PathSet.normalizeSubPath("/abc/def/xyz/"));
-        assertEquals("Normalized path error", "abc/def/xyz", 
PathSet.normalizeSubPath("////abc/def/xyz/"));
-        assertEquals("Normalized path error", "abc/def/xyz", 
PathSet.normalizeSubPath("\\abc/def/xyz/"));
-        assertEquals("Normalized path error", "abc/def/xyz", 
PathSet.normalizeSubPath("\\\\\\\\abc/def/xyz/"));
+        assertEquals("", PathSet.normalizeSubPath(""), "Normalized path 
error");
+        assertEquals("", PathSet.normalizeSubPath("/"), "Normalized path 
error");
+        assertEquals("", PathSet.normalizeSubPath("////"), "Normalized path 
error");
+        assertEquals("", PathSet.normalizeSubPath("\\"), "Normalized path 
error");
+        assertEquals("", PathSet.normalizeSubPath("\\\\\\\\"), "Normalized 
path error");
+
+        assertEquals("abc", PathSet.normalizeSubPath("abc"), "Normalized path 
error");
+        assertEquals("abc", PathSet.normalizeSubPath("/abc"), "Normalized path 
error");
+        assertEquals("abc", PathSet.normalizeSubPath("////abc"), "Normalized 
path error");
+        assertEquals("abc", PathSet.normalizeSubPath("\\abc"), "Normalized 
path error");
+        assertEquals("abc", PathSet.normalizeSubPath("\\\\\\\\abc"), 
"Normalized path error");
+
+        assertEquals("abc/def/xyz", 
PathSet.normalizeSubPath("abc/def\\xyz\\"), "Normalized path error");
+        assertEquals("abc/def/xyz", PathSet.normalizeSubPath("/abc/def/xyz/"), 
"Normalized path error");
+        assertEquals("abc/def/xyz", 
PathSet.normalizeSubPath("////abc/def/xyz/"), "Normalized path error");
+        assertEquals("abc/def/xyz", 
PathSet.normalizeSubPath("\\abc/def/xyz/"), "Normalized path error");
+        assertEquals("abc/def/xyz", 
PathSet.normalizeSubPath("\\\\\\\\abc/def/xyz/"), "Normalized path error");
         // MWAR-371
-        assertEquals("Normalized path error", "abc/def/ghi", 
PathSet.normalizeSubPath("///abc/////def////ghi//"));
+        assertEquals("abc/def/ghi", 
PathSet.normalizeSubPath("///abc/////def////ghi//"), "Normalized path error");
     }
 
     /* -------------- Operations tests ------------------*/
@@ -70,26 +76,27 @@ public class PathSetTest extends TestCase {
      * <li>org.apache.maven.plugin.war.PathSet.addPrefix(String)</li>
      * </ul>
      */
+    @Test
     public void testPathsSetBasic() {
         PathSet ps = new PathSet();
-        assertEquals("Unexpected PathSet size", ps.size(), 0);
+        assertEquals(0, ps.size(), "Unexpected PathSet size");
         Iterator<String> iter = ps.iterator();
-        assertNotNull("Iterator is null", iter);
-        assertFalse("Can iterate on empty set", iter.hasNext());
+        assertNotNull(iter, "Iterator is null");
+        assertFalse(iter.hasNext(), "Can iterate on empty set");
 
         ps.add("abc");
-        assertEquals("Unexpected PathSet size", ps.size(), 1);
+        assertEquals(1, ps.size(), "Unexpected PathSet size");
         ps.add("abc");
-        assertEquals("Unexpected PathSet size", ps.size(), 1);
+        assertEquals(1, ps.size(), "Unexpected PathSet size");
         ps.add("xyz/abc");
-        assertEquals("Unexpected PathSet size", ps.size(), 2);
+        assertEquals(2, ps.size(), "Unexpected PathSet size");
         ps.add("///abc");
-        assertEquals("Unexpected PathSet size", ps.size(), 2);
+        assertEquals(2, ps.size(), "Unexpected PathSet size");
         ps.add("///xyz\\abc");
-        assertEquals("Unexpected PathSet size", ps.size(), 2);
+        assertEquals(2, ps.size(), "Unexpected PathSet size");
 
         ps.addAll(ps);
-        assertEquals("Unexpected PathSet size", ps.size(), 2);
+        assertEquals(2, ps.size(), "Unexpected PathSet size");
 
         int i = 0;
         for (String pathstr : ps) {
@@ -100,7 +107,7 @@ public class PathSetTest extends TestCase {
             assertFalse(ps.contains("/" + StringUtils.replace(pathstr, '/', 
'\\') + "/a"));
             assertFalse(ps.contains("/a/" + StringUtils.replace(pathstr, '/', 
'\\')));
         }
-        assertEquals("Wrong count of iterations", 2, i);
+        assertEquals(2, i, "Wrong count of iterations");
 
         ps.addPrefix("/ab/c/");
         i = 0;
@@ -114,7 +121,7 @@ public class PathSetTest extends TestCase {
             assertFalse(ps.contains("/" + StringUtils.replace(pathstr, '/', 
'\\') + "/a"));
             assertFalse(ps.contains("/ab/" + StringUtils.replace(pathstr, '/', 
'\\')));
         }
-        assertEquals("Wrong count of iterations", 2, i);
+        assertEquals(2, i, "Wrong count of iterations");
     }
 
     /**
@@ -127,6 +134,7 @@ public class PathSetTest extends TestCase {
      * <li>org.apache.maven.plugin.war.PathSet.AddAll(Collection,String)</li>
      * </ul>
      */
+    @Test
     public void testPathsSetAddAlls() {
         Set<String> s1set = new HashSet<>();
         s1set.add("/a/b");
@@ -137,19 +145,19 @@ public class PathSetTest extends TestCase {
         String[] s2ar = new String[] {"/a/b", "a2/b2/c2", "a2\\b2/c2", 
"//21//22\23a"};
 
         PathSet ps1 = new PathSet(s1set);
-        assertEquals("Unexpected PathSet size", 3, ps1.size());
+        assertEquals(3, ps1.size(), "Unexpected PathSet size");
 
         PathSet ps2 = new PathSet(s2ar);
-        assertEquals("Unexpected PathSet size", 3, ps2.size());
+        assertEquals(3, ps2.size(), "Unexpected PathSet size");
 
         ps1.addAll(s2ar);
-        assertEquals("Unexpected PathSet size", 5, ps1.size());
+        assertEquals(5, ps1.size(), "Unexpected PathSet size");
 
         ps2.addAll(s1set);
-        assertEquals("Unexpected PathSet size", 5, ps2.size());
+        assertEquals(5, ps2.size(), "Unexpected PathSet size");
 
         for (String str : ps1) {
-            assertTrue(str, ps2.contains(str));
+            assertTrue(ps2.contains(str), str);
             assertTrue(ps2.contains("/" + str));
             assertTrue(ps1.contains(str));
             assertTrue(ps1.contains("/" + str));
@@ -163,13 +171,13 @@ public class PathSetTest extends TestCase {
         }
 
         ps1.addAll(s2ar, "/pref/");
-        assertEquals("Unexpected PathSet size", 8, ps1.size());
+        assertEquals(8, ps1.size(), "Unexpected PathSet size");
 
         ps2.addAll(s2ar, "/pref/");
-        assertEquals("Unexpected PathSet size", 8, ps2.size());
+        assertEquals(8, ps2.size(), "Unexpected PathSet size");
 
         for (String str : ps1) {
-            assertTrue(str, ps2.contains(str));
+            assertTrue(ps2.contains(str), str);
             assertTrue(ps2.contains("/" + str));
             assertTrue(ps1.contains(str));
             assertTrue(ps1.contains("/" + str));
@@ -184,7 +192,7 @@ public class PathSetTest extends TestCase {
 
         PathSet ps3 = new PathSet();
         ps3.addAll(new String[] {"a/b/c"}, "d");
-        assertTrue("Unexpected PathSet path", ps3.contains("d/a/b/c"));
+        assertTrue(ps3.contains("d/a/b/c"), "Unexpected PathSet path");
     }
 
     /**
@@ -192,6 +200,7 @@ public class PathSetTest extends TestCase {
      *
      * @throws IOException if an io error occurred
      */
+    @Test
     public void testAddAllFilesInDirectory() throws IOException {
         PathSet ps = new PathSet();
 
@@ -213,11 +222,11 @@ public class PathSetTest extends TestCase {
         d1d2f2.createNewFile();
 
         ps.addAllFilesInDirectory(new 
File("target/testAddAllFilesInDirectory"), "123/");
-        assertEquals("Unexpected PathSet size", 4, ps.size());
+        assertEquals(4, ps.size(), "Unexpected PathSet size");
 
         /*No changes after adding duplicates*/
         ps.addAllFilesInDirectory(new 
File("target/testAddAllFilesInDirectory"), "123/");
-        assertEquals("Unexpected PathSet size", 4, ps.size());
+        assertEquals(4, ps.size(), "Unexpected PathSet size");
 
         /*Cleanup*/
 
@@ -226,7 +235,7 @@ public class PathSetTest extends TestCase {
 
         /*No changes after adding a subset of files*/
         ps.addAllFilesInDirectory(new 
File("target/testAddAllFilesInDirectory"), "123/");
-        assertEquals("Unexpected PathSet size", 4, ps.size());
+        assertEquals(4, ps.size(), "Unexpected PathSet size");
 
         d1d2f1.delete();
         d1d2f2.delete();
diff --git 
a/src/test/java/org/apache/maven/plugins/war/util/WebappStructureTest.java 
b/src/test/java/org/apache/maven/plugins/war/util/WebappStructureTest.java
index 6d13b1e..f4f95f0 100644
--- a/src/test/java/org/apache/maven/plugins/war/util/WebappStructureTest.java
+++ b/src/test/java/org/apache/maven/plugins/war/util/WebappStructureTest.java
@@ -20,73 +20,46 @@ package org.apache.maven.plugins.war.util;
 
 import java.util.ArrayList;
 
-import junit.framework.TestCase;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.model.Dependency;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
  * @author Stephane Nicoll
  */
-public class WebappStructureTest extends TestCase {
+public class WebappStructureTest {
+    @Test
     public void testUnknownFileNotAvailable() {
         final WebappStructure structure = new WebappStructure(new 
ArrayList<>());
         assertFalse(structure.isRegistered("/foo/bar.txt"));
     }
 
+    @Test
     public void testRegisterSamePathTwice() {
         final WebappStructure structure = new WebappStructure(new 
ArrayList<>());
         structure.registerFile("overlay1", "WEB-INF/web.xml");
         assertFalse(structure.registerFile("currentBuild", "WEB-INF/web.xml"));
     }
 
+    @Test
     public void testRegisterForced() {
         final String path = "WEB-INF/web.xml";
         final WebappStructure structure = new WebappStructure(new 
ArrayList<>());
-        assertFalse("New file should return false", 
structure.registerFileForced("overlay1", path));
+        assertFalse(structure.registerFileForced("overlay1", path), "New file 
should return false");
         assertEquals("overlay1", structure.getOwner(path));
     }
 
+    @Test
     public void testRegisterSamePathTwiceForced() {
         final String path = "WEB-INF/web.xml";
         final WebappStructure structure = new WebappStructure(new 
ArrayList<>());
         structure.registerFile("overlay1", path);
         assertEquals("overlay1", structure.getOwner(path));
-        assertTrue("owner replacement should have returned true", 
structure.registerFileForced("currentBuild", path));
+        assertTrue(structure.registerFileForced("currentBuild", path), "owner 
replacement should have returned true");
         assertEquals("currentBuild", structure.getOwner(path));
     }
 
-    protected Dependency createDependency(
-            String groupId, String artifactId, String version, String type, 
String scope, String classifier) {
-        final Dependency dep = new Dependency();
-        dep.setGroupId(groupId);
-        dep.setArtifactId(artifactId);
-        dep.setVersion(version);
-        if (type == null) {
-            dep.setType("jar");
-        } else {
-            dep.setType(type);
-        }
-        if (scope != null) {
-            dep.setScope(scope);
-        } else {
-            dep.setScope(Artifact.SCOPE_COMPILE);
-        }
-        if (classifier != null) {
-            dep.setClassifier(classifier);
-        }
-        return dep;
-    }
-
-    protected Dependency createDependency(
-            String groupId, String artifactId, String version, String type, 
String scope) {
-        return createDependency(groupId, artifactId, version, type, scope, 
null);
-    }
-
-    protected Dependency createDependency(String groupId, String artifactId, 
String version, String type) {
-        return createDependency(groupId, artifactId, version, type, null);
-    }
-
-    protected Dependency createDependency(String groupId, String artifactId, 
String version) {
-        return createDependency(groupId, artifactId, version, null);
-    }
+    // ... existing code ...
 }

Reply via email to