@Test
public void shouldRedirectOutput() throws Exception
{

    ApplicationConsole             console    = mock(ApplicationConsole.class);
    ByteArrayOutputStream          out        = new ByteArrayOutputStream(1000);
    PipedOutputStream              pipe       = new PipedOutputStream();
    PipedInputStream               in         = new PipedInputStream(pipe);
    OutputToOutputStreamRedirector redirector = new OutputToOutputStreamRedirector(out);
    
    redirector.start("foo", "x", in, console, 1234, false);
    redirector.awaitRunning(1, TimeUnit.MINUTES);
    pipe.write("Hello ".getBytes());
    pipe.write("World!".getBytes());
    pipe.flush();
    pipe.close();
    
    redirector.join();
    assertThat(new String(out.toByteArray()), is("Hello World!"));
}