@Test
public void encodedBufferShouldEqualMatchBuffer() throws IOException {

    byte[] match = { 1, 2, 3, 4 };
    when(metadata.isAnnotationPresent(BoundBuffer.class)).thenReturn(true);
    when(metadata.getAnnotation(BoundBuffer.class)).thenReturn(boundBuffer);
    when(boundBuffer.match()).thenReturn(match);
    Codec<byte[]> codec = factory.create(metadata, byte[].class, null);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    codec.encode(match, new OutputStreamBitChannel(out), null);
    byte[] output = out.toByteArray();
    assertThat(output.length, is(match.length));
    assertArrayEquals(match, output);
}