Skip to content
Permalink
Browse files
Seems like this test class's methods cannot be run in parallel. gathered
the two tests into one.
  • Loading branch information
elecharny committed May 7, 2019
1 parent cb569e7 commit 359f0800ef755490edb8f1d81fa2a78a36c3ba5d
Showing 1 changed file with 12 additions and 20 deletions.
@@ -32,14 +32,11 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;

/**
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@Execution(ExecutionMode.SAME_THREAD)
public class RuntimeMultiExceptionTest
{
private PrintStream originalOut;
@@ -81,27 +78,22 @@ public void testPrintStacktracePrintWriterDoesNotWriteToSystemOutErr()
assertThat( customOut.toString(), containsString( "nested1" ) );
assertThat( customOut.toString(), containsString( "nested2" ) );
assertThat( systemOut.size(), equalTo( 0 ) );
}


@Test
public void testPrintStacktraceToPrintStreamDoesNotWriteToSystemOutErr()
{
ByteArrayOutputStream systemOut = new ByteArrayOutputStream();
PrintStream systemPrintStream = new PrintStream( systemOut );
System.setOut( systemPrintStream );
System.setErr( systemPrintStream );
ByteArrayOutputStream systemOut2 = new ByteArrayOutputStream();
PrintStream systemPrintStream2 = new PrintStream( systemOut2 );
System.setOut( systemPrintStream2 );
System.setErr( systemPrintStream2 );

ByteArrayOutputStream customOut = new ByteArrayOutputStream();
PrintStream customPrintWriter = new PrintStream( customOut );
RuntimeMultiException runtimeMultiException = new RuntimeMultiException( "multi" );
ByteArrayOutputStream customOut2 = new ByteArrayOutputStream();
PrintStream customPrintWriter2 = new PrintStream( customOut2 );
runtimeMultiException = new RuntimeMultiException( "multi" );
runtimeMultiException.addThrowable( new Exception( "nested1" ) );
runtimeMultiException.addThrowable( new Exception( "nested2" ) );
runtimeMultiException.printStackTrace( customPrintWriter );
runtimeMultiException.printStackTrace( customPrintWriter2 );

assertThat( customOut.toString(), containsString( "multi" ) );
assertThat( customOut.toString(), containsString( "nested1" ) );
assertThat( customOut.toString(), containsString( "nested2" ) );
assertThat( systemOut.size(), equalTo( 0 ) );
assertThat( customOut2.toString(), containsString( "multi" ) );
assertThat( customOut2.toString(), containsString( "nested1" ) );
assertThat( customOut2.toString(), containsString( "nested2" ) );
assertThat( systemOut2.size(), equalTo( 0 ) );
}
}

0 comments on commit 359f080

Please sign in to comment.