Package com.rometools.rome.io

Examples of com.rometools.rome.io.XmlReader


      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


  @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

    @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

        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

    }

    @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

        testInvalidEntities(" <!-- just in case -->\n" + XML_PROLOG + "<hello>&Pi;&Rho;&#9x13;&Rho;</hello>");
    }

    protected void testXmlParse(final String garbish, final String xmlDoc) throws Exception {
        final InputStream is = getStream(garbish, xmlDoc);
        Reader reader = new XmlReader(is);
        reader = new XmlFixerReader(reader);
        final SAXBuilder saxBuilder = new SAXBuilder();
        saxBuilder.build(reader);
    }
View Full Code Here

        testXmlParse(garbish, xmlDoc);
    }

    protected void testXmlParse(final String garbish, final String xmlDoc) throws Exception {
        final InputStream is = getStream(garbish, xmlDoc);
        Reader reader = new XmlReader(is);
        reader = new XmlFixerReader(reader);

        final SAXBuilder saxBuilder = new SAXBuilder();
        saxBuilder.build(reader);
    }
View Full Code Here

        checkEncoding(XML5, encoding, encoding);
    }

    private void checkEncoding(final String xmlType, final String encoding, final String expected) throws IOException {
        InputStream is = null;
        XmlReader xmlReader = null;
        try {
            is = getXmlStream("no-bom", xmlType, encoding, encoding);
            xmlReader = new XmlReader(is, false);
            assertEquals(xmlReader.getEncoding(), expected);
        } finally {
            if (xmlReader != null) {
                xmlReader.close();
            }
            if (is != null) {
                is.close();
            }
        }
View Full Code Here

TOP

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

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.