You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/12/30 13:03:10 UTC
(commons-exec) 09/09: Proper set up and teardown of system properties in test
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
commit aaa3b48e43816cef57347edd43140fe6b96d13d3
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Dec 30 08:02:56 2023 -0500
Proper set up and teardown of system properties in test
Remove dead comments
---
pom.xml | 7 +++++++
.../apache/commons/exec/LogOutputStreamTest.java | 24 ++++------------------
2 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/pom.xml b/pom.xml
index ca71df34..46400a1e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -72,6 +72,13 @@
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.junit-pioneer</groupId>
+ <artifactId>junit-pioneer</artifactId>
+ <!-- Version 2.x requires Java 11 -->
+ <version>1.9.1</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java b/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java
index 1e605a75..1f084c88 100644
--- a/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/exec/LogOutputStreamTest.java
@@ -29,10 +29,14 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.SetSystemProperty;
/**
* Test the LogOutputStream.
*/
+// turn on debug mode and throw an exception for each encountered problem
+@SetSystemProperty(key = "org.apache.commons.exec.lenient", value = "false")
+@SetSystemProperty(key = "org.apache.commons.exec.debug", value = "true")
public class LogOutputStreamTest {
private static final class SystemLogOutputStream extends LogOutputStream {
@@ -58,13 +62,6 @@ public class LogOutputStreamTest {
}
}
- @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");
- System.setProperty("org.apache.commons.exec.debug", "true");
- }
-
private final Executor exec = new DefaultExecutor();
private final File testDir = new File("src/test/scripts");
private OutputStream systemOut;
@@ -73,15 +70,6 @@ public class LogOutputStreamTest {
private final File utf8CharacterScript = TestUtil.resolveScriptForOS(testDir + "/utf8Characters");
- @BeforeEach
- public void setUp() throws Exception {
-
- }
-
- // ======================================================================
- // Start of regression tests
- // ======================================================================
-
@AfterEach
public void tearDown() throws Exception {
if (this.systemOut != null) {
@@ -99,10 +87,6 @@ public class LogOutputStreamTest {
assertFalse(exec.isFailure(exitValue));
}
- // ======================================================================
- // Helper classes
- // ======================================================================
-
@Test
@Disabled("The file utf8CharacterScript is missing from the repository and is not in its history")
public void testStdoutWithUTF8Characters() throws Exception {