SitemapWriter { protected void writeDocument(OutputStream outputStream, Collection<String> urls, String rootName, String childName, Map<String, String> parametersForChildren) throws XMLStreamException { XMLEventWriter writer = outputFactory.createXMLEventWriter(outputStream); writer.add(eventFactory.createStartDocument()); writer.add(eventFactory.createStartElement("", "", rootName)); writer.add(eventFactory.createAttribute("xmlns", "http: for (String url: urls) { writeChild(writer, url, childName, parametersForChildren); } writer.add(eventFactory.createEndElement("", "", rootName)); writer.add(eventFactory.createEndDocument()); writer.close(); }  void writeSitemapIndex(OutputStream outputStream,
                                  Collection<SpeciesProperties> speciesProperties); void writeGenes(OutputStream outputStream, Collection<String> various, Collection<String> genes);  }
@Test public void testEmptyUrl() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); subject.writeDocument(baos, Collections.emptyList(), "urlset", "url", ImmutableMap.of()); assertThat( "<?xml version='1.0' encoding='UTF-8'?>" + "<urlset xmlns=\"http: is(baos.toString(Charset.defaultCharset()))); }
@Test public void testWriteMany() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); subject.writeDocument( baos, Collections.nCopies(10, "myCharacteristicWord"), "urlset", "url", ImmutableMap.of()); assertThat(baos.toString(Charset.defaultCharset()).split("myCharacteristicWord").length, is(11)); }