Package org.rssowl.core.internal.persist

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


   */
  @Test
  @SuppressWarnings("nls")
  public void testHTTPSFeed() throws Exception {
    URI feedUrl = new URI("https://sourceforge.net/export/rss2_projnews.php?group_id=141424&rss_fulltext=1");
    IFeed feed = new Feed(feedUrl);

    InputStream inS = new DefaultProtocolHandler().openStream(feed.getLink(), null);
    assertNotNull(inS);

    Owl.getInterpreter().interpret(inS, feed);
    assertEquals("RSS 2.0", feed.getFormat());
  }
View Full Code Here


  @SuppressWarnings("nls")
  public void testFILEFeed() throws Exception {
    URL pluginLocation = FileLocator.toFileURL(Platform.getBundle("org.rssowl.core.tests").getEntry("/"));
    IConnectionService conManager = Owl.getConnectionService();
    URL feedUrl = pluginLocation.toURI().resolve("data/interpreter/feed_rss.xml").toURL();
    IFeed feed = new Feed(feedUrl.toURI());

    Pair<IFeed, IConditionalGet> result = conManager.reload(feed.getLink(), null, null);

    assertEquals("RSS 2.0", result.getFirst().getFormat());
  }
View Full Code Here

   */
  @Test
  @SuppressWarnings("nls")
  public void testConditionalGet() throws Exception {
    URI feedUrl = new URI("http://rss.slashdot.org/Slashdot/slashdot/to");
    IFeed feed = new Feed(feedUrl);
    NotModifiedException e = null;

    InputStream inS = new DefaultProtocolHandler().openStream(feed.getLink(), null);
    assertNotNull(inS);

    String ifModifiedSince = null;
    String ifNoneMatch = null;
    if (inS instanceof IConditionalGetCompatible) {
      ifModifiedSince = ((IConditionalGetCompatible) inS).getIfModifiedSince();
      ifNoneMatch = ((IConditionalGetCompatible) inS).getIfNoneMatch();
    }
    IConditionalGet conditionalGet = Owl.getModelFactory().createConditionalGet(ifModifiedSince, feedUrl, ifNoneMatch);

    Map<Object, Object> conProperties = new HashMap<Object, Object>();
    ifModifiedSince = conditionalGet.getIfModifiedSince();
    if (ifModifiedSince != null)
      conProperties.put(IConnectionPropertyConstants.IF_MODIFIED_SINCE, ifModifiedSince);

    ifNoneMatch = conditionalGet.getIfNoneMatch();
    if (ifNoneMatch != null)
      conProperties.put(IConnectionPropertyConstants.IF_NONE_MATCH, ifNoneMatch);

    try {
      new DefaultProtocolHandler().openStream(feed.getLink(), conProperties);
    } catch (NotModifiedException e1) {
      e = e1;
    }

    assertNotNull(e);
View Full Code Here

  @Test
  @SuppressWarnings("nls")
  public void testAuthCredentialProviderContribution() 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);
    AuthenticationRequiredException e = null;

    try {
      conManager.getCredentialsProvider(feedUrl).deleteProxyCredentials(feedUrl); //Disable Proxy
      new DefaultProtocolHandler().openStream(feed.getLink(), null);
    } catch (AuthenticationRequiredException e1) {
      e = e1;
    }

    assertNull(e);
View Full Code Here

   */
  @Test
  public void testCredentialsDeleted() 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);

    DynamicDAO.save(feed);

    ICredentials authCreds = new ICredentials() {
      public String getDomain() {
View Full Code Here

    IFolder rootFolder = new Folder(null, null, "Root");
    for (int i = 1; i < FEEDS + 1; i++) {
      try {
        URI feedLink = fPluginLocation.resolve("data/performance/" + i + ".xml").toURL().toURI();

        IFeed feed = new Feed(feedLink);

        if (withRetention) {
          for (int j = 0; j < 10; j++) {
            INews news = new News(feed);
            news.setTitle("Random Title " + j);
            news.setDescription(getLongDecription());
            news.setLink(new URI("http://www." + System.currentTimeMillis() + ".com/" + rand.nextInt(10000) + j));
            news.setComments("Comments");
            news.setState(INews.State.READ);
            feed.addNews(news);
          }
        }

        feed = DynamicDAO.save(feed);

        IBookMark bookmark = new BookMark(null, rootFolder, new FeedLinkReference(feed.getLink()), "Bookmark");

        if (withRetention)
          Owl.getPreferenceService().getEntityScope(bookmark).putBoolean(DefaultPreferences.DEL_READ_NEWS_STATE, true);

        rootFolder.addMark(bookmark, null, false);
View Full Code Here

      final int c = i;
      tasks.add(new TaskAdapter() {
        public IStatus run(IProgressMonitor monitor) {
          try {
            URI feedLink = fPluginLocation.resolve("data/performance/" + c + ".xml").toURL().toURI();
            IFeed feed = new Feed(feedLink);

            InputStream inS = loadFileProtocol(feed.getLink());
            Owl.getInterpreter().interpret(inS, feed);
          } catch (Exception e) {
            ex.add(e);
          }
          return Status.OK_STATUS;
View Full Code Here

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

        InputStream inS = loadFileProtocol(feed.getLink());
        Owl.getInterpreter().interpret(inS, feed);

        feeds.add(feed);
      } catch (Exception e) {
        Activator.getDefault().logError(e.getMessage(), e);
View Full Code Here

  @Test
  public void testNewsService() throws Exception {
    INewsDAO newsDao = Owl.getPersistenceService().getDAOService().getNewsDAO();
    NewsService service = Controller.getDefault().getNewsService();

    IFeed feed = new Feed(new URI("http://www.rssowl.org/rssowl2dg/tests/manager/rss_2_0.xml")); //$NON-NLS-1$
    feed = DynamicDAO.save(feed);

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

    Owl.getModelFactory().createNews(null, feed, new Date()); //$NON-NLS-1$
    feed = DynamicDAO.save(feed);

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

    newsDao.setState(feed.getNews(), INews.State.READ, true, false);
    assertEquals(0, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));
    assertEquals(0, getStickyCount(feed));

    newsDao.setState(feed.getNews(), INews.State.UNREAD, true, false);
    feed.getNews().get(0).setFlagged(true);
    DynamicDAO.save(feed.getNews().get(0));

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

    newsDao.setState(feed.getNews(), INews.State.READ, true, false);
    assertEquals(0, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));
    assertEquals(1, getStickyCount(feed));

    newsDao.setState(feed.getNews(), INews.State.UPDATED, true, false);
    assertEquals(1, getUnreadCount(feed));
    assertEquals(0, getNewCount(feed));
    assertEquals(1, getStickyCount(feed));

    feed.getNews().get(0).setFlagged(false);
    DynamicDAO.save(feed.getNews().get(0));
    newsDao.setState(feed.getNews(), INews.State.READ, true, false);

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

    /* Simulate Shutdown */
    service.stopService();

    Owl.getModelFactory().createNews(null, feed, new Date()); //$NON-NLS-1$
    feed = DynamicDAO.save(feed);

    Owl.getModelFactory().createNews(null, feed, new Date()); //$NON-NLS-1$
    feed = DynamicDAO.save(feed);

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

    newsDao.setState(feed.getNews(), INews.State.READ, true, false);
    feed.getNews().get(0).setFlagged(true);
    feed.getNews().get(1).setFlagged(true);
    DynamicDAO.save(feed);

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

    newsDao.setState(feed.getNews(), INews.State.UNREAD, true, false);

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

    /* Simulate Dirty Shutdown */
    Owl.getPersistenceService().recreateSchema();

    feed = new Feed(new URI("http://www.rssowl.org/rssowl2dg/tests/manager/rss_2_0.xml")); //$NON-NLS-1$
    feed = DynamicDAO.save(feed);

    Owl.getModelFactory().createNews(null, feed, new Date()); //$NON-NLS-1$
    feed = DynamicDAO.save(feed);

    Owl.getModelFactory().createNews(null, feed, new Date()); //$NON-NLS-1$
    feed = DynamicDAO.save(feed);

    feed.getNews().get(0).setFlagged(true);
    feed.getNews().get(1).setFlagged(true);
    DynamicDAO.save(feed);

    service.testDirtyShutdown();

    assertEquals(2, getUnreadCount(feed));
View Full Code Here

   * @throws Exception
   */
  @SuppressWarnings("nls")
  @Test
  public void testNewsServiceWithUpdatedNews() 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));

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

    assertEquals(1, getUnreadCount(feed));
    assertEquals(1, getNewCount(feed));
    assertEquals(1, getStickyCount(feed));
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.