Search in sources :

Example 1 with WaitSetAddSpec

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());
}
Also used : WaitSetRequest(com.zimbra.soap.mail.message.WaitSetRequest) WaitSetAddSpec(com.zimbra.soap.type.WaitSetAddSpec) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement) JSONElement(com.zimbra.common.soap.Element.JSONElement) JAXBElement(javax.xml.bind.JAXBElement) Test(org.junit.Test)

Example 2 with WaitSetAddSpec

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"));
}
Also used : WaitSetRequest(com.zimbra.soap.mail.message.WaitSetRequest) CreateWaitSetRequest(com.zimbra.soap.mail.message.CreateWaitSetRequest) ZMailbox(com.zimbra.client.ZMailbox) WaitSetAddSpec(com.zimbra.soap.type.WaitSetAddSpec) WaitSetResponse(com.zimbra.soap.mail.message.WaitSetResponse) CreateWaitSetResponse(com.zimbra.soap.mail.message.CreateWaitSetResponse) DocumentResult(org.dom4j.io.DocumentResult) CreateWaitSetResponse(com.zimbra.soap.mail.message.CreateWaitSetResponse) Document(org.dom4j.Document) IOException(java.io.IOException) ServiceException(com.zimbra.common.service.ServiceException) HttpException(org.apache.commons.httpclient.HttpException) CreateWaitSetRequest(com.zimbra.soap.mail.message.CreateWaitSetRequest) Test(org.junit.Test)

Aggregations

WaitSetRequest (com.zimbra.soap.mail.message.WaitSetRequest)2 WaitSetAddSpec (com.zimbra.soap.type.WaitSetAddSpec)2 Test (org.junit.Test)2 ZMailbox (com.zimbra.client.ZMailbox)1 ServiceException (com.zimbra.common.service.ServiceException)1 Element (com.zimbra.common.soap.Element)1 JSONElement (com.zimbra.common.soap.Element.JSONElement)1 XMLElement (com.zimbra.common.soap.Element.XMLElement)1 CreateWaitSetRequest (com.zimbra.soap.mail.message.CreateWaitSetRequest)1 CreateWaitSetResponse (com.zimbra.soap.mail.message.CreateWaitSetResponse)1 WaitSetResponse (com.zimbra.soap.mail.message.WaitSetResponse)1 IOException (java.io.IOException)1 JAXBElement (javax.xml.bind.JAXBElement)1 HttpException (org.apache.commons.httpclient.HttpException)1 Document (org.dom4j.Document)1 DocumentResult (org.dom4j.io.DocumentResult)1