@Test
void testNullPadded() {

    StringPaddingHandler nullPadded = new NullPadded();
    ByteBuffer byteBuffer = ByteBuffer.allocate(20);
    byteBuffer.put("hello".getBytes(US_ASCII));
    byteBuffer.put(Constants.NULL); // Stick a null in the middle
    byteBuffer.put("again".getBytes(US_ASCII)); // This should be included as its not on the end
    byteBuffer.put(Constants.NULL); // a null at the end
    byteBuffer.rewind();
    assertThat(byteBuffer.limit(), is(20)); // length of buffer
    nullPadded.setBufferLimit(byteBuffer);
    assertThat(byteBuffer.limit(), is(11)); // hello + null + again is 11 chars
    // Read the string back and check the value
    assertThat(US_ASCII.decode(byteBuffer).toString(), is("hello" + NULL_AS_CHAR + "again"));
}