Search in sources :

Example 1 with ListData

use of com.zimbra.cs.mailclient.imap.ListData in project zm-mailbox by Zimbra.

the class ImapUtilTest method preTest.

@Before
public void preTest() {
    folders.clear();
    folders.add(new ListData("INBOX", '/'));
    // dup
    folders.add(new ListData("Inbox", '/'));
    folders.add(new ListData("Inbox/sub", '/'));
    folders.add(new ListData("Personal", '/'));
    folders.add(new ListData("Receipts", '/'));
    folders.add(new ListData("Travel", '/'));
    folders.add(new ListData("Work", '/'));
    folders.add(new ListData("[Gmail]", '/'));
    folders.add(new ListData("[Gmail]/All Mail", '/'));
    folders.add(new ListData("[Gmail]/Drafts", '/'));
    folders.add(new ListData("[Gmail]/Sent Mail", '/'));
    folders.add(new ListData("[Gmail]/Spam", '/'));
    folders.add(new ListData("[Gmail]/Starred", '/'));
    folders.add(new ListData("[Gmail]/Trash", '/'));
    folders.add(new ListData("Inbox/a", '/'));
    folders.add(new ListData("Inbox/b", '/'));
    folders.add(new ListData("Inbox/c", '/'));
    // different from Travel
    folders.add(new ListData("travel", '/'));
}
Also used : ListData(com.zimbra.cs.mailclient.imap.ListData) Before(org.junit.Before)

Example 2 with ListData

use of com.zimbra.cs.mailclient.imap.ListData in project zm-mailbox by Zimbra.

the class ImapUtilTest method testIsInboxInferior.

@Test
public void testIsInboxInferior() throws Exception {
    ListData ld = new ListData("inbox/aa", '/');
    Method testMethod = ImapUtil.class.getDeclaredMethod("isInboxInferior", ListData.class);
    testMethod.setAccessible(true);
    Assert.assertEquals(true, testMethod.invoke(null, ld));
    ld = new ListData("inbox", '/');
    Assert.assertEquals(false, testMethod.invoke(null, ld));
    ld = new ListData("abc", '/');
    Assert.assertEquals(false, testMethod.invoke(null, ld));
}
Also used : Method(java.lang.reflect.Method) ListData(com.zimbra.cs.mailclient.imap.ListData) Test(org.junit.Test)

Example 3 with ListData

use of com.zimbra.cs.mailclient.imap.ListData in project zm-mailbox by Zimbra.

the class ImapSync method syncRemoteFolders.

private void syncRemoteFolders(List<ListData> folders) throws ServiceException {
    for (ListData ld : folders) {
        checkIsEnabled();
        try {
            ImapFolderSync ifs = new ImapFolderSync(this);
            ImapFolder tracker = ifs.syncFolder(ld);
            if (tracker != null) {
                syncedFolders.put(tracker.getItemId(), ifs);
            }
        } catch (Exception e) {
            syncFailed(ld.getMailbox(), e);
        }
    }
}
Also used : ServiceException(com.zimbra.common.service.ServiceException) CommandFailedException(com.zimbra.cs.mailclient.CommandFailedException) IOException(java.io.IOException) MailServiceException(com.zimbra.cs.mailbox.MailServiceException) RemoteServiceException(com.zimbra.common.service.RemoteServiceException) ListData(com.zimbra.cs.mailclient.imap.ListData)

Example 4 with ListData

use of com.zimbra.cs.mailclient.imap.ListData in project zm-mailbox by Zimbra.

the class SharedImapTests method doRangeSearch.

private void doRangeSearch(String user, String folderName, int numMessages) throws Exception {
    connection = connect(user);
    connection.login(PASS);
    doListShouldSucceed(connection, "", folderName, Lists.newArrayList(folderName), "List just single folder");
    if (!folderName.startsWith("/home")) {
        List<ListData> listResult = connection.list("", "*");
        assertNotNull("list result 'list \"\" \"*\"' should not be null", listResult);
        boolean seenIt = false;
        for (ListData listEnt : listResult) {
            if (folderName.equals(listEnt.getMailbox())) {
                seenIt = true;
                break;
            }
        }
        assertTrue(String.format("'%s' mailbox not in result of 'list \"\" \"*\"'", folderName), seenIt);
    }
    connection.select(folderName);
    /* on remote IMAP this used to result in a search request with 9 item IDs (see ZCS-3557)
         * Now should make use of ranges.  This is true of later searches too. */
    SearchInfo ten18 = new SearchInfo(folderName, "10:18", 9);
    ten18.uidSearch(connection);
    SearchInfo twenty = new SearchInfo(folderName, "20", 1);
    twenty.uidSearch(connection);
    SearchInfo ten18uidRange = new SearchInfo(folderName, "UID " + ten18.firstToLast, 9);
    ten18uidRange.uidSearch(connection);
    SearchInfo twenty23 = new SearchInfo(folderName, "20:23", 4);
    twenty23.uidSearch(connection);
    SearchInfo ten18twenty23uidRange = new SearchInfo(folderName, String.format("UID %s,%s", ten18.firstToLast, twenty23.firstToLast), 9 + 4);
    ten18twenty23uidRange.uidSearch(connection);
    SearchInfo ten800 = new SearchInfo(folderName, "10:800", 791);
    ten800.uidSearch(connection);
    SearchInfo oneThousand1999 = new SearchInfo(folderName, "1000:1999", 1000);
    oneThousand1999.uidSearch(connection);
    SearchInfo one2000 = new SearchInfo(folderName, "1:2000", 2000);
    one2000.uidSearch(connection);
    SearchInfo oneThousand2100 = new SearchInfo(folderName, "1000:2100", 1101);
    oneThousand2100.uidSearch(connection);
    SearchInfo oneStar = new SearchInfo(folderName, "1:*", numMessages);
    oneStar.uidSearch(connection);
    /*
         * The reason for performing all assertions together and reporting all numbers in each
         * assertion message is to get a more complete picture when tests fail.
         */
    String assertTemplate = "Wrong number of results for 'UID SEARCH %s'. Results are: " + String.format("%s, %s, %s, %s, %s, %s, %s, %s, %s", ten18, twenty, twenty23, ten18uidRange, ten18twenty23uidRange, ten800, one2000, oneThousand1999, oneThousand2100, oneStar);
    ten18.assertPassed(assertTemplate);
    ten18uidRange.assertPassed(assertTemplate);
    twenty.assertPassed(assertTemplate);
    twenty23.assertPassed(assertTemplate);
    ten18twenty23uidRange.assertPassed(assertTemplate);
    /* Once ZCS-3810 has been fixed, can delete associated small range tests and always do this */
    if (numMessages >= 800) {
        ten800.assertPassed(assertTemplate);
        oneThousand1999.assertPassed(assertTemplate);
        one2000.assertPassed(assertTemplate);
        oneThousand2100.assertPassed(assertTemplate);
        oneStar.assertPassed(assertTemplate);
    }
    // Test out some odd searches
    SearchInfo same = new SearchInfo(folderName, "20:20", 1);
    same.uidSearch(connection);
    same.assertPassed();
    SearchInfo negMin = new SearchInfo(folderName, "-20:23", 0);
    negMin.uidSearchExpectingFailure(connection);
    SearchInfo negMax = new SearchInfo(folderName, "20:-23", 0);
    negMax.uidSearchExpectingFailure(connection);
    SearchInfo negs = new SearchInfo(folderName, "-26:-23", 0);
    negs.uidSearchExpectingFailure(connection);
    /* Code seems to assume range given wrong way round and adjusts accordingly.
         * Doesn't seem particularly harmful, so left like that.
         */
    SearchInfo rangeWrongWayRound = new SearchInfo(folderName, "23:20", 4);
    rangeWrongWayRound.uidSearch(connection);
    rangeWrongWayRound.assertPassed();
    connection.logout();
    connection.close();
    connection = null;
}
Also used : ListData(com.zimbra.cs.mailclient.imap.ListData)

Example 5 with ListData

use of com.zimbra.cs.mailclient.imap.ListData in project zm-mailbox by Zimbra.

the class SharedImapTests method testListContacts.

@Test(timeout = 100000)
public void testListContacts() throws Exception {
    connection = connectAndSelectInbox();
    List<ListData> listResult = connection.list("", "*Contacts*");
    assertNotNull("list result should not be null", listResult);
    // 'Contacts' and 'Emailed Contacts'
    assertTrue("List result should have at least 2 entries. Got " + listResult.size(), listResult.size() >= 2);
    for (ListData le : listResult) {
        assertTrue(String.format("mailbox '%s' contains 'Contacts'", le.getMailbox()), le.getMailbox().contains("Contacts"));
    }
}
Also used : ListData(com.zimbra.cs.mailclient.imap.ListData) Test(org.junit.Test)

Aggregations

ListData (com.zimbra.cs.mailclient.imap.ListData)19 Test (org.junit.Test)13 ZMailbox (com.zimbra.client.ZMailbox)6 ZFolder (com.zimbra.client.ZFolder)2 ServiceException (com.zimbra.common.service.ServiceException)2 CommandFailedException (com.zimbra.cs.mailclient.CommandFailedException)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ZGetInfoResult (com.zimbra.client.ZGetInfoResult)1 ZSearchFolder (com.zimbra.client.ZSearchFolder)1 RemoteServiceException (com.zimbra.common.service.RemoteServiceException)1 AuthTokenException (com.zimbra.cs.account.AuthTokenException)1 MailServiceException (com.zimbra.cs.mailbox.MailServiceException)1 Envelope (com.zimbra.cs.mailclient.imap.Envelope)1 ImapInputStream (com.zimbra.cs.mailclient.imap.ImapInputStream)1 MessageData (com.zimbra.cs.mailclient.imap.MessageData)1 AuthProviderException (com.zimbra.cs.service.AuthProviderException)1 Method (java.lang.reflect.Method)1 TimeoutException (java.util.concurrent.TimeoutException)1 MessagingException (javax.mail.MessagingException)1