use of com.zimbra.cs.service.FeedManager.RemoteDataInfo in project zm-mailbox by Zimbra.
the class FeedManagerTest method atomEnabledOrg.
@Test
public void atomEnabledOrg() throws Exception {
long lastModified = 0;
String expectedCharset = MimeConstants.P_CHARSET_UTF8;
BufferedInputStream content = new BufferedInputStream(getClass().getResourceAsStream("atomEnabledOrg.xml"));
RemoteDataInfo rdi = new RemoteDataInfo(HttpStatus.OK_200, 0, content, expectedCharset, lastModified);
SubscriptionData<?> subsData = FeedManager.retrieveRemoteDatasource(null, rdi, null);
List<?> subs = subsData.getItems();
Assert.assertNotNull("List of subscriptions", subs);
Assert.assertEquals("Number of items", 2, subs.size());
Object obj;
obj = subs.get(0);
if (obj instanceof ParsedMessage) {
ParsedMessage pm = (ParsedMessage) obj;
List<MPartInfo> parts = pm.getMessageParts();
Assert.assertEquals("Number of message parts", 1, parts.size());
String msgContent = streamToString(parts.get(0).getMimePart().getInputStream(), Charsets.UTF_8);
Assert.assertTrue("Some content text", msgContent.indexOf("Rev 0.9 of the AtomAPI has just been posted") > 0);
} else {
Assert.fail("Expecting a ParsedMessage where is " + obj.getClass().getName());
}
obj = subs.get(1);
if (obj instanceof ParsedMessage) {
ParsedMessage pm = (ParsedMessage) obj;
List<MPartInfo> parts = pm.getMessageParts();
Assert.assertEquals("Number of message parts", 1, parts.size());
String msgContent = streamToString(parts.get(0).getMimePart().getInputStream(), Charsets.UTF_8);
Assert.assertTrue("Some content text", msgContent.indexOf("AtomAPI at ApacheCon in Las Vegas") > 0);
} else {
Assert.fail("Expecting a ParsedMessage where is " + obj.getClass().getName());
}
}
use of com.zimbra.cs.service.FeedManager.RemoteDataInfo in project zm-mailbox by Zimbra.
the class FeedManagerTest method socialcastAtomFeed.
@Test
public void socialcastAtomFeed() throws Exception {
long lastModified = 0;
String expectedCharset = MimeConstants.P_CHARSET_UTF8;
BufferedInputStream content = new BufferedInputStream(getClass().getResourceAsStream("socialcastAtomFeed.xml"));
RemoteDataInfo rdi = new RemoteDataInfo(HttpStatus.OK_200, 0, content, expectedCharset, lastModified);
SubscriptionData<?> subsData = FeedManager.retrieveRemoteDatasource(null, rdi, null);
List<?> subs = subsData.getItems();
Assert.assertNotNull("List of subscriptions", subs);
Assert.assertEquals("Number of items", 1, subs.size());
for (Object obj : subs) {
if (obj instanceof ParsedMessage) {
ParsedMessage pm = (ParsedMessage) obj;
List<MPartInfo> parts = pm.getMessageParts();
Assert.assertEquals("Number of message parts", 1, parts.size());
String msgContent = streamToString(parts.get(0).getMimePart().getInputStream(), Charsets.UTF_8);
Assert.assertTrue("Text from inside <div>", msgContent.indexOf("Congratulations for passing!") > 0);
Assert.assertTrue("Article reference", msgContent.indexOf("https://pink.socialcast.com/messages/15629747-active-learner-thanks-to-cccc") > 0);
} else {
Assert.fail("Expecting a ParsedMessage where is " + obj.getClass().getName());
}
}
}
Aggregations