use of com.zimbra.soap.type.WaitSetAddSpec in project zm-mailbox by Zimbra.
the class JaxbToElementTest method jaxbBelowWrapperFixupTest.
/**
* Ensure that we still find attributes encoded as elements below a wrapped element in the hierarchy
* @throws Exception
*/
@Test
public void jaxbBelowWrapperFixupTest() throws Exception {
Element rootElem = Element.XMLElement.mFactory.createElement(MailConstants.WAIT_SET_REQUEST);
// JAXB Attribute - not Element
rootElem.addNonUniqueElement(MailConstants.A_WAITSET_ID).addText("myWaitSet");
// JAXB Attribute - not Element
rootElem.addNonUniqueElement(MailConstants.A_SEQ).addText("lastKnownSeq");
// JAXB XmlElementWrapper
Element addElem = rootElem.addNonUniqueElement(MailConstants.E_WAITSET_ADD);
Element aElem = addElem.addNonUniqueElement(MailConstants.E_A);
// JAXB Attribute - not Element
aElem.addNonUniqueElement(MailConstants.A_NAME).addText("waitsetName");
// JAXB Attribute - not Element
aElem.addNonUniqueElement(MailConstants.A_ID).addText("waitsetId");
WaitSetRequest req = JaxbUtil.elementToJaxb(rootElem);
List<WaitSetAddSpec> adds = req.getAddAccounts();
Assert.assertEquals("Waitset add number", 1, adds.size());
WaitSetAddSpec wsAdd = adds.get(0);
Assert.assertEquals("Waitset name", "waitsetName", wsAdd.getName());
Assert.assertEquals("Waitset id", "waitsetId", wsAdd.getId());
}
use of com.zimbra.soap.type.WaitSetAddSpec in project zm-mailbox by Zimbra.
the class TestWaitSetRequest method testWaitSetRequest.
@Test
public void testWaitSetRequest() throws Exception {
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
String authToken = mbox.getAuthToken().getValue();
CreateWaitSetRequest req = new CreateWaitSetRequest("all");
WaitSetAddSpec add = new WaitSetAddSpec();
add.setId(mbox.getAccountInfo(false).getId());
req.addAccount(add);
DocumentResult dr = new DocumentResult();
marshaller.marshal(req, dr);
Document doc = dr.getDocument();
ZimbraLog.test.info(doc.getRootElement().asXML());
CreateWaitSetResponse createResp = (CreateWaitSetResponse) sendReq(envelope(authToken, doc.getRootElement().asXML()), "CreateWaitSetRequest");
String waitSetId = createResp.getWaitSetId();
Assert.assertNotNull(waitSetId);
WaitSetRequest waitSet = new com.zimbra.soap.mail.message.WaitSetRequest(waitSetId, "0");
dr = new DocumentResult();
marshaller.marshal(waitSet, dr);
doc = dr.getDocument();
WaitSetResponse wsResp = (WaitSetResponse) sendReq(envelope(authToken, doc.getRootElement().asXML()), "WaitSetRequest");
Assert.assertEquals("0", wsResp.getSeqNo());
String subject = NAME_PREFIX + " test wait set request 1";
TestUtil.addMessageLmtp(subject, USER_NAME, "user999@example.com");
try {
Thread.sleep(500);
} catch (Exception e) {
}
wsResp = (WaitSetResponse) sendReq(envelope(authToken, doc.getRootElement().asXML()), "WaitSetRequest");
Assert.assertFalse(wsResp.getSeqNo().equals("0"));
}
Aggregations