use of com.zimbra.cs.mailclient.imap.AppendResult in project zm-mailbox by Zimbra.
the class TestImapClient method testAppend.
@Test
public void testAppend() throws Exception {
login();
MailboxInfo mb = connection.select("INBOX");
long exists = mb.getExists();
Date date = new Date((System.currentTimeMillis() / 1000) * 1000);
Flags flags = Flags.fromSpec("fs");
AppendResult res = connection.append("INBOX", Flags.fromSpec("fs"), date, new Literal(Ascii.getBytes(MESSAGE)));
assertNotNull(res);
mb = connection.select("INBOX");
assertEquals(1, mb.getExists() - exists);
MessageData md = connection.uidFetch(res.getUid(), "(FLAGS BODY.PEEK[] INTERNALDATE)");
assertNotNull(md);
assertEquals(date, md.getInternalDate());
assertEquals(res.getUid(), md.getUid());
assertEquals(flags, md.getFlags());
Body[] parts = md.getBodySections();
assertNotNull(parts);
assertEquals(1, parts.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();
}
}
use of com.zimbra.cs.mailclient.imap.AppendResult in project zm-mailbox by Zimbra.
the class ImapTestBase method doAppend.
protected AppendResult doAppend(ImapConnection conn, String folderName, String subject, String body, Flags flags, boolean fetchResult) {
checkConnection(conn);
assertTrue("expecting UIDPLUS capability", conn.hasCapability("UIDPLUS"));
String msg = simpleMessage(subject, body);
Date date = new Date(System.currentTimeMillis());
AppendMessage am = new AppendMessage(flags, date, literal(msg));
try {
AppendResult res = conn.append(folderName, am);
assertNotNull("result of append command should not be null", res);
if (fetchResult) {
doSelectShouldSucceed(conn, folderName);
MessageData md = fetchMessage(conn, res.getUid());
byte[] b = getBody(md);
assertArrayEquals("FETCH content not same as APPENDed content", msg.getBytes(), b);
}
return res;
} catch (IOException e) {
ZimbraLog.test.info("Exception thrown trying to append", e);
fail("Exception thrown trying to append:" + e.getMessage());
}
return null;
}
use of com.zimbra.cs.mailclient.imap.AppendResult 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();
}
}
Aggregations