Skip to content

Commit b566668

Browse files
committed
Test doesn't need to write to the console
Reduce vertical space
1 parent 11a38d4 commit b566668

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

src/test/java/org/apache/commons/exec/LogOutputStreamTest.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@
4040
@SetSystemProperty(key = "org.apache.commons.exec.debug", value = "true")
4141
class LogOutputStreamTest {
4242

43-
private static final class SystemLogOutputStream extends LogOutputStream {
43+
private static final class TestLogOutputStream extends LogOutputStream {
4444

4545
private final StringBuffer output = new StringBuffer();
4646

47-
private SystemLogOutputStream(final int level) {
47+
private TestLogOutputStream(final int level) {
4848
super(level);
4949
}
5050

51-
private SystemLogOutputStream(final int level, final Charset charset) {
51+
private TestLogOutputStream(final int level, final Charset charset) {
5252
super(level, charset);
5353
}
5454

@@ -58,17 +58,14 @@ private String getOutput() {
5858

5959
@Override
6060
protected void processLine(final String line, final int level) {
61-
System.out.println(line);
6261
output.append(line);
6362
}
6463
}
6564

6665
private final Executor exec = DefaultExecutor.builder().get();
6766
private final File testDir = new File("src/test/scripts");
6867
private OutputStream systemOut;
69-
7068
private final Path environmentScript = TestUtil.resolveScriptPathForOS(testDir + "/environment");
71-
7269
private final Path utf8CharacterScript = TestUtil.resolveScriptPathForOS(testDir + "/utf8Characters");
7370

7471
@AfterEach
@@ -80,9 +77,8 @@ public void tearDown() throws Exception {
8077

8178
@Test
8279
void testStdout() throws Exception {
83-
this.systemOut = new SystemLogOutputStream(1);
80+
this.systemOut = new TestLogOutputStream(1);
8481
this.exec.setStreamHandler(new PumpStreamHandler(systemOut, systemOut));
85-
8682
final CommandLine cl = new CommandLine(environmentScript);
8783
final int exitValue = exec.execute(cl);
8884
assertFalse(exec.isFailure(exitValue));
@@ -91,14 +87,13 @@ void testStdout() throws Exception {
9187
@Test
9288
@Disabled("The file utf8CharacterScript is missing from the repository and is not in its history")
9389
void testStdoutWithUTF8Characters() throws Exception {
94-
this.systemOut = new SystemLogOutputStream(1, StandardCharsets.UTF_8);
90+
this.systemOut = new TestLogOutputStream(1, StandardCharsets.UTF_8);
9591
this.exec.setStreamHandler(new PumpStreamHandler(systemOut, systemOut));
96-
9792
final CommandLine cl = new CommandLine(utf8CharacterScript);
9893
final int exitValue = exec.execute(cl);
9994
assertFalse(exec.isFailure(exitValue));
10095
assertEquals("This string contains UTF-8 characters like the see no evil monkey \uD83D\uDE48 and the right single quotation mark \u2019",
101-
((SystemLogOutputStream) systemOut).getOutput());
96+
((TestLogOutputStream) systemOut).getOutput());
10297
}
10398

10499
}

0 commit comments

Comments
 (0)