use of com.zimbra.soap.admin.message.QueryWaitSetResponse in project zm-mailbox by Zimbra.
the class TestImapServerListener method testGetListeners.
@Test
public void testGetListeners() throws Exception {
Assume.assumeNotNull(remoteServer);
Assume.assumeNotNull(remoteAccount);
assertNotNull("ImapServerListener instance should not be null", remoteListener);
RemoteImapMailboxStore imapStore = new RemoteImapMailboxStore(mboxStore);
ImapCredentials creds = new ImapCredentials(remoteAccount);
ImapPath path = new ImapPath("INBOX", creds);
byte params = 0;
ImapHandler handler = new MockImapHandler().setCredentials(creds);
ImapFolder i4folder = new ImapFolder(path, params, handler);
MockImapListener session = new MockImapListener(imapStore, i4folder, handler);
assertNotNull("ImapListener instance should not be null", session);
Set<ImapRemoteSession> sessions = remoteListener.getListeners(remoteAccount.getId(), i4folder.getId());
assertNotNull("getListeners should not return NULL before adding a listener", sessions);
assertTrue("expecting an empty list before adding a listener", sessions.isEmpty());
remoteListener.addListener(session);
// wait for waitset session to be created
QueryWaitSetResponse resp = TestUtil.waitForSessions(1, 1, 6000, remoteListener.getWSId(), remoteServer);
sessions = remoteListener.getListeners(remoteAccount.getId(), i4folder.getId());
assertNotNull("getListeners should not return NULL after adding a listener", sessions);
assertFalse("expecting a non empty list after adding a listener", sessions.isEmpty());
remoteListener.removeListener(session);
sessions = remoteListener.getListeners(remoteAccount.getId(), i4folder.getId());
assertNotNull("getListeners should not return NULL after removing a listener", sessions);
assertTrue("expecting an empty list after removing a listener", sessions.isEmpty());
assertNull("Should not have a waitset after removing last listener", remoteListener.getWSId());
}
Aggregations