@Test
public void shouldBeAbleToReadPipedStdErrAfterConsoleClosed() throws Exception
{

    PipedApplicationConsole console = new PipedApplicationConsole(1024, false);
    try (JavaApplication application = LocalPlatform.get().launch(JavaApplication.class,
                                                                  ClassName.of(SimpleApp.class),
                                                                  Arguments.of("foo", "bar"),
                                                                  Console.of(console)))
    {
        application.waitFor();
    }
    BufferedReader reader = console.getErrorReader();
    String line = reader.readLine();
    while(line.contains("JAVA_TOOL_OPTIONS")) {
        line = reader.readLine();
    }
    assertThat(line, is("Err: foo"));
    assertThat(reader.readLine(), is("Err: bar"));
    assertThat(reader.readLine(), is("(terminated)"));
    assertThat(reader.readLine(), is(nullValue()));
}