Skip to content
Permalink
Browse files

[FIXED JENKINS-14864] Merge multiple XMLs

Applied patch provided by David Churchill in the Jenkins issue.
  • Loading branch information...
David Churchill authored and akoeplinger committed Jul 8, 2014
1 parent f73f7bd commit 792cb7da50a5b1afa30790300ce24d6a02cd98eb
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/main/java/hudson/plugins/nunit/NUnitReportTransformer.java
@@ -45,6 +45,7 @@
private transient Transformer nunitTransformer;
private transient Transformer writerTransformer;
private transient DocumentBuilder xmlDocumentBuilder;
private transient int transformCount;

/**
* Transform the nunit file into several junit files in the output path
@@ -97,13 +98,14 @@ private void initialize() throws TransformerFactoryConfigurationError, Transform
*/
private void splitJUnitFile(File junitFile, File junitOutputPath) throws SAXException, IOException,
TransformerException {
transformCount++;
Document document = xmlDocumentBuilder.parse(junitFile);

NodeList elementsByTagName = ((Element) document.getElementsByTagName("testsuites").item(0)).getElementsByTagName("testsuite");
for (int i = 0; i < elementsByTagName.getLength(); i++) {
Element element = (Element) elementsByTagName.item(i);
DOMSource source = new DOMSource(element);
String filename = JUNIT_FILE_PREFIX + element.getAttribute("name").replaceAll(ILLEGAL_FILE_CHARS_REGEX, "_") + "_" + i + JUNIT_FILE_POSTFIX;
String filename = JUNIT_FILE_PREFIX + element.getAttribute("name").replaceAll(ILLEGAL_FILE_CHARS_REGEX, "_") + "_" + transformCount + "_" + i + JUNIT_FILE_POSTFIX;
File junitOutputFile = new File(junitOutputPath, filename);
FileOutputStream fileOutputStream = new FileOutputStream(junitOutputFile);
try {

0 comments on commit 792cb7d

Please sign in to comment.
You can’t perform that action at this time.