PrettyStaxDriver extends StandardStaxDriver { @Override public HierarchicalStreamWriter createWriter(OutputStream out) { return createWriter(new OutputStreamWriter(out)); } PrettyStaxDriver();  PrettyStaxDriver(Collection<String> pCdataFields, boolean jdkOnlyStax); @Override HierarchicalStreamWriter createWriter(OutputStream out); @Override HierarchicalStreamWriter createWriter(Writer out);  }
@Test public void testCreateWriter() { PrettyStaxDriver driver = new PrettyStaxDriver(cdata, true); assertNotNull(driver.createWriter(new ByteArrayOutputStream())); }
@Test public void testPrettyPrintWriter() throws Exception { PrettyStaxDriver driver = new PrettyStaxDriver(cdata, true); StringWriter writer = new StringWriter(); try (Writer w = writer) { PrettyPrintWriter printWriter = (PrettyPrintWriter) driver.createWriter(w); printWriter.startNode("payload-from-template-service", PayloadFromTemplateService.class); printWriter.startNode("unique-id", String.class); printWriter.setValue("naughty-hodgkin"); printWriter.endNode(); printWriter.startNode("template", String.class); printWriter.setValue("Hello World"); printWriter.endNode(); printWriter.endNode(); } System.err.println(writer.toString()); assertTrue(writer.toString().contains("CDATA")); }