@Test
public void testProduceData() throws Exception {

    final DigestingEntityProducer producer = new DigestingEntityProducer("MD5",
            new StringAsyncEntityProducer("12345", ContentType.TEXT_PLAIN));
    final WritableByteChannelMock byteChannel = new WritableByteChannelMock(1024);
    final BasicDataStreamChannel dataStreamChannel = new BasicDataStreamChannel(byteChannel);
    while (byteChannel.isOpen()) {
        producer.produce(dataStreamChannel);
    }
    Assert.assertEquals("12345", byteChannel.dump(StandardCharsets.US_ASCII));
    final List<Header> trailers = dataStreamChannel.getTrailers();
    Assert.assertNotNull(trailers);
    Assert.assertEquals(2, trailers.size());
    Assert.assertEquals("digest-algo", trailers.get(0).getName());
    Assert.assertEquals("MD5", trailers.get(0).getValue());
    Assert.assertEquals("digest", trailers.get(1).getName());
    Assert.assertEquals("0827c0cb0e0ea08a706c4c340a1680910f84e7b", trailers.get(1).getValue());
}