@Test public void parse() throws FileNotFoundException, IOException { InputStream inputStream = this.getClass().getResourceAsStream("/GoogleBookmarks.rss"); ByteArrayOutputStream out = new ByteArrayOutputStream(); IOUtils.copy(inputStream, out); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); Set<Link> links = fixture.parse(new ParseContext(in, null, "/GoogleBookmarks.rss")); assertNotNull(links); assertTrue(links.size() == 2); Iterator<Link> it = links.iterator(); Link link = it.next(); assertEquals("Another title", link.getTitle()); assertEquals("Bla bla", link.getDescription()); assertEquals(1, link.getLabels().size()); Iterator<String> labels = link.getLabels().iterator(); assertEquals("Label1", labels.next()); link = it.next(); assertEquals("Some title", link.getTitle()); assertEquals("Some description", link.getDescription()); assertEquals(2, link.getLabels().size()); Iterator<String> labelIt = link.getLabels().iterator(); assertEquals("Label1", labelIt.next()); assertEquals("Label2", labelIt.next()); }
@Override public Set<Link> parse(ParseContext context) throws IOException { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(context.getInputStream()); NodeList nodeList = doc.getElementsByTagName("item"); for (int i = 0; i < nodeList.getLength(); i++) { parseBookmark(nodeList.item(i)); } } catch (ParserConfigurationException | SAXException ex) { } return getLinks(); }
GoogleBookmarkRssXmlParser extends AbstractParser { @Override public Set<Link> parse(ParseContext context) throws IOException { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(context.getInputStream()); NodeList nodeList = doc.getElementsByTagName("item"); for (int i = 0; i < nodeList.getLength(); i++) { parseBookmark(nodeList.item(i)); } } catch (ParserConfigurationException | SAXException ex) { } return getLinks(); } }
GoogleBookmarkRssXmlParser extends AbstractParser { @Override public Set<Link> parse(ParseContext context) throws IOException { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(context.getInputStream()); NodeList nodeList = doc.getElementsByTagName("item"); for (int i = 0; i < nodeList.getLength(); i++) { parseBookmark(nodeList.item(i)); } } catch (ParserConfigurationException | SAXException ex) { } return getLinks(); } GoogleBookmarkRssXmlParser(); }
GoogleBookmarkRssXmlParser extends AbstractParser { @Override public Set<Link> parse(ParseContext context) throws IOException { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(context.getInputStream()); NodeList nodeList = doc.getElementsByTagName("item"); for (int i = 0; i < nodeList.getLength(); i++) { parseBookmark(nodeList.item(i)); } } catch (ParserConfigurationException | SAXException ex) { } return getLinks(); } GoogleBookmarkRssXmlParser(); @Override String getName(); @Override boolean canParse(ParseContext context); @Override Set<Link> parse(ParseContext context); }
GoogleBookmarkRssXmlParser extends AbstractParser { @Override public Set<Link> parse(ParseContext context) throws IOException { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(context.getInputStream()); NodeList nodeList = doc.getElementsByTagName("item"); for (int i = 0; i < nodeList.getLength(); i++) { parseBookmark(nodeList.item(i)); } } catch (ParserConfigurationException | SAXException ex) { } return getLinks(); } GoogleBookmarkRssXmlParser(); @Override String getName(); @Override boolean canParse(ParseContext context); @Override Set<Link> parse(ParseContext context);  }