### Question:
XMLExporter extends Exporter<T> { @Override public void exportStream(OutputStream outputStream, Iterator<T> iterator) throws IOException, ClassNotFoundException, IllegalAccessException { JacksonXmlModule module = new JacksonXmlModule(); module.setDefaultUseWrapper(false); XmlMapper xmlMapper = new XmlMapper(module); XmlFactory factory = new XmlFactory(); ToXmlGenerator generator = factory.createGenerator(outputStream); generator.setCodec(xmlMapper); generator.writeRaw("<xml>"); while (iterator.hasNext()) { generator.writeRaw(xmlMapper.writeValueAsString(iterator.next())); } generator.writeRaw("</xml>"); generator.flush(); } XMLExporter(Class dataClass); @Override void exportStream(OutputStream outputStream, Iterator<T> iterator);  }### Answer:
@Test public void testExportStream() throws Exception { ByteArrayOutputStream os = new ByteArrayOutputStream(); XMLExporter<SamplePojo> exporter = new XMLExporter<>(SamplePojo.class); exporter.exportStream(os, TestData.getData().iterator()); os.flush(); os.close(); XMLImporter<SamplePojo> importer = new XMLImporter<>(SamplePojo.class); List<SamplePojo> list = importer.importStream(new ByteArrayInputStream(os.toByteArray())); assert list.size() == TestData.getData().size(); int index = 0; for (SamplePojo item : list) { SamplePojo ref = TestData.getData().get(index++); assertEquals(ref,item); } }