Serializer { public void writeLong(long l) { BigEndianCodec.putLong(_getBuffer(8), _index, l); _index += 8; } 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 testWriteLong() { Serializer serializer = new Serializer(); ByteBuffer byteBuffer = ByteBuffer.allocate(_COUNT * 8); byteBuffer.order(ByteOrder.BIG_ENDIAN); LongBuffer longBuffer = byteBuffer.asLongBuffer(); long[] longs = new long[_COUNT]; for (int i = 0; i < _COUNT; i++) { longs[i] = _random.nextLong(); serializer.writeLong(longs[i]); longBuffer.put(longs[i]); } ByteBuffer serializerByteBuffer = serializer.toByteBuffer(); Assert.assertArrayEquals( byteBuffer.array(), serializerByteBuffer.array()); }