### Question:
MavenJDOMWriter { @Deprecated public void write(Model project, Document document, OutputStream stream) throws java.io.IOException { updateModel(project, "project", new Counter(0), document.getRootElement()); XMLOutputter outputter = new XMLOutputter(); outputter.setFormat(Format.getPrettyFormat().setIndent(" ").setLineSeparator(LS)); outputter.output(document, stream); } MavenJDOMWriter(); @Deprecated void write(Model project, Document document, OutputStream stream); void write(Model project, Document document, String encoding, OutputStreamWriter writer); void write(Model project, Document document, Writer writer, Format jdomFormat);  }### Answer:
@Test public void testKeepComments() throws Exception { Path path = Paths.get("src/test/resources/pom-template.xml"); String pom = new String(Files.readAllBytes(path)); Model model = new MavenXpp3Reader().read(new StringReader(pom)); model.setArtifactId("mytest"); SAXBuilder saxBuilder = new SAXBuilder(); Document document = saxBuilder.build(new StringReader(pom)); MavenJDOMWriter writer = new MavenJDOMWriter(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); writer.write(model, document, "UTF-8", new OutputStreamWriter(baos)); Assert.assertEquals(pom.replace("myartifactid", "mytest").trim(), baos.toString().trim()); }
@Test public void testConcurrentModificationShouldNotHappen() throws Exception { Path path = Paths.get("src/test/resources/FORGE-2646-pom.xml"); String pom = new String(Files.readAllBytes(path)); Assert.assertThat(pom, containsString("wildfly-swarm-plugin")); Model model = new MavenXpp3Reader().read(new StringReader(pom)); model.getBuild().getPlugins().remove(0); SAXBuilder saxBuilder = new SAXBuilder(); Document document = saxBuilder.build(new StringReader(pom)); MavenJDOMWriter writer = new MavenJDOMWriter(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); writer.write(model, document, "UTF-8", new OutputStreamWriter(baos)); Assert.assertThat(baos.toString(), not(containsString("wildfly-swarm-plugin"))); }