Search in sources :

Example 1 with ZImapDataSource

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

the class TestImapOneWayImport method setUp.

@Override
public void setUp() throws Exception {
    cleanUp();
    mDisplayMailFoldersOnly = Provisioning.getInstance().getLocalServer().isImapDisplayMailFoldersOnly();
    Provisioning.getInstance().getLocalServer().setImapDisplayMailFoldersOnly(false);
    // Get mailbox references
    if (!TestUtil.accountExists(LOCAL_USER_NAME)) {
        TestUtil.createAccount(LOCAL_USER_NAME);
    }
    if (!TestUtil.accountExists(REMOTE_USER_NAME)) {
        TestUtil.createAccount(REMOTE_USER_NAME);
    }
    mRemoteMbox = TestUtil.getZMailbox(REMOTE_USER_NAME);
    mLocalMbox = TestUtil.getZMailbox(LOCAL_USER_NAME);
    // Get or create folder
    ZFolder folder = mLocalMbox.getFolderByPath(DS_FOLDER_ROOT);
    if (folder == null) {
        folder = TestUtil.createFolder(mLocalMbox, NAME_PREFIX);
    }
    // Create data source
    int port = Integer.parseInt(TestUtil.getServerAttr(Provisioning.A_zimbraImapBindPort));
    mDataSource = new ZImapDataSource(NAME_PREFIX, true, "localhost", port, REMOTE_USER_NAME, TestUtil.DEFAULT_PASSWORD, folder.getId(), ConnectionType.cleartext, true);
    String id = mLocalMbox.createDataSource(mDataSource);
    mDataSource = null;
    for (ZDataSource ds : mLocalMbox.getAllDataSources()) {
        if (ds.getId().equals(id)) {
            mDataSource = ds;
        }
    }
    assertNotNull(mDataSource);
    // Turn on cleartext login
    mOriginalCleartextValue = TestUtil.getServerAttr(Provisioning.A_zimbraImapCleartextLoginEnabled);
    TestUtil.setServerAttr(Provisioning.A_zimbraImapCleartextLoginEnabled, ProvisioningConstants.TRUE);
    // Turn off STARTTLS support so that unit tests don't bomb on Linux
    // (see bug 33683).
    mOriginalEnableStarttls = LC.javamail_imap_enable_starttls.booleanValue();
    LC.javamail_imap_enable_starttls.setDefault(Boolean.toString(false));
}
Also used : ZImapDataSource(com.zimbra.client.ZImapDataSource) ZFolder(com.zimbra.client.ZFolder) ZDataSource(com.zimbra.client.ZDataSource)

Example 2 with ZImapDataSource

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

the class TestImapImport method setUp.

@Override
public void setUp() throws Exception {
    cleanUp();
    mDisplayMailFoldersOnly = Provisioning.getInstance().getLocalServer().isImapDisplayMailFoldersOnly();
    Provisioning.getInstance().getLocalServer().setImapDisplayMailFoldersOnly(false);
    // Get mailbox references
    if (!TestUtil.accountExists(LOCAL_USER_NAME)) {
        TestUtil.createAccount(LOCAL_USER_NAME);
    }
    if (!TestUtil.accountExists(REMOTE_USER_NAME)) {
        TestUtil.createAccount(REMOTE_USER_NAME);
    }
    mRemoteMbox = TestUtil.getZMailbox(REMOTE_USER_NAME);
    mLocalMbox = TestUtil.getZMailbox(LOCAL_USER_NAME);
    // Get or create folder
    ZFolder folder = mLocalMbox.getFolderByPath(DS_FOLDER_ROOT);
    if (folder == null) {
        folder = TestUtil.createFolder(mLocalMbox, NAME_PREFIX);
    }
    // Create data source
    int port = Integer.parseInt(TestUtil.getServerAttr(Provisioning.A_zimbraImapBindPort));
    mDataSource = new ZImapDataSource(NAME_PREFIX, true, "localhost", port, REMOTE_USER_NAME, TestUtil.DEFAULT_PASSWORD, folder.getId(), ConnectionType.cleartext);
    String id = mLocalMbox.createDataSource(mDataSource);
    mDataSource = null;
    for (ZDataSource ds : mLocalMbox.getAllDataSources()) {
        if (ds.getId().equals(id)) {
            mDataSource = ds;
        }
    }
    assertNotNull(mDataSource);
    // Turn on cleartext login
    mOriginalCleartextValue = TestUtil.getServerAttr(Provisioning.A_zimbraImapCleartextLoginEnabled);
    TestUtil.setServerAttr(Provisioning.A_zimbraImapCleartextLoginEnabled, ProvisioningConstants.TRUE);
    // Turn off STARTTLS support so that unit tests don't bomb on Linux (see bug 33683).
    mOriginalEnableStarttls = LC.javamail_imap_enable_starttls.booleanValue();
    LC.javamail_imap_enable_starttls.setDefault(Boolean.toString(false));
}
Also used : ZImapDataSource(com.zimbra.client.ZImapDataSource) ZFolder(com.zimbra.client.ZFolder) ZDataSource(com.zimbra.client.ZDataSource)

Example 3 with ZImapDataSource

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

the class TestImapSync method createDataSource.

private ZDataSource createDataSource() throws Exception {
    ConnectionType ctype = config.getSecurity() == MailConfig.Security.SSL ? ConnectionType.ssl : ConnectionType.cleartext;
    String id = localMailbox.createDataSource(new ZImapDataSource("TestImapSync", true, config.getHost(), config.getPort(), config.getAuthenticationId(), pass, "1", ctype));
    for (ZDataSource ds : localMailbox.getAllDataSources()) {
        if (ds.getId().equals(id)) {
            return ds;
        }
    }
    Assert.fail("Could not find data source");
    return null;
}
Also used : ZImapDataSource(com.zimbra.client.ZImapDataSource) ConnectionType(com.zimbra.soap.type.DataSource.ConnectionType) ZDataSource(com.zimbra.client.ZDataSource)

Example 4 with ZImapDataSource

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

the class TestDataSourceServer method testScheduling.

public void testScheduling() throws Exception {
    // Create data source.
    ZMailbox zmbox = TestUtil.getZMailbox(USER_NAME);
    ZFolder folder = TestUtil.createFolder(zmbox, "/" + NAME_PREFIX + "-testScheduling");
    Provisioning prov = Provisioning.getInstance();
    Server server = prov.getLocalServer();
    int port = server.getImapBindPort();
    ZImapDataSource zds = new ZImapDataSource(NAME_PREFIX + " testScheduling", true, "localhost", port, "user2", "test123", folder.getId(), ConnectionType.cleartext);
    String dsId = zmbox.createDataSource(zds);
    // Test scheduling based on polling interval. 
    Mailbox mbox = TestUtil.getMailbox(USER_NAME);
    String attrName = Provisioning.A_zimbraDataSourcePollingInterval;
    String imapAttrName = Provisioning.A_zimbraDataSourceImapPollingInterval;
    TestUtil.setDataSourceAttr(USER_NAME, zds.getName(), attrName, "0");
    checkSchedule(mbox, dsId, null);
    TestUtil.setDataSourceAttr(USER_NAME, zds.getName(), attrName, "10m");
    checkSchedule(mbox, dsId, 600000);
    TestUtil.setAccountAttr(USER_NAME, imapAttrName, "");
    TestUtil.setDataSourceAttr(USER_NAME, zds.getName(), attrName, "");
    checkSchedule(mbox, dsId, null);
    TestUtil.setAccountAttr(USER_NAME, imapAttrName, "5m");
    checkSchedule(mbox, dsId, 300000);
    TestUtil.setDataSourceAttr(USER_NAME, zds.getName(), attrName, "0");
    checkSchedule(mbox, dsId, null);
    // Bug 44502: test changing polling interval from 0 to unset when
    // interval is set on the account.
    TestUtil.setDataSourceAttr(USER_NAME, zds.getName(), attrName, "");
    checkSchedule(mbox, dsId, 300000);
    TestUtil.setDataSourceAttr(USER_NAME, zds.getName(), Provisioning.A_zimbraDataSourceEnabled, LdapConstants.LDAP_FALSE);
    checkSchedule(mbox, dsId, null);
}
Also used : ZImapDataSource(com.zimbra.client.ZImapDataSource) ZMailbox(com.zimbra.client.ZMailbox) Server(com.zimbra.cs.account.Server) Mailbox(com.zimbra.cs.mailbox.Mailbox) ZMailbox(com.zimbra.client.ZMailbox) ZFolder(com.zimbra.client.ZFolder) Provisioning(com.zimbra.cs.account.Provisioning)

Aggregations

ZImapDataSource (com.zimbra.client.ZImapDataSource)4 ZDataSource (com.zimbra.client.ZDataSource)3 ZFolder (com.zimbra.client.ZFolder)3 ZMailbox (com.zimbra.client.ZMailbox)1 Provisioning (com.zimbra.cs.account.Provisioning)1 Server (com.zimbra.cs.account.Server)1 Mailbox (com.zimbra.cs.mailbox.Mailbox)1 ConnectionType (com.zimbra.soap.type.DataSource.ConnectionType)1