Author: bdaw
Date: 2007-10-10 10:53:42 -0400 (Wed, 10 Oct 2007)
New Revision: 8588
Added:
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/ExcludeType.java
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/HTMLReportsType.java
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/IncludeType.java
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/ReportsType.java
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/TestsType.java
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/XMLReportsType.java
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitReporter.java
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitTestReport.java
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/XMLConstants.java
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/filter/
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/filter/ExcludeTestFilter.java
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/filter/IncludeTestFilter.java
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/filter/InfoTestFilter.java
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/filter/MainTestFilter.java
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/report/
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/report/DelegatingReporter.java
Removed:
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/ExcludeTask.java
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/IncludeTask.java
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/TestsTask.java
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitReporter.java
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitTestReport.java
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/XMLConstants.java
modules/test/trunk/unit/src/main/org/jboss/unit/report/junit/
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/ExcludeTestFilter.java
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/IncludeTestFilter.java
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/InfoTestFilter.java
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/MainTestFilter.java
Modified:
modules/test/trunk/tooling/build.xml
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/JBossUnitTask.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/blah/BlahTestTwo.java
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/Main.java
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/MainBuilder.java
Log:
totosome refactorings, added xml reporting
Modified: modules/test/trunk/tooling/build.xml
===================================================================
--- modules/test/trunk/tooling/build.xml 2007-10-10 14:07:54 UTC (rev 8587)
+++ modules/test/trunk/tooling/build.xml 2007-10-10 14:53:42 UTC (rev 8588)
@@ -85,7 +85,8 @@
<!-- Configure thirdparty libraries -->
&libraries;
<path id="library.classpath">
- <path refid="apache.ant.classpath"/>
+ <path location="${apache.ant.lib}/ant-junit.jar"/>
+ <path location="${apache.ant.lib}/ant.jar"/>
<path location="${project.root}/unit/"/>
</path>
@@ -219,7 +220,7 @@
<include ids="testOne,otherTestOne"/>
</tests>
- <tests config="./output/resources/test/bobo-tests.xml">
+ <tests config="./output/resources/test/bobo-tests.xml"
suiteName="one">
<!-- no include tag means invoke all -->
<!-- but you can still exclude some tests -->
<exclude id="otherTestTwo"/>
@@ -231,22 +232,32 @@
<exclude ids="testOne,testTwo"/>
</tests>
- <tests config="output/resources/test/bobo-tests.xml">
+ <tests config="output/resources/test/bobo-tests.xml"
suiteName="three">
<include id="otherTestOne"/>
<include id="testOne"/>
<include id="otherTestTwo"/>
</tests>
- <tests config="output/resources/test/bobo-tests.xml">
+ <tests config="output/resources/test/bobo-tests.xml"
suiteName="four">
<include keywords="simpleTag"/>
</tests>
<tests config="output/resources/test/bobo-tests.xml">
<!-- this one should fail as attribute 'id' is exclusive -->
- <include id="otherTestOne" ids="testOne,testTwo"
keywords="lola,lolo,loli"/>
+ <!--<include id="otherTestOne"
ids="testOne,testTwo" keywords="lola,lolo,loli"/>-->
</tests>
+ <!-- provide noConsole="true" to disable console output -->
+ <reports>
+ <!-- if toDir for xml reports doesn't exist it'll be created
-->
+ <!-- at the moment it produces xmls in junit format -->
+ <xml toDir="./output/test-results"/>
+
+ <!-- html reports uses junit reporting task and will reuse reports
generated by <xml> task-->
+ <html toDir="./output/test-results"/>
+ </reports>
+
<classpath>
Deleted: modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/ExcludeTask.java
===================================================================
---
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/ExcludeTask.java 2007-10-10
14:07:54 UTC (rev 8587)
+++
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/ExcludeTask.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -1,83 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-
-package org.jboss.unit.tooling.ant;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
- * @version $Revision: 0.1 $
- */
-public class ExcludeTask
-{
- private String id;
-
- private String ids;
-
- private String idPatterns;
-
- private String keywords;
-
-
- public ExcludeTask()
- {
- }
-
- public String getId()
- {
- return id;
- }
-
- public void setId(String id)
- {
- this.id = id;
- }
-
- public String getIds()
- {
- return ids;
- }
-
- public void setIds(String ids)
- {
- this.ids = ids;
- }
-
- public String getIdPatterns()
- {
- return idPatterns;
- }
-
-// public void setIdPatterns(String idPatterns)
-// {
-// this.idPatterns = idPatterns;
-// }
-
- public String getKeywords()
- {
- return keywords;
- }
-
- public void setKeywords(String keywords)
- {
- this.keywords = keywords;
- }
-}
Copied: modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/ExcludeType.java
(from rev 8562,
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/ExcludeTask.java)
===================================================================
--- modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/ExcludeType.java
(rev 0)
+++
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/ExcludeType.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -0,0 +1,83 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.unit.tooling.ant;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 0.1 $
+ */
+public class ExcludeType
+{
+ private String id;
+
+ private String ids;
+
+ private String idPatterns;
+
+ private String keywords;
+
+
+ public ExcludeType()
+ {
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+ public String getIds()
+ {
+ return ids;
+ }
+
+ public void setIds(String ids)
+ {
+ this.ids = ids;
+ }
+
+ public String getIdPatterns()
+ {
+ return idPatterns;
+ }
+
+// public void setIdPatterns(String idPatterns)
+// {
+// this.idPatterns = idPatterns;
+// }
+
+ public String getKeywords()
+ {
+ return keywords;
+ }
+
+ public void setKeywords(String keywords)
+ {
+ this.keywords = keywords;
+ }
+}
Added:
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/HTMLReportsType.java
===================================================================
--- modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/HTMLReportsType.java
(rev 0)
+++
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/HTMLReportsType.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -0,0 +1,47 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.unit.tooling.ant;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 0.1 $
+ */
+public class HTMLReportsType
+{
+ public HTMLReportsType()
+ {
+ }
+
+ private String toDir = ".";
+
+ public String getToDir()
+ {
+ return toDir;
+ }
+
+ public void setToDir(String toDir)
+ {
+ this.toDir = toDir;
+ }
+
+}
Deleted: modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/IncludeTask.java
===================================================================
---
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/IncludeTask.java 2007-10-10
14:07:54 UTC (rev 8587)
+++
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/IncludeTask.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -1,83 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-
-package org.jboss.unit.tooling.ant;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
- * @version $Revision: 0.1 $
- */
-public class IncludeTask
-{
- private String id;
-
- private String ids;
-
- private String idPatterns;
-
- private String keywords;
-
-
- public IncludeTask()
- {
- }
-
- public String getId()
- {
- return id;
- }
-
- public void setId(String id)
- {
- this.id = id;
- }
-
- public String getIds()
- {
- return ids;
- }
-
- public void setIds(String ids)
- {
- this.ids = ids;
- }
-
- public String getIdPatterns()
- {
- return idPatterns;
- }
-
-// public void setIdPatterns(String idPatterns)
-// {
-// this.idPatterns = idPatterns;
-// }
-
- public String getKeywords()
- {
- return keywords;
- }
-
- public void setKeywords(String keywords)
- {
- this.keywords = keywords;
- }
-}
Copied: modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/IncludeType.java
(from rev 8562,
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/IncludeTask.java)
===================================================================
--- modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/IncludeType.java
(rev 0)
+++
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/IncludeType.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -0,0 +1,83 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.unit.tooling.ant;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 0.1 $
+ */
+public class IncludeType
+{
+ private String id;
+
+ private String ids;
+
+ private String idPatterns;
+
+ private String keywords;
+
+
+ public IncludeType()
+ {
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+ public String getIds()
+ {
+ return ids;
+ }
+
+ public void setIds(String ids)
+ {
+ this.ids = ids;
+ }
+
+ public String getIdPatterns()
+ {
+ return idPatterns;
+ }
+
+// public void setIdPatterns(String idPatterns)
+// {
+// this.idPatterns = idPatterns;
+// }
+
+ public String getKeywords()
+ {
+ return keywords;
+ }
+
+ public void setKeywords(String keywords)
+ {
+ this.keywords = keywords;
+ }
+}
Modified:
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/JBossUnitTask.java
===================================================================
---
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/JBossUnitTask.java 2007-10-10
14:07:54 UTC (rev 8587)
+++
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/JBossUnitTask.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -24,10 +24,16 @@
import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator;
+import org.apache.tools.ant.taskdefs.optional.junit.AggregateTransformer;
import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.FileSet;
+import org.jboss.unit.tooling.MainBuilder;
+import org.jboss.unit.report.impl.junit.JUnitTestReport;
import java.util.List;
import java.util.LinkedList;
+import java.io.File;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
@@ -36,18 +42,20 @@
public class JBossUnitTask extends Task
{
- List<TestsTask> testsTasks = new LinkedList();
+ List<TestsType> testsTypes = new LinkedList();
+ private ReportsType reports;
+
private Path path;
public JBossUnitTask()
{
}
- public void addConfiguredTests(TestsTask tests)
+ public void addConfiguredTests(TestsType tests)
{
tests.setProject(getProject());
- testsTasks.add(tests);
+ testsTypes.add(tests);
}
public void addConfiguredClasspath(Path path)
@@ -56,21 +64,123 @@
this.path = path;
}
+ public void addConfiguredReports(ReportsType reports)
+ {
+ this.reports = reports;
+ }
+
+
public void execute() throws BuildException
{
- System.out.println("Executing JBossUnit. tests: " + testsTasks.size());
- for (TestsTask testsTask : testsTasks)
+ //System.out.println("Executing JBossUnit. tests: " +
testsTypes.size());
+ for (TestsType testsType : testsTypes)
{
+ // Update reports
+ if (testsType.getReports() == null && getReports() != null)
+ {
+ testsType.setReports(getReports());
+ }
+
// Local classpath for tests overide the global one
- if (testsTask.getClasspath() == null && path != null)
+ if (testsType.getClasspath() == null && path != null)
{
- testsTask.addConfiguredClasspath(path);
+ testsType.addConfiguredClasspath(path);
}
- testsTask.execute();
+ testsType.execute();
}
+
+
+ //Not working at the moment - issues with using <fileset> dynamicly
+// if (getReports() != null && getReports().getXmlReports() != null
&& getReports().getHtmlReports() != null)
+// {
+// try
+// {
+// generateHTMLReports(createJunitReporter());
+// }
+// catch (Exception e)
+// {
+// e.printStackTrace();
+// }
+// }
+
}
+ private XMLResultAggregator createJunitReporter()
+ {
+ XMLResultAggregator reporter = null;
+ try
+ {
+
+ if (getProject() == null)
+ {
+ throw new IllegalStateException("Current project is missing. Task was
not setup properly");
+ }
+
+ reporter =
(XMLResultAggregator)getProject().createTask("junitreport");
+
+
+ return reporter;
+
+ }
+ catch (BuildException e)
+ {
+ throw new IllegalStateException("Failed to create <java> ant task:
", e);
+ }
+ }
+
+// private void generateHTMLReports(XMLResultAggregator reporter) throws Exception
+// {
+//
+// String htmlToDir = getReports().getHtmlReports().getToDir();
+//
+// String xmlDir = getReports().getXmlReports().getToDir();
+//
+// MainBuilder.checkCreateOutputDirectory(htmlToDir);
+//
+// reporter.setTodir(new File(htmlToDir));
+//
+//
+// // <report>
+// AggregateTransformer report = reporter.createReport();
+//
+// AggregateTransformer.Format format;
+// format = new AggregateTransformer.Format();
+// format.setValue(AggregateTransformer.FRAMES);
+// report.setFormat(format);
+// report.setTodir(new File(htmlToDir));
+//
+// //String includeFile = JUnitTestReport.TEST_FILE_NAME_START + "*.xml";
+// String includeFile = "*.xml";
+//
+// FileSet fs = new FileSet();
+//
+// //File toDir = new File(xmlDir);
+//
+// fs.setDir(new File(xmlDir));
+//
+//
+//
+// fs.createIncludesFile().setName(includeFile);
+//
+//
+//
+// reporter.addFileSet(fs);
+//
+// reporter.execute();
+// }
+
+
+ public ReportsType getReports()
+ {
+ return reports;
+ }
+
+ public void setReports(ReportsType reports)
+ {
+ this.reports = reports;
+ }
+
}
Added: modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/ReportsType.java
===================================================================
--- modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/ReportsType.java
(rev 0)
+++
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/ReportsType.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -0,0 +1,68 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.unit.tooling.ant;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 0.1 $
+ */
+public class ReportsType
+{
+
+ private XMLReportsType xmlReports;
+
+ private HTMLReportsType htmlReports;
+
+ private boolean noConsole;
+
+
+ public boolean isNoConsole()
+ {
+ return noConsole;
+ }
+
+ public void setNoConsole(boolean noConsole)
+ {
+ this.noConsole = noConsole;
+ }
+
+ public void addConfiguredXml(XMLReportsType xml)
+ {
+ xmlReports = xml;
+ }
+
+ public void addConfiguredHtml(HTMLReportsType html)
+ {
+ htmlReports = html;
+ }
+
+ public XMLReportsType getXmlReports()
+ {
+ return xmlReports;
+ }
+
+ public HTMLReportsType getHtmlReports()
+ {
+ return htmlReports;
+ }
+}
Deleted: modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/TestsTask.java
===================================================================
---
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/TestsTask.java 2007-10-10
14:07:54 UTC (rev 8587)
+++
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/TestsTask.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -1,299 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-
-package org.jboss.unit.tooling.ant;
-
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.taskdefs.Java;
-import org.jboss.unit.tooling.IncludeTestFilter;
-import org.jboss.unit.tooling.ExcludeTestFilter;
-import org.jboss.unit.tooling.Main;
-
-import java.util.List;
-import java.util.LinkedList;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
- * @version $Revision: 0.1 $
- */
-public class TestsTask
-{
- private String config;
-
- private boolean fork = true;
-
- private List<IncludeTask> includes = new LinkedList();
-
- private List<ExcludeTask> excludes = new LinkedList();
-
- private Project project;
-
- private Path path;
-
-
- public TestsTask()
- {
- }
-
-
- public void execute() throws BuildException
- {
- System.out.println("Executing Task. Includes: " + includes.size() +
" excludes: " + excludes.size() + " config: " + config);
-
- //Evaluate all the include filters
-
- Java javaTask = createJava();
-
- addArguments(javaTask);
-
-
-
- javaTask.setClassname("org.jboss.unit.tooling.Main");
-
- try
- {
- System.out.println("Invoking java: " +
javaTask.getCommandLine().toString());
- TaskExecutingThread executor = new TaskExecutingThread(javaTask);
- executor.run();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
-
- }
-
- private Java createJava()
- {
- Java javaTask = null;
- try
- {
-
- if (getProject() == null)
- {
- throw new IllegalStateException("Current project is missing. Task was
not setup properly");
- }
-
- javaTask = (Java)getProject().createTask("java");
-
-
- // Apply task classpath
- if (getClasspath() != null)
- {
- Path javaPath = javaTask.createClasspath();
- javaPath.add(getClasspath());
- }
-
- // Set fork
- if (isFork())
- {
- javaTask.setFork(true);
- }
-
-
-
- }
- catch (BuildException e)
- {
- throw new IllegalStateException("Failed to create <java> ant task:
", e);
- }
-
- return javaTask;
- }
-
- private void addArguments(Java javaTask)
- {
- javaTask.createArg().setValue(Main.OPT_CONFIG + "=" + config);
-
- //TODO: change bilto
- javaTask.createArg().setValue(Main.OPT_SUITE_NAME + "=" +
"bilto");
-
-
- // Filters to aggregate all the values
- IncludeTestFilter includeFilter = new IncludeTestFilter();
-
- ExcludeTestFilter excludeFilter = new ExcludeTestFilter();
-
- for (IncludeTask include : includes)
- {
- //Check attributes consistency
-
- if (include.getId() != null && (include.getIds() != null ||
include.getKeywords() != null))
- {
- throw new IllegalStateException("The use of attribute 'id' in
<include> tag should be exclusive");
- }
-
-
- if (include.getIds() != null)
- {
- includeFilter.addUnparsedNames(include.getIds());
- }
- if (include.getKeywords() != null)
- {
- includeFilter.addUnparsedKeywords(include.getKeywords());
- }
- if (include.getIdPatterns() != null)
- {
- includeFilter.addUnparsedNamePatterns(include.getIdPatterns());
- }
- if (include.getId() != null)
- {
- includeFilter.addUnparsedNames(include.getId());
- }
- }
-
- if (includeFilter.getNames().size() != 0)
- {
- javaTask.createArg().setValue(generateArgument(includeFilter.getNames(),
Main.OPT_NAMES));
- }
-
- if (includeFilter.getNamePatterns().size() != 0)
- {
- javaTask.createArg().setValue(generateArgument(includeFilter.getNamePatterns(),
Main.OPT_PATTERNS));
- }
-
- if (includeFilter.getKeywords().size() != 0)
- {
- javaTask.createArg().setValue(generateArgument(includeFilter.getKeywords(),
Main.OPT_KEYWORDS));
- }
-
-
-// List<TestFilter> excludeFilters = new LinkedList<TestFilter>();
-
- for (ExcludeTask exclude : excludes)
- {
-
- if (exclude.getId() != null && (exclude.getIds() != null ||
exclude.getKeywords() != null))
- {
- throw new IllegalStateException("The use of attribute 'id' in
<exclude> tag should be exclusive");
- }
-
- if (exclude.getIds() != null)
- {
- excludeFilter.addUnparsedNames(exclude.getIds());
- }
- if (exclude.getKeywords() != null)
- {
- excludeFilter.addUnparsedKeywords(exclude.getKeywords());
- }
- if (exclude.getIdPatterns() != null)
- {
- excludeFilter.addUnparsedNamePatterns(exclude.getIdPatterns());
- }
- if (exclude.getId() != null)
- {
- excludeFilter.addUnparsedNames(exclude.getId());
- }
- }
-
- if (excludeFilter.getNames().size() != 0)
- {
- javaTask.createArg().setValue(generateArgument(excludeFilter.getNames(),
Main.OPT_EX_NAMES));
- }
-
- if (excludeFilter.getNamePatterns().size() != 0)
- {
- javaTask.createArg().setValue(generateArgument(excludeFilter.getNamePatterns(),
Main.OPT_EX_PATTERNS));
- }
-
- if (excludeFilter.getKeywords().size() != 0)
- {
- javaTask.createArg().setValue(generateArgument(excludeFilter.getKeywords(),
Main.OPT_EX_KEYWORDS));
- }
- }
-
- private String generateArgument(Set<String> values, String argumentName)
- {
-
- StringBuffer argument = new StringBuffer(argumentName).append("=");
- for (String s : values)
- {
- argument.append(s).append(",");
- }
- // Remove last ','
- argument.deleteCharAt(argument.length() - 1);
- return argument.toString();
- }
-
-
- public void addConfiguredInclude(IncludeTask include)
- {
- includes.add(include);
- }
-
- public void addConfiguredExclude(ExcludeTask exclude)
- {
- excludes.add(exclude);
- }
-
- public void addTask(Task task)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public String getConfig()
- {
- return config;
- }
-
- public void setConfig(String config)
- {
- this.config = config;
- }
-
-
- public Path getClasspath()
- {
- return path;
- }
-
- public void addConfiguredClasspath(Path path)
- {
- this.path = path;
- }
-
-
- public boolean isFork()
- {
- return fork;
- }
-
- public void setFork(boolean fork)
- {
- this.fork = fork;
- }
-
-
- public Project getProject()
- {
- return project;
- }
-
- public void setProject(Project project)
- {
- this.project = project;
- }
-}
Copied: modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/TestsType.java
(from rev 8562,
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/TestsTask.java)
===================================================================
--- modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/TestsType.java
(rev 0)
+++
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/TestsType.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -0,0 +1,350 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.unit.tooling.ant;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.taskdefs.Java;
+import org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator;
+import org.apache.tools.ant.taskdefs.optional.junit.AggregateTransformer;
+import org.jboss.unit.tooling.filter.IncludeTestFilter;
+import org.jboss.unit.tooling.filter.ExcludeTestFilter;
+import org.jboss.unit.tooling.Main;
+import org.jboss.unit.tooling.MainBuilder;
+import org.jboss.unit.report.impl.junit.JUnitTestReport;
+
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Set;
+import java.io.File;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 0.1 $
+ */
+public class TestsType
+{
+ private String config;
+
+ private boolean fork = true;
+
+ private List<IncludeType> includes = new LinkedList();
+
+ private List<ExcludeType> excludes = new LinkedList();
+
+ private ReportsType reports;
+
+ private Project project;
+
+ private Path path;
+
+ private String suiteName;
+
+
+ public TestsType()
+ {
+ }
+
+
+ public void execute() throws BuildException
+ {
+ //System.out.println("Executing Task. Includes: " + includes.size() +
" excludes: " + excludes.size() + " config: " + config);
+
+ //Evaluate all the include filters
+
+ Java javaTask = createJava();
+
+ addArguments(javaTask);
+
+
+
+ javaTask.setClassname("org.jboss.unit.tooling.Main");
+
+ try
+ {
+ System.out.println("Invoking java: " +
javaTask.getCommandLine().toString());
+ TaskExecutingThread executor = new TaskExecutingThread(javaTask);
+ executor.run();
+
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ }
+
+ private Java createJava()
+ {
+ Java javaTask = null;
+ try
+ {
+
+ if (getProject() == null)
+ {
+ throw new IllegalStateException("Current project is missing. Task was
not setup properly");
+ }
+
+ javaTask = (Java)getProject().createTask("java");
+
+
+ // Apply task classpath
+ if (getClasspath() != null)
+ {
+ Path javaPath = javaTask.createClasspath();
+ javaPath.add(getClasspath());
+ }
+
+ // Set fork
+ if (isFork())
+ {
+ javaTask.setFork(true);
+ }
+
+
+
+ }
+ catch (BuildException e)
+ {
+ throw new IllegalStateException("Failed to create <java> ant task:
", e);
+ }
+
+ return javaTask;
+ }
+
+
+
+ private void addArguments(Java javaTask)
+ {
+ javaTask.createArg().setValue(Main.OPT_CONFIG + "=" + config);
+
+ if (getSuiteName() != null)
+ {
+ javaTask.createArg().setValue(Main.OPT_SUITE_NAME + "=" +
getSuiteName());
+ }
+
+
+
+ if (getReports() != null && getReports().getXmlReports() != null)
+ {
+ javaTask.createArg().setValue(Main.OPT_XML_REPORT_DIR + "=" +
getReports().getXmlReports().getToDir());
+ }
+
+
+ // Filters to aggregate all the values
+ IncludeTestFilter includeFilter = new IncludeTestFilter();
+
+ ExcludeTestFilter excludeFilter = new ExcludeTestFilter();
+
+ for (IncludeType include : includes)
+ {
+ //Check attributes consistency
+
+ if (include.getId() != null && (include.getIds() != null ||
include.getKeywords() != null))
+ {
+ throw new IllegalStateException("The use of attribute 'id' in
<include> tag should be exclusive");
+ }
+
+
+ if (include.getIds() != null)
+ {
+ includeFilter.addUnparsedNames(include.getIds());
+ }
+ if (include.getKeywords() != null)
+ {
+ includeFilter.addUnparsedKeywords(include.getKeywords());
+ }
+ if (include.getIdPatterns() != null)
+ {
+ includeFilter.addUnparsedNamePatterns(include.getIdPatterns());
+ }
+ if (include.getId() != null)
+ {
+ includeFilter.addUnparsedNames(include.getId());
+ }
+ }
+
+ if (includeFilter.getNames().size() != 0)
+ {
+ javaTask.createArg().setValue(generateArgument(includeFilter.getNames(),
Main.OPT_NAMES));
+ }
+
+ if (includeFilter.getNamePatterns().size() != 0)
+ {
+ javaTask.createArg().setValue(generateArgument(includeFilter.getNamePatterns(),
Main.OPT_PATTERNS));
+ }
+
+ if (includeFilter.getKeywords().size() != 0)
+ {
+ javaTask.createArg().setValue(generateArgument(includeFilter.getKeywords(),
Main.OPT_KEYWORDS));
+ }
+
+
+// List<TestFilter> excludeFilters = new LinkedList<TestFilter>();
+
+ for (ExcludeType exclude : excludes)
+ {
+
+ if (exclude.getId() != null && (exclude.getIds() != null ||
exclude.getKeywords() != null))
+ {
+ throw new IllegalStateException("The use of attribute 'id' in
<exclude> tag should be exclusive");
+ }
+
+ if (exclude.getIds() != null)
+ {
+ excludeFilter.addUnparsedNames(exclude.getIds());
+ }
+ if (exclude.getKeywords() != null)
+ {
+ excludeFilter.addUnparsedKeywords(exclude.getKeywords());
+ }
+ if (exclude.getIdPatterns() != null)
+ {
+ excludeFilter.addUnparsedNamePatterns(exclude.getIdPatterns());
+ }
+ if (exclude.getId() != null)
+ {
+ excludeFilter.addUnparsedNames(exclude.getId());
+ }
+ }
+
+ if (excludeFilter.getNames().size() != 0)
+ {
+ javaTask.createArg().setValue(generateArgument(excludeFilter.getNames(),
Main.OPT_EX_NAMES));
+ }
+
+ if (excludeFilter.getNamePatterns().size() != 0)
+ {
+ javaTask.createArg().setValue(generateArgument(excludeFilter.getNamePatterns(),
Main.OPT_EX_PATTERNS));
+ }
+
+ if (excludeFilter.getKeywords().size() != 0)
+ {
+ javaTask.createArg().setValue(generateArgument(excludeFilter.getKeywords(),
Main.OPT_EX_KEYWORDS));
+ }
+ }
+
+ private String generateArgument(Set<String> values, String argumentName)
+ {
+
+ StringBuffer argument = new StringBuffer(argumentName).append("=");
+ for (String s : values)
+ {
+ argument.append(s).append(",");
+ }
+ // Remove last ','
+ argument.deleteCharAt(argument.length() - 1);
+ return argument.toString();
+ }
+
+
+
+
+ public void addConfiguredInclude(IncludeType include)
+ {
+ this.includes.add(include);
+ }
+
+ public void addConfiguredExclude(ExcludeType exclude)
+ {
+ this.excludes.add(exclude);
+ }
+
+ public void addConfiguredReports(ReportsType reports)
+ {
+ this.reports = reports;
+ }
+
+ public void addTask(Task task)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public String getConfig()
+ {
+ return config;
+ }
+
+ public void setConfig(String config)
+ {
+ this.config = config;
+ }
+
+
+ public Path getClasspath()
+ {
+ return path;
+ }
+
+ public void addConfiguredClasspath(Path path)
+ {
+ this.path = path;
+ }
+
+
+ public boolean isFork()
+ {
+ return fork;
+ }
+
+ public void setFork(boolean fork)
+ {
+ this.fork = fork;
+ }
+
+
+ public Project getProject()
+ {
+ return project;
+ }
+
+ public void setProject(Project project)
+ {
+ this.project = project;
+ }
+
+
+ public ReportsType getReports()
+ {
+ return reports;
+ }
+
+ public void setReports(ReportsType reports)
+ {
+ this.reports = reports;
+ }
+
+ public String getSuiteName()
+ {
+ return suiteName;
+ }
+
+ public void setSuiteName(String suiteName)
+ {
+ this.suiteName = suiteName;
+ }
+}
Added: modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/XMLReportsType.java
===================================================================
--- modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/XMLReportsType.java
(rev 0)
+++
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/XMLReportsType.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -0,0 +1,47 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.unit.tooling.ant;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 0.1 $
+ */
+public class XMLReportsType
+{
+
+ public XMLReportsType()
+ {
+ }
+
+ private String toDir = ".";
+
+ public String getToDir()
+ {
+ return toDir;
+ }
+
+ public void setToDir(String toDir)
+ {
+ this.toDir = toDir;
+ }
+}
Modified: modules/test/trunk/unit/src/main/org/jboss/test/unit/blah/BlahTestTwo.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/blah/BlahTestTwo.java 2007-10-10
14:07:54 UTC (rev 8587)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/blah/BlahTestTwo.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -25,7 +25,7 @@
import java.io.InputStream;
import org.jboss.unit.report.impl.console.PrintListener;
-import org.jboss.unit.report.junit.JUnitReporter;
+import org.jboss.unit.report.impl.junit.JUnitReporter;
import org.jboss.unit.runner.TestRunner;
import org.jboss.unit.runner.TestRunnerEventListener;
import org.jboss.unit.runner.model.ModelBuilder;
Copied: modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit (from rev 8562,
modules/test/trunk/unit/src/main/org/jboss/unit/report/junit)
Deleted:
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitReporter.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/report/junit/JUnitReporter.java 2007-10-08
13:26:57 UTC (rev 8562)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitReporter.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -1,163 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.unit.report.junit;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintStream;
-
-import org.jboss.unit.runner.TestRunnerEventListener;
-import org.jboss.unit.runner.TestRunnerEvent;
-import org.jboss.unit.runner.event.EndRunnerEvent;
-import org.jboss.unit.runner.event.EndTestEvent;
-import org.jboss.unit.runner.event.RunnerFailureEvent;
-import org.jboss.unit.runner.event.StartRunnerEvent;
-import org.jboss.unit.runner.event.StartTestEvent;
-
-/**
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
- * @version $Revision: 1.1 $
- */
-public class JUnitReporter implements TestRunnerEventListener
-{
- /** The JUnit test report */
- private JUnitTestReport report;
-
- /** The system error printStream */
- private ByteArrayOutputStream systemError;
-
- /** The system out printStream */
- private ByteArrayOutputStream systemOut;
-
- /** To dir */
- private static String toDir;
-
- public JUnitReporter(String reportToDir,
- String testSuiteName)
- {
- this.report = new JUnitTestReport(testSuiteName);
- toDir = reportToDir;
- // redirecting system out and err
- this.systemError = new ByteArrayOutputStream();
- this.systemOut = new ByteArrayOutputStream();
- this.setStreams(systemError, systemOut);
- }
-
- public void onEvent(TestRunnerEvent event)
- {
- if (event instanceof StartRunnerEvent)
- {
- report.startTestSuite((StartRunnerEvent) event);
- }
- else if (event instanceof EndRunnerEvent)
- {
- // append system out and system err
- report.appendSystemError(systemError.toString());
- report.appendSystemOutput(systemOut.toString());
-
- // Testsuite End
- report.endTestSuite((EndRunnerEvent) event);
-
- // Export xml
- report.exportXML(toDir);
- }
- else if (event instanceof RunnerFailureEvent)
- {
- report.runnerFailed((RunnerFailureEvent) event);
- }
- else if (event instanceof StartTestEvent)
- {
- report.startTest((StartTestEvent) event);
- }
- else if (event instanceof EndTestEvent)
- {
- report.endTest((EndTestEvent) event);
- }
- }
-
- private void setStreams(ByteArrayOutputStream a, ByteArrayOutputStream b)
- {
- PrintStream savedError = System.err;
- PrintStream savedOut = System.out;
-
- System.setErr(new PrintStream(new CaptureOutputStream(savedError, a)));
- System.setOut(new PrintStream(new CaptureOutputStream(savedOut, b)));
-
- }
-
- private class CaptureOutputStream extends OutputStream
- {
- private OutputStream s1;
- private OutputStream s2;
-
- public CaptureOutputStream(OutputStream s1, OutputStream s2)
- {
- this.s1 = s1;
- this.s2 = s2;
- }
-
- @Override
- public void close() throws IOException
- {
- try
- {
- s1.close();
- }
- finally
- {
- s2.close();
- }
- }
-
- @Override
- public void flush() throws IOException
- {
- s1.flush();
- s2.flush();
- }
-
- @Override
- public void write(int b) throws IOException
- {
- s1.write(b);
- s2.write(b);
- }
-
- @Override
- public void write(byte[] b) throws IOException
- {
- s1.write(b);
- s2.write(b);
- }
-
- @Override
- public void write(byte[] b, int off, int len) throws IOException
- {
- s1.write(b, off, len);
- s2.write(b, off, len);
- }
- }
-}
Copied:
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitReporter.java (from
rev 8587,
modules/test/trunk/unit/src/main/org/jboss/unit/report/junit/JUnitReporter.java)
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitReporter.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitReporter.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -0,0 +1,174 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.report.impl.junit;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+import org.jboss.unit.runner.TestRunnerEventListener;
+import org.jboss.unit.runner.TestRunnerEvent;
+import org.jboss.unit.runner.event.EndRunnerEvent;
+import org.jboss.unit.runner.event.EndTestEvent;
+import org.jboss.unit.runner.event.RunnerFailureEvent;
+import org.jboss.unit.runner.event.StartRunnerEvent;
+import org.jboss.unit.runner.event.StartTestEvent;
+
+/**
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
+ * @version $Revision: 1.1 $
+ */
+public class JUnitReporter implements TestRunnerEventListener
+{
+ /** The JUnit test report */
+ private JUnitTestReport report;
+
+ /** The system error printStream */
+ private ByteArrayOutputStream systemError;
+
+ /** The system out printStream */
+ private ByteArrayOutputStream systemOut;
+
+ /** To dir */
+ private static String toDir;
+
+
+ public JUnitReporter(String reportToDir)
+ {
+ toDir = reportToDir;
+ // redirecting system out and err
+ this.systemError = new ByteArrayOutputStream();
+ this.systemOut = new ByteArrayOutputStream();
+ this.setStreams(systemError, systemOut);
+
+ this.report = new JUnitTestReport();
+ }
+
+ public JUnitReporter(String reportToDir,
+ String testSuiteName)
+ {
+ this(reportToDir);
+
+ this.report.setTestSuiteName(testSuiteName);
+
+
+ }
+
+ public void onEvent(TestRunnerEvent event)
+ {
+ if (event instanceof StartRunnerEvent)
+ {
+ report.startTestSuite((StartRunnerEvent) event);
+ }
+ else if (event instanceof EndRunnerEvent)
+ {
+ // append system out and system err
+ report.appendSystemError(systemError.toString());
+ report.appendSystemOutput(systemOut.toString());
+
+ // Testsuite End
+ report.endTestSuite((EndRunnerEvent) event);
+
+ // Export xml
+ report.exportXML(toDir);
+ }
+ else if (event instanceof RunnerFailureEvent)
+ {
+ report.runnerFailed((RunnerFailureEvent) event);
+ }
+ else if (event instanceof StartTestEvent)
+ {
+ report.startTest((StartTestEvent) event);
+ }
+ else if (event instanceof EndTestEvent)
+ {
+ report.endTest((EndTestEvent) event);
+ }
+ }
+
+ private void setStreams(ByteArrayOutputStream a, ByteArrayOutputStream b)
+ {
+ PrintStream savedError = System.err;
+ PrintStream savedOut = System.out;
+
+ System.setErr(new PrintStream(new CaptureOutputStream(savedError, a)));
+ System.setOut(new PrintStream(new CaptureOutputStream(savedOut, b)));
+
+ }
+
+ private class CaptureOutputStream extends OutputStream
+ {
+ private OutputStream s1;
+ private OutputStream s2;
+
+ public CaptureOutputStream(OutputStream s1, OutputStream s2)
+ {
+ this.s1 = s1;
+ this.s2 = s2;
+ }
+
+ @Override
+ public void close() throws IOException
+ {
+ try
+ {
+ s1.close();
+ }
+ finally
+ {
+ s2.close();
+ }
+ }
+
+ @Override
+ public void flush() throws IOException
+ {
+ s1.flush();
+ s2.flush();
+ }
+
+ @Override
+ public void write(int b) throws IOException
+ {
+ s1.write(b);
+ s2.write(b);
+ }
+
+ @Override
+ public void write(byte[] b) throws IOException
+ {
+ s1.write(b);
+ s2.write(b);
+ }
+
+ @Override
+ public void write(byte[] b, int off, int len) throws IOException
+ {
+ s1.write(b, off, len);
+ s2.write(b, off, len);
+ }
+ }
+}
Deleted:
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitTestReport.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/report/junit/JUnitTestReport.java 2007-10-08
13:26:57 UTC (rev 8562)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitTestReport.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -1,292 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.unit.report.junit;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Iterator;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.jboss.unit.Failure;
-import org.jboss.unit.FailureType;
-import org.jboss.unit.TestId;
-import org.jboss.unit.runner.TestResult;
-import org.jboss.unit.runner.event.EndRunnerEvent;
-import org.jboss.unit.runner.event.EndTestEvent;
-import org.jboss.unit.runner.event.RunnerFailureEvent;
-import org.jboss.unit.runner.event.StartRunnerEvent;
-import org.jboss.unit.runner.event.StartTestEvent;
-import org.jboss.unit.runner.results.TestFailure;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
- * @version $Revision$
- */
-public class JUnitTestReport
-{
-
- /** The test suite name */
- private String testSuiteName;
-
- /** The line separator */
- private final static String ls = System.getProperty("line.separator");
-
- /** The document */
- private Document document;
-
- /** The root element */
- private Element rootElement;
-
- /** The system error */
- private StringBuffer systemErr = new StringBuffer();
-
- /** The system output */
- private StringBuffer systemOut = new StringBuffer();
-
- /** The test count */
- private int tests;
-
- /** The error count */
- private int errors;
-
- /** The failed count */
- private int failed;
-
- public JUnitTestReport(String testSuiteName)
- {
- this.testSuiteName = testSuiteName;
- }
-
-
- public void startTestSuite(StartRunnerEvent event)
- {
- this.document = getDocumentBuilder().newDocument();
- this.rootElement = this.document.createElement(XMLConstants.TESTSUITE);
- this.rootElement.setAttribute(XMLConstants.TIMESTAMP, getTimestamp());
- this.rootElement.setAttribute(XMLConstants.HOSTNAME, getHostName());
- this.rootElement.setAttribute(XMLConstants.ATTR_NAME, this.testSuiteName);
- Element properties = document.createElement(XMLConstants.PROPERTIES);
- this.rootElement.appendChild(properties);
- // add properties list
-
- }
-
- public void startTest(StartTestEvent event)
- {
- this.tests++;
- }
-
- public void runnerFailed(RunnerFailureEvent event)
- {
- this.tests++;
- this.errors++;
- Element e = document.createElement(XMLConstants.ERROR);
- e.appendChild(document.createCDATASection(ls + event.getFailure().getMessage() + ls
+ stackToString(event.getFailure().getCause())));
- rootElement.appendChild(e);
- }
-
- public void endTest(EndTestEvent event)
- {
- TestId testId = event.getTestId();
- TestResult result = event.getTestResult();
- Element test = document.createElement(XMLConstants.TESTCASE);
- // The test name
- StringBuffer nb = new StringBuffer();
- for(int i = 0; i < testId.getLength(); i ++)
- {
- if (i > 0)
- {
- nb.append(".");
- }
- nb.append(testId.getName(i));
- }
- String testName = nb.toString();
- // Test parameters
- StringBuffer parameters = new StringBuffer();
- for(Iterator<String> i = result.getParametrization().values().iterator();
i.hasNext(); )
- {
- String name = i.next();
- String value = result.getParametrization().get(name);
- parameters.append(name + "=" + value + "?");
- }
-
- if ( parameters.length() > 0)
- testName = testName + "?" + parameters.toString();
-
- test.setAttribute(XMLConstants.ATTR_NAME, testName);
- // Testcase time
- test.setAttribute(XMLConstants.ATTR_TIME, new
Long(result.getDurationMillis()).toString());
- // If test failed
- if (result instanceof TestFailure)
- {
- TestFailure testFailure = (TestFailure) result;
- Failure failure = testFailure.getFailure();
-
- String failureType;
- // Check failure type (failed, error)
- if(FailureType.ASSERTION == failure.getType())
- {
- this.failed++;
- failureType = XMLConstants.FAILURE;
- }
- else
- {
- this.errors++;
- failureType = XMLConstants.ERROR;
- }
-
- test.appendChild(addError(failureType, failure.getCause()));
- }
- this.rootElement.appendChild(test);
- }
-
- public void endTestSuite(EndRunnerEvent event)
- {
- // Testsuite counts (tests, errors, failures)
- this.rootElement.setAttribute(XMLConstants.ATTR_TESTS,
Integer.toString(this.tests));
- this.rootElement.setAttribute(XMLConstants.ATTR_ERRORS,
Integer.toString(this.errors));
- this.rootElement.setAttribute(XMLConstants.ATTR_FAILURES,
Integer.toString(this.failed));
-
- // Testsuite system-err
- Element systemError = document.createElement(XMLConstants.SYSTEM_ERR);
- systemError.appendChild(document.createCDATASection(systemErr.toString()));
- // Testsuite system-out
- Element systemOutElement = document.createElement(XMLConstants.SYSTEM_OUT);
- systemOutElement.appendChild(document.createCDATASection(systemOut.toString()));
-
- this.rootElement.appendChild(systemError);
- this.rootElement.appendChild(systemOutElement);
-
- // System.out.println(exportXML());
- }
-
- public void appendSystemOutput(String output)
- {
- this.systemOut.append(output);
- }
-
- public void appendSystemError(String error)
- {
- this.systemErr.append(error);
- }
-
- public void exportXML(String toDir)
- {
- try
- {
- File file = new File(toDir + "/" + "TEST-" + testSuiteName +
".xml");
-
- Source source = new DOMSource(this.rootElement);
- Transformer xtrans = TransformerFactory.newInstance().newTransformer();
- xtrans.setOutputProperty(OutputKeys.INDENT, "yes");
- Result result = new StreamResult(new FileOutputStream(file));
- xtrans.transform(source, result);
- }
- catch(FileNotFoundException e)
- {
- e.printStackTrace();
- }
- catch(TransformerException e)
- {
- e.printStackTrace();
- }
- catch(IllegalArgumentException e)
- {
- e.printStackTrace();
- }
- }
-
- private Element addError(String type, Throwable t)
- {
- Element error = document.createElement(type);
- // Testcase error message
- error.setAttribute(XMLConstants.ATTR_MESSAGE, t.getMessage());
- // Testcase error type
- error.setAttribute(XMLConstants.ATTR_TYPE, t.getClass().getName());
- // Testcase stacktrace
- error.appendChild(document.createCDATASection(stackToString(t)));
- return error;
- }
-
- private static String stackToString(Throwable t)
- {
- final Writer writer = new StringWriter();
- final PrintWriter printWriter = new PrintWriter(writer);
- t.printStackTrace(printWriter);
- printWriter.flush();
- printWriter.close();
- return writer.toString();
- }
-
- private static String getTimestamp()
- {
- SimpleDateFormat date = new
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
- return date.format(new Date());
- }
-
- private static String getHostName()
- {
- try
- {
- return InetAddress.getLocalHost().getHostName();
- }
- catch(UnknownHostException e)
- {
- return "localhost";
- }
- }
-
- private static DocumentBuilder getDocumentBuilder()
- {
- try
- {
- return DocumentBuilderFactory.newInstance().newDocumentBuilder();
- }
- catch(ParserConfigurationException e)
- {
- e.printStackTrace();
- return null;
- }
- }
-}
\ No newline at end of file
Copied:
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitTestReport.java
(from rev 8587,
modules/test/trunk/unit/src/main/org/jboss/unit/report/junit/JUnitTestReport.java)
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitTestReport.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitTestReport.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -0,0 +1,335 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.report.impl.junit;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Iterator;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.jboss.unit.Failure;
+import org.jboss.unit.FailureType;
+import org.jboss.unit.TestId;
+import org.jboss.unit.runner.TestResult;
+import org.jboss.unit.runner.event.EndRunnerEvent;
+import org.jboss.unit.runner.event.EndTestEvent;
+import org.jboss.unit.runner.event.RunnerFailureEvent;
+import org.jboss.unit.runner.event.StartRunnerEvent;
+import org.jboss.unit.runner.event.StartTestEvent;
+import org.jboss.unit.runner.results.TestFailure;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * @author <a href="mailto:emuckenh@redhat.com">Emanuel
Muckenhuber</a>
+ * @version $Revision$
+ */
+public class JUnitTestReport
+{
+
+ /** The test suite name */
+ private String testSuiteName;
+
+ public static final String DEFAULT_TEST_SUITE_NAME = "JBossUnitTestSuite";
+
+ public static final String TEST_FILE_NAME_START = "TEST-";
+
+ /** The line separator */
+ private final static String ls = System.getProperty("line.separator");
+
+ /** The document */
+ private Document document;
+
+ /** The root element */
+ private Element rootElement;
+
+ /** The system error */
+ private StringBuffer systemErr = new StringBuffer();
+
+ /** The system output */
+ private StringBuffer systemOut = new StringBuffer();
+
+ /** The test count */
+ private int tests;
+
+ /** The error count */
+ private int errors;
+
+ /** The failed count */
+ private int failed;
+
+ private String timeStamp;
+
+
+ public JUnitTestReport()
+ {
+ }
+
+ public JUnitTestReport(String testSuiteName)
+ {
+ this.testSuiteName = testSuiteName;
+ }
+
+
+ public void startTestSuite(StartRunnerEvent event)
+ {
+ this.document = getDocumentBuilder().newDocument();
+ this.rootElement = this.document.createElement(XMLConstants.TESTSUITE);
+ this.rootElement.setAttribute(XMLConstants.TIMESTAMP, getTimestamp());
+ this.rootElement.setAttribute(XMLConstants.HOSTNAME, getHostName());
+ this.rootElement.setAttribute(XMLConstants.ATTR_NAME, getTestSuiteName());
+ Element properties = document.createElement(XMLConstants.PROPERTIES);
+ this.rootElement.appendChild(properties);
+ // add properties list
+
+ }
+
+ public void startTest(StartTestEvent event)
+ {
+ this.tests++;
+ }
+
+ public void runnerFailed(RunnerFailureEvent event)
+ {
+ this.tests++;
+ this.errors++;
+ Element e = document.createElement(XMLConstants.ERROR);
+ e.appendChild(document.createCDATASection(ls + event.getFailure().getMessage() + ls
+ stackToString(event.getFailure().getCause())));
+ rootElement.appendChild(e);
+ }
+
+ public void endTest(EndTestEvent event)
+ {
+ TestId testId = event.getTestId();
+ TestResult result = event.getTestResult();
+ Element test = document.createElement(XMLConstants.TESTCASE);
+ // The test name
+ StringBuffer nb = new StringBuffer();
+ for(int i = 0; i < testId.getLength(); i ++)
+ {
+ if (i > 0)
+ {
+ nb.append(".");
+ }
+ nb.append(testId.getName(i));
+ }
+ String testName = nb.toString();
+ // Test parameters
+ StringBuffer parameters = new StringBuffer();
+ for(Iterator<String> i = result.getParametrization().values().iterator();
i.hasNext(); )
+ {
+ String name = i.next();
+ String value = result.getParametrization().get(name);
+ parameters.append(name + "=" + value + "?");
+ }
+
+ if ( parameters.length() > 0)
+ testName = testName + "?" + parameters.toString();
+
+ test.setAttribute(XMLConstants.ATTR_NAME, testName);
+ // Testcase time
+ test.setAttribute(XMLConstants.ATTR_TIME, new
Long(result.getDurationMillis()).toString());
+ // If test failed
+ if (result instanceof TestFailure)
+ {
+ TestFailure testFailure = (TestFailure) result;
+ Failure failure = testFailure.getFailure();
+
+ String failureType;
+ // Check failure type (failed, error)
+ if(FailureType.ASSERTION == failure.getType())
+ {
+ this.failed++;
+ failureType = XMLConstants.FAILURE;
+ }
+ else
+ {
+ this.errors++;
+ failureType = XMLConstants.ERROR;
+ }
+
+ test.appendChild(addError(failureType, failure.getCause()));
+ }
+ this.rootElement.appendChild(test);
+ }
+
+ public void endTestSuite(EndRunnerEvent event)
+ {
+ // Testsuite counts (tests, errors, failures)
+ this.rootElement.setAttribute(XMLConstants.ATTR_TESTS,
Integer.toString(this.tests));
+ this.rootElement.setAttribute(XMLConstants.ATTR_ERRORS,
Integer.toString(this.errors));
+ this.rootElement.setAttribute(XMLConstants.ATTR_FAILURES,
Integer.toString(this.failed));
+
+ // Testsuite system-err
+ Element systemError = document.createElement(XMLConstants.SYSTEM_ERR);
+ systemError.appendChild(document.createCDATASection(systemErr.toString()));
+ // Testsuite system-out
+ Element systemOutElement = document.createElement(XMLConstants.SYSTEM_OUT);
+ systemOutElement.appendChild(document.createCDATASection(systemOut.toString()));
+
+ this.rootElement.appendChild(systemError);
+ this.rootElement.appendChild(systemOutElement);
+
+ // System.out.println(exportXML());
+ }
+
+ public void appendSystemOutput(String output)
+ {
+ this.systemOut.append(output);
+ }
+
+ public void appendSystemError(String error)
+ {
+ this.systemErr.append(error);
+ }
+
+ public void exportXML(String toDir)
+ {
+ try
+ {
+
+ StringBuffer filePath = new StringBuffer();
+
+ // If no test suite name is specified use default and add timestamp
+ filePath.append(toDir)
+ .append("/")
+ .append(TEST_FILE_NAME_START)
+ .append(getTestSuiteName())
+ .append(getTestSuiteName().equals(DEFAULT_TEST_SUITE_NAME) ? "-" +
getTimestamp() : "" )
+ .append(".xml");
+
+
+ File file = new File(filePath.toString());
+
+ Source source = new DOMSource(this.rootElement);
+ Transformer xtrans = TransformerFactory.newInstance().newTransformer();
+ xtrans.setOutputProperty(OutputKeys.INDENT, "yes");
+ Result result = new StreamResult(new FileOutputStream(file));
+ xtrans.transform(source, result);
+ }
+ catch(FileNotFoundException e)
+ {
+ e.printStackTrace();
+ }
+ catch(TransformerException e)
+ {
+ e.printStackTrace();
+ }
+ catch(IllegalArgumentException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ private Element addError(String type, Throwable t)
+ {
+ Element error = document.createElement(type);
+ // Testcase error message
+ error.setAttribute(XMLConstants.ATTR_MESSAGE, t.getMessage());
+ // Testcase error type
+ error.setAttribute(XMLConstants.ATTR_TYPE, t.getClass().getName());
+ // Testcase stacktrace
+ error.appendChild(document.createCDATASection(stackToString(t)));
+ return error;
+ }
+
+ private static String stackToString(Throwable t)
+ {
+ final Writer writer = new StringWriter();
+ final PrintWriter printWriter = new PrintWriter(writer);
+ t.printStackTrace(printWriter);
+ printWriter.flush();
+ printWriter.close();
+ return writer.toString();
+ }
+
+ private String getTimestamp()
+ {
+ if (timeStamp == null)
+ {
+ SimpleDateFormat date = new
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
+ timeStamp = date.format(new Date());
+
+ }
+ return timeStamp;
+ }
+
+ private static String getHostName()
+ {
+ try
+ {
+ return InetAddress.getLocalHost().getHostName();
+ }
+ catch(UnknownHostException e)
+ {
+ return "localhost";
+ }
+ }
+
+ private static DocumentBuilder getDocumentBuilder()
+ {
+ try
+ {
+ return DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ }
+ catch(ParserConfigurationException e)
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+
+ public String getTestSuiteName()
+ {
+ if (testSuiteName == null)
+ {
+ return DEFAULT_TEST_SUITE_NAME;
+ }
+ return testSuiteName;
+ }
+
+ public void setTestSuiteName(String testSuiteName)
+ {
+ this.testSuiteName = testSuiteName;
+ }
+}
\ No newline at end of file
Deleted:
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/XMLConstants.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/report/junit/XMLConstants.java 2007-10-08
13:26:57 UTC (rev 8562)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/XMLConstants.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -1,119 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.unit.report.junit;
-
-/**
- * <p> Interface groups XML constants.
- * Interface that groups all constants used throughout the <tt>XML</tt>
- * documents that are generated by the <tt>XMLJUnitResultFormatter</tt>
- * As of now the DTD is:
- * <code><pre>
- *
- * </pre></code>
- */
-public class XMLConstants {
-
- /** the testsuites element for the aggregate document */
- public static final String TESTSUITES = "testsuites";
-
- /** the testsuite element */
- public static final String TESTSUITE = "testsuite";
-
- /** the testcase element */
- public static final String TESTCASE = "testcase";
-
- /** the error element */
- public static final String ERROR = "error";
-
- /** the failure element */
- public static final String FAILURE = "failure";
-
- /** the system-err element */
- public static final String SYSTEM_ERR = "system-err";
-
- /** the system-out element */
- public static final String SYSTEM_OUT = "system-out";
-
- /** package attribute for the aggregate document */
- public static final String ATTR_PACKAGE = "package";
-
- /** name attribute for property, testcase and testsuite elements */
- public static final String ATTR_NAME = "name";
-
- /** time attribute for testcase and testsuite elements */
- public static final String ATTR_TIME = "time";
-
- /** errors attribute for testsuite elements */
- public static final String ATTR_ERRORS = "errors";
-
- /** failures attribute for testsuite elements */
- public static final String ATTR_FAILURES = "failures";
-
- /** tests attribute for testsuite elements */
- public static final String ATTR_TESTS = "tests";
-
- /** type attribute for failure and error elements */
- public static final String ATTR_TYPE = "type";
-
- /** message attribute for failure elements */
- public static final String ATTR_MESSAGE = "message";
-
- /** the properties element */
- public static final String PROPERTIES = "properties";
-
- /** the property element */
- public static final String PROPERTY = "property";
-
- /** value attribute for property elements */
- public static final String ATTR_VALUE = "value";
-
- /** classname attribute for testcase elements */
- public static final String ATTR_CLASSNAME = "classname";
-
- /** id attribute */
- public static final String ATTR_ID = "id";
-
- /** timestamp of test cases */
- public static final String TIMESTAMP = "timestamp";
-
- /** name of host running the tests */
- public static final String HOSTNAME = "hostname";
-
-}
-
-/*
- * Copyright 2001,2004-2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
Copied:
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/XMLConstants.java (from
rev 8587, modules/test/trunk/unit/src/main/org/jboss/unit/report/junit/XMLConstants.java)
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/XMLConstants.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/XMLConstants.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -0,0 +1,119 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.unit.report.impl.junit;
+
+/**
+ * <p> Interface groups XML constants.
+ * Interface that groups all constants used throughout the <tt>XML</tt>
+ * documents that are generated by the <tt>XMLJUnitResultFormatter</tt>
+ * As of now the DTD is:
+ * <code><pre>
+ *
+ * </pre></code>
+ */
+public class XMLConstants {
+
+ /** the testsuites element for the aggregate document */
+ public static final String TESTSUITES = "testsuites";
+
+ /** the testsuite element */
+ public static final String TESTSUITE = "testsuite";
+
+ /** the testcase element */
+ public static final String TESTCASE = "testcase";
+
+ /** the error element */
+ public static final String ERROR = "error";
+
+ /** the failure element */
+ public static final String FAILURE = "failure";
+
+ /** the system-err element */
+ public static final String SYSTEM_ERR = "system-err";
+
+ /** the system-out element */
+ public static final String SYSTEM_OUT = "system-out";
+
+ /** package attribute for the aggregate document */
+ public static final String ATTR_PACKAGE = "package";
+
+ /** name attribute for property, testcase and testsuite elements */
+ public static final String ATTR_NAME = "name";
+
+ /** time attribute for testcase and testsuite elements */
+ public static final String ATTR_TIME = "time";
+
+ /** errors attribute for testsuite elements */
+ public static final String ATTR_ERRORS = "errors";
+
+ /** failures attribute for testsuite elements */
+ public static final String ATTR_FAILURES = "failures";
+
+ /** tests attribute for testsuite elements */
+ public static final String ATTR_TESTS = "tests";
+
+ /** type attribute for failure and error elements */
+ public static final String ATTR_TYPE = "type";
+
+ /** message attribute for failure elements */
+ public static final String ATTR_MESSAGE = "message";
+
+ /** the properties element */
+ public static final String PROPERTIES = "properties";
+
+ /** the property element */
+ public static final String PROPERTY = "property";
+
+ /** value attribute for property elements */
+ public static final String ATTR_VALUE = "value";
+
+ /** classname attribute for testcase elements */
+ public static final String ATTR_CLASSNAME = "classname";
+
+ /** id attribute */
+ public static final String ATTR_ID = "id";
+
+ /** timestamp of test cases */
+ public static final String TIMESTAMP = "timestamp";
+
+ /** name of host running the tests */
+ public static final String HOSTNAME = "hostname";
+
+}
+
+/*
+ * Copyright 2001,2004-2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
Deleted: modules/test/trunk/unit/src/main/org/jboss/unit/tooling/ExcludeTestFilter.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/ExcludeTestFilter.java 2007-10-10
14:07:54 UTC (rev 8587)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/ExcludeTestFilter.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -1,78 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-
-package org.jboss.unit.tooling;
-
-import org.jboss.unit.TestId;
-import org.jboss.unit.runner.TestFilter;
-import org.jboss.unit.info.TestInfo;
-
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
- * @version $Revision: 0.1 $
- */
-public class ExcludeTestFilter extends InfoTestFilter
-{
-
-
- public ExcludeTestFilter()
- {
- }
-
- public ExcludeTestFilter(Set<String> keywords, Set<String> names,
Set<String> namePatterns)
- {
- super(keywords, names, namePatterns);
- }
-
- public boolean include(TestId testId, TestInfo testInfo)
- {
- // First check names
-
- if (checkName(testInfo.getName()))
- {
- return false;
- }
-
- // ... then keywords
-
- if (checkKeywords(testInfo.getKeywords()))
- {
- return false;
- }
-
- // ... then check if name matches any of provided regex
-
- if (checkNamePatterns(testInfo.getName()))
- {
- return false;
- }
-
- return true;
- }
-
-
-
-}
Deleted: modules/test/trunk/unit/src/main/org/jboss/unit/tooling/IncludeTestFilter.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/IncludeTestFilter.java 2007-10-10
14:07:54 UTC (rev 8587)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/IncludeTestFilter.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -1,77 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-
-package org.jboss.unit.tooling;
-
-import org.jboss.unit.TestId;
-import org.jboss.unit.runner.TestFilter;
-import org.jboss.unit.info.TestInfo;
-
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
- * @version $Revision: 0.1 $
- */
-public class IncludeTestFilter extends InfoTestFilter
-{
-
-
- public IncludeTestFilter()
- {
- }
-
- public IncludeTestFilter(Set<String> keywords, Set<String> names,
Set<String> namePatterns)
- {
- super(keywords, names, namePatterns);
- }
-
- public boolean include(TestId testId, TestInfo testInfo)
- {
-
- // First check names
-
- if (checkName(testInfo.getName()))
- {
- return true;
- }
-
- // ... then keywords
-
- if (checkKeywords(testInfo.getKeywords()))
- {
- return true;
- }
-
- // ... then check if name matches any of provided regex
-
- if (checkNamePatterns(testInfo.getName()))
- {
- return true;
- }
-
- return false;
- }
-
-}
Deleted: modules/test/trunk/unit/src/main/org/jboss/unit/tooling/InfoTestFilter.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/tooling/InfoTestFilter.java 2007-10-10
14:07:54 UTC (rev 8587)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/tooling/InfoTestFilter.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -1,226 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-
-package org.jboss.unit.tooling;
-
-import org.jboss.unit.runner.TestFilter;
-import org.jboss.unit.TestId;
-import org.jboss.unit.info.TestInfo;
-
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
- * @version $Revision: 0.1 $
- */
-public abstract class InfoTestFilter implements TestFilter
-{
-
- private Set<String> keywords = new HashSet<String>();
-
- private Set<String> names = new HashSet<String>();
-
- private Set<String> namePatterns = new HashSet<String>();
-
- public InfoTestFilter()
- {
- }
-
- public InfoTestFilter(Set<String> keywords, Set<String> names,
Set<String> namePatterns)
- {
- if (keywords == null)
- {
- throw new IllegalArgumentException("keywords cannot be null");
- }
- if (names == null)
- {
- throw new IllegalArgumentException("names cannot be null");
- }
- if (namePatterns == null)
- {
- throw new IllegalArgumentException("namePatterns cannot be null");
- }
-
- this.keywords = keywords;
- this.names = names;
- this.namePatterns = namePatterns;
- }
-
- public InfoTestFilter addKeyword(String keyword)
- {
- if (keyword == null)
- {
- throw new IllegalArgumentException("keyword cannot be null");
- }
-
- keywords.add(keyword);
-
- return this;
- }
-
-
- public InfoTestFilter addUnparsedKeywords(String keywordsString)
- {
- if (keywordsString == null)
- {
- throw new IllegalArgumentException("keywordsString cannot be null");
- }
- String[] keywordValues = keywordsString.split(",");
- for (String keyword : keywordValues)
- {
- this.keywords.add(keyword.trim());
- }
- return this;
- }
-
- public InfoTestFilter addName(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("name cannot be null");
- }
- names.add(name);
-
- return this;
- }
-
- public InfoTestFilter addUnparsedNames(String namesString)
- {
- if (namesString == null)
- {
- throw new IllegalArgumentException("namesString cannot be null");
- }
- String[] namesValues = namesString.split(",");
- for (String name : namesValues)
- {
- this.names.add(name.trim());
- }
- return this;
- }
-
- public InfoTestFilter addNamePattern(String pattern)
- {
- if (pattern == null)
- {
- throw new IllegalArgumentException("pattern cannot be null");
- }
- namePatterns.add(pattern);
-
- return this;
- }
-
- public InfoTestFilter addUnparsedNamePatterns(String patternString)
- {
- if (patternString == null)
- {
- throw new IllegalArgumentException("patternString cannot be null");
- }
- String[] patternValues = patternString.split(",");
- for (String pattern : patternValues)
- {
- this.namePatterns.add(pattern.trim());
- }
- return this;
- }
-
- public abstract boolean include(TestId testId, TestInfo testInfo);
-
- public boolean include(TestId testId, Map<String, String> parametrization,
TestInfo testInfo)
- {
- // At the moment no parametrization match
-
- return include (testId, testInfo);
- }
-
- boolean checkName(String name)
- {
- for (String s : names)
- {
- if (s.equals(name))
- {
- return true;
- }
- }
- return false;
- }
-
- boolean checkKeywords(Set<String> keywords)
- {
- for (String keyword : this.keywords)
- {
- for (String toMatch : keywords)
- {
- if (keyword.equals(toMatch))
- {
- return true;
- }
- }
- }
- return false;
- }
-
- boolean checkNamePatterns(String name)
- {
- for (String regex : this.namePatterns)
- {
- if (name.matches(regex))
- {
- return true;
- }
- }
- return false;
- }
-
-
- public String toString()
- {
- StringBuffer sb = new StringBuffer();
- sb.append("Filter: ")
- .append(getClass().getName())
- .append("; names: ")
- .append(names.toString())
- .append("; keywords: ")
- .append(keywords.toString())
- .append("; namePatterns: ")
- .append(namePatterns.toString())
- .append(";");
- return sb.toString();
- }
-
-
- public Set<String> getKeywords()
- {
- return keywords;
- }
-
- public Set<String> getNames()
- {
- return names;
- }
-
- public Set<String> getNamePatterns()
- {
- return namePatterns;
- }
-}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/tooling/Main.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/tooling/Main.java 2007-10-10 14:07:54
UTC (rev 8587)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/tooling/Main.java 2007-10-10 14:53:42
UTC (rev 8588)
@@ -25,6 +25,7 @@
import org.jboss.unit.runner.TestRunnerEventListener;
import org.jboss.unit.runner.TestRunner;
import org.jboss.unit.runner.model.TestSuiteDef;
+import org.jboss.unit.tooling.filter.MainTestFilter;
import java.util.Set;
import java.util.HashSet;
@@ -85,6 +86,8 @@
public static final Set options;
+ public static final Set options_no_arg;
+
static {
Set<String> opts = new HashSet<String>();
opts.add(OPT_ID);
@@ -97,8 +100,15 @@
opts.add(OPT_EX_PATTERNS);
opts.add(OPT_CONFIG);
opts.add(OPT_SUITE_NAME);
+ opts.add(OPT_NO_CONSOLE);
+ opts.add(OPT_XML_REPORT_DIR);
+ opts.add(OPT_HTML_REPORT_DIR);
options = Collections.unmodifiableSet(opts);
+
+ opts = new HashSet<String>();
+ opts.add(OPT_NO_CONSOLE);
+ options_no_arg = Collections.unmodifiableSet(opts);
}
private Main()
@@ -149,7 +159,7 @@
for (String arg : args)
{
String[] params = arg.split("=",2);
- if (params.length < 2)
+ if (params.length < 2 && !options_no_arg.contains(params[0]))
{
throw new IllegalArgumentException("Argument '" + arg +
"' doesn't follow the name=value pattern");
}
@@ -161,13 +171,25 @@
throw new IllegalArgumentException("Argument '" + OPT_CONFIG +
"' is missing");
}
- if (!arguments.keySet().contains(OPT_SUITE_NAME))
+
+
+ MainBuilder builder = null;
+
+
+
+ if (arguments.keySet().contains(OPT_SUITE_NAME))
{
- throw new IllegalArgumentException("Argument '" + OPT_SUITE_NAME +
"' is missing");
+ builder = new MainBuilder(arguments.get(OPT_CONFIG),
arguments.get(OPT_SUITE_NAME));
+
+ builder.setSuiteName(arguments.get(OPT_SUITE_NAME));
}
+ else
+ {
+ builder = new MainBuilder(arguments.get(OPT_CONFIG));
- MainBuilder builder = new MainBuilder(arguments.get(OPT_CONFIG),
arguments.get(OPT_SUITE_NAME));
+ }
+
if (arguments.keySet().contains(OPT_NAMES))
{
builder.addUnparsedNames(arguments.get(OPT_NAMES));
@@ -208,7 +230,24 @@
builder.addUnparsedExcludeNamePatterns(arguments.get(OPT_EX_PATTERNS));
}
+ if (arguments.keySet().contains(OPT_NO_CONSOLE))
+ {
+ builder.setNoConsole(true);
+ }
+ if (arguments.keySet().contains(OPT_XML_REPORT_DIR))
+ {
+ builder.setXmlReportDir(arguments.get(OPT_XML_REPORT_DIR));
+ }
+
+ if (arguments.keySet().contains(OPT_HTML_REPORT_DIR))
+ {
+ builder.setHtmlReportDir(arguments.get(OPT_HTML_REPORT_DIR));
+ }
+
+
+
+
Main main = builder.build();
main.execute();
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/tooling/MainBuilder.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/tooling/MainBuilder.java 2007-10-10
14:07:54 UTC (rev 8587)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/tooling/MainBuilder.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -27,14 +27,18 @@
import org.jboss.unit.runner.filter.NullFilter;
import org.jboss.unit.runner.model.ModelBuilder;
import org.jboss.unit.runner.model.TestSuiteDef;
-import org.jboss.unit.report.junit.JUnitReporter;
-import org.jboss.unit.report.impl.console.PrintListener;
+import org.jboss.unit.report.impl.junit.JUnitReporter;
+import org.jboss.unit.tooling.filter.ExcludeTestFilter;
+import org.jboss.unit.tooling.filter.IncludeTestFilter;
+import org.jboss.unit.tooling.filter.MainTestFilter;
+import org.jboss.unit.tooling.report.DelegatingReporter;
import org.xml.sax.InputSource;
import java.util.Set;
import java.util.HashSet;
import java.io.InputStream;
import java.io.FileInputStream;
+import java.io.File;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
@@ -57,30 +61,43 @@
private Set<TestRunnerEventListener> listeners = new HashSet();
- private String name = "noname";
+ private String suiteName;
private String configFile;
+ private boolean noConsole = false;
+ private String xmlReportDir;
+
+ private String htmlReportDir;
+
+
private MainBuilder()
{
}
- public MainBuilder(String configFile, String name)
+ public MainBuilder(String configFile)
{
+
if (configFile == null)
{
throw new IllegalArgumentException("configFile cannot be null");
}
+ this.configFile = configFile;
+ }
+
+ public MainBuilder(String configFile, String name)
+ {
+ this(configFile);
+
if (name == null)
{
throw new IllegalArgumentException("name cannot be null");
}
- this.configFile = configFile;
- this.name = name;
+ this.suiteName = name;
}
@@ -241,23 +258,37 @@
throw new IllegalArgumentException("directory cannot be null");
}
- listeners.add(new JUnitReporter(directory, name));
+ listeners.add(new JUnitReporter(directory, suiteName));
return this;
}
- public MainBuilder addXMLReporting(String directory)
+ public String getSuiteName()
{
- throw new RuntimeException("NYI");
+ return suiteName;
+ }
+ public void setSuiteName(String suiteName)
+ {
+ this.suiteName = suiteName;
}
- public MainBuilder addHTMLReporting(String directory)
+ public void setNoConsole(boolean noConsole)
{
- throw new RuntimeException("NYI");
+ this.noConsole = noConsole;
}
+ public void setXmlReportDir(String xmlReportDir)
+ {
+ this.xmlReportDir = xmlReportDir;
+ }
+
+ public void setHtmlReportDir(String htmlReportDir)
+ {
+ this.htmlReportDir = htmlReportDir;
+ }
+
public Main build() throws Exception
{
@@ -277,10 +308,33 @@
}
//add PrintListener by default
- runner.addListener(new PrintListener());
+ DelegatingReporter reporter = new DelegatingReporter(noConsole);
+ if (xmlReportDir != null)
+ {
+ //XML Output directory must exists
+ checkCreateOutputDirectory(xmlReportDir);
+
+ JUnitReporter xmlReporter = null;
+ if (getSuiteName() != null)
+ {
+ xmlReporter = new JUnitReporter(xmlReportDir, getSuiteName());
+ }
+ else
+ {
+ xmlReporter = new JUnitReporter(xmlReportDir);
+ }
+
+ reporter.setXmlReporter(xmlReporter);
+ }
+
+ runner.addListener(reporter);
+
+
+
+
MainTestFilter filter = new MainTestFilter();
if (keywords.size() == 0 && names.size() == 0 &&
namePatterns.size() == 0)
@@ -305,4 +359,35 @@
return new Main(runner, filter, listeners, suite);
}
+ public static void checkCreateOutputDirectory(String dir) throws Exception
+ {
+ File output = null;
+
+ try
+ {
+ output = new File(dir);
+
+ //Check if the dir exits and if not create it
+ if (!output.exists())
+ {
+
+ output.mkdirs();
+ }
+ else
+ {
+ if (!output.isDirectory())
+ {
+ throw new IllegalStateException("Provided path points to a file
instead of directory");
+ }
+ }
+
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException("Failed to use provided output directory:
'" + dir + "'", e);
+ }
+
+ }
+
}
+
Deleted: modules/test/trunk/unit/src/main/org/jboss/unit/tooling/MainTestFilter.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/tooling/MainTestFilter.java 2007-10-10
14:07:54 UTC (rev 8587)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/tooling/MainTestFilter.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -1,122 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-
-package org.jboss.unit.tooling;
-
-import org.jboss.unit.runner.TestFilter;
-import org.jboss.unit.TestId;
-import org.jboss.unit.info.TestInfo;
-
-import java.util.Map;
-import java.util.List;
-import java.util.LinkedList;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
- * @version $Revision: 0.1 $
- */
-public class MainTestFilter implements TestFilter
-{
-
- private List<TestFilter> includeFilters = new LinkedList();
-
- private List<TestFilter> excludeFilters = new LinkedList();
-
-
- public MainTestFilter()
- {
- }
-
- public MainTestFilter(List<TestFilter> matchFilters, List<TestFilter>
excludeFilters)
- {
- if (matchFilters == null)
- {
- throw new IllegalArgumentException("includeFilters cannot be null");
- }
- if (excludeFilters == null)
- {
- throw new IllegalArgumentException("excludeFilters cannot be null");
- }
-
-
- this.includeFilters = matchFilters;
- this.excludeFilters = excludeFilters;
- }
-
- public boolean include(TestId testId, TestInfo testInfo)
- {
-
- // First check if test isn't excluded
-
- // Make logic OR on all filters
-
- for (TestFilter ef : excludeFilters)
- {
- if (!ef.include(testId, testInfo))
- {
- return false;
- }
- }
-
- // make logic OR on all match filters
-
- for (TestFilter mf : includeFilters)
- {
- if (mf.include(testId, testInfo))
- {
- return true;
- }
-
- }
-
-
- return false;
- }
-
- public boolean include(TestId testId, Map<String, String> parametrization,
TestInfo testInfo)
- {
-
- // At the moment no parametrization match
-
- return include (testId, testInfo);
- }
-
- public void addIncludeFilter(TestFilter filter)
- {
- if (filter == null)
- {
- throw new IllegalArgumentException("filter cannot be null");
- }
- includeFilters.add(filter);
- }
-
- public void addExcludeFilter(TestFilter filter)
- {
- if (filter == null)
- {
- throw new IllegalArgumentException("filter cannot be null");
- }
- excludeFilters.add(filter);
- }
-
-
-}
Copied:
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/filter/ExcludeTestFilter.java
(from rev 8562,
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/ExcludeTestFilter.java)
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/tooling/filter/ExcludeTestFilter.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/filter/ExcludeTestFilter.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -0,0 +1,75 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.unit.tooling.filter;
+
+import org.jboss.unit.TestId;
+import org.jboss.unit.info.TestInfo;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 0.1 $
+ */
+public class ExcludeTestFilter extends InfoTestFilter
+{
+
+
+ public ExcludeTestFilter()
+ {
+ }
+
+ public ExcludeTestFilter(Set<String> keywords, Set<String> names,
Set<String> namePatterns)
+ {
+ super(keywords, names, namePatterns);
+ }
+
+ public boolean include(TestId testId, TestInfo testInfo)
+ {
+ // First check names
+
+ if (checkName(testInfo.getName()))
+ {
+ return false;
+ }
+
+ // ... then keywords
+
+ if (checkKeywords(testInfo.getKeywords()))
+ {
+ return false;
+ }
+
+ // ... then check if name matches any of provided regex
+
+ if (checkNamePatterns(testInfo.getName()))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+
+
+}
Copied:
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/filter/IncludeTestFilter.java
(from rev 8562,
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/IncludeTestFilter.java)
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/tooling/filter/IncludeTestFilter.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/filter/IncludeTestFilter.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -0,0 +1,74 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.unit.tooling.filter;
+
+import org.jboss.unit.TestId;
+import org.jboss.unit.info.TestInfo;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 0.1 $
+ */
+public class IncludeTestFilter extends InfoTestFilter
+{
+
+
+ public IncludeTestFilter()
+ {
+ }
+
+ public IncludeTestFilter(Set<String> keywords, Set<String> names,
Set<String> namePatterns)
+ {
+ super(keywords, names, namePatterns);
+ }
+
+ public boolean include(TestId testId, TestInfo testInfo)
+ {
+
+ // First check names
+
+ if (checkName(testInfo.getName()))
+ {
+ return true;
+ }
+
+ // ... then keywords
+
+ if (checkKeywords(testInfo.getKeywords()))
+ {
+ return true;
+ }
+
+ // ... then check if name matches any of provided regex
+
+ if (checkNamePatterns(testInfo.getName()))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+}
Copied: modules/test/trunk/unit/src/main/org/jboss/unit/tooling/filter/InfoTestFilter.java
(from rev 8562,
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/InfoTestFilter.java)
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/tooling/filter/InfoTestFilter.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/filter/InfoTestFilter.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -0,0 +1,226 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.unit.tooling.filter;
+
+import org.jboss.unit.runner.TestFilter;
+import org.jboss.unit.TestId;
+import org.jboss.unit.info.TestInfo;
+
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 0.1 $
+ */
+public abstract class InfoTestFilter implements TestFilter
+{
+
+ private Set<String> keywords = new HashSet<String>();
+
+ private Set<String> names = new HashSet<String>();
+
+ private Set<String> namePatterns = new HashSet<String>();
+
+ public InfoTestFilter()
+ {
+ }
+
+ public InfoTestFilter(Set<String> keywords, Set<String> names,
Set<String> namePatterns)
+ {
+ if (keywords == null)
+ {
+ throw new IllegalArgumentException("keywords cannot be null");
+ }
+ if (names == null)
+ {
+ throw new IllegalArgumentException("names cannot be null");
+ }
+ if (namePatterns == null)
+ {
+ throw new IllegalArgumentException("namePatterns cannot be null");
+ }
+
+ this.keywords = keywords;
+ this.names = names;
+ this.namePatterns = namePatterns;
+ }
+
+ public InfoTestFilter addKeyword(String keyword)
+ {
+ if (keyword == null)
+ {
+ throw new IllegalArgumentException("keyword cannot be null");
+ }
+
+ keywords.add(keyword);
+
+ return this;
+ }
+
+
+ public InfoTestFilter addUnparsedKeywords(String keywordsString)
+ {
+ if (keywordsString == null)
+ {
+ throw new IllegalArgumentException("keywordsString cannot be null");
+ }
+ String[] keywordValues = keywordsString.split(",");
+ for (String keyword : keywordValues)
+ {
+ this.keywords.add(keyword.trim());
+ }
+ return this;
+ }
+
+ public InfoTestFilter addName(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name cannot be null");
+ }
+ names.add(name);
+
+ return this;
+ }
+
+ public InfoTestFilter addUnparsedNames(String namesString)
+ {
+ if (namesString == null)
+ {
+ throw new IllegalArgumentException("namesString cannot be null");
+ }
+ String[] namesValues = namesString.split(",");
+ for (String name : namesValues)
+ {
+ this.names.add(name.trim());
+ }
+ return this;
+ }
+
+ public InfoTestFilter addNamePattern(String pattern)
+ {
+ if (pattern == null)
+ {
+ throw new IllegalArgumentException("pattern cannot be null");
+ }
+ namePatterns.add(pattern);
+
+ return this;
+ }
+
+ public InfoTestFilter addUnparsedNamePatterns(String patternString)
+ {
+ if (patternString == null)
+ {
+ throw new IllegalArgumentException("patternString cannot be null");
+ }
+ String[] patternValues = patternString.split(",");
+ for (String pattern : patternValues)
+ {
+ this.namePatterns.add(pattern.trim());
+ }
+ return this;
+ }
+
+ public abstract boolean include(TestId testId, TestInfo testInfo);
+
+ public boolean include(TestId testId, Map<String, String> parametrization,
TestInfo testInfo)
+ {
+ // At the moment no parametrization match
+
+ return include (testId, testInfo);
+ }
+
+ boolean checkName(String name)
+ {
+ for (String s : names)
+ {
+ if (s.equals(name))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ boolean checkKeywords(Set<String> keywords)
+ {
+ for (String keyword : this.keywords)
+ {
+ for (String toMatch : keywords)
+ {
+ if (keyword.equals(toMatch))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ boolean checkNamePatterns(String name)
+ {
+ for (String regex : this.namePatterns)
+ {
+ if (name.matches(regex))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append("Filter: ")
+ .append(getClass().getName())
+ .append("; names: ")
+ .append(names.toString())
+ .append("; keywords: ")
+ .append(keywords.toString())
+ .append("; namePatterns: ")
+ .append(namePatterns.toString())
+ .append(";");
+ return sb.toString();
+ }
+
+
+ public Set<String> getKeywords()
+ {
+ return keywords;
+ }
+
+ public Set<String> getNames()
+ {
+ return names;
+ }
+
+ public Set<String> getNamePatterns()
+ {
+ return namePatterns;
+ }
+}
Copied: modules/test/trunk/unit/src/main/org/jboss/unit/tooling/filter/MainTestFilter.java
(from rev 8562,
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/MainTestFilter.java)
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/tooling/filter/MainTestFilter.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/filter/MainTestFilter.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -0,0 +1,122 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.unit.tooling.filter;
+
+import org.jboss.unit.runner.TestFilter;
+import org.jboss.unit.TestId;
+import org.jboss.unit.info.TestInfo;
+
+import java.util.Map;
+import java.util.List;
+import java.util.LinkedList;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 0.1 $
+ */
+public class MainTestFilter implements TestFilter
+{
+
+ private List<TestFilter> includeFilters = new LinkedList();
+
+ private List<TestFilter> excludeFilters = new LinkedList();
+
+
+ public MainTestFilter()
+ {
+ }
+
+ public MainTestFilter(List<TestFilter> matchFilters, List<TestFilter>
excludeFilters)
+ {
+ if (matchFilters == null)
+ {
+ throw new IllegalArgumentException("includeFilters cannot be null");
+ }
+ if (excludeFilters == null)
+ {
+ throw new IllegalArgumentException("excludeFilters cannot be null");
+ }
+
+
+ this.includeFilters = matchFilters;
+ this.excludeFilters = excludeFilters;
+ }
+
+ public boolean include(TestId testId, TestInfo testInfo)
+ {
+
+ // First check if test isn't excluded
+
+ // Make logic OR on all filters
+
+ for (TestFilter ef : excludeFilters)
+ {
+ if (!ef.include(testId, testInfo))
+ {
+ return false;
+ }
+ }
+
+ // make logic OR on all match filters
+
+ for (TestFilter mf : includeFilters)
+ {
+ if (mf.include(testId, testInfo))
+ {
+ return true;
+ }
+
+ }
+
+
+ return false;
+ }
+
+ public boolean include(TestId testId, Map<String, String> parametrization,
TestInfo testInfo)
+ {
+
+ // At the moment no parametrization match
+
+ return include (testId, testInfo);
+ }
+
+ public void addIncludeFilter(TestFilter filter)
+ {
+ if (filter == null)
+ {
+ throw new IllegalArgumentException("filter cannot be null");
+ }
+ includeFilters.add(filter);
+ }
+
+ public void addExcludeFilter(TestFilter filter)
+ {
+ if (filter == null)
+ {
+ throw new IllegalArgumentException("filter cannot be null");
+ }
+ excludeFilters.add(filter);
+ }
+
+
+}
Added:
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/report/DelegatingReporter.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/report/DelegatingReporter.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/report/DelegatingReporter.java 2007-10-10
14:53:42 UTC (rev 8588)
@@ -0,0 +1,104 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.unit.tooling.report;
+
+import org.jboss.unit.runner.TestRunnerEventListener;
+import org.jboss.unit.runner.TestRunnerEvent;
+import org.jboss.unit.report.impl.console.PrintListener;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 0.1 $
+ */
+public class DelegatingReporter implements TestRunnerEventListener
+{
+
+ private TestRunnerEventListener consoleReporter = new PrintListener();
+
+ private TestRunnerEventListener xmlReporter;
+
+ private TestRunnerEventListener htmlReporter;
+
+ boolean noConsole = true;
+
+
+ public DelegatingReporter(boolean console)
+ {
+ noConsole = console;
+ }
+
+ public void onEvent(TestRunnerEvent event)
+ {
+ //For now simple dispatch
+ if (!isNoConsole())
+ {
+ consoleReporter.onEvent(event);
+ }
+
+ if (getXmlReporter() != null)
+ {
+ xmlReporter.onEvent(event);
+ }
+
+ if (getHtmlReporter() != null)
+ {
+ htmlReporter.onEvent(event);
+ }
+ }
+
+ public TestRunnerEventListener getConsoleReporter()
+ {
+ return consoleReporter;
+ }
+
+ public boolean isNoConsole()
+ {
+ return noConsole;
+ }
+
+ public void setNoConsole(boolean noConsole)
+ {
+ this.noConsole = noConsole;
+ }
+
+
+ public TestRunnerEventListener getXmlReporter()
+ {
+ return xmlReporter;
+ }
+
+ public void setXmlReporter(TestRunnerEventListener xmlReporter)
+ {
+ this.xmlReporter = xmlReporter;
+ }
+
+ public TestRunnerEventListener getHtmlReporter()
+ {
+ return htmlReporter;
+ }
+
+ public void setHtmlReporter(TestRunnerEventListener htmlReporter)
+ {
+ this.htmlReporter = htmlReporter;
+ }
+}