use of com.zimbra.cs.mailclient.imap.Flags in project zm-mailbox by Zimbra.
the class SharedImapNotificationTests method testRenameTagNotificationCachedFolder.
@Test
public void testRenameTagNotificationCachedFolder() throws Exception {
String folderName1 = "TestRemoteImapNotifications-folder1";
String folderName2 = "TestRemoteImapNotifications-folder2";
String tagName = "TestRemoteImapNotifications-tag";
String newTagName = "TestRemoteImapNotifications-tag2";
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(flags.contains(new Atom(tagName)));
info = connection.select(folderName2);
MailboxOperation renameTag = new MailboxOperation() {
@Override
protected void run(ZMailbox zmbox) throws Exception {
zmbox.renameTag(tag.getId(), newTagName);
}
@Override
protected String checkResult() throws Exception {
MailboxInfo info = connection.select(folderName1);
Flags flags = info.getPermanentFlags();
if (flags.contains(new Atom(tagName))) {
return String.format("Flags should NOT contain %s", tagName);
}
if (!flags.contains(new Atom(newTagName))) {
return String.format("Flags should contain %s", newTagName);
}
return null;
}
};
runOp(renameTag, zmbox, folder);
}
use of com.zimbra.cs.mailclient.imap.Flags in project zm-mailbox by Zimbra.
the class SharedImapTests method appendInvalidFlag.
private void appendInvalidFlag(String flag) throws IOException {
connection = connectAndSelectInbox();
Literal msg = message(10);
Flags flags = Flags.fromSpec("afs");
flags.set(flag);
Date date = new Date(System.currentTimeMillis());
try {
connection.append("INBOX", flags, date, msg);
fail("server allowed client to set system flag " + flag);
} catch (CommandFailedException e) {
// expected
} finally {
msg.dispose();
}
// do a no-op so we don't hit max consecutive error limit
connection.noop();
}
use of com.zimbra.cs.mailclient.imap.Flags in project zm-mailbox by Zimbra.
the class SharedImapTests method testCopyThrottle.
@Test(timeout = 100000)
public void testCopyThrottle() throws IOException {
connection = connectAndSelectInbox();
Flags flags = Flags.fromSpec("afs");
for (int i = 0; i < 3; i++) {
Date date = new Date(System.currentTimeMillis());
Literal msg = message(1000 + i * 1000);
try {
connection.append("INBOX", flags, date, msg);
} finally {
msg.dispose();
}
}
connection.create("FOO");
for (int i = 0; i < LOOP_LIMIT; i++) {
connection.copy("1:3", "FOO");
}
try {
connection.copy("1:3", "FOO");
fail("should have been rejected");
} catch (CommandFailedException e) {
assertTrue("expecting connection to be closed", connection.isClosed());
}
}
use of com.zimbra.cs.mailclient.imap.Flags in project zm-mailbox by Zimbra.
the class SharedImapTests method testAppendFlags.
@Test(timeout = 100000)
public void testAppendFlags() throws Exception {
connection = connectAndSelectInbox();
assertTrue("expecting UIDPLUS capability", connection.hasCapability("UIDPLUS"));
Flags flags = Flags.fromSpec("afs");
Date date = new Date(System.currentTimeMillis());
Literal msg = message(100000);
try {
AppendResult res = connection.append("INBOX", flags, date, msg);
assertNotNull("result of append command should not be null", res);
MessageData md = fetchMessage(connection, res.getUid());
Flags msgFlags = md.getFlags();
assertTrue("expecting isAnswered flag", msgFlags.isAnswered());
assertTrue("expecting isFlagged flag", msgFlags.isFlagged());
assertTrue("expecting isSeen flag", msgFlags.isSeen());
byte[] b = getBody(md);
assertArrayEquals("content mismatch", msg.getBytes(), b);
} finally {
msg.dispose();
}
}
use of com.zimbra.cs.mailclient.imap.Flags in project zm-mailbox by Zimbra.
the class SharedImapTests method testSortThrottle.
@Test(timeout = 100000)
public void testSortThrottle() throws IOException {
connection = connectAndSelectInbox();
Flags flags = Flags.fromSpec("afs");
for (int i = 0; i < 3; i++) {
Date date = new Date(System.currentTimeMillis());
Literal msg = message(1000 + i * 1000);
try {
connection.append("INBOX", flags, date, msg);
} finally {
msg.dispose();
}
}
for (int i = 0; i < LOOP_LIMIT; i++) {
connection.newRequest("SORT (DATE REVERSE SUBJECT) UTF-8 ALL").sendCheckStatus();
}
try {
connection.newRequest("SORT (DATE REVERSE SUBJECT) UTF-8 ALL").sendCheckStatus();
fail("should have been rejected");
} catch (CommandFailedException e) {
assertTrue("expecting connection to be closed", connection.isClosed());
}
}
Aggregations