Search in sources :

Example 16 with QueryWaitSetResponse

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());
}
Also used : ImapRemoteSession(com.zimbra.cs.imap.ImapRemoteSession) ImapFolder(com.zimbra.cs.imap.ImapFolder) QueryWaitSetResponse(com.zimbra.soap.admin.message.QueryWaitSetResponse) RemoteImapMailboxStore(com.zimbra.cs.imap.RemoteImapMailboxStore) ImapHandler(com.zimbra.cs.imap.ImapHandler) ImapCredentials(com.zimbra.cs.imap.ImapCredentials) ImapPath(com.zimbra.cs.imap.ImapPath) Test(org.junit.Test)

Aggregations

QueryWaitSetResponse (com.zimbra.soap.admin.message.QueryWaitSetResponse)16 Test (org.junit.Test)13 ImapCredentials (com.zimbra.cs.imap.ImapCredentials)12 ImapFolder (com.zimbra.cs.imap.ImapFolder)12 ImapHandler (com.zimbra.cs.imap.ImapHandler)12 ImapPath (com.zimbra.cs.imap.ImapPath)12 RemoteImapMailboxStore (com.zimbra.cs.imap.RemoteImapMailboxStore)12 ZMailbox (com.zimbra.client.ZMailbox)10 ServiceException (com.zimbra.common.service.ServiceException)8 ImapServerListener (com.zimbra.cs.imap.ImapServerListener)8 IOException (java.io.IOException)8 CountDownLatch (java.util.concurrent.CountDownLatch)8 HttpException (org.apache.http.HttpException)8 ZMessage (com.zimbra.client.ZMessage)5 QueryWaitSetRequest (com.zimbra.soap.admin.message.QueryWaitSetRequest)5 ZFolder (com.zimbra.client.ZFolder)3 WaitSetInfo (com.zimbra.soap.admin.type.WaitSetInfo)3 ZTag (com.zimbra.client.ZTag)2 SoapTransport (com.zimbra.common.soap.SoapTransport)2 ImapRemoteSession (com.zimbra.cs.imap.ImapRemoteSession)2