Code example for LinkedList

Methods: iterator

0
 
    public static void main(String[] args) throws Exception {
        new Report().main(); 
    } 
 
    private final LinkedList<TestClass> classes = new LinkedList<TestClass>();
 
    private void main() throws Exception { 
//        final File file = new File("/Users/dblevins/work/uber/geronimo-tck-public-trunk/jcdi-tck-runner/target/surefire-reports/testng-results.xml"); 
        final File file = new File("/Users/dblevins/work/all/openejb/tck/cdi-tomee/target/failsafe-reports/testng-results.xml");
//        final File file = new File("/Users/dblevins/work/uber/testng-results.xml"); 
 
        final SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
 
        parser.parse(file, new DefaultHandler() {
            @Override 
            public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
                final String name = qName;
                if ("class".equals(name)) {
                    classes.add(new TestClass(attributes.getValue("name")));
                } 
 
                if ("test-method".equals(name)) {
                    classes.getLast().addStatus(attributes.getValue("status"), attributes.getValue("name"));
                } 
            } 
        }); 
 
        Collections.sort(classes);
 
        textReport(file);
        passingXml(file);
        failingXml(file);
 
    } 
 
    private void textReport(File file) throws FileNotFoundException {
        final File report = new File(file.getParentFile(), file.getName().replaceAll(".xml$", ".txt"));
        final PrintStream out = new PrintStream(new FileOutputStream(report));
        printResults(out);
        out.close();
    } 
 
    private void passingXml(File file) throws FileNotFoundException {
        final File report = new File(file.getParentFile(), file.getName().replaceAll(".xml$", "-passing.xml"));
        final PrintStream out = new PrintStream(new FileOutputStream(report));
 
        out.println(header +
                "<suite name=\"CDI TCK\" verbose=\"0\">\n" + 
                "  <test name=\"CDI TCK\">\n" + 
                "    <packages>\n" + 
                "        <package name=\"org.jboss.jsr299.tck.tests.*\"/>\n" + 
                "        <package name=\"org.jboss.jsr299.tck.interceptors.tests.*\"/>\n" + 
                "    </packages>\n" + 
                "    <classes>"); 
 
        for (TestClass testClass : classes) {
 
            if (contains(testClass, Status.FAIL)) {
                out.printf("      <class name=\"%s\">\n", testClass.name);
                out.printf("        <methods>\n");
 
                for (TestResult result : testClass.getResults()) {
                    if (result.status == Status.FAIL) {
                        out.printf("          <exclude name=\"%s\"/>\n", result.name);
                    } 
                } 
 
                out.printf("        </methods>\n");
                out.printf("      </class>\n");
            } 
        } 
        out.println("    </classes>");
        out.println("  </test>");
        out.println("</suite>");
 
        out.close();
    } 
 
    private void failingXml(File file) throws FileNotFoundException {
        final File report = new File(file.getParentFile(), file.getName().replaceAll(".xml$", "-failing.xml"));
        final PrintStream out = new PrintStream(new FileOutputStream(report));
 
        out.println(header);
        out.println("<suite name=\"CDI TCK\" verbose=\"0\">");
        out.println("  <test name=\"CDI TCK\">");
        out.println("    <!--<packages>-->\n" +
                "        <!--<package name=\"org.jboss.jsr299.tck.tests.*\"/>-->\n" + 
                "        <!--<package name=\"org.jboss.jsr299.tck.interceptors.tests.*\"/>-->\n" + 
                "    <!--</packages>-->"); 
        out.println("    <classes>");
 
        for (TestClass testClass : classes) {
 
            if (contains(testClass, Status.FAIL)) {
                out.printf("      <class name=\"%s\"/>\n", testClass.name);
            } 
        }