@Test
public void demultiplexing() throws IOException {

    inputStream = new TestInputStream(multiplexedStream);
    StreamHandler handler = createHandler();
    StdioInputStream streamFragment = handler.getNextStreamFragment();
    assertThat(streamFragment).isNotNull();
    assertThat(streamFragment.getType()).isSameAs(StdioType.STDIN);
    assertThat(DockerCloudUtils.readUTF8String(streamFragment)).isEqualTo(STDIN_MSG);
    streamFragment = handler.getNextStreamFragment();
    assertThat(streamFragment).isNotNull();
    assertThat(streamFragment.getType()).isSameAs(StdioType.STDOUT);
    assertThat(DockerCloudUtils.readUTF8String(streamFragment)).isEqualTo(STDOUT_MSG);
    streamFragment = handler.getNextStreamFragment();
    assertThat(streamFragment).isNotNull();
    assertThat(streamFragment.getType()).isSameAs(StdioType.STDERR);
    assertThat(DockerCloudUtils.readUTF8String(streamFragment)).isEqualTo(STDERR_MSG);
}