use of com.zimbra.client.ZRssDataSource in project zm-mailbox by Zimbra.
the class TestDataSource method testRss.
/**
* Creates a folder that syncs to another folder via RSS, and verifies that an
* RSS data source was implicitly created.
*/
@Test
public void testRss() throws Exception {
// Create source folder, make it publicly readable, and add a message to it.
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
String parentId = Integer.toString(Mailbox.ID_FOLDER_USER_ROOT);
ZFolder sourceFolder = TestUtil.createFolder(mbox, "/" + NAME_PREFIX + " testRss source");
mbox.modifyFolderGrant(sourceFolder.getId(), GranteeType.pub, null, "r", null);
String subject = NAME_PREFIX + " testRss";
TestUtil.addMessage(mbox, subject, sourceFolder.getId());
// Create destination folder that syncs to the source folder via RSS.
String urlString = String.format("https://%s:%s/home/%s%s.rss", TestUtil.getServerAttr(Provisioning.A_zimbraServiceHostname), TestUtil.getServerAttr(Provisioning.A_zimbraMailSSLPort), USER_NAME, sourceFolder.getPath());
urlString = HttpUtil.encodePath(urlString);
ZFolder rssFolder = mbox.createFolder(parentId, NAME_PREFIX + " testRss destination", null, null, null, urlString);
// Get the data source that was implicitly created.
ZRssDataSource ds = (ZRssDataSource) getDataSource(mbox, rssFolder.getId());
assertNotNull(ds);
assertNull(mbox.testDataSource(ds));
// Import data and validate the synced message.
List<ZDataSource> list = new ArrayList<ZDataSource>();
list.add(ds);
mbox.importData(list);
waitForData(mbox, rssFolder);
ZMessage syncedMsg = TestUtil.getMessage(mbox, "in:\"" + rssFolder.getPath() + "\"");
assertEquals(subject, syncedMsg.getSubject());
/*
* Bug 102261 - simulate ZWC deleting an item from the folder
*/
ConvActionSelector sel = ConvActionSelector.createForIdsAndOperation(syncedMsg.getConversationId(), "trash");
sel.setConstraint("-dtjs");
sel.setFolder(syncedMsg.getFolderId());
try {
mbox.invokeJaxb(new ConvActionRequest(sel));
} catch (SoapFaultException sfe) {
fail("SoapFaultException caught when deleting item from RSS datasource folder - " + sfe.getMessage());
}
// Delete folder, import data, and make sure that the data source was deleted.
// Data source import runs asynchronously, so poll until the data source is gone.
mbox.deleteFolder(rssFolder.getId());
// JBF - do not do the import; it will fail if DS is already deleted
// mbox.importData(list);
// XXX bburtin: disabled check to avoid false positives (bug 54816). Some sort
// of race condition is causing this check to fail intermittently. I was unable
// to consistently repro.
/*
for (int i = 1; i <= 10; i++) {
ds = (ZRssDataSource) getDataSource(mbox, rssFolder.getId());
if (ds == null) {
break;
}
Thread.sleep(500);
}
assertNull(ds);
*/
}
Aggregations