XmlFormatter extends AbstractFormatter { public static String toString(final Feld feld) { StringWriter swriter = new StringWriter(); XmlFormatter formatter = new XmlFormatter(swriter); try { formatter.write(feld); } catch (XMLStreamException shouldnothappen) { throw new ShitHappenedException("can't convert " + feld + " to String", shouldnothappen); } IOUtils.closeQuietly(swriter); return swriter.toString(); } XmlFormatter();  XmlFormatter(final Writer writer);  XmlFormatter(final XMLStreamWriter xmlStreamWriter);  XmlFormatter(final OutputStream ostream); @Override void setWriter(final Writer writer); @Override void setWriter(final OutputStream ostream); void write(final Feld feld); void write(final Teildatensatz teildatensatz); @Override void write(final Satz satz); static String toString(final Feld feld); static String toString(final Teildatensatz teildatensatz); static String toString(final Satz satz); static String toString(final Datenpaket datenpaket);  }
@Test public void testWriteFeld() throws XMLStreamException { Feld x = new Feld("Hello", "World", Align.LEFT); String xmlString = XmlFormatter.toString(x); LOG.info("{} as XML: {}", x, xmlString); checkXML(xmlString); }
@Test public void testWriteTeildatensatz() throws XMLStreamException { Teildatensatz teildatensatz = new Vorsatz().getTeildatensatz(1); String xmlString = XmlFormatter.toString(teildatensatz); LOG.info(teildatensatz + " as XML:\n" + xmlString); checkXML(xmlString); }
@Test public void testWriteSatz() throws XMLStreamException { Satz satz = new Nachsatz(); String xmlString = XmlFormatter.toString(satz); LOG.info(satz + " as XML:\n" + xmlString); checkXML(xmlString); }
@Test public void testWriteDatenpaket() throws XMLStreamException, SAXException, IOException { Datenpaket datenpaket = new Datenpaket(); String xmlString = XmlFormatter.toString(datenpaket); LOG.debug(datenpaket + " as XML:\n" + xmlString); checkXML(xmlString); XmlHelper.validate(xmlString, "/xsd/datenpaket.xsd"); }