Skip to content

Commit

Permalink
[FIXED JENKINS-14864] Merge multiple XMLs
Browse files Browse the repository at this point in the history
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 792cb7d
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -45,6 +45,7 @@ public class NUnitReportTransformer implements TestReportTransformer, Serializab
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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 792cb7d

Please sign in to comment.