XmlWriter implements BulkWriter { public XmlWriter(final OutputStream os, final String[] outTemplate, final String rootNode, final String recordNode) { this.os = os; this.outTemplate = outTemplate; this.rootNode = rootNode; this.recordNode = recordNode; this.xmlRecords = new ArrayList<String>(); } XmlWriter(final OutputStream os, final String[] outTemplate,
                     final String rootNode, final String recordNode); @Override void writeOutput(DataPipe cr); @Override void finish(); String getXmlFormatted(Map<String, String> dataMap);  }
@Test public void testXmlWriter() { DataPipe dataFormatter = new DataPipe(); dataFormatter.getDataMap().put("var1", "var1val"); dataFormatter.getDataMap().put("var2", "var2val"); dataFormatter.getDataMap().put("var3", "var3val"); dataFormatter.getDataMap().put("var4", "var4val"); dataFormatter.getDataMap().put("var5", "var5val"); String[] outTemplate = new String[]{ "var1", "var2", "var3", "var4", "var5" }; XmlWriter xmlWriter = new XmlWriter(System.out, outTemplate, "root", "record"); String expected = "<var1>var1val</var1><var2>var2val</var2><var3>var3val</var3>" + "<var4>var4val</var4><var5>var5val</var5>"; Assert.assertEquals(5, dataFormatter.getDataMap().size()); Assert.assertEquals(expected, xmlWriter.getXmlFormatted(dataFormatter.getDataMap())); }