use of org.opencastproject.feed.api.Content in project opencast by opencast.
the class ContentImplTest method setterAndGetter.
/**
* Test for Setters and Getters ContentImpl
*/
@Test
public void setterAndGetter() {
Content content = new ContentImpl("value");
instance.setMode(content.getMode());
Assert.assertEquals(instance.getMode(), content.getMode());
instance.setType("type");
Assert.assertEquals(instance.getType(), "type");
instance.setValue("value");
Assert.assertEquals(instance.getValue(), "value");
}
use of org.opencastproject.feed.api.Content in project opencast by opencast.
the class FeedImplTest method setupClass.
@BeforeClass
public static void setupClass() {
Content title = new PlainTextContent("Test Feed");
Content description = new HtmlContent("generated by <b>unit test</b>", Mode.Escaped);
instance = new FeedImpl(Type.RSS, "http://localhost:8080/feeds/rss/2.0/test", title, description, "http://localhost:8080/feeds/rss/2.0/test");
}
use of org.opencastproject.feed.api.Content in project opencast by opencast.
the class FeedImplTest method setterGetterTest.
@Test
public void setterGetterTest() {
instance.setTitle("text");
logger.info(instance.getTitle().getValue());
Assert.assertEquals(instance.getTitle().getValue(), "text");
instance.setLink("http://localhost:8080/feeds/rss/2.0/test");
Assert.assertEquals(instance.getLink(), "http://localhost:8080/feeds/rss/2.0/test");
instance.setCopyright("text");
Assert.assertEquals(instance.getCopyright(), "text");
List<Person> person = new ArrayList<Person>();
instance.setAuthors(person);
Assert.assertEquals(instance.getAuthors(), person);
instance.setContributors(person);
Assert.assertEquals(instance.getContributors(), person);
instance.setUri("http://testuri/");
Assert.assertEquals(instance.getUri(), "http://testuri/");
List<Category> category = new ArrayList<Category>();
instance.setCategories(category);
Assert.assertEquals(instance.getCategories(), category);
instance.setDescription("description");
Assert.assertEquals(instance.getDescription().getValue(), "description");
Content content = new ContentImpl("desciption");
instance.setDescription(content);
Assert.assertEquals(instance.getDescription(), content);
instance.setEncoding("encode");
Assert.assertEquals(instance.getEncoding(), "encode");
List<FeedEntry> feed = new ArrayList<FeedEntry>();
instance.setEntries(feed);
Assert.assertEquals(instance.getEntries(), feed);
Image image = new ImageImpl("http://picture/");
instance.setImage(image);
Assert.assertEquals(instance.getImage(), image);
instance.setLanguage("English");
Assert.assertEquals(instance.getLanguage(), "English");
List<Link> link = new ArrayList<Link>();
instance.setLinks(link);
Assert.assertEquals(instance.getLinks(), link);
List<FeedExtension> feedExtension = new ArrayList<FeedExtension>();
instance.setModules(feedExtension);
Assert.assertEquals(instance.getModules(), feedExtension);
Date date = new Date(21091981);
instance.setPublishedDate(date);
Assert.assertEquals(instance.getPublishedDate(), date);
instance.setUpdatedDate(date);
Assert.assertEquals(instance.getUpdatedDate(), date);
instance.setTitle(content);
Assert.assertEquals(instance.getTitle(), content);
}
use of org.opencastproject.feed.api.Content in project opencast by opencast.
the class FeedImplTest method testFeedImpl.
@Test
public void testFeedImpl() {
try {
Content title = new PlainTextContent("Test Feed");
Content description = new HtmlContent("generated by <b>unit test</b>", Mode.Escaped);
FeedImpl feed = new FeedImpl(Type.RSS, "http://localhost:8080/feeds/rss/2.0/test", title, description, "http://localhost:8080/feeds/rss/2.0/test");
feed.addAuthor(new PersonImpl("Test User", "testuser@example.com", "http://www.example.com/testuser"));
feed.addContributor(new PersonImpl("test university"));
FeedEntry entry = new FeedEntryImpl(feed, "test entry", new LinkImpl("http://localhost:8080/feeds/rss/2.0/test/testentry"), "http://localhost:8080/feeds/rss/2.0/test/testentry");
entry.addEnclosure(new EnclosureImpl("http://www.example.com/video.mp4", "video/mp4", "presenter/delivery", 12));
feed.addEntry(entry);
ITunesFeedExtension itunesmodule = new ITunesFeedExtension();
itunesmodule.addKeyword("test");
List<String> categories = new LinkedList<String>();
categories.add("Higher Education");
itunesmodule.setCategories(categories);
feed.addModule(itunesmodule);
DublinCoreExtension dcModule = new DublinCoreExtension();
feed.addModule(dcModule);
Assert.assertEquals(feed.getAuthors().get(0).getName(), "Test User");
Assert.assertEquals(feed.getAuthors().get(0).getEmail(), "testuser@example.com");
Assert.assertEquals(feed.getContributors().get(0).getName(), "test university");
Assert.assertEquals(feed.getTitle().getValue(), "Test Feed");
Assert.assertEquals(feed.getDescription().getType(), "text/html");
Assert.assertEquals(feed.getType(), Type.RSS);
Assert.assertEquals(feed.getLink(), "http://localhost:8080/feeds/rss/2.0/test");
} catch (Exception e) {
Assert.fail();
}
// Todo test Services... but this cannot be done outside OSGI and the servlet Container, so this has to be done by
// an integration test.
}
use of org.opencastproject.feed.api.Content in project opencast by opencast.
the class AbstractFeedGenerator method setImage.
/**
* Adds the image as a content element to the feed entry.
*
* @param entry
* the feed entry
* @param imageUrl
* the image url
* @return the image
*/
protected Content setImage(FeedEntry entry, String imageUrl) {
StringBuffer buf = new StringBuffer("<div xmlns=\"http://www.w3.org/1999/xhtml\">");
buf.append("<img src=\"");
buf.append(imageUrl);
buf.append("\" />");
buf.append("</div>");
Content image = new ContentImpl(buf.toString(), "application/xhtml+xml", Mode.Xml);
entry.addContent(image);
return image;
}
Aggregations