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 5717d9a6 Port to from JUnit assertions 4 to 5
5717d9a6 is described below
commit 5717d9a67a8aa95800e857182844d9ba63e39df8
Author: Gary Gregory <[email protected]>
AuthorDate: Fri Dec 29 09:44:23 2023 -0500
Port to from JUnit assertions 4 to 5
---
.../org/apache/commons/exec/AbstractExecTest.java | 4 +-
.../org/apache/commons/exec/CommandLineTest.java | 10 +--
.../apache/commons/exec/DefaultExecutorTest.java | 76 +++++++++++-----------
.../apache/commons/exec/LogOutputStreamTest.java | 4 +-
.../org/apache/commons/exec/StandAloneTest.java | 2 +-
.../java/org/apache/commons/exec/TutorialTest.java | 2 +-
.../exec/environment/EnvironmentUtilsTest.java | 16 ++---
.../org/apache/commons/exec/issues/Exec33Test.java | 2 +-
.../org/apache/commons/exec/issues/Exec34Test.java | 18 ++---
.../org/apache/commons/exec/issues/Exec36Test.java | 4 +-
.../org/apache/commons/exec/issues/Exec41Test.java | 10 +--
.../org/apache/commons/exec/issues/Exec44Test.java | 10 +--
.../org/apache/commons/exec/issues/Exec57Test.java | 4 +-
.../org/apache/commons/exec/issues/Exec60Test.java | 14 ++--
.../org/apache/commons/exec/issues/Exec65Test.java | 8 +--
.../org/apache/commons/exec/util/MapUtilTest.java | 4 +-
.../apache/commons/exec/util/StringUtilTest.java | 4 +-
17 files changed, 96 insertions(+), 96 deletions(-)
diff --git a/src/test/java/org/apache/commons/exec/AbstractExecTest.java
b/src/test/java/org/apache/commons/exec/AbstractExecTest.java
index 0bb91af3..d735e5ed 100644
--- a/src/test/java/org/apache/commons/exec/AbstractExecTest.java
+++ b/src/test/java/org/apache/commons/exec/AbstractExecTest.java
@@ -17,11 +17,11 @@
package org.apache.commons.exec;
+import java.io.File;
+
import org.junit.Rule;
import org.junit.rules.TestName;
-import java.io.File;
-
public abstract class AbstractExecTest {
public static final int TEST_TIMEOUT = 15000;
diff --git a/src/test/java/org/apache/commons/exec/CommandLineTest.java
b/src/test/java/org/apache/commons/exec/CommandLineTest.java
index 4d25a87f..df06627e 100644
--- a/src/test/java/org/apache/commons/exec/CommandLineTest.java
+++ b/src/test/java/org/apache/commons/exec/CommandLineTest.java
@@ -17,10 +17,10 @@
package org.apache.commons.exec;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.File;
import java.util.HashMap;
@@ -496,7 +496,7 @@ public class CommandLineTest {
final CommandLine cmd2 = new
CommandLine("sh").addArgument("-c").addArgument("echo").addArgument("1");
System.out.println("cmd1: " + cmd1.toString());
System.out.println("cmd2: " + cmd2.toString());
- assertTrue("toString() is useful for troubleshooting",
!cmd1.toString().equals(cmd2.toString()));
+ assertTrue(!cmd1.toString().equals(cmd2.toString()), "toString() is
useful for troubleshooting");
}
}
diff --git a/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
b/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
index 2a386a88..05fbdf58 100644
--- a/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
+++ b/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
@@ -17,13 +17,13 @@
package org.apache.commons.exec;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
@@ -118,7 +118,7 @@ public class DefaultExecutorTest {
exec.setWatchdog(watchdog);
exec.execute(cl, env, resultHandler);
resultHandler.waitFor(WAITFOR_TIMEOUT);
- assertTrue("ResultHandler received a result",
resultHandler.hasResult());
+ assertTrue(resultHandler.hasResult(), "ResultHandler received a
result");
assertNotNull(resultHandler.getException());
baos.reset();
}
@@ -182,8 +182,8 @@ public class DefaultExecutorTest {
myEnvVars.put(name, value);
exec.execute(new CommandLine(environmentSript), myEnvVars);
final String environment = baos.toString().trim();
- assertTrue("Expecting " + name + " in " + environment,
environment.indexOf(name) >= 0);
- assertTrue("Expecting " + value + " in " + environment,
environment.indexOf(value) >= 0);
+ assertTrue(environment.indexOf(name) >= 0, () -> "Expecting " + name +
" in " + environment);
+ assertTrue(environment.indexOf(value) >= 0, () -> "Expecting " + value
+ " in " + environment);
}
/**
@@ -197,8 +197,8 @@ public class DefaultExecutorTest {
myEnvVars.put("NEW_VAR", "NEW_VAL");
exec.execute(new CommandLine(environmentSript), myEnvVars);
final String environment = baos.toString().trim();
- assertTrue("Expecting NEW_VAR in " + environment,
environment.indexOf("NEW_VAR") >= 0);
- assertTrue("Expecting NEW_VAL in " + environment,
environment.indexOf("NEW_VAL") >= 0);
+ assertTrue(environment.indexOf("NEW_VAR") >= 0, () -> "Expecting
NEW_VAR in " + environment);
+ assertTrue(environment.indexOf("NEW_VAL") >= 0, () -> "Expecting
NEW_VAL in " + environment);
}
/**
@@ -210,7 +210,7 @@ public class DefaultExecutorTest {
public void testEnvironmentVariables() throws Exception {
exec.execute(new CommandLine(environmentSript));
final String environment = baos.toString().trim();
- assertFalse("Found no environment variables", environment.isEmpty());
+ assertFalse(environment.isEmpty(), "Found no environment variables");
assertFalse(environment.indexOf("NEW_VAR") >= 0);
}
@@ -333,18 +333,18 @@ public class DefaultExecutorTest {
Thread.sleep(2000);
// our process destroyer should be initialized now
- assertNotNull("Process destroyer should exist",
exec.getProcessDestroyer());
- assertEquals("Process destroyer size should be 1", 1,
processDestroyer.size());
- assertTrue("Process destroyer should exist as shutdown hook",
processDestroyer.isAddedAsShutdownHook());
+ assertNotNull(exec.getProcessDestroyer(), "Process destroyer should
exist");
+ assertEquals(1, processDestroyer.size(), "Process destroyer size
should be 1");
+ assertTrue(processDestroyer.isAddedAsShutdownHook(), "Process
destroyer should exist as shutdown hook");
// terminate it and the process destroyer is detached
watchdog.destroyProcess();
assertTrue(watchdog.killedProcess());
handler.waitFor(WAITFOR_TIMEOUT);
- assertTrue("ResultHandler received a result", handler.hasResult());
+ assertTrue(handler.hasResult(), "ResultHandler received a result");
assertNotNull(handler.getException());
- assertEquals("Processor Destroyer size should be 0", 0,
processDestroyer.size());
- assertFalse("Process destroyer should not exist as shutdown hook",
processDestroyer.isAddedAsShutdownHook());
+ assertEquals(0, processDestroyer.size(), "Processor Destroyer size
should be 0");
+ assertFalse(processDestroyer.isAddedAsShutdownHook(), "Process
destroyer should not exist as shutdown hook");
}
/**
@@ -361,15 +361,15 @@ public class DefaultExecutorTest {
exec.execute(cl, handler);
// wait for script to run
Thread.sleep(2000);
- assertTrue("Watchdog should watch the process", watchdog.isWatching());
+ assertTrue(watchdog.isWatching(), "Watchdog should watch the process");
// terminate it manually using the watchdog
watchdog.destroyProcess();
// wait until the result of the process execution is propagated
handler.waitFor(WAITFOR_TIMEOUT);
- assertTrue("Watchdog should have killed the process",
watchdog.killedProcess());
- assertFalse("Watchdog is no longer watching the process",
watchdog.isWatching());
- assertTrue("ResultHandler received a result", handler.hasResult());
- assertNotNull("ResultHandler received an exception as result",
handler.getException());
+ assertTrue(watchdog.killedProcess(), "Watchdog should have killed the
process");
+ assertFalse(watchdog.isWatching(), "Watchdog is no longer watching the
process");
+ assertTrue(handler.hasResult(), "ResultHandler received a result");
+ assertNotNull(handler.getException(), "ResultHandler received an
exception as result");
}
/**
@@ -391,10 +391,10 @@ public class DefaultExecutorTest {
watchdog.destroyProcess();
// wait until the result of the process execution is propagated
handler.waitFor(WAITFOR_TIMEOUT);
- assertTrue("Watchdog should have killed the process already",
watchdog.killedProcess());
- assertFalse("Watchdog is no longer watching the process",
watchdog.isWatching());
- assertTrue("ResultHandler received a result", handler.hasResult());
- assertNotNull("ResultHandler received an exception as result",
handler.getException());
+ assertTrue(watchdog.killedProcess(), "Watchdog should have killed the
process already");
+ assertFalse(watchdog.isWatching(), "Watchdog is no longer watching the
process");
+ assertTrue(handler.hasResult(), "ResultHandler received a result");
+ assertNotNull(handler.getException(), "ResultHandler received an
exception as result");
}
/**
@@ -440,12 +440,12 @@ public class DefaultExecutorTest {
executor.execute(cl, handler);
handler.waitFor(WAITFOR_TIMEOUT);
- assertTrue("Killed process should be true",
executor.getWatchdog().killedProcess());
- assertTrue("ResultHandler received a result", handler.hasResult());
- assertNotNull("ResultHandler received an exception as result",
handler.getException());
+ assertTrue(executor.getWatchdog().killedProcess(), "Killed process
should be true");
+ assertTrue(handler.hasResult(), "ResultHandler received a result");
+ assertNotNull(handler.getException(), "ResultHandler received an
exception as result");
final int nrOfInvocations =
getOccurrences(readFile(this.foreverOutputFile), '.');
- assertTrue("Killing the process did not work : " + nrOfInvocations,
nrOfInvocations > 5 && nrOfInvocations <= 11);
+ assertTrue(nrOfInvocations > 5 && nrOfInvocations <= 11, () ->
"Killing the process did not work : " + nrOfInvocations);
}
/**
@@ -476,13 +476,13 @@ public class DefaultExecutorTest {
Thread.sleep(timeout);
final int nrOfInvocations =
getOccurrences(readFile(this.foreverOutputFile), '.');
assertTrue(executor.getWatchdog().killedProcess());
- assertTrue("killing the subprocess did not work : " +
nrOfInvocations, nrOfInvocations > 5 && nrOfInvocations <= 11);
+ assertTrue(nrOfInvocations > 5 && nrOfInvocations <= 11, () ->
"killing the subprocess did not work : " + nrOfInvocations);
return;
} catch (final Throwable t) {
fail(t.getMessage());
}
- assertTrue("Killed process should be true",
executor.getWatchdog().killedProcess());
+ assertTrue(executor.getWatchdog().killedProcess(), "Killed process
should be true");
fail("Process did not create ExecuteException when killed");
}
@@ -505,7 +505,7 @@ public class DefaultExecutorTest {
try {
executor.execute(cl);
} catch (final ExecuteException e) {
- assertFalse("Process should exit normally, not be killed by
watchdog", watchdog.killedProcess());
+ assertFalse(watchdog.killedProcess(), "Process should exit
normally, not be killed by watchdog");
// If the Watchdog did not kill it, something else went wrong.
throw e;
}
@@ -656,8 +656,8 @@ public class DefaultExecutorTest {
final int exitValue = executor.execute(cl);
fis.close();
final String result = baos.toString().trim();
- assertTrue(result, result.indexOf("Finished reading from stdin") >
0);
- assertFalse("exitValue=" + exitValue, exec.isFailure(exitValue));
+ assertTrue(result.indexOf("Finished reading from stdin") > 0,
result);
+ assertFalse(exec.isFailure(exitValue), () -> "exitValue=" +
exitValue);
} else {
if (OS.isFamilyWindows()) {
System.err.println("The code samples to do that in windows
look like a joke ... :-( .., no way I'm doing that");
@@ -755,10 +755,10 @@ public class DefaultExecutorTest {
executor.execute(cl, resultHandler);
resultHandler.waitFor(WAITFOR_TIMEOUT);
- assertTrue("ResultHandler received a result",
resultHandler.hasResult());
+ assertTrue(resultHandler.hasResult(), "ResultHandler received a
result");
assertFalse(exec.isFailure(resultHandler.getExitValue()));
final String result = baos.toString();
- assertTrue("Result '" + result + "' should contain 'Hello Foo!'",
result.indexOf("Hello Foo!") >= 0);
+ assertTrue(result.indexOf("Hello Foo!") >= 0, "Result '" + result + "'
should contain 'Hello Foo!'");
}
}
diff --git a/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java
b/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java
index c999cbaa..6f600a97 100644
--- a/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java
@@ -16,8 +16,8 @@
*/
package org.apache.commons.exec;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import java.io.File;
import java.io.OutputStream;
diff --git a/src/test/java/org/apache/commons/exec/StandAloneTest.java
b/src/test/java/org/apache/commons/exec/StandAloneTest.java
index 36875dc3..06353fd0 100644
--- a/src/test/java/org/apache/commons/exec/StandAloneTest.java
+++ b/src/test/java/org/apache/commons/exec/StandAloneTest.java
@@ -17,7 +17,7 @@
package org.apache.commons.exec;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
diff --git a/src/test/java/org/apache/commons/exec/TutorialTest.java
b/src/test/java/org/apache/commons/exec/TutorialTest.java
index 4f83f71a..b796484a 100644
--- a/src/test/java/org/apache/commons/exec/TutorialTest.java
+++ b/src/test/java/org/apache/commons/exec/TutorialTest.java
@@ -17,7 +17,7 @@
package org.apache.commons.exec;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
import java.io.File;
import java.io.IOException;
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 cb6a5cd0..f87a2e87 100644
---
a/src/test/java/org/apache/commons/exec/environment/EnvironmentUtilsTest.java
+++
b/src/test/java/org/apache/commons/exec/environment/EnvironmentUtilsTest.java
@@ -17,11 +17,11 @@
package org.apache.commons.exec.environment;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+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.assertNull;
import java.io.IOException;
import java.util.Arrays;
@@ -61,11 +61,11 @@ public class EnvironmentUtilsTest {
final Map<String, String> procEnvironment =
EnvironmentUtils.getProcEnvironment();
// we assume that there is at least one environment variable
// for this process, i.e. $JAVA_HOME
- assertFalse("Expecting non-zero environment size",
procEnvironment.isEmpty());
+ assertFalse(procEnvironment.isEmpty(), "Expecting non-zero environment
size");
final String[] envArgs = EnvironmentUtils.toStrings(procEnvironment);
for (int i = 0; i < envArgs.length; i++) {
- assertNotNull("Entry " + i + " should not be null", envArgs[i]);
- assertFalse("Entry " + i + " should not be empty",
envArgs[i].isEmpty());
+ assertNotNull(envArgs[i], "Entry " + i + " should not be null");
+ assertFalse(envArgs[i].isEmpty(), "Entry " + i + " should not be
empty");
// System.out.println(envArgs[i]);
}
}
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 d8a15a6a..97ac30cc 100644
--- a/src/test/java/org/apache/commons/exec/issues/Exec33Test.java
+++ b/src/test/java/org/apache/commons/exec/issues/Exec33Test.java
@@ -17,7 +17,7 @@
package org.apache.commons.exec.issues;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import java.io.File;
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 f14495aa..10eb25ba 100644
--- a/src/test/java/org/apache/commons/exec/issues/Exec34Test.java
+++ b/src/test/java/org/apache/commons/exec/issues/Exec34Test.java
@@ -17,9 +17,9 @@
package org.apache.commons.exec.issues;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
@@ -59,8 +59,8 @@ public class Exec34Test {
exec.execute(cmdLine, handler);
assertTrue(watchdog.isWatching());
watchdog.destroyProcess();
- assertTrue("Watchdog should have killed the process",
watchdog.killedProcess());
- assertFalse("Watchdog is no longer watching the process",
watchdog.isWatching());
+ assertTrue(watchdog.killedProcess(), "Watchdog should have killed the
process");
+ assertFalse(watchdog.isWatching(), "Watchdog is no longer watching the
process");
}
/**
@@ -79,9 +79,9 @@ public class Exec34Test {
exec.setWatchdog(watchdog);
exec.execute(cmdLine, handler);
handler.waitFor();
- assertTrue("Process has exited", handler.hasResult());
- assertNotNull("Process was aborted", handler.getException());
- assertTrue("Watchdog should have killed the process",
watchdog.killedProcess());
- assertFalse("Watchdog is no longer watching the process",
watchdog.isWatching());
+ assertTrue(handler.hasResult(), "Process has exited");
+ assertNotNull(handler.getException(), "Process was aborted");
+ assertTrue(watchdog.killedProcess(), "Watchdog should have killed the
process");
+ assertFalse(watchdog.isWatching(), "Watchdog is no longer watching the
process");
}
}
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 cec9b978..41121f3d 100644
--- a/src/test/java/org/apache/commons/exec/issues/Exec36Test.java
+++ b/src/test/java/org/apache/commons/exec/issues/Exec36Test.java
@@ -17,8 +17,8 @@
package org.apache.commons.exec.issues;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import java.io.ByteArrayOutputStream;
import java.io.File;
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 87f55d90..8e058779 100644
--- a/src/test/java/org/apache/commons/exec/issues/Exec41Test.java
+++ b/src/test/java/org/apache/commons/exec/issues/Exec41Test.java
@@ -17,7 +17,7 @@
package org.apache.commons.exec.issues;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
@@ -77,8 +77,8 @@ public class Exec41Test {
System.out.println("Process timed out and was killed.");
}
- assertTrue("The process was killed by the watchdog",
watchdog.killedProcess());
- assertTrue("Skipping the Thread.join() did not work, duration=" +
duration, duration < 9000);
+ assertTrue(watchdog.killedProcess(), "The process was killed by the
watchdog");
+ assertTrue(duration < 9000, () -> "Skipping the Thread.join() did not
work, duration=" + duration);
}
/**
@@ -131,7 +131,7 @@ public class Exec41Test {
System.out.println("Process timed out and was killed by
watchdog.");
}
- assertTrue("The process was killed by the watchdog",
watchdog.killedProcess());
- assertTrue("Skipping the Thread.join() did not work", duration < 9000);
+ assertTrue(watchdog.killedProcess(), "The process was killed by the
watchdog");
+ assertTrue(duration < 9000, "Skipping the Thread.join() did not work");
}
}
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 80acee19..c640f2e0 100644
--- a/src/test/java/org/apache/commons/exec/issues/Exec44Test.java
+++ b/src/test/java/org/apache/commons/exec/issues/Exec44Test.java
@@ -17,8 +17,8 @@
package org.apache.commons.exec.issues;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
@@ -58,11 +58,11 @@ public class Exec44Test {
// wait for script to run
Thread.sleep(5000);
- assertTrue("The watchdog is watching the process",
watchdog.isWatching());
+ assertTrue(watchdog.isWatching(), "The watchdog is watching the
process");
// terminate it
watchdog.destroyProcess();
- assertTrue("The watchdog has killed the process",
watchdog.killedProcess());
- assertFalse("The watchdog is no longer watching any process",
watchdog.isWatching());
+ assertTrue(watchdog.killedProcess(), "The watchdog has killed the
process");
+ assertFalse(watchdog.isWatching(), "The watchdog is no longer watching
any process");
}
}
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 6817f079..904e20cf 100644
--- a/src/test/java/org/apache/commons/exec/issues/Exec57Test.java
+++ b/src/test/java/org/apache/commons/exec/issues/Exec57Test.java
@@ -17,6 +17,8 @@
package org.apache.commons.exec.issues;
+import java.io.IOException;
+
import org.apache.commons.exec.AbstractExecTest;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
@@ -25,8 +27,6 @@ import org.apache.commons.exec.PumpStreamHandler;
import org.junit.Ignore;
import org.junit.Test;
-import java.io.IOException;
-
/**
* Test EXEC-57 (https://issues.apache.org/jira/browse/EXEC-57).
*/
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 6899d6e7..b6b5f6e7 100644
--- a/src/test/java/org/apache/commons/exec/issues/Exec60Test.java
+++ b/src/test/java/org/apache/commons/exec/issues/Exec60Test.java
@@ -17,6 +17,10 @@
package org.apache.commons.exec.issues;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.File;
+
import org.apache.commons.exec.AbstractExecTest;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
@@ -26,10 +30,6 @@ import org.apache.commons.exec.Executor;
import org.junit.Ignore;
import org.junit.Test;
-import java.io.File;
-
-import static org.junit.Assert.assertTrue;
-
/**
* Test EXEC-60 (https://issues.apache.org/jira/browse/EXEC-60).
*/
@@ -72,7 +72,7 @@ public class Exec60Test extends AbstractExecTest {
}
} catch (final ExecuteException ex) {
// System.out.println(offset + ": process was killed: " +
watchdog.killedProcess());
- assertTrue("Watchdog killed the process",
watchdog.killedProcess());
+ assertTrue(watchdog.killedProcess(), "Watchdog killed the
process");
watchdogKilledProcessCounter++;
}
}
@@ -80,7 +80,7 @@ public class Exec60Test extends AbstractExecTest {
final long avg = (System.currentTimeMillis() - startTime) /
(watchdogKilledProcessCounter + processTerminatedCounter);
System.out.println("Processes terminated: " + processTerminatedCounter
+ " killed: " + watchdogKilledProcessCounter + " Multiplier: " +
offsetMultiplier
+ " MaxRetries: " + maxRetries + " Elapsed (avg ms): " + avg);
- assertTrue("Not a single process terminated on its own",
processTerminatedCounter > 0);
- assertTrue("Not a single process was killed by the watch dog",
watchdogKilledProcessCounter > 0);
+ assertTrue(processTerminatedCounter > 0, "Not a single process
terminated on its own");
+ assertTrue(watchdogKilledProcessCounter > 0, "Not a single process was
killed by the watch dog");
}
}
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 61430846..e3240c9a 100644
--- a/src/test/java/org/apache/commons/exec/issues/Exec65Test.java
+++ b/src/test/java/org/apache/commons/exec/issues/Exec65Test.java
@@ -17,6 +17,10 @@
package org.apache.commons.exec.issues;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.File;
+
import org.apache.commons.exec.AbstractExecTest;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
@@ -27,10 +31,6 @@ import org.apache.commons.exec.PumpStreamHandler;
import org.junit.Assume;
import org.junit.Test;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-
/**
* Test to show that watchdog can destroy 'sudo' and 'sleep'.
*
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 4382bcc0..c1788c51 100644
--- a/src/test/java/org/apache/commons/exec/util/MapUtilTest.java
+++ b/src/test/java/org/apache/commons/exec/util/MapUtilTest.java
@@ -17,8 +17,8 @@
package org.apache.commons.exec.util;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.HashMap;
import java.util.Map;
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 f4ca6509..4ffb4c82 100644
--- a/src/test/java/org/apache/commons/exec/util/StringUtilTest.java
+++ b/src/test/java/org/apache/commons/exec/util/StringUtilTest.java
@@ -17,8 +17,8 @@
package org.apache.commons.exec.util;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
import java.util.HashMap;
import java.util.Map;