use of com.zimbra.cs.imap.ImapPath in project zm-mailbox by Zimbra.
the class ImapCommandThrottleTest method create.
@Test
public void create() {
String pathName = "folder123";
CreateCommand create = new CreateCommand(new ImapPath(pathName, null));
Assert.assertTrue("same obj", create.isDuplicate(create));
CreateCommand create2 = new CreateCommand(new ImapPath(pathName, null));
Assert.assertTrue("same fields", create.isDuplicate(create2));
create2 = new CreateCommand(new ImapPath("foo", null));
Assert.assertFalse("different path", create.isDuplicate(create2));
for (int repeats = 0; repeats < LC.imap_throttle_command_limit.intValue(); repeats++) {
create2 = new CreateCommand(new ImapPath("foo" + repeats, null));
Assert.assertFalse(create2.throttle(create));
create = create2;
}
Assert.assertTrue(create2.throttle(create));
}
use of com.zimbra.cs.imap.ImapPath in project zm-mailbox by Zimbra.
the class ImapCommandThrottleTest method select.
@Test
public void select() {
String pathName = "testfolder";
SelectCommand select = new SelectCommand(new ImapPath(pathName, null), (byte) 123, makeQri());
Assert.assertTrue("same obj", select.isDuplicate(select));
SelectCommand select2 = new SelectCommand(new ImapPath(pathName, null), (byte) 123, makeQri());
Assert.assertTrue("diff obj same fields", select.isDuplicate(select2));
SelectCommand select3 = new SelectCommand(new ImapPath(pathName + "foo", null), (byte) 123, makeQri());
Assert.assertFalse("different path", select.isDuplicate(select3));
SelectCommand select4 = new SelectCommand(new ImapPath(pathName, null), (byte) 101, makeQri());
Assert.assertFalse("different params", select.isDuplicate(select4));
QResyncInfo qri = makeQri();
qri.setKnownUIDs("foo");
SelectCommand select5 = new SelectCommand(new ImapPath(pathName, null), (byte) 123, qri);
Assert.assertFalse("different qri", select.isDuplicate(select5));
}
use of com.zimbra.cs.imap.ImapPath in project zm-mailbox by Zimbra.
the class ImapCommandThrottleTest method examine.
@Test
public void examine() {
String pathName = "testfolder";
ExamineCommand examine = new ExamineCommand(new ImapPath(pathName, null), (byte) 123, makeQri());
Assert.assertTrue("same obj", examine.isDuplicate(examine));
SelectCommand select = new SelectCommand(new ImapPath(pathName, null), (byte) 123, makeQri());
Assert.assertFalse("select vs examine", examine.isDuplicate(select));
ExamineCommand examine2 = new ExamineCommand(new ImapPath(pathName, null), (byte) 123, makeQri());
Assert.assertTrue("diff obj same fields", examine.isDuplicate(examine2));
ExamineCommand examine3 = new ExamineCommand(new ImapPath(pathName + "foo", null), (byte) 123, makeQri());
Assert.assertFalse("different path", examine.isDuplicate(examine3));
ExamineCommand examine4 = new ExamineCommand(new ImapPath(pathName, null), (byte) 101, makeQri());
Assert.assertFalse("different params", examine.isDuplicate(examine4));
QResyncInfo qri = makeQri();
qri.setKnownUIDs("foo");
ExamineCommand examine5 = new ExamineCommand(new ImapPath(pathName, null), (byte) 123, qri);
Assert.assertFalse("different qri", examine.isDuplicate(examine5));
}
use of com.zimbra.cs.imap.ImapPath in project zm-mailbox by Zimbra.
the class SharedImapTests method checkImapPath.
private void checkImapPath(String mboxName, ImapCredentials creds, String expectedPathToString, boolean usingReferent, int expectedReferentFolderId, String expectedReferentFolderAcct) throws ServiceException {
ImapPath path = new ImapPath(mboxName, creds);
path.canonicalize();
ImapPath referent = path.getReferent();
assertEquals(String.format("toString() for ImapPath for mailbox '%s'", mboxName), expectedPathToString, path.toString());
if (usingReferent) {
assertNotSame(String.format("ImapPath=%s and it's getReferent() for mailbox '%s'", path, mboxName), path, referent);
} else {
assertSame(String.format("ImapPath=%s and it's getReferent() for mailbox '%s'", path, mboxName), path, referent);
}
FolderStore folderForPath = path.getFolder();
assertEquals(String.format("Folder ID for path.getReferent().getFolder() for mailbox '%s'", mboxName), expectedReferentFolderId, folderIdForFolder(folderForPath));
assertEquals(String.format("Account ID for path.getReferent().getFolder() for mailbox '%s'", mboxName), expectedReferentFolderAcct, acctIdForFolder(folderForPath));
}
use of com.zimbra.cs.imap.ImapPath in project zm-mailbox by Zimbra.
the class TestImapServerListener method testRemoveFolderInterest.
@Test
public void testRemoveFolderInterest() throws Exception {
Assume.assumeNotNull(remoteServer);
Assume.assumeNotNull(remoteAccount);
RemoteImapMailboxStore imapStore = new RemoteImapMailboxStore(mboxStore);
ImapCredentials creds = new ImapCredentials(remoteAccount);
// add listener on INBOX
ImapPath path = new ImapPath("INBOX", creds);
byte params = 0;
ImapHandler handler = new MockImapHandler().setCredentials(creds);
ImapFolder i4folder = new ImapFolder(path, params, handler);
MockImapListener inboxSession = new MockImapListener(imapStore, i4folder, handler);
remoteListener.addListener(inboxSession);
// check created waitset
QueryWaitSetResponse resp = TestUtil.waitForSessions(1, 1, 6000, remoteListener.getWSId(), remoteServer);
assertNotNull(resp);
List<WaitSetInfo> wsInfoList = resp.getWaitsets();
assertFalse(wsInfoList.isEmpty());
assertEquals(1, wsInfoList.size());
WaitSetInfo wsInfo = wsInfoList.get(0);
assertNotNull(wsInfo);
assertEquals(remoteListener.getWSId(), wsInfo.getWaitSetId());
List<SessionForWaitSet> sessions = wsInfo.getSessions();
assertNotNull(sessions);
assertEquals("expected to find 1 session after adding a listener for INBOX", 1, sessions.size());
SessionForWaitSet s = sessions.get(0);
Set<Integer> folders = s.getWaitSetSession().getFolderInterestsAsSet();
assertNotNull("folder interests cannot be NULL", folders);
assertEquals("should have one folder interest", 1, folders.size());
assertTrue("folder interests should contain INBOX", folders.contains(Mailbox.ID_FOLDER_INBOX));
// add listener on DRAFTS
path = new ImapPath("DRAFTS", creds);
params = 0;
i4folder = new ImapFolder(path, params, handler);
ImapRemoteSession draftsSession = (ImapRemoteSession) imapStore.createListener(i4folder, handler);
remoteListener.addListener(draftsSession);
// check that waitset was updated
resp = TestUtil.waitForSessions(1, 2, 6000, remoteListener.getWSId(), remoteServer);
assertNotNull(resp);
wsInfoList = resp.getWaitsets();
assertFalse(wsInfoList.isEmpty());
wsInfo = wsInfoList.get(0);
assertNotNull(wsInfo);
assertEquals(remoteListener.getWSId(), wsInfo.getWaitSetId());
sessions = wsInfo.getSessions();
assertNotNull(sessions);
assertEquals("expected to find 1 session after adding a listener for DRAFTS", 1, sessions.size());
s = sessions.get(0);
folders = s.getWaitSetSession().getFolderInterestsAsSet();
assertNotNull("folder interests cannot be NULL", folders);
assertEquals("should have two folder interests", 2, folders.size());
assertTrue("folder interests should contain DRAFTS", folders.contains(Mailbox.ID_FOLDER_DRAFTS));
assertTrue("folder interests should contain INBOX", folders.contains(Mailbox.ID_FOLDER_INBOX));
remoteListener.removeListener(inboxSession);
// check that waitset was updated after removing a listener
resp = TestUtil.waitForSessions(1, 1, 6000, remoteListener.getWSId(), remoteServer);
assertNotNull(resp);
wsInfoList = resp.getWaitsets();
assertFalse(wsInfoList.isEmpty());
wsInfo = wsInfoList.get(0);
assertNotNull(wsInfo);
assertEquals(remoteListener.getWSId(), wsInfo.getWaitSetId());
sessions = wsInfo.getSessions();
assertNotNull(sessions);
assertEquals("expected to find 1 session after removing listener for inbox", 1, sessions.size());
s = sessions.get(0);
folders = s.getWaitSetSession().getFolderInterestsAsSet();
assertNotNull("folder interests cannot be NULL", folders);
assertEquals("should have one folder interest after removing a listener", 1, folders.size());
assertTrue("folder interests should contain DRAFTS after removing INBOX listener", folders.contains(Mailbox.ID_FOLDER_DRAFTS));
}
Aggregations