public void testDetail() { System.out.println("DETAIL TEST"); String testString = "<?xml version='1.0' encoding='ISO-8859-1'?><response state='ok' boolean='true' int='-100' long='4676767676' ns:olli='cool'><mixed>Olli <b>ist</b> toll<</mixed><text>Text<<![CDATA[<huhu>Dies ist aller CDATA</huhu>]]></text></response>\n"; System.out.println("TEST STRING:"); System.out.println(testString); System.out.println(""); try { InputStream in = new ByteArrayInputStream(testString.getBytes("ISO-8859-1")); SimpleImporter dumpImporter = new SimpleImporter(); DetailTester detailTester = new DetailTester(); dumpImporter.addSimpleImportHandler(detailTester); dumpImporter.setIncludeLeadingCDataIntoStartElementCallback(true); dumpImporter.parse(new InputSource(in)); } catch (Exception e) { e.printStackTrace(); fail("Error: " + e); } }
public void testPathList() { System.out.println("PATH LIST TEST"); String testString = "<?xml version='1.0' encoding='ISO-8859-1'?>" + "<root xmlns:olli=\"http://www.zeigermann.de\" xmlns:daniel=\"http://www.floreysoft.de\"><sub>" + "<olli:element>\n" + "<daniel:element>Huhu</daniel:element>\n" + "</olli:element>" + "</sub></root>"; System.out.println("TEST STRING:"); System.out.println(testString); System.out.println(""); try { InputStream in = new ByteArrayInputStream(testString.getBytes("ISO-8859-1")); SimpleImporter testImporter = new SimpleImporter(); PathListTester tester = new PathListTester(); testImporter.addSimpleImportHandler(tester); testImporter.setBuildComplexPath(true); testImporter.setUseQName(false); testImporter.setIncludeLeadingCDataIntoStartElementCallback(false); testImporter.parse(new InputSource(in)); } catch (Exception e) { e.printStackTrace(); fail("Error: " + e); } }
public void testMain() { System.out.println("MAIN TEST"); String testString = "<?xml version='1.0' encoding='ISO-8859-1'?><response state='ok'><mixed>Olli <b>ist</b> toll<</mixed><text>Text<<![CDATA[<huhu>Dies ist aller CDATA</huhu>]]></text></response>\n"; System.out.println("TEST STRING:"); System.out.println(testString); System.out.println(""); SimpleImporter dumpImporter = new SimpleImporter(); DumpTester dumpTester = new DumpTester(); try { InputStream in = new ByteArrayInputStream(testString.getBytes("ISO-8859-1")); dumpImporter.addSimpleImportHandler(dumpTester); dumpImporter.setIncludeLeadingCDataIntoStartElementCallback(true); dumpImporter.setFullDebugMode(true); dumpImporter.setUseQName(false); dumpImporter.parse(new InputSource(in)); String fullDebug = dumpImporter.getParsedStreamForDebug(); System.out.println("FULL DEBUG START"); System.out.println(fullDebug); System.out.println("FULL DEBUG END"); assertEquals(testString, fullDebug); System.out.println(dumpImporter.getFoundMixedPCData() ? "MIXED" : "NOT MIXED"); // checks for maximum chunk go here as well (no two text() callbacks may follow each other) String expectedDump = "DOCUMENT START\n/response:\n<response state=\"ok\">\n/response/mixed:\n<mixed>\nOlli\n/response/mixed/b:\n<b>\nist\n/response/mixed/b:\n</b>\n/response/mixed/text():\ntoll<\n/response/mixed:\n</mixed>\n/response/text:\n<text>\n<![CDATA[Text<<huhu>Dies ist aller CDATA</huhu>]]>\n/response/text:\n</text>\n/response:\n</response>\nDOCUMENT END\n"; String actualDump = dumpTester.logBuffer.toString(); System.out.println("COLLECTED DUMP START"); System.out.println(actualDump); System.out.println("COLLECTED DUMP END"); if (!actualDump.equals(expectedDump)) { fail("\nWrong output:\n'" + actualDump + "'\nShould be:\n'" + expectedDump + "'\n"); } } catch (Exception e) { e.printStackTrace(); fail("Error: " + e); } }