@Test(timeout = 10000)
public void writeTimeout() throws IOException {

    int writeBufferSize = 4;
    byte[] msgBytes = "Hello world!".getBytes(StandardCharsets.UTF_8);
    assertThat(msgBytes.length).isGreaterThan(writeBufferSize);
    testChannel = new TestPipeChannel(writeBufferSize);
    PipeChannelOutputStream output = new PipeChannelOutputStream(testChannel, Duration.ofSeconds(1));
    assertThat(Stopwatch.measure(() -> {
        try {
            output.write(msgBytes);
            fail("Write operation must not complete.");
        } catch (WriteTimeoutIOException e) {
            // OK
        } catch (IOException e) {
            fail("Unexpected exception.", e);
        }
    }).toMillis()).isCloseTo(1000, Offset.offset(150L));
}