use of com.zimbra.cs.mailclient.imap.Flags in project zm-mailbox by Zimbra.
the class TestImapThrottle method append.
@Test
public void append() throws Exception {
assertTrue(connection.hasCapability("UIDPLUS"));
Date date = new Date(System.currentTimeMillis());
Flags flags = Flags.fromSpec("afs");
for (int i = 0; i < LOOP_LIMIT; i++) {
Literal msg = message(100000);
try {
connection.append("INBOX", flags, date, msg);
} finally {
msg.dispose();
}
}
Literal msg = message(100000);
try {
connection.append("INBOX", flags, date, msg);
Assert.fail("expected exception here...");
} catch (Exception e) {
Assert.assertTrue(connection.isClosed());
} finally {
msg.dispose();
}
}
use of com.zimbra.cs.mailclient.imap.Flags in project zm-mailbox by Zimbra.
the class SharedImapNotificationTests method testModifyItemNotificationActiveFolder.
@Test
public void testModifyItemNotificationActiveFolder() throws Exception {
String folderName = "testNotificationsActiveFolder-folder";
String subject = "testNotificationsActiveFolder-msg1";
String tagName = "testNotificationsActiveFolder-tag";
ZMailbox zmbox = TestUtil.getZMailbox(USER);
ZFolder folder = TestUtil.createFolder(zmbox, folderName);
ZTag tag = zmbox.createTag(tagName, Color.blue);
String msgId = TestUtil.addMessage(zmbox, subject, folder.getId(), null);
connection = connect();
connection.login(PASS);
connection.select(folderName);
Map<Long, MessageData> mdMap = connection.fetch("1:*", "(FLAGS)");
assertEquals("Size of map returned by fetch 1", 1, mdMap.size());
// sanity check - make sure the tag is not already set on the message
Flags flags = mdMap.get(1L).getFlags();
assertFalse(flags.contains(new Atom(tag.getName())));
MailboxOperation tagMessage = new MailboxOperation() {
@Override
protected void run(ZMailbox zmbox) throws Exception {
zmbox.tagMessage(msgId, tag.getId(), true);
}
@Override
protected String checkResult() throws Exception {
Map<Long, MessageData> mdMap = connection.fetch("1:*", "(FLAGS)");
if (mdMap.size() != 1) {
return String.format("Size of map returned by fetch should be 1. Getting %d", mdMap.size());
}
Flags flags = mdMap.get(1L).getFlags();
if (!flags.contains(new Atom(tag.getName()))) {
return String.format("Flags should contain %s", tag.getName());
}
return null;
}
};
runOp(tagMessage, zmbox, folder);
}
use of com.zimbra.cs.mailclient.imap.Flags in project zm-mailbox by Zimbra.
the class SharedImapNotificationTests method testDeleteTagNotificationCachedFolder.
@Test
public void testDeleteTagNotificationCachedFolder() throws Exception {
String folderName1 = "TestRemoteImapNotifications-folder";
String folderName2 = "TestRemoteImapNotifications-folder2";
String tagName = "TestRemoteImapNotifications-tag";
String subject = "TestRemoteImapNotifications-testMessage";
ZMailbox zmbox = TestUtil.getZMailbox(USER);
ZFolder folder = TestUtil.createFolder(zmbox, folderName1);
TestUtil.createFolder(zmbox, folderName2);
ZTag tag = zmbox.createTag(tagName, Color.blue);
zmbox.addMessage(folder.getId(), null, tag.getId(), 0, TestUtil.getTestMessage(subject), true);
connection = connect();
connection.login(PASS);
MailboxInfo info = connection.select(folderName1);
Flags flags = info.getPermanentFlags();
assertTrue("folder info should list tag", flags.contains(new Atom(tagName)));
Map<Long, MessageData> mdMap = connection.fetch("1:*", "(FLAGS)");
Flags msgFlags = mdMap.get(1L).getFlags();
assertTrue("message should be flagged with tag", msgFlags.contains(new Atom(tagName)));
connection.select(folderName2);
MailboxOperation deleteTag = new MailboxOperation() {
@Override
protected void run(ZMailbox zmbox) throws Exception {
zmbox.deleteTag(tag.getId());
}
@Override
protected String checkResult() throws Exception {
MailboxInfo info = connection.select(folderName1);
Flags flags = info.getPermanentFlags();
if (flags.contains(new Atom(tagName))) {
return String.format("folder info should not list tag %s", tagName);
}
Map<Long, MessageData> mdMap = connection.fetch("1:*", "(FLAGS)");
Flags msgFlags = mdMap.get(1L).getFlags();
if (msgFlags.contains(new Atom(tagName))) {
return String.format("message should not be flagged with %s", tagName);
}
return null;
}
};
runOp(deleteTag, zmbox, folder);
}
use of com.zimbra.cs.mailclient.imap.Flags in project zm-mailbox by Zimbra.
the class TestRemoteImapMultiServer method testAppend.
@Ignore("requires SELECT to work")
public void testAppend() throws Exception {
connection = connect(imapServer);
connection.login(PASS);
Assert.assertTrue("IMAP connection is not authenticated", connection.isAuthenticated());
assertTrue(connection.hasCapability("UIDPLUS"));
Flags flags = Flags.fromSpec("afs");
Date date = new Date(System.currentTimeMillis());
Literal msg = SharedImapTests.message(100000);
try {
AppendResult res = connection.append("INBOX", flags, date, msg);
assertNotNull(res);
byte[] b = fetchBody(res.getUid());
assertArrayEquals("content mismatch", msg.getBytes(), b);
} finally {
msg.dispose();
}
}
Aggregations