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

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-exec.git


The following commit(s) were added to refs/heads/master by this push:
     new 3e57bb81 Port from JUnit 4 to 5
3e57bb81 is described below

commit 3e57bb81e578637fa3d9c3e30c894e65d5f1388c
Author: Gary Gregory <[email protected]>
AuthorDate: Fri Dec 29 10:04:34 2023 -0500

    Port from JUnit 4 to 5
---
 pom.xml                                            |  4 +--
 src/changes/changes.xml                            |  3 ++
 .../org/apache/commons/exec/AbstractExecTest.java  | 17 ++----------
 .../org/apache/commons/exec/CommandLineTest.java   |  2 +-
 .../apache/commons/exec/DefaultExecutorTest.java   | 18 ++++++------
 .../apache/commons/exec/LogOutputStreamTest.java   | 18 ++++++------
 .../org/apache/commons/exec/StandAloneTest.java    |  6 ++--
 .../java/org/apache/commons/exec/TestUtil.java     | 10 ++++---
 .../java/org/apache/commons/exec/TutorialTest.java |  2 +-
 .../exec/environment/EnvironmentUtilsTest.java     |  2 +-
 .../org/apache/commons/exec/issues/Exec33Test.java |  2 +-
 .../org/apache/commons/exec/issues/Exec34Test.java |  2 +-
 .../org/apache/commons/exec/issues/Exec36Test.java | 18 ++++++------
 .../org/apache/commons/exec/issues/Exec41Test.java |  2 +-
 .../org/apache/commons/exec/issues/Exec44Test.java |  2 +-
 .../org/apache/commons/exec/issues/Exec49Test.java |  2 +-
 .../org/apache/commons/exec/issues/Exec57Test.java | 14 ++++++----
 .../org/apache/commons/exec/issues/Exec60Test.java |  6 ++--
 .../org/apache/commons/exec/issues/Exec62Test.java | 19 +++++++------
 .../org/apache/commons/exec/issues/Exec65Test.java | 32 ++++++++++++++--------
 .../org/apache/commons/exec/util/MapUtilTest.java  |  2 +-
 .../apache/commons/exec/util/StringUtilTest.java   |  2 +-
 22 files changed, 96 insertions(+), 89 deletions(-)

diff --git a/pom.xml b/pom.xml
index 9b16436a..13aed45c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,8 +51,8 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.junit.vintage</groupId>
-            <artifactId>junit-vintage-engine</artifactId>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
             <scope>test</scope>
         </dependency>
     </dependencies>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c7d71dad..f0728194 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -50,6 +50,9 @@
             <action dev="ggregory" type="fix" due-to="step-security-bot, Gary 
Gregory">
                 [StepSecurity] ci: Harden GitHub Actions #107.
             </action>
+            <action dev="ggregory" type="fix" due-to="Gary Gregory">
+                Port from JUnit 4 to 5.
+            </action>
             <!-- REMOVE -->
             <action dev="ggregory" type="remove" due-to="Gary 
Gregory">Deprecate DefaultExecuteResultHandler.waitFor(long).</action>
             <action dev="ggregory" type="remove" due-to="Gary 
Gregory">Deprecate ExecuteWatchdog.ExecuteWatchdog(long).</action>
diff --git a/src/test/java/org/apache/commons/exec/AbstractExecTest.java 
b/src/test/java/org/apache/commons/exec/AbstractExecTest.java
index d735e5ed..fab1c7d6 100644
--- a/src/test/java/org/apache/commons/exec/AbstractExecTest.java
+++ b/src/test/java/org/apache/commons/exec/AbstractExecTest.java
@@ -19,9 +19,6 @@ package org.apache.commons.exec;
 
 import java.io.File;
 
-import org.junit.Rule;
-import org.junit.rules.TestName;
-
 public abstract class AbstractExecTest {
 
     public static final int TEST_TIMEOUT = 15000;
@@ -31,16 +28,6 @@ public abstract class AbstractExecTest {
 
     private final File testDir = new File("src/test/scripts");
 
-    @Rule
-    public TestName name = new TestName();
-
-    /**
-     * Gets the name of the currently executed test.
-     */
-    protected String getName() {
-        return name.getMethodName();
-    }
-
     /**
      * Resolve the OS-specific test file to execute.
      */
@@ -64,13 +51,13 @@ public abstract class AbstractExecTest {
     }
 
     protected String testIsBrokenForCurrentOperatingSystem() {
-        final String msg = String.format("The test '%s' is broken for OS : 
%s", name.getMethodName(), OS_NAME);
+        final String msg = String.format("The test is broken for OS : %s", 
OS_NAME);
         System.err.println(msg);
         return msg;
     }
 
     protected String testNotSupportedForCurrentOperatingSystem() {
-        final String msg = String.format("The test '%s' is not possible for OS 
: %s", name.getMethodName(), OS_NAME);
+        final String msg = String.format("The test is not possible for OS : 
%s", OS_NAME);
         System.out.println(msg);
         return msg;
     }
diff --git a/src/test/java/org/apache/commons/exec/CommandLineTest.java 
b/src/test/java/org/apache/commons/exec/CommandLineTest.java
index df06627e..d0c4e41a 100644
--- a/src/test/java/org/apache/commons/exec/CommandLineTest.java
+++ b/src/test/java/org/apache/commons/exec/CommandLineTest.java
@@ -27,7 +27,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.commons.exec.util.StringUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  */
diff --git a/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java 
b/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
index 05fbdf58..b02553cb 100644
--- a/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
+++ b/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
@@ -40,11 +40,11 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.commons.exec.environment.EnvironmentUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 /**
  */
@@ -58,7 +58,7 @@ public class DefaultExecutorTest {
     private static int SUCCESS_STATUS; // test script successful exit code
     private static int ERROR_STATUS; // test script error exit code
 
-    @BeforeClass
+    @BeforeAll
     public static void classSetUp() {
 
         final int[] statuses = TestUtil.getTestScriptCodesForOS();
@@ -94,7 +94,7 @@ public class DefaultExecutorTest {
      * @throws Exception the test failed
      */
     @Test
-    @Ignore
+    @Disabled
     public void _testExecuteStability() throws Exception {
 
         // make a plain-vanilla test
@@ -154,7 +154,7 @@ public class DefaultExecutorTest {
         return contents.toString();
     }
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
 
         // delete the marker file
@@ -168,7 +168,7 @@ public class DefaultExecutorTest {
         this.exec.setStreamHandler(new PumpStreamHandler(baos, baos));
     }
 
-    @After
+    @AfterEach
     public void tearDown() throws Exception {
         this.baos.close();
         foreverOutputFile.delete();
diff --git a/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java 
b/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java
index 6f600a97..1e605a75 100644
--- a/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java
@@ -24,11 +24,11 @@ import java.io.OutputStream;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test the LogOutputStream.
@@ -58,7 +58,7 @@ public class LogOutputStreamTest {
         }
     }
 
-    @BeforeClass
+    @BeforeAll
     public static void classSetUp() {
         // turn on debug mode and throw an exception for each encountered 
problem
         System.setProperty("org.apache.commons.exec.lenient", "false");
@@ -73,7 +73,7 @@ public class LogOutputStreamTest {
 
     private final File utf8CharacterScript = 
TestUtil.resolveScriptForOS(testDir + "/utf8Characters");
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
 
     }
@@ -82,7 +82,7 @@ public class LogOutputStreamTest {
     // Start of regression tests
     // ======================================================================
 
-    @After
+    @AfterEach
     public void tearDown() throws Exception {
         if (this.systemOut != null) {
             this.systemOut.close();
@@ -104,7 +104,7 @@ public class LogOutputStreamTest {
     // ======================================================================
 
     @Test
-    @Ignore("The file utf8CharacterScript is missing from the repository and 
is not in its history")
+    @Disabled("The file utf8CharacterScript is missing from the repository and 
is not in its history")
     public void testStdoutWithUTF8Characters() throws Exception {
         this.systemOut = new SystemLogOutputStream(1, StandardCharsets.UTF_8);
         this.exec.setStreamHandler(new PumpStreamHandler(systemOut, 
systemOut));
diff --git a/src/test/java/org/apache/commons/exec/StandAloneTest.java 
b/src/test/java/org/apache/commons/exec/StandAloneTest.java
index 06353fd0..add634a7 100644
--- a/src/test/java/org/apache/commons/exec/StandAloneTest.java
+++ b/src/test/java/org/apache/commons/exec/StandAloneTest.java
@@ -21,15 +21,15 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.File;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 /**
  * Placeholder for mailing list question - provided a minimal test case to 
answer the question as sel-contained regression test.
  */
 public class StandAloneTest {
 
-    @BeforeClass
+    @BeforeAll
     public static void classSetUp() {
         System.setProperty("org.apache.commons.exec.lenient", "false");
         System.setProperty("org.apache.commons.exec.debug", "true");
diff --git a/src/test/java/org/apache/commons/exec/TestUtil.java 
b/src/test/java/org/apache/commons/exec/TestUtil.java
index 4ee7fed7..20d125d1 100644
--- a/src/test/java/org/apache/commons/exec/TestUtil.java
+++ b/src/test/java/org/apache/commons/exec/TestUtil.java
@@ -17,9 +17,9 @@
 
 package org.apache.commons.exec;
 
-import java.io.File;
+import static org.junit.jupiter.api.Assertions.fail;
 
-import junit.framework.AssertionFailedError;
+import java.io.File;
 
 /**
  */
@@ -40,7 +40,8 @@ public final class TestUtil {
         if (OS.isFamilyOpenVms()) {
             return new int[] { 1, 2 };
         }
-        throw new AssertionFailedError("Test not supported for this OS");
+        fail("Test not supported for this OS");
+        return null; // unreachable.
     }
 
     public static File resolveScriptForOS(final String script) {
@@ -53,7 +54,8 @@ public final class TestUtil {
         if (OS.isFamilyOpenVms()) {
             return new File(script + ".dcl");
         }
-        throw new AssertionFailedError("Test not supported for this OS");
+        fail("Test not supported for this OS");
+        return null; // unreachable.
     }
 
     private TestUtil() {
diff --git a/src/test/java/org/apache/commons/exec/TutorialTest.java 
b/src/test/java/org/apache/commons/exec/TutorialTest.java
index b796484a..a21fc122 100644
--- a/src/test/java/org/apache/commons/exec/TutorialTest.java
+++ b/src/test/java/org/apache/commons/exec/TutorialTest.java
@@ -24,7 +24,7 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * An example based on the tutorial where the user can safely play with
diff --git 
a/src/test/java/org/apache/commons/exec/environment/EnvironmentUtilsTest.java 
b/src/test/java/org/apache/commons/exec/environment/EnvironmentUtilsTest.java
index f87a2e87..796e409d 100644
--- 
a/src/test/java/org/apache/commons/exec/environment/EnvironmentUtilsTest.java
+++ 
b/src/test/java/org/apache/commons/exec/environment/EnvironmentUtilsTest.java
@@ -31,7 +31,7 @@ import java.util.Map;
 import java.util.Map.Entry;
 
 import org.apache.commons.exec.OS;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  */
diff --git a/src/test/java/org/apache/commons/exec/issues/Exec33Test.java 
b/src/test/java/org/apache/commons/exec/issues/Exec33Test.java
index 97ac30cc..16a24b2f 100644
--- a/src/test/java/org/apache/commons/exec/issues/Exec33Test.java
+++ b/src/test/java/org/apache/commons/exec/issues/Exec33Test.java
@@ -26,7 +26,7 @@ import org.apache.commons.exec.DefaultExecutor;
 import org.apache.commons.exec.Executor;
 import org.apache.commons.exec.PumpStreamHandler;
 import org.apache.commons.exec.TestUtil;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test the patch for EXEC-33 (https://issues.apache.org/jira/browse/EXEC-33)
diff --git a/src/test/java/org/apache/commons/exec/issues/Exec34Test.java 
b/src/test/java/org/apache/commons/exec/issues/Exec34Test.java
index 10eb25ba..657d55ab 100644
--- a/src/test/java/org/apache/commons/exec/issues/Exec34Test.java
+++ b/src/test/java/org/apache/commons/exec/issues/Exec34Test.java
@@ -29,7 +29,7 @@ import org.apache.commons.exec.DefaultExecutor;
 import org.apache.commons.exec.ExecuteWatchdog;
 import org.apache.commons.exec.Executor;
 import org.apache.commons.exec.TestUtil;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * EXEC-34 https://issues.apache.org/jira/browse/EXEC-34
diff --git a/src/test/java/org/apache/commons/exec/issues/Exec36Test.java 
b/src/test/java/org/apache/commons/exec/issues/Exec36Test.java
index 41121f3d..8aaed1f2 100644
--- a/src/test/java/org/apache/commons/exec/issues/Exec36Test.java
+++ b/src/test/java/org/apache/commons/exec/issues/Exec36Test.java
@@ -31,10 +31,10 @@ import org.apache.commons.exec.Executor;
 import org.apache.commons.exec.OS;
 import org.apache.commons.exec.PumpStreamHandler;
 import org.apache.commons.exec.TestUtil;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test EXEC-36 see https://issues.apache.org/jira/browse/EXEC-36
@@ -51,7 +51,7 @@ public class Exec36Test {
      * Some complex real-life command line from 
http://blogs.msdn.com/b/astebner/archive/2005/12/13/503471.aspx
      */
     @Test
-    @Ignore
+    @Disabled
     public void _testExec36_4() throws Exception {
 
         CommandLine cmdl;
@@ -73,7 +73,7 @@ public class Exec36Test {
      * Some complex real-life command line from 
http://blogs.msdn.com/b/astebner/archive/2005/12/13/503471.aspx
      */
     @Test
-    @Ignore
+    @Disabled
     public void _testExec36_5() {
 
         CommandLine cmdl;
@@ -94,7 +94,7 @@ public class Exec36Test {
      * C:\CVS_DB\WeightsEngine /f WeightsEngine.mak CFG="WeightsEngine - 
Win32Release"
      */
     @Test
-    @Ignore
+    @Disabled
     public void _testExec36_6() {
 
         final String commandline = "C:\\CVS_DB\\WeightsEngine /f 
WeightsEngine.mak CFG=\"WeightsEngine - Win32Release\"";
@@ -106,14 +106,14 @@ public class Exec36Test {
         assertEquals("CFG=\"WeightsEngine - Win32Release\"", args[2]);
     }
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         // prepare a ready to Executor
         this.baos = new ByteArrayOutputStream();
         this.exec.setStreamHandler(new PumpStreamHandler(baos, baos));
     }
 
-    @After
+    @AfterEach
     public void tearDown() throws Exception {
         this.baos.close();
     }
diff --git a/src/test/java/org/apache/commons/exec/issues/Exec41Test.java 
b/src/test/java/org/apache/commons/exec/issues/Exec41Test.java
index 8e058779..95a3e188 100644
--- a/src/test/java/org/apache/commons/exec/issues/Exec41Test.java
+++ b/src/test/java/org/apache/commons/exec/issues/Exec41Test.java
@@ -28,7 +28,7 @@ import org.apache.commons.exec.ExecuteWatchdog;
 import org.apache.commons.exec.OS;
 import org.apache.commons.exec.PumpStreamHandler;
 import org.apache.commons.exec.TestUtil;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test the patch for EXEC-41 (https://issues.apache.org/jira/browse/EXEC-41).
diff --git a/src/test/java/org/apache/commons/exec/issues/Exec44Test.java 
b/src/test/java/org/apache/commons/exec/issues/Exec44Test.java
index c640f2e0..add83c82 100644
--- a/src/test/java/org/apache/commons/exec/issues/Exec44Test.java
+++ b/src/test/java/org/apache/commons/exec/issues/Exec44Test.java
@@ -28,7 +28,7 @@ import org.apache.commons.exec.DefaultExecutor;
 import org.apache.commons.exec.ExecuteWatchdog;
 import org.apache.commons.exec.Executor;
 import org.apache.commons.exec.TestUtil;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test EXEC-44 (https://issues.apache.org/jira/browse/EXEC-44).
diff --git a/src/test/java/org/apache/commons/exec/issues/Exec49Test.java 
b/src/test/java/org/apache/commons/exec/issues/Exec49Test.java
index 716a1c40..544afa9b 100644
--- a/src/test/java/org/apache/commons/exec/issues/Exec49Test.java
+++ b/src/test/java/org/apache/commons/exec/issues/Exec49Test.java
@@ -28,7 +28,7 @@ import org.apache.commons.exec.DefaultExecutor;
 import org.apache.commons.exec.Executor;
 import org.apache.commons.exec.OS;
 import org.apache.commons.exec.PumpStreamHandler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test EXEC-44 (https://issues.apache.org/jira/browse/EXEC-44).
diff --git a/src/test/java/org/apache/commons/exec/issues/Exec57Test.java 
b/src/test/java/org/apache/commons/exec/issues/Exec57Test.java
index 904e20cf..20ed2ef0 100644
--- a/src/test/java/org/apache/commons/exec/issues/Exec57Test.java
+++ b/src/test/java/org/apache/commons/exec/issues/Exec57Test.java
@@ -18,14 +18,16 @@
 package org.apache.commons.exec.issues;
 
 import java.io.IOException;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.exec.AbstractExecTest;
 import org.apache.commons.exec.CommandLine;
 import org.apache.commons.exec.DefaultExecutor;
 import org.apache.commons.exec.OS;
 import org.apache.commons.exec.PumpStreamHandler;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 /**
  * Test EXEC-57 (https://issues.apache.org/jira/browse/EXEC-57).
@@ -40,8 +42,9 @@ public class Exec57Test extends AbstractExecTest {
      *
      * @TODO [EXEC-57] Broken for Mac OS X & Linux
      */
-    @Ignore("Broken for Unix-based systems")
-    @Test(timeout = TEST_TIMEOUT)
+    @Disabled("Broken for Unix-based systems")
+    @Test
+    @Timeout(value = TEST_TIMEOUT, unit = TimeUnit.MILLISECONDS)
     public void testExecutionOfBackgroundProcess() throws IOException {
 
         final CommandLine cmdLine = new 
CommandLine("sh").addArgument("-c").addArgument("./src/test/scripts/issues/exec-57-nohup.sh",
 false);
@@ -58,7 +61,8 @@ public class Exec57Test extends AbstractExecTest {
      *
      * @throws IOException
      */
-    @Test(timeout = TEST_TIMEOUT)
+    @Test
+    @Timeout(value = TEST_TIMEOUT, unit = TimeUnit.MILLISECONDS)
     public void testExecutionOfDetachedProcess() throws IOException {
 
         if (!OS.isFamilyUnix()) {
diff --git a/src/test/java/org/apache/commons/exec/issues/Exec60Test.java 
b/src/test/java/org/apache/commons/exec/issues/Exec60Test.java
index b6b5f6e7..fd6ec048 100644
--- a/src/test/java/org/apache/commons/exec/issues/Exec60Test.java
+++ b/src/test/java/org/apache/commons/exec/issues/Exec60Test.java
@@ -27,8 +27,8 @@ import org.apache.commons.exec.DefaultExecutor;
 import org.apache.commons.exec.ExecuteException;
 import org.apache.commons.exec.ExecuteWatchdog;
 import org.apache.commons.exec.Executor;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test EXEC-60 (https://issues.apache.org/jira/browse/EXEC-60).
@@ -42,7 +42,7 @@ public class Exec60Test extends AbstractExecTest {
      * Possible deadlock when a process is terminating at the same time its 
timing out. Please note that a successful test is no proof that the issues was
      * indeed fixed.
      */
-    @Ignore("The test is fragile and might fail out of the blue")
+    @Disabled("The test is fragile and might fail out of the blue")
     @Test
     public void testExec_60() throws Exception {
 
diff --git a/src/test/java/org/apache/commons/exec/issues/Exec62Test.java 
b/src/test/java/org/apache/commons/exec/issues/Exec62Test.java
index cbbee4f0..6c36ec5c 100644
--- a/src/test/java/org/apache/commons/exec/issues/Exec62Test.java
+++ b/src/test/java/org/apache/commons/exec/issues/Exec62Test.java
@@ -21,6 +21,7 @@ import java.io.File;
 import java.io.OutputStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
 import org.apache.commons.exec.CommandLine;
@@ -29,10 +30,11 @@ import org.apache.commons.exec.ExecuteWatchdog;
 import org.apache.commons.exec.OS;
 import org.apache.commons.exec.PumpStreamHandler;
 import org.apache.commons.exec.TestUtil;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 /**
  * @see <a href="https://issues.apache.org/jira/browse/EXEC-62";>EXEC-62</a>
@@ -61,18 +63,19 @@ public class Exec62Test {
         }
     }
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         outputFile = Files.createTempFile("foo", ".log");
     }
 
-    @After
+    @AfterEach
     public void tearDown() throws Exception {
         Files.delete(outputFile);
     }
 
-    @Ignore("Test behaves differently between Mac OS X and Linux - don't know 
why")
-    @Test(expected = TimeoutException.class, timeout = 10000)
+    @Disabled("Test behaves differently between Mac OS X and Linux - don't 
know why")
+    @Test
+    @Timeout(value = 10, unit = TimeUnit.SECONDS)
     public void testMe() throws Exception {
         if (OS.isFamilyUnix()) {
             execute("exec-62");
diff --git a/src/test/java/org/apache/commons/exec/issues/Exec65Test.java 
b/src/test/java/org/apache/commons/exec/issues/Exec65Test.java
index e3240c9a..af9df9ae 100644
--- a/src/test/java/org/apache/commons/exec/issues/Exec65Test.java
+++ b/src/test/java/org/apache/commons/exec/issues/Exec65Test.java
@@ -17,9 +17,13 @@
 
 package org.apache.commons.exec.issues;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assumptions.assumeFalse;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
 
 import java.io.File;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.exec.AbstractExecTest;
 import org.apache.commons.exec.CommandLine;
@@ -28,8 +32,8 @@ import org.apache.commons.exec.ExecuteException;
 import org.apache.commons.exec.ExecuteWatchdog;
 import org.apache.commons.exec.OS;
 import org.apache.commons.exec.PumpStreamHandler;
-import org.junit.Assume;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 /**
  * Test to show that watchdog can destroy 'sudo' and 'sleep'.
@@ -47,7 +51,8 @@ public class Exec65Test extends AbstractExecTest {
      *
      * @TODO Fix tests for Windows & Linux
      */
-    @Test(expected = ExecuteException.class, timeout = TEST_TIMEOUT)
+    @Test
+    @Timeout(value = TEST_TIMEOUT, unit = TimeUnit.MILLISECONDS)
     public void testExec65WithSleepUsingShellScript() throws Exception {
 
         if (!OS.isFamilyMac()) {
@@ -58,13 +63,14 @@ public class Exec65Test extends AbstractExecTest {
         executor.setWatchdog(new ExecuteWatchdog(WATCHDOG_TIMEOUT));
         final CommandLine command = new 
CommandLine(resolveTestScript("sleep"));
 
-        executor.execute(command);
+        assertThrows(ExecuteException.class, () -> executor.execute(command));
     }
 
     /**
      * This is the original code snippet from the JIRA to show that killing 
the process actually works with JDK only but it does not re-direct any streams.
      */
-    @Test(timeout = TEST_TIMEOUT)
+    @Test
+    @Timeout(value = TEST_TIMEOUT, unit = TimeUnit.MILLISECONDS)
     public void testExec65WithSleepUsingShellScriptAndJDKOnly() throws 
Exception {
 
         final Process process = 
Runtime.getRuntime().exec(resolveTestScript("sleep").getAbsolutePath());
@@ -81,12 +87,13 @@ public class Exec65Test extends AbstractExecTest {
      * Please note that this tests make assumptions about the environment. It 
assumes that user "root" exists and that the current user is not a "sudoer"
      * already (thereby requiring a password).
      */
-    @Test(expected = ExecuteException.class, timeout = TEST_TIMEOUT)
+    @Test
+    @Timeout(value = TEST_TIMEOUT, unit = TimeUnit.MILLISECONDS)
     public void testExec65WithSudoUsingShellScript() throws Exception {
-        Assume.assumeFalse("Test is skipped on travis, because we have to be a 
sudoer " + "to make the other tests pass.",
-                new File(".").getAbsolutePath().contains("travis"));
+        assumeFalse(new File(".").getAbsolutePath().contains("travis"),
+                "Test is skipped on travis, because we have to be a sudoer to 
make the other tests pass.");
         // TODO Fails on GitHub
-        Assume.assumeTrue(System.getenv("GITHUB_WORKFLOW") == null);
+        assumeTrue(System.getenv("GITHUB_WORKFLOW") == null);
         if (!OS.isFamilyUnix()) {
             throw new 
ExecuteException(testNotSupportedForCurrentOperatingSystem(), 0);
         }
@@ -95,10 +102,11 @@ public class Exec65Test extends AbstractExecTest {
         executor.setWatchdog(new ExecuteWatchdog(WATCHDOG_TIMEOUT));
         final CommandLine command = new 
CommandLine(resolveTestScript("issues", "exec-65"));
 
-        executor.execute(command);
+        assertThrows(ExecuteException.class, () -> executor.execute(command));
     }
 
-    @Test(expected = ExecuteException.class, timeout = TEST_TIMEOUT)
+    @Test
+    @Timeout(value = TEST_TIMEOUT, unit = TimeUnit.MILLISECONDS)
     public void testExec65WitSleepUsingSleepCommandDirectly() throws Exception 
{
 
         if (!OS.isFamilyUnix()) {
@@ -111,6 +119,6 @@ public class Exec65Test extends AbstractExecTest {
         executor.setStreamHandler(new PumpStreamHandler(System.out, 
System.err));
         executor.setWatchdog(watchdog);
 
-        executor.execute(command);
+        assertThrows(ExecuteException.class, () -> executor.execute(command));
     }
 }
diff --git a/src/test/java/org/apache/commons/exec/util/MapUtilTest.java 
b/src/test/java/org/apache/commons/exec/util/MapUtilTest.java
index c1788c51..9bdc676a 100644
--- a/src/test/java/org/apache/commons/exec/util/MapUtilTest.java
+++ b/src/test/java/org/apache/commons/exec/util/MapUtilTest.java
@@ -24,7 +24,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.commons.exec.environment.EnvironmentUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  */
diff --git a/src/test/java/org/apache/commons/exec/util/StringUtilTest.java 
b/src/test/java/org/apache/commons/exec/util/StringUtilTest.java
index 4ffb4c82..17a6933a 100644
--- a/src/test/java/org/apache/commons/exec/util/StringUtilTest.java
+++ b/src/test/java/org/apache/commons/exec/util/StringUtilTest.java
@@ -23,7 +23,7 @@ import static org.junit.jupiter.api.Assertions.fail;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  */

Reply via email to