use of com.zimbra.cs.mailclient.imap.AppendResult in project zm-mailbox by Zimbra.
the class TestImapClient method testDelete.
@Test
public void testDelete() throws Exception {
login();
MailboxInfo mb = connection.select("INBOX");
long exists = mb.getExists();
AppendResult res = connection.append("INBOX", Flags.fromSpec("fs"), new Date(System.currentTimeMillis()), new Literal(Ascii.getBytes(MESSAGE)));
assertNotNull(res);
mb = connection.select("INBOX");
assertEquals(exists, mb.getExists() - 1);
connection.uidStore(String.valueOf(res.getUid()), "+FLAGS.SILENT", Flags.fromSpec("d"));
mb = connection.select("INBOX");
assertEquals(exists, mb.getExists() - 1);
connection.expunge();
mb = connection.select("INBOX");
assertEquals(exists, mb.getExists());
}
use of com.zimbra.cs.mailclient.imap.AppendResult in project zm-mailbox by Zimbra.
the class TestImap method appendInvalidFlag.
private void appendInvalidFlag(String flag) throws IOException {
Literal msg = message(10);
Flags flags = Flags.fromSpec("afs");
flags.set(flag);
Date date = new Date(System.currentTimeMillis());
try {
AppendResult res = 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.AppendResult in project zm-mailbox by Zimbra.
the class TestImap method testMultiappend.
@Test
public void testMultiappend() throws Exception {
assertTrue(connection.hasCapability("MULTIAPPEND"));
assertTrue(connection.hasCapability("UIDPLUS"));
AppendMessage msg1 = new AppendMessage(null, null, literal("test 1"));
AppendMessage msg2 = new AppendMessage(null, null, literal("test 2"));
AppendResult res = connection.append("INBOX", msg1, msg2);
assertNotNull(res);
assertEquals("expecting 2 uids", 2, res.getUids().length);
}
use of com.zimbra.cs.mailclient.imap.AppendResult in project zm-mailbox by Zimbra.
the class TestImap method testCatenateUrl.
@Test
public void testCatenateUrl() throws Exception {
assertTrue(connection.hasCapability("CATENATE"));
assertTrue(connection.hasCapability("UIDPLUS"));
String msg1 = simpleMessage("test message");
AppendResult res1 = connection.append("INBOX", null, null, literal(msg1));
String s1 = "first part\r\n";
String s2 = "second part\r\n";
String msg2 = msg1 + s1 + s2;
AppendMessage am = new AppendMessage(null, null, url("INBOX", res1), literal(s1), literal(s2));
AppendResult res2 = connection.append("INBOX", am);
connection.select("INBOX");
byte[] b2 = fetchBody(res2.getUid());
assertArrayEquals("content mismatch", bytes(msg2), b2);
}
use of com.zimbra.cs.mailclient.imap.AppendResult in project zm-mailbox by Zimbra.
the class TestImap method testAppend.
@Test
public void testAppend() throws Exception {
assertTrue(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(res);
byte[] b = fetchBody(res.getUid());
assertArrayEquals("content mismatch", msg.getBytes(), b);
} finally {
msg.dispose();
}
}
Aggregations