use of com.zimbra.cs.store.external.ContentAddressableStoreManager in project zm-mailbox by Zimbra.
the class TritonBlobStoreManagerTest method sisEmpty.
@Test
public void sisEmpty() throws Exception {
TritonBlobStoreManager sm = (TritonBlobStoreManager) StoreManager.getInstance();
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
Assert.assertTrue("StoreManager is content addressable", sm instanceof ContentAddressableStoreManager);
Assert.assertTrue("StoreManager supports SIS check", sm.supports(StoreFeature.SINGLE_INSTANCE_SERVER_CREATE));
byte[] bytes = new byte[0];
Blob blob = sm.storeIncoming(new ByteArrayInputStream(bytes));
// blob has not yet been finalized, so it shouldn't exist in remote system yet
byte[] hash = sm.getHash(blob);
Assert.assertNotNull("empty blob always exists", sm.getSisBlob(hash));
Assert.assertEquals("blob size = incoming written", bytes.length, blob.getRawSize());
Assert.assertTrue("blob content = mime content", TestUtil.bytesEqual(bytes, blob.getInputStream()));
StagedBlob staged = sm.stage(blob, mbox);
Assert.assertEquals("staged size = blob size", blob.getRawSize(), staged.getSize());
MailboxBlob mblob = sm.link(staged, mbox, 0, 0);
Assert.assertEquals("link size = staged size", staged.getSize(), mblob.getSize());
Assert.assertTrue("link content = mime content", TestUtil.bytesEqual(bytes, mblob.getLocalBlob().getInputStream()));
// blob uploaded, now sis should return true and increment ref count
Blob sisBlob = sm.getSisBlob(hash);
Assert.assertNotNull("object created", sisBlob);
Assert.assertEquals("blob size = incoming written", bytes.length, sisBlob.getRawSize());
Assert.assertTrue("blob content = mime content", TestUtil.bytesEqual(bytes, sisBlob.getInputStream()));
}
use of com.zimbra.cs.store.external.ContentAddressableStoreManager in project zm-mailbox by Zimbra.
the class TritonBlobStoreManagerTest method sis.
@Test
public void sis() throws Exception {
TritonBlobStoreManager sm = (TritonBlobStoreManager) StoreManager.getInstance();
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
Assert.assertTrue("StoreManager is content addressable", sm instanceof ContentAddressableStoreManager);
Assert.assertTrue("StoreManager supports SIS check", sm.supports(StoreFeature.SINGLE_INSTANCE_SERVER_CREATE));
Random rand = new Random();
byte[] bytes = new byte[10000];
rand.nextBytes(bytes);
Blob blob = sm.storeIncoming(new ByteArrayInputStream(bytes));
// blob has not yet been finalized, so it shouldn't exist in remote system yet
byte[] hash = sm.getHash(blob);
Assert.assertNull("object not yet created", sm.getSisBlob(hash));
Assert.assertEquals("blob size = incoming written", bytes.length, blob.getRawSize());
Assert.assertTrue("blob content = mime content", TestUtil.bytesEqual(bytes, blob.getInputStream()));
StagedBlob staged = sm.stage(blob, mbox);
Assert.assertEquals("staged size = blob size", blob.getRawSize(), staged.getSize());
MailboxBlob mblob = sm.link(staged, mbox, 0, 0);
Assert.assertEquals("link size = staged size", staged.getSize(), mblob.getSize());
Assert.assertTrue("link content = mime content", TestUtil.bytesEqual(bytes, mblob.getLocalBlob().getInputStream()));
// blob uploaded, now sis should return true and increment ref count
Blob sisBlob = sm.getSisBlob(hash);
Assert.assertNotNull("object created", sisBlob);
Assert.assertEquals("blob size = incoming written", bytes.length, sisBlob.getRawSize());
Assert.assertTrue("blob content = mime content", TestUtil.bytesEqual(bytes, sisBlob.getInputStream()));
// delete once, should still exist;
sm.delete(mblob);
Assert.assertNotNull("object still ref'd", sm.getSisBlob(hash));
// delete twice (once for original, once since we just did a sisCheck above)
sm.delete(mblob);
sm.delete(mblob);
Assert.assertNull("object deleted", sm.getSisBlob(hash));
}
Aggregations