@Test public void test_transformThreeRowsOfComplexXML() throws Exception { String xml = TRIPLE_ROW_MULTIPLE_ORG; makeTsv(xml); psr.setKeepElderInfo(false); psr.setRowElementName("Site"); ByteStreams.copy(inn, tsv); tsv.close(); String result = new String(out.toByteArray()); System.err.println(result); StringReader reader = new StringReader(result); LineReader lines = new LineReader(reader); String line; line = lines.readLine(); assertTrue(line.startsWith("\"code\"\t\"agency\"\t\"Id\"\t\"level\"\t\"Type\"")); line = lines.readLine(); assertTrue(line.startsWith("\"01\"\t\"\"\t\"2172257\"\t\"admin\"\t\"water\"")); line = lines.readLine(); assertTrue(line.startsWith("\"02\"\t\"USGS2\"\t\"\"\t\"\"\t\"clay\"")); line = lines.readLine(); assertTrue(line.startsWith("\"03\"\t\"\"\t\"2172258\"\t\"user\"\t\"stream\"")); }
@Test public void test_transformTwoRowsOfSimplerXML() throws Exception { String xml = "<get><Site>2172257</Site><Site>2172258</Site></get>"; makeTsv(xml); ByteStreams.copy(inn, tsv); tsv.close(); String result = new String(out.toByteArray()); System.err.println(result); StringReader reader = new StringReader(result); LineReader lines = new LineReader(reader); String line; line = lines.readLine(); assertEquals("\"Site\"", line); line = lines.readLine(); assertEquals("\"2172257\"", line); line = lines.readLine(); assertEquals("\"2172258\"", line); }