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

slachiewicz pushed a commit to branch MSHARED-1264
in repository https://gitbox.apache.org/repos/asf/maven-file-management.git

commit 0ae9f39da984120243bcc671e0c06c5d03f6505a
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Tue Jun 6 19:57:51 2023 +0200

    [MSHARED-1264] Convert to JUnit5
---
 pom.xml                                            | 18 ++++--
 .../model/fileset/mappers/MapperUtilTest.java      | 18 +++---
 .../model/fileset/util/FileSetUtilsTest.java       | 74 +++++++++++-----------
 3 files changed, 60 insertions(+), 50 deletions(-)

diff --git a/pom.xml b/pom.xml
index bac0142..02609b7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -67,6 +67,18 @@
     
<project.build.outputTimestamp>2022-06-29T11:20:20Z</project.build.outputTimestamp>
   </properties>
 
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.junit</groupId>
+        <artifactId>junit-bom</artifactId>
+        <version>5.9.3</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
   <dependencies>
     <dependency>
       <groupId>org.slf4j</groupId>
@@ -77,7 +89,6 @@
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
-      <version>3.5.1</version>
     </dependency>
     <dependency>
       <groupId>commons-io</groupId>
@@ -87,9 +98,8 @@
 
     <!-- Test -->
     <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>4.13.2</version>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
diff --git 
a/src/test/java/org/apache/maven/shared/model/fileset/mappers/MapperUtilTest.java
 
b/src/test/java/org/apache/maven/shared/model/fileset/mappers/MapperUtilTest.java
index 19ad22e..855a8a0 100644
--- 
a/src/test/java/org/apache/maven/shared/model/fileset/mappers/MapperUtilTest.java
+++ 
b/src/test/java/org/apache/maven/shared/model/fileset/mappers/MapperUtilTest.java
@@ -19,24 +19,24 @@
 package org.apache.maven.shared.model.fileset.mappers;
 
 import org.apache.maven.shared.model.fileset.Mapper;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
 
 /**
  * A test-case for the MapperUtil.
  */
 public class MapperUtilTest {
     @Test
-    public void getFileNameMapperShouldReturnNull() throws MapperException {
+    void getFileNameMapperShouldReturnNull() throws MapperException {
         assertNull(MapperUtil.getFileNameMapper(null));
     }
 
     @Test
-    public void getFileNameMapperShouldReturnIdentityMapper() throws 
MapperException {
+    void getFileNameMapperShouldReturnIdentityMapper() throws MapperException {
         Mapper mapper = new Mapper();
         FileNameMapper fileNameMapper = MapperUtil.getFileNameMapper(mapper);
         assertNotNull(fileNameMapper);
@@ -44,7 +44,7 @@ public class MapperUtilTest {
     }
 
     @Test
-    public void getFileNameMapperShouldFileNameMapperType() throws 
MapperException {
+    void getFileNameMapperShouldFileNameMapperType() throws MapperException {
         // check with FileNameMapper type
         Mapper mapper = new Mapper();
         mapper.setType("glob");
@@ -56,7 +56,7 @@ public class MapperUtilTest {
     }
 
     @Test
-    public void testGetFileNameMapper() throws MapperException {
+    void testGetFileNameMapper() throws MapperException {
         try {
             assertNull(MapperUtil.getFileNameMapper(null));
         } catch (MapperException e) {
diff --git 
a/src/test/java/org/apache/maven/shared/model/fileset/util/FileSetUtilsTest.java
 
b/src/test/java/org/apache/maven/shared/model/fileset/util/FileSetUtilsTest.java
index bf2054a..662900f 100644
--- 
a/src/test/java/org/apache/maven/shared/model/fileset/util/FileSetUtilsTest.java
+++ 
b/src/test/java/org/apache/maven/shared/model/fileset/util/FileSetUtilsTest.java
@@ -28,14 +28,14 @@ import java.util.Set;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.maven.shared.model.fileset.FileSet;
-import org.junit.After;
-import org.junit.Assume;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 /**
  * Test the FileSet
@@ -46,7 +46,7 @@ public class FileSetUtilsTest {
     private final Set<File> linkFiles = new HashSet<>();
 
     /** {@inheritDoc} */
-    @After
+    @AfterEach
     public void tearDown() throws IOException {
         for (File linkFile : linkFiles) {
             linkFile.delete();
@@ -61,7 +61,7 @@ public class FileSetUtilsTest {
      * @throws IOException if any
      */
     @Test
-    public void testGetIncludedFiles() throws IOException {
+    void testGetIncludedFiles() throws IOException {
         File directory = setupTestDirectory("testGetIncludedFiles");
 
         FileSet set = new FileSet();
@@ -76,7 +76,7 @@ public class FileSetUtilsTest {
     }
 
     @Test
-    public void testIncludesDontFollowSymlinks() throws IOException {
+    void testIncludesDontFollowSymlinks() throws IOException {
         File directory = setupTestDirectory("testIncludesDontFollowSymlinks");
         File subdir = new File(directory, directory.getName());
 
@@ -85,7 +85,7 @@ public class FileSetUtilsTest {
         } catch (UnsupportedOperationException | SecurityException ex) {
             // failed to create a sym link is because the system does not 
support them
             // and not because the sym link creation failed.
-            Assume.assumeFalse(true);
+            Assumptions.assumeFalse(true);
         }
 
         FileSet set = new FileSet();
@@ -101,7 +101,7 @@ public class FileSetUtilsTest {
     }
 
     @Test
-    public void testDeleteDontFollowSymlinks() throws IOException {
+    void testDeleteDontFollowSymlinks() throws IOException {
         File directory = setupTestDirectory("testDeleteDontFollowSymlinks");
         File subdir = new File(directory, directory.getName());
 
@@ -110,7 +110,7 @@ public class FileSetUtilsTest {
         } catch (UnsupportedOperationException | SecurityException ex) {
             // failed to create a sym link is because the system does not 
support them
             // and not because the sym link creation failed.
-            Assume.assumeFalse(true);
+            Assumptions.assumeFalse(true);
         }
 
         FileSet set = new FileSet();
@@ -130,7 +130,7 @@ public class FileSetUtilsTest {
      * @throws IOException if any
      */
     @Test
-    public void testDelete() throws IOException {
+    void testDelete() throws IOException {
         File directory = setupTestDirectory("testDelete");
         File subdirFile = new File(directory, "subdir/excluded.txt");
 
@@ -143,14 +143,14 @@ public class FileSetUtilsTest {
 
         fileSetManager.delete(set);
 
-        assertFalse("file in marked subdirectory still exists.", 
subdirFile.exists());
+        assertFalse(subdirFile.exists(), "file in marked subdirectory still 
exists.");
     }
 
     /**
      * @throws Exception if any
      */
     @Test
-    public void testDeleteDanglingSymlink() throws Exception {
+    void testDeleteDanglingSymlink() throws Exception {
         File directory = setupTestDirectory("testDeleteDanglingSymlink");
         File targetFile = new File(directory, "test.txt");
         File linkFile = new File(directory, "symlink");
@@ -160,7 +160,7 @@ public class FileSetUtilsTest {
         } catch (UnsupportedOperationException | SecurityException ex) {
             // failed to create a sym link is because the system does not 
support them
             // and not because the sym link creation failed.
-            Assume.assumeFalse(true);
+            Assumptions.assumeFalse(true);
         }
         targetFile.delete();
 
@@ -172,14 +172,14 @@ public class FileSetUtilsTest {
 
         fileSetManager.delete(set);
 
-        assertFalse("directory still exists", directory.exists());
+        assertFalse(directory.exists(), "directory still exists");
     }
 
     /**
      * @throws Exception if any
      */
     @Test
-    public void testDeleteExcludeParentOfExcludedFile() throws Exception {
+    void testDeleteExcludeParentOfExcludedFile() throws Exception {
         File directory = 
setupTestDirectory("testDeleteExcludeParentOfExcludedFile");
 
         FileSet set = new FileSet();
@@ -191,14 +191,14 @@ public class FileSetUtilsTest {
 
         fileSetManager.delete(set);
 
-        assertTrue("excluded file has been deleted", new File(directory, 
"excluded.txt").exists());
+        assertTrue(new File(directory, "excluded.txt").exists(), "excluded 
file has been deleted");
     }
 
     /**
      * @throws Exception if any
      */
     @Test
-    public void testDeleteExcludeParentOfExcludedDir() throws Exception {
+    void testDeleteExcludeParentOfExcludedDir() throws Exception {
         File directory = 
setupTestDirectory("testDeleteExcludeParentOfExcludedDir");
 
         FileSet set = new FileSet();
@@ -210,14 +210,14 @@ public class FileSetUtilsTest {
 
         fileSetManager.delete(set);
 
-        assertTrue("excluded directory has been deleted", new File(directory, 
"excluded").exists());
+        assertTrue(new File(directory, "excluded").exists(), "excluded 
directory has been deleted");
     }
 
     /**
      * @throws Exception if any
      */
     @Test
-    public void testDeleteExcludeFollowSymlinks() throws Exception {
+    void testDeleteExcludeFollowSymlinks() throws Exception {
         File directory = setupTestDirectory("testDeleteExcludeFollowSymlinks");
 
         FileSet set = new FileSet();
@@ -229,16 +229,16 @@ public class FileSetUtilsTest {
 
         fileSetManager.delete(set);
 
-        assertTrue("excluded file has been deleted", new File(directory, 
"excluded.txt").exists());
-        assertTrue("excluded directory has been deleted", new File(directory, 
"excluded").exists());
-        assertFalse("included file has not been deleted", new File(directory, 
"included.txt").exists());
+        assertTrue(new File(directory, "excluded.txt").exists(), "excluded 
file has been deleted");
+        assertTrue(new File(directory, "excluded").exists(), "excluded 
directory has been deleted");
+        assertFalse(new File(directory, "included.txt").exists(), "included 
file has not been deleted");
     }
 
     /**
      * @throws Exception if any
      */
     @Test
-    public void testDeleteExcludeDontFollowSymlinks() throws Exception {
+    void testDeleteExcludeDontFollowSymlinks() throws Exception {
         File directory = 
setupTestDirectory("testDeleteExcludeDontFollowSymlinks");
 
         FileSet set = new FileSet();
@@ -250,13 +250,13 @@ public class FileSetUtilsTest {
 
         fileSetManager.delete(set);
 
-        assertTrue("excluded file has been deleted", new File(directory, 
"excluded.txt").exists());
-        assertTrue("excluded directory has been deleted", new File(directory, 
"excluded").exists());
-        assertFalse("included file has not been deleted", new File(directory, 
"included.txt").exists());
+        assertTrue(new File(directory, "excluded.txt").exists(), "excluded 
file has been deleted");
+        assertTrue(new File(directory, "excluded").exists(), "excluded 
directory has been deleted");
+        assertFalse(new File(directory, "included.txt").exists(), "included 
file has not been deleted");
     }
 
     @Test
-    public void testDeleteDontFollowSymlinksButDeleteThem() throws IOException 
{
+    void testDeleteDontFollowSymlinksButDeleteThem() throws IOException {
         File directory = 
setupTestDirectory("testDeleteDontFollowSymlinksButDeleteThem");
 
         createSymlink(new File(directory, "excluded"), new File(directory, 
"dirlink"));
@@ -273,12 +273,12 @@ public class FileSetUtilsTest {
 
         fileSetManager.delete(set);
 
-        assertTrue("excluded file has been deleted", new File(directory, 
"excluded.txt").exists());
-        assertTrue("excluded directory has been deleted", new File(directory, 
"excluded").exists());
-        assertFalse("included dirlink has not been deleted", new 
File(directory, "dirlink").exists());
-        assertFalse("included filelink has not been deleted", new 
File(directory, "filelink").exists());
-        assertFalse("included directory has not been deleted", new 
File(directory, "dir0").exists());
-        assertFalse("included directory has not been deleted", new 
File(directory, "dir1").exists());
+        assertTrue(new File(directory, "excluded.txt").exists(), "excluded 
file has been deleted");
+        assertTrue(new File(directory, "excluded").exists(), "excluded 
directory has been deleted");
+        assertFalse(new File(directory, "dirlink").exists(), "included dirlink 
has not been deleted");
+        assertFalse(new File(directory, "filelink").exists(), "included 
filelink has not been deleted");
+        assertFalse(new File(directory, "dir0").exists(), "included directory 
has not been deleted");
+        assertFalse(new File(directory, "dir1").exists(), "included directory 
has not been deleted");
     }
 
     private void createSymlink(File target, File link) throws IOException {

Reply via email to