Search in sources :

Example 1 with CreateWaitSetRequest

use of com.zimbra.soap.mail.message.CreateWaitSetRequest 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

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