@Test public void test() throws IOException, ParserConfigurationException, SAXException, FeedException { final String url = "http: final String host = "Host"; final String port = "Port"; final int timeout = 42; BasicFeedFetcher sut = new BasicFeedFetcher(docFetcher); final Map headers = context.mock(Map.class); String documentText = "<rss version=\"2.0\"><channel><title>The Title</title>" + "<link>http: + "<description>The Description</description><item><title>Item Title</title>" + "<link>http: + "</item></channel></rss>"; final Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder() .parse(new InputSource(new StringReader(documentText))); context.checking(new Expectations() { { oneOf(docFetcher).fetchDocument(with(equal(url)), with(same(headers)), with(equal(host)), with(equal(port)), with(equal(timeout)), with(any(DocumentBuilderFactory.class))); will(returnValue(doc)); } }); SyndFeed result = sut.fetchFeed(url, headers, host, port, timeout); context.assertIsSatisfied(); assertEquals("The Title", result.getTitle()); List<SyndEntry> entries = result.getEntries(); assertEquals(1, entries.size()); assertEquals("Item Title", entries.get(0).getTitle()); }
public SyndFeed fetchFeed(final String inFeedUrl, final Map<String, String> inHttpHeaders, final String inProxyHost, final String inProxyPort, final int inTimeout) throws IOException, ParserConfigurationException, FeedException, SAXException { DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); domFactory.setNamespaceAware(true); Document doc = documentFetcher.fetchDocument(inFeedUrl, inHttpHeaders, inProxyHost, inProxyPort, inTimeout, domFactory); SyndFeedInput input = new SyndFeedInput(); return input.build(doc); }
BasicFeedFetcher implements FeedFetcher { public SyndFeed fetchFeed(final String inFeedUrl, final Map<String, String> inHttpHeaders, final String inProxyHost, final String inProxyPort, final int inTimeout) throws IOException, ParserConfigurationException, FeedException, SAXException { DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); domFactory.setNamespaceAware(true); Document doc = documentFetcher.fetchDocument(inFeedUrl, inHttpHeaders, inProxyHost, inProxyPort, inTimeout, domFactory); SyndFeedInput input = new SyndFeedInput(); return input.build(doc); } }
BasicFeedFetcher implements FeedFetcher { public SyndFeed fetchFeed(final String inFeedUrl, final Map<String, String> inHttpHeaders, final String inProxyHost, final String inProxyPort, final int inTimeout) throws IOException, ParserConfigurationException, FeedException, SAXException { DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); domFactory.setNamespaceAware(true); Document doc = documentFetcher.fetchDocument(inFeedUrl, inHttpHeaders, inProxyHost, inProxyPort, inTimeout, domFactory); SyndFeedInput input = new SyndFeedInput(); return input.build(doc); } BasicFeedFetcher(final HttpDocumentFetcher inDocumentFetcher); }
BasicFeedFetcher implements FeedFetcher { public SyndFeed fetchFeed(final String inFeedUrl, final Map<String, String> inHttpHeaders, final String inProxyHost, final String inProxyPort, final int inTimeout) throws IOException, ParserConfigurationException, FeedException, SAXException { DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); domFactory.setNamespaceAware(true); Document doc = documentFetcher.fetchDocument(inFeedUrl, inHttpHeaders, inProxyHost, inProxyPort, inTimeout, domFactory); SyndFeedInput input = new SyndFeedInput(); return input.build(doc); } BasicFeedFetcher(final HttpDocumentFetcher inDocumentFetcher); SyndFeed fetchFeed(final String inFeedUrl, final Map<String, String> inHttpHeaders,
            final String inProxyHost, final String inProxyPort, final int inTimeout); }
BasicFeedFetcher implements FeedFetcher { public SyndFeed fetchFeed(final String inFeedUrl, final Map<String, String> inHttpHeaders, final String inProxyHost, final String inProxyPort, final int inTimeout) throws IOException, ParserConfigurationException, FeedException, SAXException { DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); domFactory.setNamespaceAware(true); Document doc = documentFetcher.fetchDocument(inFeedUrl, inHttpHeaders, inProxyHost, inProxyPort, inTimeout, domFactory); SyndFeedInput input = new SyndFeedInput(); return input.build(doc); } BasicFeedFetcher(final HttpDocumentFetcher inDocumentFetcher); SyndFeed fetchFeed(final String inFeedUrl, final Map<String, String> inHttpHeaders,
            final String inProxyHost, final String inProxyPort, final int inTimeout);  }