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);
}
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());
}
Aggregations