Examples of FeedFetcher


Examples of com.sun.syndication.fetcher.FeedFetcher

    }     
  }
 
  public void testDeltaEncoding() {
      FeedFetcherCache feedInfoCache = new HashMapFeedInfoCache();
    FeedFetcher feedFetcher = getFeedFetcher(feedInfoCache);         
    try {
        feedFetcher.setUsingDeltaEncoding(true);
       
        // first retrieval should just grab the default feed
      SyndFeed feed1 = feedFetcher.retrieveFeed(new URL("http://localhost:8080/rome/FetcherTestServlet?deltaencode=TRUE&refreshfeed=TRUE"));
      assertNotNull(feed1);
      assertEquals("atom_0.3.feed.title", feed1.getTitle());
      assertEquals(2, feed1.getEntries().size());
      SyndEntry entry1 = (SyndEntry) feed1.getEntries().get(0);
      assertEquals("atom_0.3.feed.entry[0].title", entry1.getTitle());
     
      // second retrieval should get only the new item
      /*
       * This is breaking with Rome 0.5 ??
       */
      SyndFeed feed2 = feedFetcher.retrieveFeed(new URL("http://localhost:8080/rome/FetcherTestServlet?deltaencode=TRUE&refreshfeed=TRUE"));         
      assertNotNull(feed2);
      assertEquals(FetcherTestServlet.DELTA_FEED_TITLE, feed2.getTitle());
      assertEquals(3, feed2.getEntries().size());
      entry1 = (SyndEntry) feed2.getEntries().get(0);
      assertEquals(FetcherTestServlet.DELTA_FEED_ENTRY_TITLE, entry1.getTitle());
View Full Code Here

Examples of com.sun.syndication.fetcher.FeedFetcher

      }
    }
  }

  public void testRetrieveFeed() {
    FeedFetcher feedFetcher = getFeedFetcher();
    try {
      SyndFeed feed = feedFetcher.retrieveFeed(new URL("http://localhost:8080/rome/FetcherTestServlet/"));
      assertNotNull(feed);
      assertEquals("atom_0.3.feed.title", feed.getTitle());
    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
View Full Code Here

Examples of com.sun.syndication.fetcher.FeedFetcher

           
            server.addContext(context);   
           
            server.start();           
           
            FeedFetcher feedFetcher = getAuthenticatedFeedFetcher();
      SyndFeed feed = feedFetcher.retrieveFeed(new URL("http://localhost:8080/rome/FetcherTestServlet/"));
      assertNotNull(feed);
      assertEquals("atom_0.3.feed.title", feed.getTitle());
           
           
        } catch (Exception e) {
View Full Code Here

Examples of com.sun.syndication.fetcher.FeedFetcher

  /**
   * Test getting a feed via a http 301 redirect
   *
   */
  public void testRetrieveRedirectedFeed() {
    FeedFetcher feedFetcher = getFeedFetcher();
    try {
      SyndFeed feed = feedFetcher.retrieveFeed(new URL("http://localhost:8080/rome/FetcherTestServlet?redirect=TRUE"));
      assertNotNull(feed);
      assertEquals("atom_0.3.feed.title", feed.getTitle());
    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
View Full Code Here

Examples of com.sun.syndication.fetcher.FeedFetcher

  /**
   * Test error handling
   *
   */
  public void testErrorHandling() {
    FeedFetcher feedFetcher = getFeedFetcher();
    try {
      SyndFeed feed = feedFetcher.retrieveFeed(new URL("http://localhost:8080/rome/FetcherTestServlet?error=404"));
      fail("4xx error handling did not work correctly");
    } catch (FetcherException e) {
      // expect this exception
      assertEquals(404, e.getResponseCode());
    } catch (Exception e) {
      e.printStackTrace();
      fail(e.getMessage());
    }
 
    try {
      SyndFeed feed = feedFetcher.retrieveFeed(new URL("http://localhost:8080/rome/FetcherTestServlet?error=500"));
      fail("5xx error handling did not work correctly");
    } catch (FetcherException e) {
      // expect this exception
      assertEquals(500, e.getResponseCode());
    } catch (Exception e) {
View Full Code Here

Examples of com.sun.syndication.fetcher.FeedFetcher

      fail(e.getMessage());
    }
  }

  public void testUserAgent() {
    FeedFetcher feedFetcher = getFeedFetcher();
    //System.out.println(feedFetcher.getUserAgent());
    //System.out.println(System.getProperty("rome.fetcher.version", "UNKNOWN"));
    assertEquals("Rome Client (http://tinyurl.com/64t5n) Ver: " + System.getProperty("rome.fetcher.version", "UNKNOWN"), feedFetcher.getUserAgent());
  }
View Full Code Here

Examples of com.sun.syndication.fetcher.FeedFetcher

  /**
   * Test events fired when there is no cache in use
   *
   */
  public void testFetchEvents() {
    FeedFetcher feedFetcher = getFeedFetcher();
    FetcherEventListenerImpl listener = new FetcherEventListenerImpl();
    feedFetcher.addFetcherEventListener(listener);
    try {
      SyndFeed feed = feedFetcher.retrieveFeed(new URL("http://localhost:8080/rome/FetcherTestServlet/"));
      assertNotNull(feed);
      assertTrue(listener.polled);
      assertTrue(listener.retrieved);
      assertFalse(listener.unchanged);
      listener.reset();
 
      // since there is no cache, the events fired should be exactly the same if
      // we re-retrieve the feed
      feed = feedFetcher.retrieveFeed(new URL("http://localhost:8080/rome/FetcherTestServlet/"));
      assertNotNull(feed);
      assertTrue(listener.polled);
      assertTrue(listener.retrieved);
      assertFalse(listener.unchanged);
      listener.reset();
View Full Code Here

Examples of com.sun.syndication.fetcher.FeedFetcher

   * Test events fired when there is a cache in use
   *
   */
  public void testFetchEventsWithCache() {
    FeedFetcherCache feedInfoCache = new HashMapFeedInfoCache();
    FeedFetcher feedFetcher = getFeedFetcher(feedInfoCache);
    FetcherEventListenerImpl listener = new FetcherEventListenerImpl();
    feedFetcher.addFetcherEventListener(listener);
    try {
      SyndFeed feed = feedFetcher.retrieveFeed(new URL("http://localhost:8080/rome/FetcherTestServlet/"));
      assertNotNull(feed);
      assertTrue(listener.polled);
      assertTrue(listener.retrieved);
      assertFalse(listener.unchanged);
      listener.reset();
 
      // Since the feed is cached, the second request should not
      // actually retrieve the feed
      feed = feedFetcher.retrieveFeed(new URL("http://localhost:8080/rome/FetcherTestServlet/"));
      assertNotNull(feed);
      assertTrue(listener.polled);
      assertFalse(listener.retrieved);
      assertTrue(listener.unchanged);
      listener.reset();
 
      // now simulate getting the feed after it has changed
      feed = feedFetcher.retrieveFeed(new URL("http://localhost:8080/rome/FetcherTestServlet?refreshfeed=TRUE"));
      assertNotNull(feed);
      assertTrue(listener.polled);
      assertTrue(listener.retrieved);
      assertFalse(listener.unchanged);
      listener.reset();
View Full Code Here

Examples of com.sun.syndication.fetcher.FeedFetcher

        // Check to see if the feed requires authentication
        if (source.getAuthentication() != null) //requires auth
        {
          try
          {
            FeedFetcher feedFetcher = new HttpClientFeedFetcher(null, authenticateFeed(source.getAuthentication()));
            if ((null != source.getRssConfig()) && (null != source.getRssConfig().getUserAgent())) {
              feedFetcher.setUserAgent(source.getRssConfig().getUserAgent());
            }
            SyndFeed retVal = feedFetcher.retrieveFeed(new URL(this.cleanUrlStart(url)));
            if (null == retVal) {
              handleRssError(new RuntimeException("Unknown RSS error") , source);             
            }
            return retVal;
          }
          catch (Exception e) {
            System.out.println(i + "  " + url);
           
            if (1 == i) { // else just try again
              handleRssError(e, source);
            }
          }
        }
        else //does not require auth
        {
          try
          {
            FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getInstance();
            FeedFetcher feedFetcher = new HttpURLFeedFetcher(feedInfoCache);
            if ((null != source.getRssConfig()) && (null != source.getRssConfig().getUserAgent())) {
              feedFetcher.setUserAgent(source.getRssConfig().getUserAgent());
            }
            SyndFeed retVal = feedFetcher.retrieveFeed(new URL(this.cleanUrlStart(url)));
            if (null == retVal) {
              handleRssError(new RuntimeException("Unknown RSS error") , source);             
            }
            return retVal;
          }
View Full Code Here

Examples of com.sun.syndication.fetcher.FeedFetcher

 
  private SyndFeed retrieveFeed(String url) {
    SyndFeed inFeed = null;
    try {
      FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getInstance();
      FeedFetcher feedFetcher = new HttpURLFeedFetcher(feedInfoCache);
      URL inputUrl = new URL(url);
      inFeed = feedFetcher.retrieveFeed(inputUrl);
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "error in retrieveFeed with url: " + url);
    }
    return inFeed;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.