Package org.rssowl.core.internal.persist

Examples of org.rssowl.core.internal.persist.Feed


   * @throws Exception
   */
  @SuppressWarnings("nls")
  @Test
  public void testNewsServiceWithUpdatedNews2() throws Exception {
    IFeed feed = new Feed(new URI("http://www.feed.com"));
    feed = DynamicDAO.save(feed);

    INews news1 = Owl.getModelFactory().createNews(null, feed, new Date());
    news1.setTitle("News Title #1");
    news1.setLink(new URI("http://www.link.com"));
    news1.setState(INews.State.READ);

    feed = DynamicDAO.save(feed);

    assertEquals(0, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));
    assertEquals(0, getStickyCount(feed));

    feed.getNews().get(0).setTitle("News Title Updated #1");
    feed.getNews().get(0).setState(INews.State.UPDATED);
    feed.getNews().get(0).setFlagged(true);
    feed = DynamicDAO.save(feed);

    assertEquals(1, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));
    assertEquals(INews.State.UPDATED, feed.getNews().get(0).getState());
    assertEquals(1, getStickyCount(feed));

    feed.getNews().get(0).setState(INews.State.READ);
    feed = DynamicDAO.save(feed);

    assertEquals(0, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));
    assertEquals(1, getStickyCount(feed));
View Full Code Here


   * @throws Exception
   */
  @SuppressWarnings("nls")
  @Test
  public void testNewsServiceWithDeletedNews() throws Exception {
    IFeed feed = new Feed(new URI("http://www.feed.com"));
    feed = DynamicDAO.save(feed);

    INews news1 = Owl.getModelFactory().createNews(null, feed, new Date());
    news1.setTitle("News Title #1");
    news1.setLink(new URI("http://www.link.com"));
    news1.setFlagged(true);

    feed = DynamicDAO.save(feed);

    assertEquals(1, getUnreadCount(feed));
    assertEquals(1, getNewCount(feed));
    assertEquals(1, getStickyCount(feed));

    DynamicDAO.delete(feed.getNews().get(0));

    assertEquals(0, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));
    assertEquals(0, getStickyCount(feed));
  }
View Full Code Here

   * @throws Exception
   */
  @SuppressWarnings("nls")
  @Test
  public void testNewsServiceWithDeletedNews2() throws Exception {
    IFeed feed = new Feed(new URI("http://www.feed.com"));
    feed = DynamicDAO.save(feed);

    INews news1 = Owl.getModelFactory().createNews(null, feed, new Date());
    news1.setTitle("News Title #1");
    news1.setLink(new URI("http://www.link.com"));
    news1.setState(INews.State.READ);

    feed = DynamicDAO.save(feed);

    assertEquals(0, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));
    assertEquals(0, getStickyCount(feed));

    feed.getNews().get(0).setTitle("News Title Updated #1");
    feed.getNews().get(0).setState(INews.State.UPDATED);
    feed.getNews().get(0).setFlagged(true);
    feed = DynamicDAO.save(feed);

    assertEquals(1, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));
    assertEquals(1, getStickyCount(feed));
    assertEquals(INews.State.UPDATED, feed.getNews().get(0).getState());

    feed.getNews().get(0).setState(INews.State.READ);
    feed = DynamicDAO.save(feed);

    DynamicDAO.delete(feed.getNews().get(0));

    assertEquals(0, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));
    assertEquals(0, getStickyCount(feed));
  }
View Full Code Here

   * @throws Exception
   */
  @SuppressWarnings("nls")
  @Test
  public void testNewsServiceWithApplicationLayerSaveNews() throws Exception {
    IFeed feed = new Feed(new URI("http://www.feed.com"));
    feed = DynamicDAO.save(feed);

    INews news1 = Owl.getModelFactory().createNews(null, feed, new Date());
    news1.setTitle("News Title #1");
    news1.setLink(new URI("http://www.link.com"));
    news1.setState(INews.State.UNREAD);
    news1.setFlagged(true);

    feed = DynamicDAO.save(feed);

    assertEquals(1, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));
    assertEquals(1, getStickyCount(feed));

    feed.getNews().get(0).setTitle("News Title Updated #1");

    List<INews> news = new ArrayList<INews>();
    news.add(feed.getNews().get(0));

    DynamicDAO.saveAll(news);

    assertEquals(1, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));
View Full Code Here

  private List<IFeed> saveFeeds() throws Exception {
    List<IFeed> feeds = new ArrayList<IFeed>();
    for (int i = 1; i < 200; i++) {
      URI feedLink = fPluginLocation.resolve("data/performance/" + i + ".xml").toURL().toURI();
      IFeed feed = new Feed(feedLink);

      InputStream inS = new BufferedInputStream(new FileInputStream(new File(feed.getLink())));
      Owl.getInterpreter().interpret(inS, feed, null);

      feeds.add(feed);
    }
    DynamicDAO.saveAll(feeds);
View Full Code Here

   */
  @Test
  @SuppressWarnings("nls")
  public void testAtom() throws Exception {
    InputStream inS = getClass().getResourceAsStream("/data/interpreter/feed_atom.xml");
    IFeed feed = new Feed(new URI("http://www.data.interpreter.feed_atom.xml"));
    Owl.getInterpreter().interpret(inS, feed, null);

    assertEquals("Atom 1.0", feed.getFormat());
    assertEquals("atom_title", feed.getTitle());
    assertEquals("atom_subtitle", feed.getDescription());
    assertEquals(new URI("atom_link_html"), feed.getHomepage());
    assertEquals("atom_generator", feed.getGenerator());
    assertEquals("en-us", feed.getLanguage());
    assertEquals(new URI("http://www.feed-uri.de"), feed.getBase());

    assertNotNull(feed.getImage());
    assertEquals(new URI("atom_logo"), feed.getImage().getLink());

    assertNotNull(feed.getLastModifiedDate());

    assertEquals(1, feed.getCategories().size());
    assertEquals("atom_category.label", feed.getCategories().get(0).getName());
    assertEquals("atom_category.term", feed.getCategories().get(0).getDomain());
    assertEquals("atom_copyright", feed.getCopyright());

    assertNotNull(feed.getAuthor());
    assertEquals("atom_author.name", feed.getAuthor().getName());
    assertEquals(new URI("atom_author.uri"), feed.getAuthor().getUri());
    assertEquals(new URI("atom_author.email"), feed.getAuthor().getEmail());

    assertEquals(6, feed.getNews().size());

    INews news1 = feed.getNews().get(0);
    assertEquals("atom_entry1.title", news1.getTitle());
    assertEquals("atom_entry1.description", news1.getDescription());
    assertEquals(new URI("http://www.entry-uri.de"), news1.getBase());

    assertNotNull(news1.getCategories());
    assertEquals("atom_entry1.category.label", news1.getCategories().get(0).getName());
    assertEquals("atom_entry1.category.term", news1.getCategories().get(0).getDomain());

    assertNotNull(news1.getGuid());
    assertEquals("atom_entry1.id", news1.getGuid().getValue());

    assertEquals(new URI("atom_entry1.link.href"), news1.getLink());

    assertEquals(2, news1.getAttachments().size());
    assertEquals(new URI("atom_entry1.enclosure1.href"), news1.getAttachments().get(0).getLink());
    assertEquals("mp3", news1.getAttachments().get(0).getType());
    assertEquals(4500000, news1.getAttachments().get(0).getLength());
    assertEquals(new URI("atom_entry1.enclosure2.href"), news1.getAttachments().get(1).getLink());
    assertEquals("wav", news1.getAttachments().get(1).getType());
    assertEquals(2500000, news1.getAttachments().get(1).getLength());

    assertNotNull(news1.getPublishDate());
    assertNotNull(news1.getModifiedDate());

    assertNotNull(news1.getSource());
    assertEquals("atom_entry1.source.title", news1.getSource().getName());
    assertEquals(new URI("atom_entry1.source.id"), news1.getSource().getLink());

    assertNotNull(news1.getAuthor());
    assertEquals("atom_entry1.author.name", news1.getAuthor().getName());
    assertEquals(new URI("atom_entry1.author.uri"), news1.getAuthor().getUri());
    assertEquals(new URI("atom_entry1.author.email"), news1.getAuthor().getEmail());

    INews news2 = feed.getNews().get(1);
    assertEquals("<p>atom_entry2.title</p>", news2.getTitle());
    assertEquals("<p>atom_entry2.description</p>", news2.getDescription());
    assertEquals(new URI("http://www.feed-uri.de/subfolder"), news2.getBase());

    assertNotNull(news2.getSource());
    assertEquals(new URI("atom_entry2.source.link"), news2.getSource().getLink());

    INews news3 = feed.getNews().get(2);
    assertEquals("<p xmlns=\"http://www.w3.org/1999/xhtml\">atom_entry3.title</p>", news3.getTitle());
    assertEquals("<p xmlns=\"http://www.w3.org/1999/xhtml\">atom_entry3.description</p>", news3.getDescription());
    assertEquals(new URI("http://www.feed-uri.de"), news3.getBase());

    INews news4 = feed.getNews().get(3);
    assertEquals(new URI("atom_entry4.link.href"), news4.getLink());

    INews news5 = feed.getNews().get(4);
    assertEquals("<p xmlns=\"http://www.w3.org/1999/xhtml\">atom_entry5.title</p>", news5.getTitle());
    assertEquals("<p xmlns=\"http://www.w3.org/1999/xhtml\">atom_entry5.description</p>", news5.getDescription());

    INews news6 = feed.getNews().get(5);
    assertEquals("<p>atom_entry6.title</p>", news6.getTitle());
  }
View Full Code Here

   */
  @Test
  @SuppressWarnings("nls")
  public void testRSS() throws Exception {
    InputStream inS = getClass().getResourceAsStream("/data/interpreter/feed_rss.xml");
    IFeed feed = new Feed(new URI("http://www.data.interpreter.feed_rss.xml"));
    Owl.getInterpreter().interpret(inS, feed, null);

    assertEquals("RSS 2.0", feed.getFormat());
    assertEquals("rss_title", feed.getTitle());
    assertEquals(new URI("rss_link"), feed.getHomepage());
    assertEquals("rss_description", feed.getDescription());
    assertEquals("rss_language", feed.getLanguage());
    assertNotNull(feed.getPublishDate());
    assertNotNull(feed.getLastBuildDate());
    assertEquals(new URI("rss_docs"), feed.getDocs());
    assertEquals("rss_generator", feed.getGenerator());

    assertNotNull(feed.getAuthor());
    assertEquals("rss_managingeditor", feed.getAuthor().getName());

    assertEquals("rss_webmaster", feed.getWebmaster());
    assertEquals("rss_copyright", feed.getCopyright());
    assertEquals(120, feed.getTTL());

    assertEquals(1, feed.getCategories().size());
    assertEquals("rss_category", feed.getCategories().get(0).getName());
    assertEquals("rss_category.domain", feed.getCategories().get(0).getDomain());

    assertNotNull(feed.getImage());
    assertEquals(new URI("rss_image.url"), feed.getImage().getLink());

    assertEquals(3, feed.getNews().size());
    INews news1 = feed.getNews().get(0);

    assertEquals("rss_item1.title", news1.getTitle());
    assertEquals(new URI("rss_item1.link"), news1.getLink());

    assertNotNull(news1.getAuthor());
View Full Code Here

   */
  @Test
  @SuppressWarnings("nls")
  public void testURINormalized() throws Exception {
    InputStream inS = getClass().getResourceAsStream("/data/interpreter/feed_uri_mix.xml");
    IFeed feed = new Feed(new URI("http://www.data.interpreter.feed_rss.xml"));
    Owl.getInterpreter().interpret(inS, feed, null);

    assertEquals(new URI("http://www.link.com/feed/link/"), feed.getHomepage());
    assertEquals(new URI("http://www.link.com/feed/docs"), feed.getDocs());

    assertNotNull(feed.getImage());
    assertEquals(new URI("http://www.link.com/image/url//"), feed.getImage().getLink());

    assertEquals(3, feed.getNews().size());
    INews news1 = feed.getNews().get(0);

    assertEquals(new URI("http://www.Link%20.com/%5Bfeed%5D/%7Bitem1%7D/link/"), news1.getLink());

    assertEquals(1, news1.getAttachments().size());
    assertEquals(new URI("http://www.Link.com/feed/item1/attachment1/link/"), news1.getAttachments().get(0).getLink());
View Full Code Here

   */
  @Test
  @SuppressWarnings("nls")
  public void testRDF() throws Exception {
    InputStream inS = getClass().getResourceAsStream("/data/interpreter/feed_rdf.xml");
    IFeed feed = new Feed(new URI("http://www.data.interpreter.feed_rdf.xml"));
    Owl.getInterpreter().interpret(inS, feed, null);

    assertEquals("RDF", feed.getFormat());
    assertEquals("rdf_title", feed.getTitle());
    assertEquals(new URI("rdf_link"), feed.getHomepage());
    assertEquals("rdf_description", feed.getDescription());
    assertEquals("rdf_rights", feed.getCopyright());
    assertEquals("en-us", feed.getLanguage());

    assertNotNull(feed.getAuthor());
    assertEquals("rdf_publisher", feed.getAuthor().getName());

    assertNotNull(feed.getPublishDate());

    assertNotNull(feed.getImage());
    assertEquals(new URI("rdf_image.url"), feed.getImage().getLink());
    assertEquals("rdf_image.title", feed.getImage().getTitle());
    assertEquals(new URI("rdf_image.link"), feed.getImage().getHomepage());

    assertEquals(4, feed.getNews().size());

    INews news1 = feed.getNews().get(0);
    assertEquals("rdf_item1.title", news1.getTitle());
    assertEquals(new URI("rdf_item1.link"), news1.getLink());
    assertEquals("rdf_item1.description", news1.getDescription());

    assertNotNull(news1.getGuid());
    assertEquals("rdf_item1.identifier", news1.getGuid().getValue());

    assertNotNull(news1.getPublishDate());

    assertNotNull(news1.getAuthor());
    assertEquals("rdf_item1.publisher", news1.getAuthor().getName());

    assertNotNull(news1.getSource());
    assertEquals(new URI("rdf_item1.source"), news1.getSource().getLink());

    INews news4 = feed.getNews().get(3);
    assertEquals("rdf_item4.title", news4.getTitle());
    assertEquals(new URI("rdf_item4.link"), news4.getLink());
    assertEquals("rdf_item4.description", news4.getDescription());
  }
View Full Code Here

  @Test
  @SuppressWarnings("nls")
  public void testProxyCredentialProvider() throws Exception {
    IConnectionService conManager = Owl.getConnectionService();
    URI feedUrl = new URI("http://www.rssowl.org/rssowl2dg/tests/connection/authrequired/feed_rdf.xml");
    IFeed feed = new Feed(feedUrl);

    IProxyCredentials proxyCredentials = conManager.getProxyCredentials(feed.getLink());

    assertEquals("", proxyCredentials.getDomain());
    assertEquals("bpasero", proxyCredentials.getUsername());
    assertEquals("admin", proxyCredentials.getPassword());
    assertEquals("127.0.0.1", proxyCredentials.getHost());
View Full Code Here

TOP

Related Classes of org.rssowl.core.internal.persist.Feed

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.