diff --git a/src/it/MWAR-131/mwar131-test/pom.xml b/src/it/MWAR-131/mwar131-test/pom.xml
index b1b1d055..7d7c14b4 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.
1.0-SNAPSHOT
http://maven.apache.org
-
- junit
- junit
- 3.8.1
- test
-
+
+ org.junit.jupiter
+ junit-jupiter-api
+ 5.14.0
+ test
+
com.example
mwar131-webapp
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 0c3fbb1c..18ad1c76 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 @@
* 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 da8558e2..f75aae7e 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.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 void testNormalizeSubPath() {
* org.apache.maven.plugin.war.PathSet.addPrefix(String)
*
*/
+ @Test
public void testPathsSetBasic() {
PathSet ps = new PathSet();
- assertEquals("Unexpected PathSet size", ps.size(), 0);
+ assertEquals(0, ps.size(), "Unexpected PathSet size");
Iterator 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 void testPathsSetBasic() {
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 void testPathsSetBasic() {
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 void testPathsSetBasic() {
* org.apache.maven.plugin.war.PathSet.AddAll(Collection,String)
*
*/
+ @Test
public void testPathsSetAddAlls() {
Set s1set = new HashSet<>();
s1set.add("/a/b");
@@ -137,19 +145,19 @@ public void testPathsSetAddAlls() {
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 void testPathsSetAddAlls() {
}
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 void testPathsSetAddAlls() {
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 void testPathsSetAddAlls() {
*
* @throws IOException if an io error occurred
*/
+ @Test
public void testAddAllFilesInDirectory() throws IOException {
PathSet ps = new PathSet();
@@ -213,11 +222,11 @@ public void testAddAllFilesInDirectory() throws IOException {
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 void testAddAllFilesInDirectory() throws IOException {
/*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 6d13b1e6..f4f95f03 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 @@
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 ...
}