Package org.rssowl.core.persist.reference

Examples of org.rssowl.core.persist.reference.FeedReference


      };
      Controller.getDefault().addBookMarkLoadListener(listener);

      Controller.getDefault().reload(bookmark, null, new NullProgressMonitor());

      assertEquals(new FeedReference(feed.getId()).resolve().getFormat(), "RSS 2.0"); //$NON-NLS-1$

      assertEquals(15, bookmark.getNewsRefs().size());
      assertEquals(15, bookmark.getNewsRefs(INews.State.getVisible()).size());
      assertEquals(15, bookmark.getNews().size());
      assertEquals(15, bookmark.getNews(INews.State.getVisible()).size());
View Full Code Here


  public void testReloadLargeFeedWithInvalidEncoding() throws Exception {
    IFeed feed = new Feed(new URI("http://www.rssowl.org/rssowl2dg/tests/manager/invalid_utf8_large.xml")); //$NON-NLS-1$
    feed = DynamicDAO.save(feed);
    Controller.getDefault().reload(createBookMark(feed), null, new NullProgressMonitor());

    assertEquals("RDF", new FeedReference(feed.getId()).resolve().getFormat()); //$NON-NLS-1$
  }
View Full Code Here

  public void testReloadSmallFeedWithInvalidEncoding() throws Exception {
    IFeed feed = new Feed(new URI("http://www.rssowl.org/rssowl2dg/tests/manager/invalid_utf8_small.xml")); //$NON-NLS-1$
    feed = DynamicDAO.save(feed);
    Controller.getDefault().reload(createBookMark(feed), null, new NullProgressMonitor());

    assertEquals("RDF", new FeedReference(feed.getId()).resolve().getFormat()); //$NON-NLS-1$
  }
View Full Code Here

    folder = DynamicDAO.save(folder);
    IBookMark bookmark = Owl.getModelFactory().createBookMark(1L, folder, new FeedLinkReference(feed.getLink()), "BookMark");

    Controller.getDefault().reload(bookmark, null, new NullProgressMonitor());

    assertEquals(new FeedReference(feed.getId()).resolve().getFormat(), "RSS 2.0"); //$NON-NLS-1$
  }
View Full Code Here

      IFeed feed = new Feed(new URI("inmemory://rss_2_0.xml")); //$NON-NLS-1$
      feed = DynamicDAO.save(feed);
      assertEquals(0, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));

      FeedReference feedRef = new FeedReference(feed.getId());

      IBookMark bookmark = createBookMark(feed);

      final int addedCounter[] = new int[] { 0 };
      final int updatedCounter[] = new int[] { 0 };
      newsListener = new NewsListener() {
        public void entitiesAdded(Set<NewsEvent> events) {
          addedCounter[0] += events.size();
        }

        public void entitiesDeleted(Set<NewsEvent> events) {
          fail("Did not expect this Event");
        }

        public void entitiesUpdated(Set<NewsEvent> events) {
          updatedCounter[0] += events.size();
        }
      };
      DynamicDAO.addEntityListener(INews.class, newsListener);

      /* First Reload */
      InMemoryProtocolHandler.FEED = generateFeed("Title", null, null, null);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feedRef.resolve().getNews().size());
      assertEquals(1, getUnreadCount(feed));
      assertEquals(1, getNewCount(feed));
      assertEquals(INews.State.NEW, feedRef.resolve().getNews().get(0).getState());
      assertEquals(1, addedCounter[0]);

      /* Set to Unread */
      fNewsDao.setState(feedRef.resolve().getNews(), INews.State.UNREAD, true, false);
      assertEquals(1, updatedCounter[0]);

      /* Second Reload with different Title */
      InMemoryProtocolHandler.FEED = generateFeed("Title *new*", null, null, null);

      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(2, feedRef.resolve().getNews().size());
      assertEquals(2, getUnreadCount(feed));
      assertEquals(1, getNewCount(feed));
      assertEquals(1, updatedCounter[0]);
      assertEquals(2, addedCounter[0]);

      List<INews> news = feedRef.resolve().getNews();
      for (INews newsItem : news) {
        if ("Title".equals(newsItem.getTitle()))
          assertEquals(INews.State.UNREAD, newsItem.getState());
        else if ("Title *new*".equals(newsItem.getTitle()))
          assertEquals(INews.State.NEW, newsItem.getState());
      }

      /* Set to Read */
      fNewsDao.setState(feedRef.resolve().getNews(), INews.State.READ, true, false);
      assertEquals(3, updatedCounter[0]);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(2, feedRef.resolve().getNews().size());
      assertEquals(0, getUnreadCount(feed));
      assertEquals(INews.State.READ, feedRef.resolve().getNews().get(0).getState());
      assertEquals(INews.State.READ, feedRef.resolve().getNews().get(1).getState());
      assertEquals(3, updatedCounter[0]);
    } finally {
      if (newsListener != null)
        DynamicDAO.removeEntityListener(INews.class, newsListener);
    }
View Full Code Here

      IFeed feed = new Feed(new URI("inmemory://rss_2_0.xml")); //$NON-NLS-1$
      feed = DynamicDAO.save(feed);
      assertEquals(0, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));

      FeedReference feedRef = new FeedReference(feed.getId());

      IBookMark bookmark = createBookMark(feed);

      final int addedCounter[] = new int[] { 0 };
      final int updatedCounter[] = new int[] { 0 };
      newsListener = new NewsListener() {
        public void entitiesAdded(Set<NewsEvent> events) {
          addedCounter[0] += events.size();
        }

        public void entitiesDeleted(Set<NewsEvent> events) {
          fail("Did not expect this Event");
        }

        public void entitiesUpdated(Set<NewsEvent> events) {
          updatedCounter[0] += events.size();
        }
      };
      DynamicDAO.addEntityListener(INews.class, newsListener);

      /* First Reload */
      InMemoryProtocolHandler.FEED = generateFeed(null, "http://www.link.de", null, null);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feedRef.resolve().getNews().size());
      assertEquals(1, getUnreadCount(feed));
      assertEquals(1, getNewCount(feed));
      assertEquals(INews.State.NEW, feedRef.resolve().getNews().get(0).getState());

      /* Set to Unread */
      fNewsDao.setState(feedRef.resolve().getNews(), INews.State.UNREAD, true, false);

      /* Second Reload with different Link */
      InMemoryProtocolHandler.FEED = generateFeed(null, "http://www.link_other.de", null, null);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(2, feedRef.resolve().getNews().size());
      assertEquals(2, getUnreadCount(feed));
      assertEquals(1, getNewCount(feed));

      List<INews> news = feedRef.resolve().getNews();
      for (INews newsItem : news) {
        if ("http://www.link.de".equals(newsItem.getLink().toString()))
          assertEquals(INews.State.UNREAD, newsItem.getState());
        else if ("http://www.link_other.de".equals(newsItem.getLink().toString()))
          assertEquals(INews.State.NEW, newsItem.getState());
      }

      /* Set to Read */
      fNewsDao.setState(feedRef.resolve().getNews(), INews.State.READ, true, false);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(2, feedRef.resolve().getNews().size());
      assertEquals(0, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));
      assertEquals(INews.State.READ, feedRef.resolve().getNews().get(0).getState());
      assertEquals(INews.State.READ, feedRef.resolve().getNews().get(1).getState());

      /* Test Event Counter */
      assertEquals(2, addedCounter[0]);
      assertEquals(3, updatedCounter[0]);
    } finally {
View Full Code Here

      IFeed feed = new Feed(new URI("inmemory://rss_2_0.xml")); //$NON-NLS-1$
      feed = DynamicDAO.save(feed);
      assertEquals(0, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));

      FeedReference feedRef = new FeedReference(feed.getId());

      IBookMark bookmark = createBookMark(feed);

      final int addedCounter[] = new int[] { 0 };
      final int updatedCounter[] = new int[] { 0 };
      newsListener = new NewsListener() {
        public void entitiesAdded(Set<NewsEvent> events) {
          addedCounter[0] += events.size();
        }

        public void entitiesDeleted(Set<NewsEvent> events) {
          fail("Did not expect this Event");
        }

        public void entitiesUpdated(Set<NewsEvent> events) {
          updatedCounter[0] += events.size();
        }
      };
      DynamicDAO.addEntityListener(INews.class, newsListener);

      /* First Reload */
      InMemoryProtocolHandler.FEED = generateFeed(null, null, "http://www.guid.de", null);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feedRef.resolve().getNews().size());
      assertEquals(1, getUnreadCount(feed));
      assertEquals(1, getNewCount(feed));
      assertEquals(INews.State.NEW, feedRef.resolve().getNews().get(0).getState());

      /* Set to Unread */
      fNewsDao.setState(feedRef.resolve().getNews(), INews.State.UNREAD, true, false);

      /* Second Reload with different Guid */
      InMemoryProtocolHandler.FEED = generateFeed(null, null, "http://www.guid_other.de", null);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(2, feedRef.resolve().getNews().size());
      assertEquals(2, getUnreadCount(feed));
      assertEquals(1, getNewCount(feed));

      List<INews> news = feedRef.resolve().getNews();
      for (INews newsItem : news) {
        if ("http://www.guid.de".equals(newsItem.getGuid().getValue()))
          assertEquals(INews.State.UNREAD, newsItem.getState());
        else if ("http://www.guid_other.de".equals(newsItem.getGuid().getValue()))
          assertEquals(INews.State.NEW, newsItem.getState());
      }

      /* Set to Read */
      fNewsDao.setState(feedRef.resolve().getNews(), INews.State.READ, true, false);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(2, feedRef.resolve().getNews().size());
      assertEquals(0, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));
      assertEquals(INews.State.READ, feedRef.resolve().getNews().get(0).getState());
      assertEquals(INews.State.READ, feedRef.resolve().getNews().get(1).getState());

      /* Test Event Counter */
      assertEquals(2, addedCounter[0]);
      assertEquals(3, updatedCounter[0]);
    } finally {
View Full Code Here

      IFeed feed = new Feed(new URI("inmemory://rss_2_0.xml")); //$NON-NLS-1$
      feed = DynamicDAO.save(feed);
      assertEquals(0, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));

      FeedReference feedRef = new FeedReference(feed.getId());

      IBookMark bookmark = createBookMark(feed);

      final int addedCounter[] = new int[] { 0 };
      final int updatedCounter[] = new int[] { 0 };
      newsListener = new NewsListener() {
        public void entitiesAdded(Set<NewsEvent> events) {
          addedCounter[0] += events.size();
        }

        public void entitiesDeleted(Set<NewsEvent> events) {
          fail("Did not expect this Event");
        }

        public void entitiesUpdated(Set<NewsEvent> events) {
          updatedCounter[0] += events.size();
        }
      };
      DynamicDAO.addEntityListener(INews.class, newsListener);

      /* First Reload */
      InMemoryProtocolHandler.FEED = generateFeed("Title", "http://www.link.de", null, null);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feedRef.resolve().getNews().size());
      assertEquals(1, getUnreadCount(feed));
      assertEquals(1, getNewCount(feed));
      assertEquals(INews.State.NEW, feedRef.resolve().getNews().get(0).getState());

      /* Set to Unread */
      fNewsDao.setState(feedRef.resolve().getNews(), INews.State.UNREAD, true, false);

      /* Second Reload with updated Title */
      InMemoryProtocolHandler.FEED = generateFeed("Title *updated*", "http://www.link.de", null, null);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feedRef.resolve().getNews().size());
      assertEquals(1, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));
      assertEquals(INews.State.UPDATED, feedRef.resolve().getNews().get(0).getState());

      /* Set to Read and Reload */
      fNewsDao.setState(feedRef.resolve().getNews(), INews.State.READ, true, false);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feedRef.resolve().getNews().size());
      assertEquals(0, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));
      assertEquals(INews.State.READ, feedRef.resolve().getNews().get(0).getState());

      /* Fourth Reload with added News */
      InMemoryProtocolHandler.FEED = generateFeed("Title *updated*", "http://www.link_other.de", null, null);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(2, feedRef.resolve().getNews().size());
      assertEquals(1, getUnreadCount(feed));
      assertEquals(1, getNewCount(feed));

      List<INews> news = feedRef.resolve().getNews();
      for (INews newsItem : news) {
        if ("http://www.link.de".equals(newsItem.getLink().toString()))
          assertEquals(INews.State.READ, newsItem.getState());
        else if ("http://www.link_other.de".equals(newsItem.getLink().toString()))
          assertEquals(INews.State.NEW, newsItem.getState());
      }

      /* Set to Read */
      fNewsDao.setState(feedRef.resolve().getNews(), INews.State.READ, true, false);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(2, feedRef.resolve().getNews().size());
      assertEquals(0, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));
      assertEquals(INews.State.READ, feedRef.resolve().getNews().get(0).getState());
      assertEquals(INews.State.READ, feedRef.resolve().getNews().get(1).getState());

      /* Test Event Counter */
      assertEquals(2, addedCounter[0]);
      assertEquals(4, updatedCounter[0]);
    } finally {
View Full Code Here

      IFeed feed = new Feed(new URI("inmemory://rss_2_0.xml")); //$NON-NLS-1$
      feed = DynamicDAO.save(feed);
      assertEquals(0, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));

      FeedReference feedRef = new FeedReference(feed.getId());

      IBookMark bookmark = createBookMark(feed);

      final int addedCounter[] = new int[] { 0 };
      final int updatedCounter[] = new int[] { 0 };
      newsListener = new NewsListener() {
        public void entitiesAdded(Set<NewsEvent> events) {
          addedCounter[0] += events.size();
        }

        public void entitiesDeleted(Set<NewsEvent> events) {
          fail("Did not expect this Event");
        }

        public void entitiesUpdated(Set<NewsEvent> events) {
          updatedCounter[0] += events.size();
        }
      };
      DynamicDAO.addEntityListener(INews.class, newsListener);

      /* First Reload */
      InMemoryProtocolHandler.FEED = generateFeed("Title", null, "http://www.guid.de", null);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feedRef.resolve().getNews().size());
      assertEquals(1, getUnreadCount(feed));
      assertEquals(1, getNewCount(feed));
      assertEquals(INews.State.NEW, feedRef.resolve().getNews().get(0).getState());

      /* Set to Unread */
      fNewsDao.setState(feedRef.resolve().getNews(), INews.State.UNREAD, true, false);

      /* Second Reload with updated Title */
      InMemoryProtocolHandler.FEED = generateFeed("Title *updated*", null, "http://www.guid.de", null);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feedRef.resolve().getNews().size());
      assertEquals(1, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));
      assertEquals(INews.State.UPDATED, feedRef.resolve().getNews().get(0).getState());

      /* Set to Read and Reload */
      fNewsDao.setState(feedRef.resolve().getNews(), INews.State.READ, true, false);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feedRef.resolve().getNews().size());
      assertEquals(0, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));
      assertEquals(INews.State.READ, feedRef.resolve().getNews().get(0).getState());

      /* Fourth Reload with added News */
      InMemoryProtocolHandler.FEED = generateFeed("Title *updated*", null, "http://www.guid_other.de", null);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(2, feedRef.resolve().getNews().size());
      assertEquals(1, getUnreadCount(feed));
      assertEquals(1, getNewCount(feed));

      List<INews> news = feedRef.resolve().getNews();
      for (INews newsItem : news) {
        if ("http://www.guid.de".equals(newsItem.getGuid().getValue()))
          assertEquals(INews.State.READ, newsItem.getState());
        else if ("http://www.guid_other.de".equals(newsItem.getGuid().getValue()))
          assertEquals(INews.State.NEW, newsItem.getState());
      }

      /* Set to Read */
      fNewsDao.setState(feedRef.resolve().getNews(), INews.State.READ, true, false);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(2, feedRef.resolve().getNews().size());
      assertEquals(0, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));
      assertEquals(INews.State.READ, feedRef.resolve().getNews().get(0).getState());
      assertEquals(INews.State.READ, feedRef.resolve().getNews().get(1).getState());

      /* Test Event Counter */
      assertEquals(2, addedCounter[0]);
      assertEquals(4, updatedCounter[0]);
    } finally {
View Full Code Here

      IFeed feed = new Feed(new URI("inmemory://rss_2_0.xml")); //$NON-NLS-1$
      feed = DynamicDAO.save(feed);
      assertEquals(0, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));

      FeedReference feedRef = new FeedReference(feed.getId());

      IBookMark bookmark = createBookMark(feed);

      final int addedCounter[] = new int[] { 0 };
      final int updatedCounter[] = new int[] { 0 };
      newsListener = new NewsListener() {
        public void entitiesAdded(Set<NewsEvent> events) {
          addedCounter[0] += events.size();
        }

        public void entitiesDeleted(Set<NewsEvent> events) {
          fail("Did not expect this Event");
        }

        public void entitiesUpdated(Set<NewsEvent> events) {
          updatedCounter[0] += events.size();
        }
      };
      DynamicDAO.addEntityListener(INews.class, newsListener);

      long now = System.currentTimeMillis();

      String description = "Initial description";
      /* First Reload */
      InMemoryProtocolHandler.FEED = generateFeed("Title", null, null, fDateFormat.format(now), description);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feedRef.resolve().getNews().size());
      assertEquals(1, getUnreadCount(feed));
      assertEquals(1, getNewCount(feed));
      assertEquals(INews.State.NEW, feedRef.resolve().getNews().get(0).getState());

      /* Set to Unread */
      fNewsDao.setState(feedRef.resolve().getNews(), INews.State.UNREAD, true, false);

      /* Second Reload with updated description */
      long ms = now + 100000;
      String updatedDescription = description + "updated";
      InMemoryProtocolHandler.FEED = generateFeed("Title", null, null, fDateFormat.format(new Date(ms)), updatedDescription);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feedRef.resolve().getNews().size());
      assertEquals(1, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));
      assertEquals(INews.State.UNREAD, feedRef.resolve().getNews().get(0).getState());

      /* Set to Read and Reload */
      fNewsDao.setState(feedRef.resolve().getNews(), INews.State.READ, true, false);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(1, feedRef.resolve().getNews().size());
      assertEquals(0, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));
      assertEquals(INews.State.READ, feedRef.resolve().getNews().get(0).getState());

      /* Fourth Reload with added News */
      ms = System.currentTimeMillis() + 1000000;
      InMemoryProtocolHandler.FEED = generateFeed("Title Other", null, null, fDateFormat.format(ms));
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(2, feedRef.resolve().getNews().size());
      assertEquals(1, getUnreadCount(feed));
      assertEquals(1, getNewCount(feed));

      List<INews> news = feedRef.resolve().getNews();
      for (INews newsItem : news) {
        if ("Title".equals(newsItem.getTitle()))
          assertEquals(INews.State.READ, newsItem.getState());
        else if ("Title Other".equals(newsItem.getTitle()))
          assertEquals(INews.State.NEW, newsItem.getState());
      }

      /* Set to Read */
      fNewsDao.setState(feedRef.resolve().getNews(), INews.State.READ, true, false);
      fController.reload(bookmark, null, new NullProgressMonitor());
      assertEquals(2, feedRef.resolve().getNews().size());
      assertEquals(0, getUnreadCount(feed));
      assertEquals(0, getNewCount(feed));
      assertEquals(INews.State.READ, feedRef.resolve().getNews().get(0).getState());
      assertEquals(INews.State.READ, feedRef.resolve().getNews().get(1).getState());

      /* Test Event Counter */
      assertEquals(2, addedCounter[0]);
      assertEquals(4, updatedCounter[0]);
    } finally {
View Full Code Here

TOP

Related Classes of org.rssowl.core.persist.reference.FeedReference

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.