Skip to content

Commit

Permalink
Fix capture of System streams
Browse files Browse the repository at this point in the history
  • Loading branch information
sualeh committed Apr 23, 2023
1 parent 2becc9b commit 3348d8e
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@
package schemacrawler.test.utility;

import static org.junit.jupiter.api.Assertions.fail;

import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.lang.reflect.Parameter;
import java.nio.charset.Charset;

import java.nio.charset.StandardCharsets;
import org.junit.jupiter.api.extension.AfterTestExecutionCallback;
import org.junit.jupiter.api.extension.BeforeTestExecutionCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
Expand All @@ -47,6 +46,7 @@ final class CaptureSystemStreamsExtension
implements ParameterResolver, BeforeTestExecutionCallback, AfterTestExecutionCallback {

private static final String DEFAULT_CHARSET = Charset.defaultCharset().name();
private static final String UTF_8_CHARSET = StandardCharsets.UTF_8.toString();

private TestOutputStream err;
private TestOutputStream out;
Expand Down Expand Up @@ -75,10 +75,10 @@ public void beforeTestExecution(final ExtensionContext context) throws Exception
err = new TestOutputStream();

System.out.flush();
System.setOut(new PrintStream(out, true, DEFAULT_CHARSET));
System.setOut(new PrintStream(out, true, UTF_8_CHARSET));

System.err.flush();
System.setErr(new PrintStream(err, true, DEFAULT_CHARSET));
System.setErr(new PrintStream(err, true, UTF_8_CHARSET));
}

@Override
Expand Down

0 comments on commit 3348d8e

Please sign in to comment.