-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid printing *expected* stack traces during test runs
- Loading branch information
Francisco Borges
committed
Oct 2, 2012
1 parent
70748a1
commit 67ec04e
Showing
3 changed files
with
45 additions
and
29 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
41 changes: 41 additions & 0 deletions
41
hornetq-core/src/test/java/org/hornetq/tests/util/SilentTestCase.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,41 @@ | ||
package org.hornetq.tests.util; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.PrintStream; | ||
|
||
import junit.framework.TestCase; | ||
|
||
/** | ||
* Test case that hijacks sys-out and sys-err. | ||
* <p> | ||
* It is meant to avoid cluttering either during test execution when the tested code (expectedly) | ||
* writes to these. | ||
*/ | ||
public abstract class SilentTestCase extends TestCase | ||
{ | ||
private PrintStream origSysOut; | ||
private PrintStream origSysErr; | ||
|
||
private PrintStream sysOut; | ||
private PrintStream sysErr; | ||
|
||
@Override | ||
protected void setUp() throws Exception | ||
{ | ||
super.setUp(); | ||
origSysOut = System.out; | ||
origSysErr = System.err; | ||
sysOut = new PrintStream(new ByteArrayOutputStream()); | ||
System.setOut(sysOut); | ||
sysErr = new PrintStream(new ByteArrayOutputStream()); | ||
System.setErr(sysErr); | ||
} | ||
|
||
@Override | ||
public void tearDown() throws Exception | ||
{ | ||
System.setOut(origSysOut); | ||
System.setErr(origSysErr); | ||
super.tearDown(); | ||
} | ||
} |
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