CachedObjectSerializer extends Serializer<CachedObject> { @Override protected byte[] serializeBytes() { appendByte(object.getCachedInformationType().getValue()); if (object.getHashValueLength() != null && object.getHashValueLength().getValue() != null) { appendInt(object.getHashValueLength().getValue(), ExtensionByteLength.CACHED_INFO_HASH_LENGTH); } if (object.getHashValue() != null && object.getHashValue().getValue() != null) { appendBytes(object.getHashValue().getValue()); } return getAlreadySerialized(); } CachedObjectSerializer(CachedObject object);   }
@Test public void testSerializeBytes() { context = new TlsContext(); object = new CachedObject((byte) 1, null, null); preparator = new CachedObjectPreparator(context.getChooser(), object); preparator.prepare(); serializer = new CachedObjectSerializer(object); assertArrayEquals(new byte[] { (byte) 1 }, serializer.serialize()); object = new CachedObject((byte) 2, 3, new byte[] { 0x01, 0x02, 0x03 }); preparator = new CachedObjectPreparator(context.getChooser(), object); preparator.prepare(); serializer = new CachedObjectSerializer(object); assertArrayEquals(new byte[] { 0x02, 0x03, 0x01, 0x02, 0x03 }, serializer.serialize()); }