public void startTestSuite()

in src/main/org/apache/ant/antunit/listener/XMLAntUnitListener.java [69:115]


    public void startTestSuite(Project testProject, String buildFile) {
        try {
            super.startTestSuite(testProject, buildFile);
            out = getOut(buildFile);
            wri = new OutputStreamWriter(out, "UTF8");
            doc = DOMUtils.newDocument();
            root = doc.createElement(XMLConstants.TESTSUITE);
            // if we want to (ab)use <junitreport> name needs to
            // follow the structure expected by that task:
            // package.class.  package will be the directory holding
            // the build file (file separators replaced by dots) and
            // class the build file name with the last dot replaced
            // by an underscore
            root.setAttribute(XMLConstants.ATTR_NAME, normalize(buildFile));
            root.setAttribute(XMLConstants.BUILD_FILE, buildFile);

            //add the timestamp
            String timestamp = DateUtils.format(new Date(),
                                                DateUtils
                                                .ISO8601_DATETIME_PATTERN);
            root.setAttribute(XMLConstants.TIMESTAMP, timestamp);
            //and the hostname.
            root.setAttribute(XMLConstants.HOSTNAME, getHostname());

            domWri.writeXMLDeclaration(wri);
            domWri.openElement(root, wri, 0, INDENT, true);
            wri.write(StringUtils.LINE_SEP);

            Element propertiesElement =
                DOMUtils.createChildElement(root, XMLConstants.PROPERTIES);
            @SuppressWarnings("unchecked")
            Hashtable<String,Object> propertiesMap = testProject.getProperties();
            for (final Iterator<Map.Entry<String, Object>> iterator = propertiesMap.entrySet().iterator();
                 iterator.hasNext();) {
                final Map.Entry<String, Object> property = iterator.next();
                Element e = DOMUtils.createChildElement(propertiesElement,
                                                        XMLConstants.PROPERTY);
                e.setAttribute(XMLConstants.ATTR_NAME,
                               property.getKey());
                e.setAttribute(XMLConstants.ATTR_VALUE,
                               property.getValue().toString());
            }
            domWri.write(propertiesElement, wri, 1, INDENT);
        } catch (IOException ex) {
            throw new BuildException(ex);
        }
    }