/** * Aggregate all testsuites into a single document and write it to the * specified directory and file. * @throws BuildException thrown if there is a serious error while writing * the document. */ @Override public void execute() throws BuildException { Element rootElement = createDocument(); File destFile = getDestinationFile(); // write the document try { writeDOMTree(rootElement.getOwnerDocument(), destFile); } catch (IOException e) { throw new BuildException("Unable to write test aggregate to '" + destFile + "'", e); } // apply transformation for (AggregateTransformer transformer : transformers) { transformer.setXmlDocument(rootElement.getOwnerDocument()); transformer.transform(); } }
DocumentBuilder builder = getDocumentBuilder(); Document doc = builder.newDocument(); Element rootElement = doc.createElement(TESTSUITES); for (File file : getFiles()) { try { log("Parsing file: '" + file + "'", Project.MSG_VERBOSE); if (file.length() > 0) { Document testsuiteDoc = builder.parse(FileUtils addTestSuite(rootElement, elem); generatedId++; } else { log("the file " + file + WARNING_INVALID_ROOT_ELEMENT, Project.MSG_WARN); log("the file " + file + WARNING_EMPTY_FILE, Project.MSG_WARN); log("The file " + file + WARNING_IS_POSSIBLY_CORRUPTED, Project.MSG_WARN); log(StringUtils.getStackTrace(e), Project.MSG_DEBUG); } catch (IOException e) { log("Error while accessing file " + file + ": " + e.getMessage(), Project.MSG_ERR); log("Error while accessing file " + file + ": " + e.getMessage(), e, Project.MSG_VERBOSE);
/** * Get the full destination file where to write the result. It is made of * the <tt>todir</tt> and <tt>tofile</tt> attributes. * @return the destination file where should be written the result file. */ public File getDestinationFile() { if (toFile == null) { toFile = DEFAULT_FILENAME; } if (toDir == null) { toDir = getProject().resolveFile(DEFAULT_DIR); } return new File(toDir, toFile); }
private XSLTProcess xsltTask() { XSLTProcess xsltTask = new XSLTProcess(); xsltTask.bindToOwner(task); xsltTask.setClasspath(classpath); xsltTask.setXslResource(getStylesheet()); xsltTask.setIn(((XMLResultAggregator) task).getDestinationFile()); return xsltTask; }
private XSLTProcess xsltTask() { XSLTProcess xsltTask = new XSLTProcess(); xsltTask.bindToOwner(task); xsltTask.setClasspath(classpath); xsltTask.setXslResource(getStylesheet()); xsltTask.setIn(((XMLResultAggregator) task).getDestinationFile()); return xsltTask; }
xsltTask.setIn(((XMLResultAggregator) task).getDestinationFile()); File outputFile; if (FRAMES.equals(format)) {
/** * Get all <code>.xml</code> files in the fileset. * * @return all files in the fileset that end with a '.xml'. */ protected File[] getFiles() { Project p = getProject(); return filesets.stream().flatMap(fs -> { DirectoryScanner ds = fs.getDirectoryScanner(p); ds.scan(); return Stream.of(ds.getIncludedFiles()) .filter(pathname -> pathname.endsWith(".xml")) .map(pathname -> p.resolveFile(new File(ds.getBasedir(), pathname).getPath())); }).toArray(File[]::new); }