Search in sources :

Example 6 with MsgToSend

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());
}
Also used : Element(com.zimbra.common.soap.Element) SendMsgRequest(com.zimbra.soap.mail.message.SendMsgRequest) MsgToSend(com.zimbra.soap.mail.type.MsgToSend) Test(org.junit.Test)

Aggregations

SendMsgRequest (com.zimbra.soap.mail.message.SendMsgRequest)6 MsgToSend (com.zimbra.soap.mail.type.MsgToSend)6 Test (org.junit.Test)5 ZMimeMessage (com.zimbra.common.zmime.ZMimeMessage)4 DeliveryOptions (com.zimbra.cs.mailbox.DeliveryOptions)4 Message (com.zimbra.cs.mailbox.Message)4 ParseMimeMessage (com.zimbra.cs.service.mail.ParseMimeMessage)4 MimeMessage (javax.mail.internet.MimeMessage)4 SharedByteArrayInputStream (javax.mail.util.SharedByteArrayInputStream)4 Mailbox (com.zimbra.cs.mailbox.Mailbox)3 MimePartInfo (com.zimbra.soap.mail.type.MimePartInfo)3 Ignore (org.junit.Ignore)3 ZMimeMultipart (com.zimbra.common.zmime.ZMimeMultipart)2 LinkedList (java.util.LinkedList)2 Element (com.zimbra.common.soap.Element)1 SoapTransport (com.zimbra.common.soap.SoapTransport)1 SendMsgResponse (com.zimbra.soap.mail.message.SendMsgResponse)1 AttachmentsInfo (com.zimbra.soap.mail.type.AttachmentsInfo)1 EmailAddrInfo (com.zimbra.soap.mail.type.EmailAddrInfo)1 MimePartAttachSpec (com.zimbra.soap.mail.type.MimePartAttachSpec)1