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());
}
Aggregations