forked from junit-pioneer/junit-pioneer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add StdErr to StdIoExtension (junit-pioneer#650 / junit-pioneer#653)
Adds a new parameter to the StdIoExtension, StdErr, which replaces System.err the same way StdOut replaces System.out. Closes: junit-pioneer#650 PR: junit-pioneer#653
- Loading branch information
1 parent
3e65c92
commit 3e5e59b
Showing
9 changed files
with
165 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2016-2022 the original author or authors. | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License v2.0 which | ||
* accompanies this distribution and is available at | ||
* | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
|
||
package org.junitpioneer.jupiter; | ||
|
||
/** | ||
* <p>For details and examples, see | ||
* <a href="https://junit-pioneer.org/docs/standard-input-output/" target="_top">the documentation on <code>Standard input/output</code></a> | ||
* </p> | ||
* | ||
* @see StdIo | ||
*/ | ||
public class StdErr extends StdOutputStream { | ||
|
||
public StdErr() { | ||
// recreate default constructor to prevent compiler warning | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/org/junitpioneer/jupiter/StdOutputStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2016-2022 the original author or authors. | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License v2.0 which | ||
* accompanies this distribution and is available at | ||
* | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
|
||
package org.junitpioneer.jupiter; | ||
|
||
import java.io.OutputStream; | ||
import java.io.StringWriter; | ||
import java.nio.charset.Charset; | ||
|
||
abstract class StdOutputStream extends OutputStream { | ||
|
||
private final StringWriter writer = new StringWriter(); | ||
|
||
public StdOutputStream() { | ||
// recreate default constructor to prevent compiler warning | ||
} | ||
|
||
@Override | ||
public void write(int i) { | ||
writer.write(i); | ||
} | ||
|
||
@Override | ||
public final void write(byte[] b, int off, int len) { | ||
writer.write(new String(b, Charset.defaultCharset()), off, len); | ||
} | ||
|
||
/** | ||
* @return the lines that were written to {@code System.out} or {@code System.err} | ||
*/ | ||
public String[] capturedLines() { | ||
return writer.toString().split(StdIoExtension.SEPARATOR); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.