@Test public void testWriteExclusionFile_indent() throws IOException, XMLStreamException, TransformerException, URISyntaxException { ExclusionFiles.write(output, linkageErrors); String actual = new String(Files.readAllBytes(output)); String expected = new String( Files.readAllBytes( absolutePathOfResource( "exclusion-sample-rules/expected-exclusion-output-file.xml")), Charsets.UTF_8); assertEquals(expected, actual); }
static void write(Path outputFile, Set<LinkageProblem> linkageProblems) throws IOException, XMLStreamException, TransformerException { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); XMLEventWriter writer = null; try { writer = XMLOutputFactory.newInstance().createXMLEventWriter(buffer); writer.add(eventFactory.createStartDocument()); writer.add(eventFactory.createStartElement(LINKAGE_CHECKER_FILTER_TAG, null, null)); for (LinkageProblem linkageProblem : linkageProblems) { writeXmlLinkageProblem(writer, linkageProblem); } writer.add(eventFactory.createEndElement(LINKAGE_CHECKER_FILTER_TAG, null)); writer.add(eventFactory.createEndDocument()); } finally { if (writer != null) { writer.close(); } } try (OutputStream outputStream = Files.newOutputStream(outputFile)) { insertIndent(new ByteArrayInputStream(buffer.toByteArray()), outputStream); } }
ExclusionFiles { static void write(Path outputFile, Set<LinkageProblem> linkageProblems) throws IOException, XMLStreamException, TransformerException { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); XMLEventWriter writer = null; try { writer = XMLOutputFactory.newInstance().createXMLEventWriter(buffer); writer.add(eventFactory.createStartDocument()); writer.add(eventFactory.createStartElement(LINKAGE_CHECKER_FILTER_TAG, null, null)); for (LinkageProblem linkageProblem : linkageProblems) { writeXmlLinkageProblem(writer, linkageProblem); } writer.add(eventFactory.createEndElement(LINKAGE_CHECKER_FILTER_TAG, null)); writer.add(eventFactory.createEndDocument()); } finally { if (writer != null) { writer.close(); } } try (OutputStream outputStream = Files.newOutputStream(outputFile)) { insertIndent(new ByteArrayInputStream(buffer.toByteArray()), outputStream); } } }
ExclusionFiles { static void write(Path outputFile, Set<LinkageProblem> linkageProblems) throws IOException, XMLStreamException, TransformerException { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); XMLEventWriter writer = null; try { writer = XMLOutputFactory.newInstance().createXMLEventWriter(buffer); writer.add(eventFactory.createStartDocument()); writer.add(eventFactory.createStartElement(LINKAGE_CHECKER_FILTER_TAG, null, null)); for (LinkageProblem linkageProblem : linkageProblems) { writeXmlLinkageProblem(writer, linkageProblem); } writer.add(eventFactory.createEndElement(LINKAGE_CHECKER_FILTER_TAG, null)); writer.add(eventFactory.createEndDocument()); } finally { if (writer != null) { writer.close(); } } try (OutputStream outputStream = Files.newOutputStream(outputFile)) { insertIndent(new ByteArrayInputStream(buffer.toByteArray()), outputStream); } }  }
ExclusionFiles { static void write(Path outputFile, Set<LinkageProblem> linkageProblems) throws IOException, XMLStreamException, TransformerException { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); XMLEventWriter writer = null; try { writer = XMLOutputFactory.newInstance().createXMLEventWriter(buffer); writer.add(eventFactory.createStartDocument()); writer.add(eventFactory.createStartElement(LINKAGE_CHECKER_FILTER_TAG, null, null)); for (LinkageProblem linkageProblem : linkageProblems) { writeXmlLinkageProblem(writer, linkageProblem); } writer.add(eventFactory.createEndElement(LINKAGE_CHECKER_FILTER_TAG, null)); writer.add(eventFactory.createEndDocument()); } finally { if (writer != null) { writer.close(); } } try (OutputStream outputStream = Files.newOutputStream(outputFile)) { insertIndent(new ByteArrayInputStream(buffer.toByteArray()), outputStream); } }   }
ExclusionFiles { static void write(Path outputFile, Set<LinkageProblem> linkageProblems) throws IOException, XMLStreamException, TransformerException { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); XMLEventWriter writer = null; try { writer = XMLOutputFactory.newInstance().createXMLEventWriter(buffer); writer.add(eventFactory.createStartDocument()); writer.add(eventFactory.createStartElement(LINKAGE_CHECKER_FILTER_TAG, null, null)); for (LinkageProblem linkageProblem : linkageProblems) { writeXmlLinkageProblem(writer, linkageProblem); } writer.add(eventFactory.createEndElement(LINKAGE_CHECKER_FILTER_TAG, null)); writer.add(eventFactory.createEndDocument()); } finally { if (writer != null) { writer.close(); } } try (OutputStream outputStream = Files.newOutputStream(outputFile)) { insertIndent(new ByteArrayInputStream(buffer.toByteArray()), outputStream); } }    }