use of com.zimbra.cs.mailbox.DeliveryOptions in project zm-mailbox by Zimbra.
the class TestContentTransferEncoding method testMultipartMimeMessage.
/*
* This tests the CTE header of a forwarded message being inferred from the existing message when the message is a multipart message.
*/
@Ignore("disabled until bug 98015 is fixed")
@Test
public void testMultipartMimeMessage() throws Exception {
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
MimeMessage mimeMsg = new ZMimeMessage(JMSession.getSession(), new SharedByteArrayInputStream(getMultipartMimeString().getBytes()));
ParsedMessage pm = new ParsedMessage(mimeMsg, true);
DeliveryOptions dopt = new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX);
Message msg = mbox.addMessage(null, pm, dopt, null);
MsgToSend msgToSend = new MsgToSend();
msgToSend.setOrigId(String.valueOf(msg.getId()));
msgToSend.setReplyType("w");
msgToSend.setSubject("Fwd: Multipart Test");
MimePartInfo mpi = new MimePartInfo();
mpi.setContentType("multipart/alternative");
List<MimePartInfo> mimeParts = new LinkedList<MimePartInfo>();
mimeParts.add(MimePartInfo.createForContentTypeAndContent("text/plain", "multipart test"));
mimeParts.add(MimePartInfo.createForContentTypeAndContent("text/html", "multipart test"));
mpi.setMimeParts(mimeParts);
msgToSend.setMimePart(mpi);
SendMsgRequest req = new SendMsgRequest();
req.setMsg(msgToSend);
MimeMessage parsed = sendForwardedMessage(req, msg);
ZMimeMultipart mmp = (ZMimeMultipart) parsed.getContent();
assertEquals("test1", mmp.getBodyPart(0).getHeader("Content-Transfer-Encoding")[0]);
assertEquals("test2", mmp.getBodyPart(1).getHeader("Content-Transfer-Encoding")[0]);
}
use of com.zimbra.cs.mailbox.DeliveryOptions in project zm-mailbox by Zimbra.
the class GetMsgTest method testMsgHeaderN.
@Test
public void testMsgHeaderN() throws Exception {
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
MimeMessage message = new JavaMailMimeMessage(JMSession.getSession(), new ZSharedFileInputStream("data/unittest/email/bug_75163.txt"));
ParsedMessage pm = new ParsedMessage(message, false);
DeliveryOptions dopt = new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX);
Message msg = mbox.addMessage(null, pm, dopt, null);
Element request = new Element.XMLElement(MailConstants.GET_MSG_REQUEST);
Element action = request.addElement(MailConstants.E_MSG);
action.addAttribute(MailConstants.A_ID, msg.getId());
action.addElement(MailConstants.A_HEADER).addAttribute(MailConstants.A_ATTRIBUTE_NAME, "Return-Path");
Element response = new GetMsg().handle(request, ServiceTestUtil.getRequestContext(mbox.getAccount())).getElement(MailConstants.E_MSG);
List<Element> headerN = response.listElements(MailConstants.A_HEADER);
for (Element elt : headerN) {
Assert.assertEquals(elt.getText(), "foo@example.com");
}
}
use of com.zimbra.cs.mailbox.DeliveryOptions in project zm-mailbox by Zimbra.
the class GetMsgTest method testMsgMaxAttr.
@Test
public void testMsgMaxAttr() throws Exception {
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
MimeMessage message = new JavaMailMimeMessage(JMSession.getSession(), new ZSharedFileInputStream("data/TestMailRaw/1"));
ParsedMessage pm = new ParsedMessage(message, false);
DeliveryOptions dopt = new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX);
Message msg = mbox.addMessage(null, pm, dopt, null);
Element request = new Element.XMLElement(MailConstants.GET_MSG_REQUEST);
Element action = request.addElement(MailConstants.E_MSG);
action.addAttribute(MailConstants.A_ID, msg.getId());
action.addAttribute(MailConstants.A_MAX_INLINED_LENGTH, 10);
Element response = new GetMsg().handle(request, ServiceTestUtil.getRequestContext(mbox.getAccount())).getElement(MailConstants.E_MSG);
Assert.assertEquals(response.getElement(MailConstants.E_MIMEPART).getElement(MailConstants.E_CONTENT).getText().length(), 10);
}
use of com.zimbra.cs.mailbox.DeliveryOptions in project zm-mailbox by Zimbra.
the class ItemActionTest method deleteIncompleteConversation.
@Test
public void deleteIncompleteConversation() throws Exception {
Account acct = Provisioning.getInstance().get(Key.AccountBy.name, "test@zimbra.com");
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(acct);
acct.setMailThreadingAlgorithm(MailThreadingAlgorithm.subject);
// setup: add the root message
ParsedMessage pm = MailboxTestUtil.generateMessage("test subject");
DeliveryOptions dopt = new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX);
int rootId = mbox.addMessage(null, pm, dopt, null).getId();
// add additional messages
pm = MailboxTestUtil.generateMessage("Re: test subject");
Message draft = mbox.saveDraft(null, pm, Mailbox.ID_AUTO_INCREMENT, rootId + "", MailSender.MSGTYPE_REPLY, null, null, 0);
Message parent = mbox.getMessageById(null, rootId);
Assert.assertEquals(parent.getConversationId(), draft.getConversationId());
pm = MailboxTestUtil.generateMessage("Re: test subject");
Message draft2 = mbox.saveDraft(null, pm, Mailbox.ID_AUTO_INCREMENT);
parent = mbox.getMessageById(null, rootId);
Assert.assertEquals(parent.getConversationId(), draft2.getConversationId());
MailItem.TargetConstraint tcon = new MailItem.TargetConstraint(mbox, MailItem.TargetConstraint.INCLUDE_TRASH);
ItemId iid = new ItemId(mbox, Mailbox.ID_FOLDER_TRASH);
// trash one message in conversation
ItemActionHelper.MOVE(null, mbox, SoapProtocol.Soap12, Collections.singletonList(draft.getId()), MailItem.Type.MESSAGE, tcon, iid);
draft = mbox.getMessageById(null, draft.getId());
Assert.assertEquals(draft.getFolderId(), Mailbox.ID_FOLDER_TRASH);
ItemActionHelper.HARD_DELETE(null, mbox, SoapProtocol.Soap12, Collections.singletonList(draft.getConversationId()), MailItem.Type.CONVERSATION, tcon);
// the messages not in the trash should still exist and attached to the same conversation
parent = mbox.getMessageById(null, rootId);
Message m = mbox.getMessageById(null, draft2.getId());
Assert.assertEquals(parent.getConversationId(), m.getConversationId());
}
use of com.zimbra.cs.mailbox.DeliveryOptions in project zm-mailbox by Zimbra.
the class ItemActionTest method deleteConversation.
@Test
public void deleteConversation() throws Exception {
Account acct = Provisioning.getInstance().get(Key.AccountBy.name, "test@zimbra.com");
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(acct);
acct.setMailThreadingAlgorithm(MailThreadingAlgorithm.subject);
// setup: add the root message
ParsedMessage pm = MailboxTestUtil.generateMessage("test subject");
DeliveryOptions dopt = new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX);
int rootId = mbox.addMessage(null, pm, dopt, null).getId();
// add additional messages
pm = MailboxTestUtil.generateMessage("Re: test subject");
Message draft = mbox.saveDraft(null, pm, Mailbox.ID_AUTO_INCREMENT, rootId + "", MailSender.MSGTYPE_REPLY, null, null, 0);
Message parent = mbox.getMessageById(null, rootId);
Assert.assertEquals(parent.getConversationId(), draft.getConversationId());
pm = MailboxTestUtil.generateMessage("Re: test subject");
Message draft2 = mbox.saveDraft(null, pm, Mailbox.ID_AUTO_INCREMENT);
parent = mbox.getMessageById(null, rootId);
Assert.assertEquals(parent.getConversationId(), draft2.getConversationId());
MailItem.TargetConstraint tcon = new MailItem.TargetConstraint(mbox, MailItem.TargetConstraint.INCLUDE_TRASH);
ItemId iid = new ItemId(mbox, Mailbox.ID_FOLDER_TRASH);
// trash the conversation
ItemActionHelper.MOVE(null, mbox, SoapProtocol.Soap12, Arrays.asList(parent.getId(), draft.getId(), draft2.getId()), MailItem.Type.MESSAGE, tcon, iid);
parent = mbox.getMessageById(null, parent.getId());
draft = mbox.getMessageById(null, draft.getId());
draft2 = mbox.getMessageById(null, draft2.getId());
Assert.assertEquals(parent.getFolderId(), Mailbox.ID_FOLDER_TRASH);
Assert.assertEquals(draft.getFolderId(), Mailbox.ID_FOLDER_TRASH);
Assert.assertEquals(draft2.getFolderId(), Mailbox.ID_FOLDER_TRASH);
ItemActionHelper.HARD_DELETE(null, mbox, SoapProtocol.Soap12, Collections.singletonList(parent.getConversationId()), MailItem.Type.CONVERSATION, tcon);
Exception ex = null;
try {
mbox.getMessageById(null, parent.getId());
} catch (Exception e) {
ex = e;
Assert.assertTrue(e instanceof NoSuchItemException);
}
Assert.assertNotNull(ex);
ex = null;
try {
mbox.getMessageById(null, draft.getId());
} catch (Exception e) {
ex = e;
Assert.assertTrue(e instanceof NoSuchItemException);
}
Assert.assertNotNull(ex);
ex = null;
try {
mbox.getMessageById(null, draft2.getId());
} catch (Exception e) {
ex = e;
Assert.assertTrue(e instanceof NoSuchItemException);
}
Assert.assertNotNull(ex);
ex = null;
try {
mbox.getConversationById(null, draft2.getConversationId());
} catch (Exception e) {
ex = e;
Assert.assertTrue(e instanceof NoSuchItemException);
}
Assert.assertNotNull(ex);
}
Aggregations