use of com.zimbra.soap.mail.message.CreateWaitSetResponse 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"));
}
use of com.zimbra.soap.mail.message.CreateWaitSetResponse in project zm-mailbox by Zimbra.
the class TestWaitSetRequest method testSyncWaitSetRequest.
@Test
public void testSyncWaitSetRequest() throws Exception {
String user1Name = "testSyncWaitSetRequest_user1";
acc1 = TestUtil.createAccount(user1Name);
ZMailbox mbox = TestUtil.getZMailbox(user1Name);
String authToken = mbox.getAuthToken().getValue();
CreateWaitSetResponse resp = createWaitSet(mbox.getAccountInfo(false).getId(), authToken);
assertNotNull(resp);
waitSetId = resp.getWaitSetId();
int seq = resp.getSequence();
WaitSetRequest waitSet = new WaitSetRequest(waitSetId, Integer.toString(seq));
WaitSetResponse wsResp = (WaitSetResponse) sendReq(envelope(authToken, jaxbToString(waitSet), "urn:zimbra"), TestUtil.getSoapUrl() + "WaitSetRequest");
assertEquals("0", wsResp.getSeqNo());
String subject = NAME_PREFIX + " test wait set request 1";
TestUtil.addMessageLmtp(subject, user1Name, "user999@example.com");
// try { Thread.sleep(500); } catch (Exception e) {}
TestUtil.waitForMessages(mbox, String.format("in:inbox is:unread \"%s\"", subject), 1, 1000);
wsResp = (WaitSetResponse) sendReq(envelope(authToken, jaxbToString(waitSet), "urn:zimbra"), TestUtil.getSoapUrl() + "WaitSetRequest");
assertFalse(wsResp.getSeqNo().equals("0"));
List<AccountWithModifications> accounts = wsResp.getSignalledAccounts();
assertEquals("should have signaled 1 account", 1, accounts.size());
assertEquals(String.format("Shold have signaled account %s", acc1.getId()), acc1.getId(), accounts.get(0).getId());
assertNull("Should not return folder notifications unless 'expand' is set to 'true'", accounts.get(0).getPendingFolderModifications());
}
use of com.zimbra.soap.mail.message.CreateWaitSetResponse in project zm-mailbox by Zimbra.
the class TestWaitSetRequest method testFolderInterestSyncWaitSetRequest.
@Test
public void testFolderInterestSyncWaitSetRequest() throws Exception {
String user1Name = "testFISyncWaitSetRequest_user1";
acc1 = TestUtil.createAccount(user1Name);
ZMailbox mbox = TestUtil.getZMailbox(user1Name);
String acctId = mbox.getAccountId();
String authToken = mbox.getAuthToken().getValue();
ZimbraLog.test.info("GREN 1");
String adminAuthToken = TestUtil.getAdminSoapTransport().getAuthToken().getValue();
ZimbraLog.test.info("GREN 2");
ZFolder myFolder = TestUtil.createFolder(mbox, "funFolder");
Set<Integer> folderInterest = Sets.newHashSet();
folderInterest.add(myFolder.getFolderIdInOwnerMailbox());
/* initially only interested in funFolder */
CreateWaitSetResponse resp = createWaitSet(acctId, authToken, folderInterest);
assertNotNull(resp);
waitSetId = resp.getWaitSetId();
int seq = resp.getSequence();
WaitSetRequest waitSet = new WaitSetRequest(waitSetId, Integer.toString(seq));
WaitSetResponse wsResp = (WaitSetResponse) sendReq(waitSet, authToken, TestUtil.getSoapUrl());
assertEquals("0", wsResp.getSeqNo());
String subject = NAME_PREFIX + " test wait set request 1";
TestUtil.addMessageLmtp(subject, user1Name, "user999@example.com");
TestUtil.waitForMessages(mbox, String.format("in:inbox is:unread \"%s\"", subject), 1, 1000);
wsResp = (WaitSetResponse) sendReq(envelope(authToken, jaxbToString(waitSet), "urn:zimbra"), TestUtil.getSoapUrl() + "WaitSetRequest");
assertTrue(wsResp.getSeqNo().equals("0"));
assertEquals("Number of signalled accounts", 0, wsResp.getSignalledAccounts().size());
QueryWaitSetResponse qwsResp;
QueryWaitSetRequest qwsReq = new QueryWaitSetRequest(waitSetId);
qwsResp = (QueryWaitSetResponse) sendReq(qwsReq, adminAuthToken, TestUtil.getAdminSoapUrl());
validateQueryWaitSetResponse(qwsResp, acctId, folderInterest, null);
/* interested in funFolder AND inbox */
folderInterest.add(Integer.valueOf(Mailbox.ID_FOLDER_INBOX));
waitSet.addUpdateAccount(createWaitSetAddSpec(acctId, folderInterest));
wsResp = (WaitSetResponse) sendReq(envelope(authToken, jaxbToString(waitSet), "urn:zimbra"), TestUtil.getSoapUrl() + "WaitSetRequest");
assertTrue(wsResp.getSeqNo().equals("0"));
assertEquals("Number of signalled accounts", 0, wsResp.getSignalledAccounts().size());
qwsResp = (QueryWaitSetResponse) sendReq(qwsReq, adminAuthToken, TestUtil.getAdminSoapUrl());
validateQueryWaitSetResponse(qwsResp, acctId, folderInterest, null);
subject = NAME_PREFIX + " test wait set request 2";
TestUtil.addMessageLmtp(subject, user1Name, "user999@example.com");
TestUtil.waitForMessages(mbox, String.format("in:inbox is:unread \"%s\"", subject), 1, 1000);
qwsResp = (QueryWaitSetResponse) sendReq(qwsReq, adminAuthToken, TestUtil.getAdminSoapUrl());
validateQueryWaitSetResponse(qwsResp, acctId, folderInterest, null);
waitSet = new WaitSetRequest(waitSetId, Integer.toString(seq));
waitSet.setExpand(true);
wsResp = (WaitSetResponse) sendReq(envelope(authToken, jaxbToString(waitSet), "urn:zimbra"), TestUtil.getSoapUrl() + "WaitSetRequest");
assertFalse(wsResp.getSeqNo().equals("0"));
assertEquals("Number of signalled accounts", 1, wsResp.getSignalledAccounts().size());
AccountWithModifications acctInfo = wsResp.getSignalledAccounts().get(0);
assertEquals("Signaled account id", mbox.getAccountId(), acctInfo.getId());
Collection<PendingFolderModifications> mods = acctInfo.getPendingFolderModifications();
assertNotNull("'mod' field should not be null", mods);
assertEquals("Should have 1 folder object with modifications", 1, mods.size());
Integer foldInt = mods.iterator().next().getFolderId();
assertEquals(String.format("Folder ID should be %d (Inbox). Getting %d instead", Mailbox.ID_FOLDER_INBOX, foldInt), foldInt.intValue(), Mailbox.ID_FOLDER_INBOX);
}
use of com.zimbra.soap.mail.message.CreateWaitSetResponse in project zm-mailbox by Zimbra.
the class CreateWaitSet method handle.
/*
<!--*************************************
CreateWaitSet: must be called once to initialize the WaitSet
and to set its "default interest types"
************************************* -->
<CreateWaitSetRequest defTypes="DEFAULT_INTEREST_TYPES" [all="1"]>
[ <add>
[<a id="ACCTID" [token="lastKnownSyncToken"] [types="if_not_default"]/>]+
</add> ]
</CreateWaitSetRequest>
<CreateWaitSetResponse waitSet="setId" defTypes="types" seq="0">
[ <error ...something.../>]*
</CreateWaitSetResponse>
*/
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
CreateWaitSetRequest req = zsc.elementToJaxb(request);
CreateWaitSetResponse resp = new CreateWaitSetResponse();
staticHandle(this, req, context, resp);
return zsc.jaxbToElement(resp);
/* MUST use zsc variant NOT JaxbUtil */
}
use of com.zimbra.soap.mail.message.CreateWaitSetResponse in project zm-mailbox by Zimbra.
the class TestWaitSetRequest method createWaitSet.
private CreateWaitSetResponse createWaitSet(String accountId, String authToken, Set<Integer> folderInterest) throws Exception {
CreateWaitSetRequest req = new CreateWaitSetRequest("all", (Boolean) null);
req.addAccount(createWaitSetAddSpec(accountId, folderInterest));
return (CreateWaitSetResponse) sendReq(envelope(authToken, jaxbToString(req), "urn:zimbra"), TestUtil.getSoapUrl() + "CreateWaitSetRequest");
}
Aggregations