use of com.zimbra.cs.store.StoreManager in project zm-mailbox by Zimbra.
the class TestBlobDeduper method testBlobDeduper.
@Test
public void testBlobDeduper() throws Exception {
StoreManager storeMgr = StoreManager.getInstance();
TestUtil.assumeTrue(String.format("StoreManager class=%s is not FileBlobStore", storeMgr.getClass().getName()), storeMgr instanceof FileBlobStore);
DeliveryOptions opt = new DeliveryOptions();
opt.setFolderId(Mailbox.ID_FOLDER_INBOX);
String[] paths = new String[5];
Volume vol = VolumeManager.getInstance().getCurrentMessageVolume();
for (int i = 0; i < 5; i++) {
Message msg = mbox.addMessage(null, new ParsedMessage(("From: test@zimbra.com\r\nTo: to1@zimbra.com\r\nSubject: " + TEST_NAME).getBytes(), false), opt, null);
paths[i] = msg.getBlob().getLocalBlob().getFile().getPath();
}
// Make sure inodes are different for paths
for (int i = 0; i < 4; i++) {
Assert.assertFalse(IO.fileInfo(paths[i]).getInodeNum() == IO.fileInfo(paths[i + 1]).getInodeNum());
}
// wait for a seconds, so that timestamp gets changed.
Thread.sleep(1000);
BlobDeduper deduper = BlobDeduper.getInstance();
List<Short> volumeIds = new ArrayList<Short>();
volumeIds.add(vol.getId());
deduper.process(volumeIds);
while (deduper.isRunning()) {
// wait until deduper finishes.
Thread.sleep(1000);
}
// Make sure inodes are same for paths
for (int i = 0; i < 4; i++) {
Assert.assertTrue(IO.fileInfo(paths[i]).getInodeNum() == IO.fileInfo(paths[i + 1]).getInodeNum());
}
}
use of com.zimbra.cs.store.StoreManager in project zm-mailbox by Zimbra.
the class TestStoreManager method testStore.
@Test
public void testStore() throws Exception {
ParsedMessage pm = getMessage();
byte[] mimeBytes = TestUtil.readInputStream(pm.getRawInputStream());
Mailbox mbox = TestUtil.getMailbox(USER_NAME);
StoreManager sm = StoreManager.getInstance();
Blob blob = sm.storeIncoming(pm.getRawInputStream());
Assert.assertEquals("blob size = message size", pm.getRawData().length, blob.getRawSize());
Assert.assertTrue("blob content = mime content", TestUtil.bytesEqual(mimeBytes, 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(mimeBytes, mblob.getLocalBlob().getInputStream()));
mblob = sm.getMailboxBlob(mbox, 0, 0, staged.getLocator());
Assert.assertEquals("mblob size = staged size", staged.getSize(), mblob.getSize());
Assert.assertTrue("mailboxblob content = mime content", TestUtil.bytesEqual(mimeBytes, mblob.getLocalBlob().getInputStream()));
}
Aggregations