ByteArrayAdapter extends TypeAdapter<byte[]> { @Override public int getSerializedSize(byte[] value) { return SIZE_OF_INT + value.length; } ByteArrayAdapter(); @Override byte[] serialize(byte[] data); @Override byte[] deserialize(byte[] buffer, int bufferPosition); @Override int getSerializedSize(byte[] value);  }
@Test public void testSerializedSizeEmpty() { assertEquals(4, adapter.getSerializedSize(new byte[0])); }
@Test public void testSerializedSizeNotEmpty() { byte[] array = {1, 2, 3}; assertEquals(7, adapter.getSerializedSize(array)); }