@Test public void testBlobPropertyV1() throws IOException, MessageFormatException { short[] versions = new short[]{VERSION_1, VERSION_2, VERSION_3}; for (short version : versions) { BlobProperties properties; long blobSize = TestUtils.RANDOM.nextLong(); long ttl = TestUtils.RANDOM.nextInt(); boolean isEncrypted = TestUtils.RANDOM.nextBoolean(); if (version == VERSION_1) { properties = new BlobProperties(blobSize, "id", "member", "test", true, ttl, Account.UNKNOWN_ACCOUNT_ID, Container.UNKNOWN_CONTAINER_ID, isEncrypted, null); } else { short accountId = Utils.getRandomShort(TestUtils.RANDOM); short containerId = Utils.getRandomShort(TestUtils.RANDOM); properties = new BlobProperties(blobSize, "id", "member", "test", true, ttl, accountId, containerId, isEncrypted, null); } ByteBuffer stream; if (version == VERSION_1) { stream = ByteBuffer.allocate(getBlobPropertiesV1RecordSize(properties)); serializeBlobPropertiesV1Record(stream, properties); } else if (version == VERSION_2) { stream = ByteBuffer.allocate(getBlobPropertiesV2RecordSize(properties)); serializeBlobPropertiesV2Record(stream, properties); } else { stream = ByteBuffer.allocate(getBlobPropertiesRecordSize(properties)); MessageFormatRecord.BlobProperties_Format_V1.serializeBlobPropertiesRecord(stream, properties); } stream.flip(); BlobProperties result = MessageFormatRecord.deserializeBlobProperties(new ByteBufferInputStream(stream)); Assert.assertEquals(properties.getBlobSize(), result.getBlobSize()); Assert.assertEquals(properties.getContentType(), result.getContentType()); Assert.assertEquals(properties.getCreationTimeInMs(), result.getCreationTimeInMs()); Assert.assertEquals(properties.getOwnerId(), result.getOwnerId()); Assert.assertEquals(properties.getServiceId(), result.getServiceId()); Assert.assertEquals(properties.getAccountId(), result.getAccountId()); Assert.assertEquals(properties.getContainerId(), result.getContainerId()); if (version > VERSION_2) { Assert.assertEquals(properties.isEncrypted(), result.isEncrypted()); } stream.flip(); stream.put(10, (byte) (stream.get(10) + 1)); try { MessageFormatRecord.deserializeBlobProperties(new ByteBufferInputStream(stream)); fail("Deserialization of BlobProperties should have failed "); } catch (MessageFormatException e) { Assert.assertEquals(e.getErrorCode(), MessageFormatErrorCodes.Data_Corrupt); } } BlobProperties properties = new BlobProperties(1000, "id", "member", "test", true, Utils.Infinite_Time, Account.UNKNOWN_ACCOUNT_ID, Container.UNKNOWN_CONTAINER_ID, false, null); ByteBuffer stream = ByteBuffer.allocate(getBlobPropertiesRecordSize(properties) - 10); try { MessageFormatRecord.BlobProperties_Format_V1.serializeBlobPropertiesRecord(stream, properties); Assert.fail("Serialization of BlobProperties should have failed since the buffer does not have sufficient space"); } catch (IllegalArgumentException e) { } }
public static BlobProperties deserializeBlobProperties(InputStream stream) throws IOException, MessageFormatException { return deserializeAndGetBlobPropertiesWithVersion(stream).getBlobProperties(); }
MessageFormatRecord { public static BlobProperties deserializeBlobProperties(InputStream stream) throws IOException, MessageFormatException { return deserializeAndGetBlobPropertiesWithVersion(stream).getBlobProperties(); } }
MessageFormatRecord { public static BlobProperties deserializeBlobProperties(InputStream stream) throws IOException, MessageFormatException { return deserializeAndGetBlobPropertiesWithVersion(stream).getBlobProperties(); }  }
MessageFormatRecord { public static BlobProperties deserializeBlobProperties(InputStream stream) throws IOException, MessageFormatException { return deserializeAndGetBlobPropertiesWithVersion(stream).getBlobProperties(); }  static boolean isValidHeaderVersion(short headerVersion); static short getCurrentMessageHeaderVersion(); static int getHeaderSizeForVersion(short headerVersion); static MessageHeader_Format getMessageHeader(short headerVersion, ByteBuffer input); static BlobProperties deserializeBlobProperties(InputStream stream); static UpdateRecord deserializeUpdateRecord(InputStream stream); static ByteBuffer deserializeBlobEncryptionKey(InputStream stream); static ByteBuffer deserializeUserMetadata(InputStream stream); static BlobData deserializeBlob(InputStream stream); static BlobAll deserializeBlobAll(InputStream stream, StoreKeyFactory storeKeyFactory); }
MessageFormatRecord { public static BlobProperties deserializeBlobProperties(InputStream stream) throws IOException, MessageFormatException { return deserializeAndGetBlobPropertiesWithVersion(stream).getBlobProperties(); }  static boolean isValidHeaderVersion(short headerVersion); static short getCurrentMessageHeaderVersion(); static int getHeaderSizeForVersion(short headerVersion); static MessageHeader_Format getMessageHeader(short headerVersion, ByteBuffer input); static BlobProperties deserializeBlobProperties(InputStream stream); static UpdateRecord deserializeUpdateRecord(InputStream stream); static ByteBuffer deserializeBlobEncryptionKey(InputStream stream); static ByteBuffer deserializeUserMetadata(InputStream stream); static BlobData deserializeBlob(InputStream stream); static BlobAll deserializeBlobAll(InputStream stream, StoreKeyFactory storeKeyFactory); static final int Version_Field_Size_In_Bytes; static final int Crc_Size; static final short Message_Header_Version_V1; static final short Message_Header_Version_V2; static final short Message_Header_Version_V3; static final short BlobProperties_Version_V1; static final short Update_Version_V1; static final short Update_Version_V2; static final short Update_Version_V3; static final short Blob_Encryption_Key_V1; static final short UserMetadata_Version_V1; static final short Blob_Version_V1; static final short Blob_Version_V2; static final short Metadata_Content_Version_V2; static final short Metadata_Content_Version_V3; static final int Message_Header_Invalid_Relative_Offset; }