XPathFinder { public List<Long> queryLongs(String query) { List<Long> ret = new ArrayList<Long>(); List<String> strs = queryTexts(query); for (String str : strs) { ret.add(new Long(str)); } return ret; }  Document getDoc(); void setDoc(Document doc); void config(WebResponse response); NodeList query(String query); List<String> queryTexts(String query); List<Long> queryLongs(String query);  }
@Test public void testQueryLongs() throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); ByteArrayInputStream in = new ByteArrayInputStream( "<a><b>2</b><b>4</b></a>".getBytes()); Document doc = builder.parse(in); XPathFinder finder = new XPathFinder(); finder.setDoc(doc); List<Long> longs = finder.queryLongs(" assertEquals(2l, longs.get(0)); assertEquals(4l, longs.get(1)); assertEquals(2, longs.size()); }