@Test
  public void readingWithSegmentRegistryTest() throws IOException {
    final Buffer byteBuffer = preparePayload();
    final long fullSize = byteBuffer.getLong();
    // full size without 4 bytes for segment_code value
    Assert.assertEquals(fullSize + 4, byteBuffer.remaining());

    final int code = byteBuffer.getInt();
    Payload payloadSegment = (Payload) SegmentRegistry.read(code, byteBuffer);

    for (int i = 0; i < 15; i++) {
      final Buffer currentPayload = payloadSegment.getPayload(i);
      final byte[] expectedPayloadBytes = ("payload" + i).getBytes();

      for (byte expectedByte : expectedPayloadBytes) {
        final byte actualByte = currentPayload.get();
        Assert.assertEquals(actualByte, expectedByte);
      }
      Assert.assertFalse(currentPayload.hasRemaining());
    }
  }