Search in sources :

Example 6 with ZPop3DataSource

use of com.zimbra.client.ZPop3DataSource in project zm-mailbox by Zimbra.

the class TestPop3ImportServer method testModifyDataSource.

/*
     * Confirms that the UID database gets cleared when the host name, account
     * name or leave on server flag are changed.
     */
@Test
public void testModifyDataSource() throws Exception {
    mIsServerSideTest = true;
    // Test modifying host
    ZPop3DataSource zds = getZDataSource();
    zds.setHost(zds.getHost() + "2");
    modifyAndCheck(zds, false);
    // Test modifying username
    zds = getZDataSource();
    zds.setUsername(zds.getUsername() + "2");
    modifyAndCheck(zds, false);
    // Test modifying leave on server
    zds = getZDataSource();
    ZimbraLog.test.info("Old leaveOnServer value: " + zds.leaveOnServer());
    zds.setLeaveOnServer(!zds.leaveOnServer());
    modifyAndCheck(zds, true);
}
Also used : ZPop3DataSource(com.zimbra.client.ZPop3DataSource) Test(org.junit.Test)

Example 7 with ZPop3DataSource

use of com.zimbra.client.ZPop3DataSource in project zm-mailbox by Zimbra.

the class TestPop3ImportServer method modifyAndCheck.

/*
     * Modifies the data source and confirms whether UID data was deleted.
     */
private void modifyAndCheck(ZPop3DataSource zds, boolean shouldDeleteData) throws Exception {
    Mailbox mbox = TestUtil.getMailbox(USER_NAME);
    DataSource ds = getDataSource();
    ZMailbox zmbox = TestUtil.getZMailbox(USER_NAME);
    // Reinitialize persisted UID's
    DbPop3Message.deleteUids(mbox, ds.getId());
    DbPop3Message.storeUid(mbox, ds.getId(), "1", Mailbox.ID_FOLDER_INBOX);
    // Modify data source and make sure the existing
    // UID's were deleted
    zmbox.modifyDataSource(zds);
    Set<String> uids = new HashSet<String>();
    uids.add("1");
    Set<String> matchingUids = DbPop3Message.getMatchingUids(mbox, ds, uids);
    int expected = shouldDeleteData ? 0 : 1;
    assertEquals("matching UID's: " + StringUtil.join(",", matchingUids), expected, matchingUids.size());
}
Also used : ZMailbox(com.zimbra.client.ZMailbox) Mailbox(com.zimbra.cs.mailbox.Mailbox) ZMailbox(com.zimbra.client.ZMailbox) ZDataSource(com.zimbra.client.ZDataSource) ZPop3DataSource(com.zimbra.client.ZPop3DataSource) DataSource(com.zimbra.cs.account.DataSource) HashSet(java.util.HashSet)

Aggregations

ZPop3DataSource (com.zimbra.client.ZPop3DataSource)7 ZMailbox (com.zimbra.client.ZMailbox)6 Test (org.junit.Test)4 ZDataSource (com.zimbra.client.ZDataSource)3 ZMessage (com.zimbra.client.ZMessage)2 ZFilterAction (com.zimbra.client.ZFilterAction)1 ZFileIntoAction (com.zimbra.client.ZFilterAction.ZFileIntoAction)1 ZFilterCondition (com.zimbra.client.ZFilterCondition)1 ZHeaderCondition (com.zimbra.client.ZFilterCondition.ZHeaderCondition)1 ZFilterRule (com.zimbra.client.ZFilterRule)1 ZFilterRules (com.zimbra.client.ZFilterRules)1 ZFolder (com.zimbra.client.ZFolder)1 DataSource (com.zimbra.cs.account.DataSource)1 Mailbox (com.zimbra.cs.mailbox.Mailbox)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 MailDateFormat (javax.mail.internet.MailDateFormat)1