use of com.zimbra.cs.mailclient.imap.AppendResult in project zm-mailbox by Zimbra.
the class SharedImapTests method copyFromSharedFolderViaHome.
@Test(timeout = 100000)
public void copyFromSharedFolderViaHome() throws IOException, ServiceException, MessagingException {
TestUtil.createAccount(SHAREE);
ZMailbox shareeZmbox = TestUtil.getZMailbox(SHAREE);
connection = connectAndSelectInbox();
String sharedFolderName = String.format("INBOX/%s-shared", testId);
connection.create(sharedFolderName);
connection.setacl(sharedFolderName, SHAREE, "lrswickxteda");
String subject = String.format("%s-missiveSubject", testInfo.getMethodName());
String bodyStr = String.format("test message body for %s", testInfo.getMethodName());
String part1 = simpleMessage(subject, bodyStr);
String part2 = "more text\r\n";
AppendMessage am = new AppendMessage(null, null, literal(part1), literal(part2));
AppendResult res = connection.append(sharedFolderName, am);
assertNotNull(String.format("Append result to folder %s", sharedFolderName), res);
doSelectShouldSucceed(sharedFolderName);
doFetchShouldSucceed(connection, "1:*", "(ENVELOPE)", Lists.newArrayList(subject));
connection.logout();
connection = null;
String remFolder = String.format("/home/%s/%s", USER, sharedFolderName);
String copyToFolder = "INBOX/copy-to";
otherConnection = connectAndSelectInbox(SHAREE);
doCopy(otherConnection, shareeZmbox, remFolder, copyToFolder, subject);
}
use of com.zimbra.cs.mailclient.imap.AppendResult in project zm-mailbox by Zimbra.
the class SharedImapTests method doMultiappend.
private void doMultiappend(ImapConnection conn) throws Exception {
assertTrue(conn.hasCapability("MULTIAPPEND"));
assertTrue(conn.hasCapability("UIDPLUS"));
AppendMessage msg1 = new AppendMessage(null, null, literal("test 1"));
AppendMessage msg2 = new AppendMessage(null, null, literal("test 2"));
AppendResult res = conn.append("INBOX", msg1, msg2);
assertNotNull("Result of multi-append", 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 SharedImapTests method testAppendAndCount.
@Test(timeout = 100000)
public void testAppendAndCount() throws Exception {
connection = connectAndSelectInbox();
Date date = new Date(System.currentTimeMillis());
Literal msg = message(100000);
try {
MailboxInfo mi;
mi = new StatusExecutor(connection).execShouldSucceed("Sent", "MESSAGES", "UIDNEXT", "UIDVALIDITY", "UNSEEN", "HIGHESTMODSEQ");
long oldCount = mi.getExists();
AppendResult res = connection.append("SENT", null, date, msg);
assertNotNull("result of append command should not be null", res);
mi = new StatusExecutor(connection).execShouldSucceed("Sent", "MESSAGES", "UIDNEXT", "UIDVALIDITY", "UNSEEN", "HIGHESTMODSEQ");
long newCount = mi.getExists();
assertEquals("message count should have increased by one", oldCount, newCount - 1);
} 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, int size, Flags flags, boolean fetchResult) throws IOException {
checkConnection(conn);
assertTrue("expecting UIDPLUS capability", conn.hasCapability("UIDPLUS"));
Date date = new Date(System.currentTimeMillis());
Literal msg = message(size);
try {
AppendResult res = conn.append(folderName, flags, date, msg);
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("content mismatch", msg.getBytes(), b);
}
return res;
} finally {
msg.dispose();
}
}
use of com.zimbra.cs.mailclient.imap.AppendResult in project zm-mailbox by Zimbra.
the class SharedImapTests method doAppendThenOtherAppendReferencingFirst.
private void doAppendThenOtherAppendReferencingFirst(ImapConnection conn, String folder1, String folder2) throws IOException {
assertTrue(conn.hasCapability("CATENATE"));
assertTrue(conn.hasCapability("UIDPLUS"));
String msg1 = simpleMessage("message to exercise ImapURL");
AppendResult res1 = conn.append(folder1, 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(folder1, res1), literal(s1), literal(s2));
/* This append command expands into the following (most of the work being done inside AppendMessage)
* APPEND INBOX CATENATE (URL "/INBOX;UIDVALIDITY=1/;UID=257" TEXT {12+}
* first part
* TEXT {13+}
* second part
* )
*
* The URL in the above ends up being processed by the ImapURL class server side.
*/
AppendResult res2 = conn.append(folder2, am);
conn.select(folder2);
byte[] b2 = getBody(fetchMessage(conn, res2.getUid()));
String newMsg = new String(b2, "UTF-8");
assertEquals("Content of message not as expected", msg2, newMsg);
}
Aggregations