Package com.rometools.rome.io

Examples of com.rometools.rome.io.SyndFeedInput


  private SyndFeed getFeed(String url) {
    try {
      URL feedUrl = new URL(url);
      URLConnection openConnection = feedUrl.openConnection();
          openConnection.addRequestProperty("User-Agent", "RSS River for Elasticsearch (https://github.com/dadoonet/rssriver)");
      SyndFeedInput input = new SyndFeedInput();
            input.setPreserveWireFeed(true);
      SyndFeed feed = input.build(new XmlReader(openConnection));
      return feed;
    } catch (MalformedURLException e) {
      logger.error("RSS Url is incorrect : [{}].", url);
    } catch (IllegalArgumentException e) {
      logger.error("Feed from [{}] is incorrect.", url);
View Full Code Here


public class RomeTest extends ElasticsearchTestCase {

  @Test
  public void testLeMonde() throws Exception {
    SyndFeedInput input = new SyndFeedInput();
        input.setPreserveWireFeed(true);
    SyndFeed feed = input.build(new XmlReader(getClass().getResource("/lemonde/rss.xml")));

        assertThat(feed, notNullValue());
        assertThat(feed.getEntries().isEmpty(), equalTo(false));

        assertThat(feed.originalWireFeed(), notNullValue());
View Full Code Here

        assertThat(channel.getTtl(), equalTo(15));
  }

    @Test
    public void testGeoLoc() throws Exception {
        SyndFeedInput input = new SyndFeedInput();
        input.setPreserveWireFeed(true);
        SyndFeed feed = input.build(new XmlReader(getClass().getResource("/reuters/rss.xml")));

        assertThat(feed, notNullValue());
        assertThat(feed.getEntries().isEmpty(), equalTo(false));

        for (Object o : feed.getEntries()) {
View Full Code Here

    public static final String JSON = "{\"feedname\":null,\"title\":\"title\",\"author\":\"\",\"description\":\"desc\",\"link\":\"http://link.com/abc\",\"publishedDate\":\"2011-11-10T06:29:02.000Z\",\"source\":null,\"raw\":{},\"location\":{\"lat\":41.8947384616695,\"lon\":12.4839019775391},\"categories\":[\"worldNews\"]}";

    @Test /* this test should be moved somewhere else */
  public void shouldParseRss() throws Exception {
        SyndFeedInput input = new SyndFeedInput();
        SyndFeed feed = input.build(new XmlReader(getClass().getResource("/reuters/rss.xml")));

        assertThat(feed.getEntries().size(), greaterThan(0));
        for (Object o : feed.getEntries()) {
            SyndEntryImpl message = (SyndEntryImpl) o;
            XContentBuilder xcb = toJson(message, null, null, true);
View Full Code Here

        final XContentBuilder xContentBuilder = RssToJson.toJson(entry, null, null, true);
        assertThat(xContentBuilder.string(), equalTo(JSON));
    }

    private SyndEntryImpl buildEntry() throws FeedException, IOException {
        SyndFeedInput input = new SyndFeedInput();
        SyndFeed feed = input.build(new XmlReader(getClass().getResource("/reuters/rss.xml")));
        return (SyndEntryImpl) feed.getEntries().get(0);
    }
View Full Code Here

        logger.info("mapping is: {}", page.string());
    }

    @Test
    public void shouldHaveRawContent() throws Exception {
        SyndFeedInput input = new SyndFeedInput();
        SyndFeed feed = input.build(new XmlReader(getClass().getResource("/dcrainmaker/rss.xml")));

        assertThat(feed.getEntries().size(), greaterThan(0));
        for (Object o : feed.getEntries()) {
            SyndEntryImpl message = (SyndEntryImpl) o;
            XContentBuilder xcb = toJson(message, null, null, true);
View Full Code Here

        }
    }

    @Test
    public void shouldNotHaveRawContent() throws Exception {
        SyndFeedInput input = new SyndFeedInput();
        SyndFeed feed = input.build(new XmlReader(getClass().getResource("/dcrainmaker/rss.xml")));

        assertThat(feed.getEntries().size(), greaterThan(0));
        for (Object o : feed.getEntries()) {
            SyndEntryImpl message = (SyndEntryImpl) o;
            XContentBuilder xcb = toJson(message, null, null, false);
View Full Code Here

      if (xmlString == null) {
        throw new FeedException("Input string is null for url " + feedUrl);
      }
      xmlString = FeedUtils.replaceHtmlEntitiesWithNumericEntities(xmlString);
      InputSource source = new InputSource(new StringReader(xmlString));
      SyndFeed rss = new SyndFeedInput().build(source);
      handleForeignMarkup(rss);

      fetchedFeed.setTitle(rss.getTitle());
      feed.setPushHub(findHub(rss));
      feed.setPushTopic(findSelf(rss));
View Full Code Here

        final WireFeedInput in = new WireFeedInput();
        return in.build(getFeedReader());
    }

    protected SyndFeed getSyndFeed(final boolean preserveWireFeed) throws Exception {
        final SyndFeedInput in = new SyndFeedInput();
        in.setPreserveWireFeed(preserveWireFeed);
        return in.build(getFeedReader());
    }
View Full Code Here

TOP

Related Classes of com.rometools.rome.io.SyndFeedInput

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.