use of com.zimbra.soap.mail.type.MsgToSend in project zm-mailbox by Zimbra.
the class TestContentTransferEncoding method testBug98015.
/*
* Tests that the message from bug 98015 retains the correct Content Transfer Encoding via the mechanism of
* inferring it from the existing message referenced by the "origid" parameter.
* This scenario also happens to test the case when a CTE header on a sub-part is inherited from the top-level.
*/
@Ignore("disabled until bug 98015 is fixed")
@Test
public void testBug98015() throws Exception {
MimeMessage mimeMsg = new ZMimeMessage(JMSession.getSession(), new SharedByteArrayInputStream(getBug98015MimeString().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: QP bug");
msgToSend.setMimePart(MimePartInfo.createForContentTypeAndContent("text/plain", "\n\n----- Forwarded Message -----\nSubject: QP Bug\n\n\\รถ/\nid=577281"));
AttachmentsInfo attach = new AttachmentsInfo();
attach.addAttachment(new MimePartAttachSpec(String.valueOf(msg.getId()), "2"));
msgToSend.setAttachments(attach);
SendMsgRequest req = new SendMsgRequest();
req.setMsg(msgToSend);
MimeMessage parsed = sendForwardedMessage(req, msg);
ZMimeMultipart mmp = (ZMimeMultipart) parsed.getContent();
assertEquals("8bit", mmp.getBodyPart(0).getHeader("Content-Transfer-Encoding")[0]);
assertEquals("base64", mmp.getBodyPart(1).getHeader("Content-Transfer-Encoding")[0]);
}
use of com.zimbra.soap.mail.type.MsgToSend 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.soap.mail.type.MsgToSend in project zm-mailbox by Zimbra.
the class SendMsgRequestTest method marshal.
@Test
public void marshal() throws Exception {
SendMsgRequest req = new SendMsgRequest();
MsgToSend msg = new MsgToSend();
msg.setHeaders(ImmutableList.of(new Msg.Header("name1", "value1"), new Msg.Header("name2", "value2")));
req.setMsg(msg);
Element jaxbElem = JaxbUtil.jaxbToElement(req);
logInfo("XML Element from JAXB:" + jaxbElem.toString());
Assert.assertEquals("SendMsgRequest elem name", MailConstants.E_SEND_MSG_REQUEST, jaxbElem.getName());
Assert.assertEquals("SendMsgRequest elem ns", MailConstants.NAMESPACE_STR, jaxbElem.getQName().getNamespaceURI());
List<Element> hdrs = jaxbElem.getElement(MailConstants.E_MSG).listElements(MailConstants.E_HEADER);
Assert.assertEquals("SendMsgRequest header 1 name", "name1", hdrs.get(0).getAttribute("name"));
Assert.assertEquals("SendMsgRequest header 2 name", "name2", hdrs.get(1).getAttribute("name"));
Assert.assertEquals("SendMsgRequest header 1 value", "value1", hdrs.get(0).getText());
Assert.assertEquals("SendMsgRequest header 2 value", "value2", hdrs.get(1).getText());
}
use of com.zimbra.soap.mail.type.MsgToSend in project zm-mailbox by Zimbra.
the class TestContentTransferEncoding method testSimpleMimeMessage.
/*
* This tests the CTE header of a forwarded message being inferred from the existing message when the message is a simple MIME message
*/
@Ignore("disabled until bug 98015 is fixed")
@Test
public void testSimpleMimeMessage() throws Exception {
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
MimeMessage mimeMsg = new ZMimeMessage(JMSession.getSession(), new SharedByteArrayInputStream(getSimpleMimeString().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: Simple Test");
msgToSend.setMimePart(MimePartInfo.createForContentTypeAndContent("text/plain", "simple test"));
SendMsgRequest req = new SendMsgRequest();
req.setMsg(msgToSend);
MimeMessage parsed = sendForwardedMessage(req, msg);
assertEquals("test", parsed.getHeader("Content-Transfer-Encoding")[0]);
}
use of com.zimbra.soap.mail.type.MsgToSend in project zm-mailbox by Zimbra.
the class TestContentTransferEncoding method testNestedMultipartMessage.
/*
* Tests bug 103193, which is a regression introduced by bugfix for 98015.
* The problem seems to be that the MIME structure of the forwarded message doesn't match the structure
* of the original, which is assumed by the bugfix. Specifically, it lacks the top-level multipart/mixed parent.
*/
@Test
public void testNestedMultipartMessage() throws Exception {
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
MimeMessage mimeMsg = new ZMimeMessage(JMSession.getSession(), new SharedByteArrayInputStream(getNestedMimeString().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", "text content"));
mimeParts.add(MimePartInfo.createForContentTypeAndContent("text/html", "html content"));
mpi.setMimeParts(mimeParts);
msgToSend.setMimePart(mpi);
SendMsgRequest req = new SendMsgRequest();
req.setMsg(msgToSend);
try {
MimeMessage parsed = sendForwardedMessage(req, msg);
} catch (ArrayIndexOutOfBoundsException e) {
fail("could not build MIME message");
}
}
Aggregations