use of com.zimbra.cs.mailclient.imap.MessageData in project zm-mailbox by Zimbra.
the class SharedImapNotificationTests method testDeleteFolderNotificationActiveFolder.
@Test
public void testDeleteFolderNotificationActiveFolder() throws Exception {
String folderName = "TestRemoteImapNotifications-folder";
String subject = "TestRemoteImapNotifications-testMessage";
ZMailbox zmbox = TestUtil.getZMailbox(USER);
ZFolder folder = TestUtil.createFolder(zmbox, folderName);
TestUtil.addMessage(zmbox, subject, folder.getId(), null);
connection = connect();
connection.login(PASS);
connection.select(folderName);
Map<Long, MessageData> mdMap = connection.fetch("1:*", "(ENVELOPE BODY)");
assertEquals("Size of map returned by initial fetch", 1, mdMap.size());
MailboxOperation deleteFolder = new MailboxOperation() {
@Override
protected void run(ZMailbox zmbox) throws Exception {
zmbox.deleteFolder(folder.getId());
}
@Override
protected String checkResult() throws Exception {
try {
connection.fetch("1:*", "(ENVELOPE BODY)");
return "should not be able to connect; connection should be closed";
}// connection is force closed
catch (SocketException | CommandFailedException e) {
}
return null;
}
};
runOp(deleteFolder, zmbox, folder);
}
use of com.zimbra.cs.mailclient.imap.MessageData in project zm-mailbox by Zimbra.
the class SharedImapNotificationTests method testNotificationsEmptyActiveFolder.
@Test
public void testNotificationsEmptyActiveFolder() throws Exception {
String folderName = "testNotificationsEmptyActiveFolder-folder";
String subject1 = "testNotificationsEmptyActiveFolder-msg";
ZMailbox zmbox = TestUtil.getZMailbox(USER);
ZFolder folder = TestUtil.createFolder(zmbox, folderName);
connection = connect();
connection.login(PASS);
connection.select(folderName);
MailboxOperation addMessage = new MailboxOperation() {
@Override
protected void run(ZMailbox zmbox) throws Exception {
TestUtil.addMessage(zmbox, subject1, folder.getId(), null);
}
@Override
protected String checkResult() throws Exception {
try {
Map<Long, MessageData> mdMap = connection.fetch("1:*", "(ENVELOPE BODY)");
if (mdMap.size() != 1) {
return String.format("Size of map returned by fetch should be 1. Getting %d", mdMap.size());
}
} catch (CommandFailedException cfe) {
return cfe.getError();
}
return null;
}
};
runOp(addMessage, zmbox, folder);
}
use of com.zimbra.cs.mailclient.imap.MessageData in project zm-mailbox by Zimbra.
the class ImapTestBase method fetchMessage.
protected MessageData fetchMessage(ImapConnection conn, long uid) throws IOException {
checkConnection(conn);
MessageData md = conn.uidFetch(uid, "(FLAGS BODY.PEEK[])");
assertNotNull(String.format("`UID FETCH %s (FLAGS BODY.PEEK[])` returned no data - assume message not found", uid), md);
assertEquals(String.format("`UID FETCH %s (FLAGS BODY.PEEK[])` returned wrong UID", uid), uid, md.getUid());
return md;
}
use of com.zimbra.cs.mailclient.imap.MessageData 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.MessageData in project zm-mailbox by Zimbra.
the class TestImap method fetchBody.
private byte[] fetchBody(long uid) throws IOException {
MessageData md = connection.uidFetch(uid, "(BODY.PEEK[])");
assertNotNull("message not found", md);
assertEquals(uid, md.getUid());
Body[] bs = md.getBodySections();
assertNotNull(bs);
assertEquals(1, bs.length);
return bs[0].getImapData().getBytes();
}
Aggregations