use of com.zimbra.soap.admin.type.WaitSetInfo in project zm-mailbox by Zimbra.
the class WaitSetBase method handleQuery.
@Override
public synchronized WaitSetInfo handleQuery() {
WaitSetInfo info = WaitSetInfo.createForWaitSetIdOwnerInterestsLastAccessDate(mWaitSetId, mOwnerAccountId, WaitSetRequest.expandInterestStr(defaultInterest), mLastAccessedTime);
if (mCurrentErrors.size() > 0) {
for (WaitSetError error : mCurrentErrors) {
info.addError(new IdAndType(error.accountId, error.error.name()));
}
}
// signaled accounts
if (mCurrentSignalledAccounts.size() > 0) {
StringBuilder signaledStr = new StringBuilder();
for (String accountId : mCurrentSignalledAccounts) {
if (signaledStr.length() > 0)
signaledStr.append(",");
signaledStr.append(accountId);
}
info.setSignalledAccounts(new AccountsAttrib(signaledStr.toString()));
}
return info;
}
use of com.zimbra.soap.admin.type.WaitSetInfo in project zm-mailbox by Zimbra.
the class TestImapServerListener method testRegisterUnregister.
@Test
public void testRegisterUnregister() throws ServiceException, IOException, HttpException {
Assume.assumeNotNull(remoteServer);
Assume.assumeNotNull(remoteAccount);
assertNotNull("ImapServerListener instance should not be null", remoteListener);
RemoteImapMailboxStore imapStore = new RemoteImapMailboxStore(mboxStore);
assertNotNull("ImapMailboxStore instance should not be null", imapStore);
ImapCredentials creds = new ImapCredentials(remoteAccount);
ImapPath path = new ImapPath("INBOX", creds);
assertNotNull("ImapPath instance should not be null", path);
byte params = 0;
ImapHandler handler = new MockImapHandler().setCredentials(creds);
ImapFolder i4folder = new ImapFolder(path, params, handler);
assertNotNull("ImapFolder instance should not be null", i4folder);
assertNotNull("ImapFolder.getCredentials() should not return null", i4folder.getCredentials());
assertNotNull("ImapFolder.getPath() should not return null", i4folder.getPath());
MockImapListener session = new MockImapListener(imapStore, i4folder, handler);
assertNotNull("ImapListener instance should not be null", session);
assertFalse("Expecting ImapServerListener::isListeningOn to return false before calling addListener", remoteListener.isListeningOn(session.getTargetAccountId(), session.getFolderId()));
assertNull("Should not have a waitset before registering first listener", remoteListener.getWSId());
remoteListener.addListener(session);
assertTrue("Expecting ImapServerListener::isListeningOn to return true after calling addListener", remoteListener.isListeningOn(session.getTargetAccountId(), session.getFolderId()));
assertNotNull("Should have a waitset after registering first listener", remoteListener.getWSId());
QueryWaitSetRequest req = new QueryWaitSetRequest(remoteListener.getWSId());
SoapTransport transport = TestUtil.getAdminSoapTransport(remoteServer);
QueryWaitSetResponse resp = JaxbUtil.elementToJaxb(transport.invoke(JaxbUtil.jaxbToElement(req)));
assertNotNull(resp);
List<WaitSetInfo> wsInfoList = resp.getWaitsets();
assertNotNull(wsInfoList);
assertFalse(wsInfoList.isEmpty());
assertEquals(1, wsInfoList.size());
WaitSetInfo wsInfo = wsInfoList.get(0);
assertNotNull(wsInfo);
assertEquals(remoteListener.getWSId(), wsInfo.getWaitSetId());
remoteListener.removeListener(session);
assertFalse("Expecting ImapServerListener::isListeningOn to return false after calling removeListener", remoteListener.isListeningOn(session.getTargetAccountId(), session.getFolderId()));
assertNull("Should not have a waitset after removing last listener", remoteListener.getWSId());
}
use of com.zimbra.soap.admin.type.WaitSetInfo in project zm-mailbox by Zimbra.
the class TestWaitSetRequest method validateQueryWaitSetResponse.
private void validateQueryWaitSetResponse(QueryWaitSetResponse qwsResp, String acctId, Set<Integer> folderInterests, Set<Integer> expectedChangedFolders, boolean checkOwner) {
assertEquals("Number of Waitsets in response", 1, qwsResp.getWaitsets().size());
WaitSetInfo wsInfo = qwsResp.getWaitsets().get(0);
if (checkOwner) {
assertEquals("waitSet owner", acctId, wsInfo.getOwner());
}
assertEquals("Number of sessions in WaitSetResponse/waitSet", 1, wsInfo.getSessions().size());
SessionForWaitSet session = wsInfo.getSessions().get(0);
assertEquals("WaitSetResponse/waitSet/session@account", acctId, session.getAccount());
WaitSetSessionInfo sessInfo = session.getWaitSetSession();
if ((null != folderInterests) && !folderInterests.isEmpty()) {
Set<Integer> respFolderInt = sessInfo.getFolderInterestsAsSet();
for (Integer folderInterest : folderInterests) {
assertTrue(String.format("Query reported folderInterests=%s should contain %s", respFolderInt, folderInterest), respFolderInt.contains(folderInterest));
}
}
if ((null != expectedChangedFolders) && !expectedChangedFolders.isEmpty()) {
Set<Integer> respChangedFolders = sessInfo.getChangedFoldersAsSet();
for (Integer changedFldr : expectedChangedFolders) {
assertTrue(String.format("Query reported respChangedFolders=%s should contain %s", respChangedFolders, changedFldr), respChangedFolders.contains(changedFldr));
}
String signalledAccts = wsInfo.getSignalledAccounts().getAccounts();
assertTrue(String.format("ready accts '%s' contains '%s'", signalledAccts, acctId), signalledAccts.contains(acctId));
}
}
Aggregations