use of com.zimbra.cs.mailbox.DeliveryOptions in project zm-mailbox by Zimbra.
the class AbstractBlobConsistencyCheckTest method missingBlobs.
@Test
public void missingBlobs() throws Exception {
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
DeliveryOptions dopt = new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX);
int msgs = 10;
for (int i = 0; i < msgs; i++) {
mbox.addMessage(null, new ParsedMessage("From: test1-1@sub1.zimbra.com".getBytes(), false), dopt, null);
}
deleteAllBlobs();
BlobConsistencyChecker checker = getChecker();
Results results = checker.check(getVolumeIds(), mbox.getId(), true, false);
Assert.assertEquals(msgs, results.missingBlobs.size());
Assert.assertEquals(0, results.unexpectedBlobs.size());
Assert.assertEquals(0, results.usedBlobs.size());
Assert.assertEquals(0, results.incorrectSize.size());
Assert.assertEquals(0, results.incorrectModContent.size());
}
use of com.zimbra.cs.mailbox.DeliveryOptions in project zm-mailbox by Zimbra.
the class AbstractBlobConsistencyCheckTest method singleBlob.
@Test
public void singleBlob() throws Exception {
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
DeliveryOptions dopt = new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX);
mbox.addMessage(null, new ParsedMessage("From: test1-1@sub1.zimbra.com".getBytes(), false), dopt, null);
BlobConsistencyChecker checker = getChecker();
Results results = checker.check(getVolumeIds(), mbox.getId(), true, false);
Assert.assertEquals(0, results.unexpectedBlobs.size());
Assert.assertEquals(0, results.missingBlobs.size());
Assert.assertEquals(0, results.usedBlobs.size());
Assert.assertEquals(0, results.incorrectSize.size());
Assert.assertEquals(0, results.incorrectModContent.size());
}
use of com.zimbra.cs.mailbox.DeliveryOptions in project zm-mailbox by Zimbra.
the class IncomingMessageHandler method addMessage.
private Message addMessage(int folderId, Collection<ActionFlag> flagActions, String[] tags) throws ServiceException {
try {
DeliveryOptions dopt = new DeliveryOptions().setFolderId(folderId).setNoICal(noICal).setRecipientEmail(recipientAddress);
dopt.setFlags(FilterUtil.getFlagBitmask(flagActions, Flag.BITMASK_UNREAD)).setTags(tags);
return mailbox.addMessage(octxt, parsedMessage, dopt, dctxt);
} catch (IOException e) {
throw ServiceException.FAILURE("Unable to add incoming message", e);
}
}
use of com.zimbra.cs.mailbox.DeliveryOptions 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.mailbox.DeliveryOptions in project zm-mailbox by Zimbra.
the class TestZClient method testImapMODSEQ.
@Test
public void testImapMODSEQ() throws Exception {
Mailbox mbox = TestUtil.getMailbox(USER_NAME);
Folder folder = mbox.createFolder(null, NAME_PREFIX, new Folder.FolderOptions().setDefaultView(MailItem.Type.MESSAGE));
int folderId = folder.getId();
ZMailbox zmbox = TestUtil.getZMailbox(USER_NAME);
ZFolder zfolder = zmbox.getFolderById(Integer.toString(folderId));
int zmodSeq = zfolder.getImapMODSEQ();
assertEquals("Before adding a message, ZFolder modseq is not the same as folder modseq", zmodSeq, folder.getImapMODSEQ());
// add a message to the folder (there is a test in FolderTest which verifies that adding a message modifies imapmodseq)
DeliveryOptions dopt = new DeliveryOptions().setFolderId(folderId).setFlags(Flag.BITMASK_UNREAD);
String message = TestUtil.getTestMessage(NAME_PREFIX, mbox.getAccount().getName(), "someone@zimbra.com", "nothing here", new Date(System.currentTimeMillis()));
ParsedMessage pm = new ParsedMessage(message.getBytes(), System.currentTimeMillis(), false);
mbox.addMessage(null, pm, dopt, null);
// get notifications and update folder cache
zmbox.noOp();
zfolder = zmbox.getFolderById(Integer.toString(folderId));
folder = mbox.getFolderById(null, folderId);
assertEquals("After adding a message, ZFolder modseq is not the same as folder modseq", zfolder.getImapMODSEQ(), folder.getImapMODSEQ());
assertFalse("ZFolder modseq did not change after adding a message", zmodSeq == zfolder.getImapMODSEQ());
}
Aggregations