Serializer { public void writeByte(byte b) { _getBuffer(1)[_index++] = b; } Serializer(); ByteBuffer toByteBuffer(); void writeBoolean(boolean b); void writeByte(byte b); void writeChar(char c); void writeDouble(double d); void writeFloat(float f); void writeInt(int i); void writeLong(long l); void writeObject(Serializable serializable); void writeShort(short s); void writeString(String s); void writeTo(OutputStream outputStream);  }
@Test public void testWriteByte() { Serializer serializer = new Serializer(); byte[] bytes = new byte[_COUNT]; _random.nextBytes(bytes); for (int i = 0; i < _COUNT; i++) { serializer.writeByte(bytes[i]); } ByteBuffer byteBuffer = serializer.toByteBuffer(); Assert.assertArrayEquals(bytes, byteBuffer.array()); }