use of com.zimbra.cs.mailclient.imap.MailboxInfo in project zm-mailbox by Zimbra.
the class TestImapClient method createTestMailbox.
private void createTestMailbox(String name, int count) throws IOException, MessagingException {
if (!connection.exists(name)) {
connection.create(name);
}
MailboxInfo mb = connection.select(name);
for (int i = (int) mb.getExists(); i < count; i++) {
MimeMessage mm = newTestMessage(i);
long uid = uidAppend(mm, null, null);
LOG.debug("Appended test message " + i + ", uid = " + uid);
}
}
use of com.zimbra.cs.mailclient.imap.MailboxInfo in project zm-mailbox by Zimbra.
the class TestImap method testStoreTagsDirty.
@Test
public void testStoreTagsDirty() throws Exception {
ZMailbox mbox = TestUtil.getZMailbox(USER);
List<ZTag> tags = mbox.getAllTags();
assertTrue(tags == null || tags.size() == 0);
String tagName = "T1";
final String tagName2 = "T2";
ZTag tag = mbox.getTag(tagName);
if (tag == null) {
tag = mbox.createTag(tagName, Color.blue);
}
tags = mbox.getAllTags();
assertTrue(tags != null && tags.size() == 1);
assertEquals("T1", tags.get(0).getName());
String folderName = "newfolder1";
ZFolder folder = mbox.createFolder(Mailbox.ID_FOLDER_USER_ROOT + "", folderName, ZFolder.View.message, ZFolder.Color.DEFAULTCOLOR, null, null);
mbox.addMessage(Mailbox.ID_FOLDER_INBOX + "", "u", tag.getId(), System.currentTimeMillis(), simpleMessage("foo1"), true);
MailboxInfo info = connection.select("INBOX");
assertTrue("INBOX does not contain expected flag " + tagName, info.getFlags().isSet(tagName));
assertFalse("INBOX contain unexpected flag " + tagName2, info.getFlags().isSet(tagName2));
Map<Long, MessageData> data = connection.fetch("1:*", "FLAGS");
assertEquals(1, data.size());
Iterator<Long> it = data.keySet().iterator();
Long seq = it.next();
assertTrue("flag not set on first message", data.get(seq).getFlags().isSet(tagName));
ImapRequest req = connection.newRequest("STORE", seq + "", "+FLAGS", tagName2);
req.setResponseHandler(new ResponseHandler() {
@Override
public void handleResponse(ImapResponse res) throws Exception {
if (res.isUntagged() && res.getCCode() == CAtom.FLAGS) {
Flags flags = (Flags) res.getData();
assertTrue(flags.isSet(tagName2));
}
}
});
req.sendCheckStatus();
}
use of com.zimbra.cs.mailclient.imap.MailboxInfo in project zm-mailbox by Zimbra.
the class TestImap method testStoreInvalidSystemFlag.
@Test
public void testStoreInvalidSystemFlag() throws Exception {
ZMailbox mbox = TestUtil.getZMailbox(USER);
mbox.addMessage(Mailbox.ID_FOLDER_INBOX + "", "u", "", System.currentTimeMillis(), simpleMessage("foo"), true);
MailboxInfo info = connection.select("INBOX");
Map<Long, MessageData> data = connection.fetch("1:*", "FLAGS");
assertEquals(1, data.size());
Iterator<Long> it = data.keySet().iterator();
Long seq = it.next();
storeInvalidFlag("\\Bulk", seq);
storeInvalidFlag("\\Unread", seq);
storeInvalidFlag("\\Forwarded", seq);
}
use of com.zimbra.cs.mailclient.imap.MailboxInfo in project zm-mailbox by Zimbra.
the class TestImap method testAppendTagsDirty.
@Test
public void testAppendTagsDirty() throws Exception {
Flags flags = Flags.fromSpec("afs");
//new tag; does not exist in mbox
final String tag1 = "NEWDIRTYTAG";
MailboxInfo info = connection.select("INBOX");
assertFalse("INBOX contains unexpected flag " + tag1, info.getFlags().isSet(tag1));
flags.set(tag1);
Date date = new Date(System.currentTimeMillis());
Literal msg = message(10);
try {
ImapRequest req = connection.newRequest("APPEND", "INBOX", flags, date, msg);
req.setResponseHandler(new ResponseHandler() {
@Override
public void handleResponse(ImapResponse res) throws Exception {
if (res.isUntagged() && res.getCCode() == CAtom.FLAGS) {
Flags flags = (Flags) res.getData();
assertTrue(flags.isSet(tag1));
}
}
});
req.sendCheckStatus();
} finally {
msg.dispose();
}
}
use of com.zimbra.cs.mailclient.imap.MailboxInfo in project zm-mailbox by Zimbra.
the class TestImapSync method testSync.
@Test
public void testSync() throws Exception {
LOG.info("Testing adding message to local mailbox");
ZFolder folder = TestUtil.createFolder(localMailbox, TEST_FOLDER_1);
TestUtil.addMessage(localMailbox, "msg1", folder.getId(), "u");
Assert.assertFalse(imapFolder1.exists());
syncFolders();
Assert.assertTrue(imapFolder1.exists());
MailboxInfo mb = imapFolder1.select();
Assert.assertEquals(1, mb.getExists());
Assert.assertEquals(1, mb.getUnseen());
}
Aggregations