JBoss Portal SVN: r8597 - in docs: branches/JBoss_Portal_Branch_2_6/userGuide/en/modules and 2 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-10-11 01:44:45 -0400 (Thu, 11 Oct 2007)
New Revision: 8597
Added:
docs/branches/JBoss_Portal_Branch_2_6/userGuide/en/images/management/portlet_details.png
docs/trunk/userGuide/en/images/management/portlet_details.png
Modified:
docs/branches/JBoss_Portal_Branch_2_6/userGuide/en/modules/dynamicity.xml
docs/trunk/userGuide/en/modules/dynamicity.xml
Log:
- Content update (text was not in synch with usability updates).
- Added portlet details screenshot.
- Fixed typos and grammar.
Added: docs/branches/JBoss_Portal_Branch_2_6/userGuide/en/images/management/portlet_details.png
===================================================================
(Binary files differ)
Property changes on: docs/branches/JBoss_Portal_Branch_2_6/userGuide/en/images/management/portlet_details.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: docs/branches/JBoss_Portal_Branch_2_6/userGuide/en/modules/dynamicity.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_6/userGuide/en/modules/dynamicity.xml 2007-10-10 22:50:59 UTC (rev 8596)
+++ docs/branches/JBoss_Portal_Branch_2_6/userGuide/en/modules/dynamicity.xml 2007-10-11 05:44:45 UTC (rev 8597)
@@ -11,10 +11,10 @@
<sect1>
<title>Introduction</title>
<note>Viewing the Management Portlet is accomplished by logging in as an admin (admin/admin) and navigating to the
- <xref linkend="adminportal"/>.
+ Admin portal (see <xref linkend="adminportal"/>).
</note>
<para>
- The concept of dynamicity is that all portal objects are able to dynamically be modified at runtime,
+ The concept of dynamicity refers to the fact all portal objects can be dynamically modified at runtime,
eliminating the need to struggle with large xml files, or restarting the application server for changes to take
effect. In the scope of dynamicity, Portal objects are defined and can be altered as follows:
<itemizedlist>
@@ -31,7 +31,7 @@
portlet, allowing for dynamic customization of any of the above components.</listitem>
</itemizedlist>
</para>
- <!--
+ <!--
<note>
Many of the operations that can be done via the Management portlet are done in the context of the current
user session. In order to see the changes on the affected pages, please log out and log back in.
@@ -81,7 +81,7 @@
<para>
The <literal>Portal Objects</literal> brings the administrator to a page showing the list of the
- available portal instances defined for this Portal server. Several points are of note. First, a
+ available portal instances defined for this Portal server. Several points are of particular interest. First, a
navigation indicator or "breadcrumbs" is located right beneath the tabs. This provides context as to
where in the hierarchy of portal objects the current screen is located as some of the screens can be
found at several levels of the hierarchy. If you are lost, take a look at the breadcrumbs for context!
@@ -106,21 +106,29 @@
<para>
A form allowing administrator to create new portal instances is located beneath the
<literal>Properties</literal> link. Enter the name of the new portal (which, of course, should be
- different from any of the already existing one) and click on <literal>Add portal</literal> and the
+ different from any of the already existing one) and click on <literal>Create portal</literal> and the
portal instances list will be refreshed to display the newly created portal instance.
</para>
<para>
- The last element of the top level of the <literal>Portal Objects</literal> tab is a table listing
+ The last element at this level is a table listing
all the available portal instances along with possible actions on them. Clicking on the portal name
will display a screen showing the information for this given portal instance, thus drilling down the
- hierarchy of available portal objects.
+ hierarchy of available portal objects. Clicking on an action name will execute the specified action
+ on the associated portal instance. These actions are available on each individual portal screen as we
+ shall see. The notable exception is the <literal>Make Default/Default</literal> action which is only
+ available in this listing as it is more of an action across portals than specific to a portal thus
+ benefiting from being seen at this level. This action allows users to specify which portal instance
+ is displayed when Portal is first being accessed. Clicking on <literal>Make Default</literal> will
+ specify that the associated portal will be displayed to users by default. The portal list will be
+ refreshed and the selected portal status will be refreshed, its action now showing its
+ <literal>Default</literal> status.
</para>
<para>
In the next sections we will demonstrate the functionality of the management portlet by drilling
progressively further down this hierarchy to look at the default portal, one of its pages, show
- how to configure content on a page and finally, look at a specific window information.
+ how to configure content on a page and, finally, look at a specific window information.
</para>
</sect3>
@@ -139,28 +147,22 @@
</imageobject>
</mediaobject>
Note the breadcrumbs at the top of the screen indicating where in the hierachy you currently are.
- In this case, we are looking at the default portal.
+ In this case, we are looking at the <literal>default</literal> portal.
</para>
<para>
Links to more information and operations that
- affect this portal instance are located beneath the breadcrumbs. We will look at them in turn later.
- We won't look at the <literal>Destroy</literal> operation, which as its name implies, allows an
- administrator to destroy the current portal instance (after a confirmation screen, as the operation is
- <emphasis role="bold">NOT</emphasis> undoable). Note that these links mirror the links that were
- available in the portal instances list on the top level page.
+ affect this portal instance are located beneath the breadcrumbs. We will look at them in turn later,
+ excluding the <literal>Destroy</literal> operation, which as its name implies, allows an
+ administrator to destroy the current portal instance. Note that these links mirror the links that were
+ available in the portal instances list on the top level page, <literal>Make Default/Default</literal>
+ excepted.
</para>
<para>
- It is also possible to designate one of the portal page as the default page that users are directed
- to when they first access the portal instance. This is done by clicking on the <literal>Make Default</literal>
- action.
- </para>
-
- <para>
It is possible to create new pages using the page creation form located under the portal-wide
- operation links. Enter the new page name and click on <literal>Add</literal> and the new page will
- appear in the pages list, ready to be configured.
+ operation links. Enter the new page name and click on <literal>Create page</literal> and the new page
+ will appear in the pages list, ready to be configured.
</para>
<para>
@@ -169,7 +171,10 @@
hierachy and display the information specific to that particular page. The second column, on the other
hand, provides a list of action links on the associated page. These links
will be also appearing on individual page screens, as we shall see, just like portal action links
- appearing in the portal instances list also appeared on individual portal pages.
+ appearing in the portal instances list also appeared on individual portal pages. Once again, the
+ <literal>Make Default/Default</literal> action, which behaves as its portal counterpart, only appears
+ in this list: this is where you specify which page should be the default one when users first access
+ the portal instance.
</para>
<para>
@@ -183,7 +188,8 @@
</imageobject>
</mediaobject>
Please refer to the
- <ulink url="http://docs.jboss.com/jbportal/v2.6/reference-guide/en/html/security.html">Security</ulink>
+ <ulink
+ url="http://docs.jboss.com/jbportal/v2.6/reference-guide/en/html/security.html">Security</ulink>
chapter of the Reference Guide for more information about how to secure portal objects.
</para>
@@ -214,7 +220,7 @@
<para>
Now that we have looked at portal level information, let's drill down the hierachy again and look at
- a page, more precisely the <literal>default</literal> page, by clicking its name in the pages list.
+ a page, more precisely the <literal>default</literal> page, by clicking its name in the pages list.
</para>
</sect3>
@@ -310,7 +316,7 @@
<para>
We can repeat this process to add content of different types. Let's add a window using a Google widget
- displaying the IP address of the user. First, give a name to your window (we'll use "google" here)
+ game. First, give a name to your window (we'll use "google" here)
and select <literal>widget/google</literal> from the content type drop-down menu:
<mediaobject>
<imageobject>
@@ -321,7 +327,7 @@
Note how the instances list is replaced by a list of Google widgets. The widget we want to use is
located in the <literal>Fun & Games</literal> category, so select it from the category drop-down menu:
<mediaobject>
- <imageobject>
+ <imageobject>
<imagedata fileref="images/management/layout_google2.png" format="png" align="center"
valign="middle"/>
</imageobject>
@@ -410,7 +416,7 @@
<para>
The <literal>Portlet Instances</literal> tab brings the administrator to the list of instances created
in the running portal. On this page, the user can either modify the security constraints for the portlet
- (to grant access only to certain roles), destoy an instance or override the portlet definition preferences
+ (to grant access only to certain roles), destroy an instance or override the portlet definition preferences
for a specific instance if there is any overridable preference.
<mediaobject>
<imageobject>
@@ -423,24 +429,14 @@
<title>Managing Portlet Definitions</title>
<para>
The <literal>Portlet Definitions</literal> tab brings the administrator to the list of portlet
- definitions. The id represent the portlet definition identifier as used in the XML descriptor.
- A more human readable name is following in the next column. For each portlet accessed through WSRP,
- the <literal>remote</literal> checkbox is selected. A <literal>remotable</literal> checkbox is used to show which
- portlet are exposed through WSRP to other consumers.
+ definitions, formatted as a table displaying name, description, whether the portlet is remote (i.e. accessed
+ via WSRP from a remote producer) or if it is remotable (i.e. if it is exposed to WSRP consumers by Portal's
+ producer).
</para>
+
<para>
- The <literal>Info</literal> action, will display the portlet definition title, description, supported languages
- and keywords. The <literal>Preferences</literal> action is used to edit preferences at the portlet definition level
- as explained in the JSR-168 specification.
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/management/portlets.png" format="png" align="center" valign="middle"/>
- </imageobject>
- </mediaobject>
- </para>
- <para>
Portlet definitions can be made available by different providers. You can select the provider you want to
- browse by selecting it in the drop-down menu and clicking <literal>Change</literal>.
+ browse by selecting it in the drop-down menu and clicking <literal>View portlets</literal>.
By default, two providers are available:
<itemizedlist>
<listitem>
@@ -458,12 +454,33 @@
<ulink url="http://docs.jboss.com/jbportal/v2.6/reference-guide/en/html/wsrp.html#con...">Consuming
remote WSRP portlets in JBoss Portal</ulink> chapter of the Reference Guide for more information on this
topic.
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/management/portlets.png" format="png" align="center" valign="middle"/>
+ </imageobject>
+ </mediaobject>
</para>
+
+ <para>
+ Clicking on a portlet name in the list will display the portlet definition title, description, supported
+ languages and keywords.
+
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/management/portlet_details.png" format="png" align="center"
+ valign="middle"/>
+ </imageobject>
+ </mediaobject>
+
+ The <literal>Preferences</literal> action (when available) is used to edit preferences at the portlet
+ definition level as explained in the JSR-168 specification.
+ </para>
+
</sect2>
<sect2 id="admin_dashboards">
<title>Managing Dashboards</title>
<para>
- The <literal>Dashboards</literal> tab allows the administrator to configure parameters for all the user dashboards.
+ The <literal>Dashboards</literal> tab allows the administrator to configure parameters for all user dashboards.
It also allows her to configure the error pages and theme properties as for the other portal objects.
</para>
</sect2>
Added: docs/trunk/userGuide/en/images/management/portlet_details.png
===================================================================
(Binary files differ)
Property changes on: docs/trunk/userGuide/en/images/management/portlet_details.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: docs/trunk/userGuide/en/modules/dynamicity.xml
===================================================================
--- docs/trunk/userGuide/en/modules/dynamicity.xml 2007-10-10 22:50:59 UTC (rev 8596)
+++ docs/trunk/userGuide/en/modules/dynamicity.xml 2007-10-11 05:44:45 UTC (rev 8597)
@@ -11,10 +11,10 @@
<sect1>
<title>Introduction</title>
<note>Viewing the Management Portlet is accomplished by logging in as an admin (admin/admin) and navigating to the
- <xref linkend="adminportal"/>.
+ Admin portal (see <xref linkend="adminportal"/>).
</note>
<para>
- The concept of dynamicity is that all portal objects are able to dynamically be modified at runtime,
+ The concept of dynamicity refers to the fact all portal objects can be dynamically modified at runtime,
eliminating the need to struggle with large xml files, or restarting the application server for changes to take
effect. In the scope of dynamicity, Portal objects are defined and can be altered as follows:
<itemizedlist>
@@ -81,7 +81,7 @@
<para>
The <literal>Portal Objects</literal> brings the administrator to a page showing the list of the
- available portal instances defined for this Portal server. Several points are of note. First, a
+ available portal instances defined for this Portal server. Several points are of particular interest. First, a
navigation indicator or "breadcrumbs" is located right beneath the tabs. This provides context as to
where in the hierarchy of portal objects the current screen is located as some of the screens can be
found at several levels of the hierarchy. If you are lost, take a look at the breadcrumbs for context!
@@ -106,21 +106,29 @@
<para>
A form allowing administrator to create new portal instances is located beneath the
<literal>Properties</literal> link. Enter the name of the new portal (which, of course, should be
- different from any of the already existing one) and click on <literal>Add portal</literal> and the
+ different from any of the already existing one) and click on <literal>Create portal</literal> and the
portal instances list will be refreshed to display the newly created portal instance.
</para>
<para>
- The last element of the top level of the <literal>Portal Objects</literal> tab is a table listing
+ The last element at this level is a table listing
all the available portal instances along with possible actions on them. Clicking on the portal name
will display a screen showing the information for this given portal instance, thus drilling down the
- hierarchy of available portal objects.
+ hierarchy of available portal objects. Clicking on an action name will execute the specified action
+ on the associated portal instance. These actions are available on each individual portal screen as we
+ shall see. The notable exception is the <literal>Make Default/Default</literal> action which is only
+ available in this listing as it is more of an action across portals than specific to a portal thus
+ benefiting from being seen at this level. This action allows users to specify which portal instance
+ is displayed when Portal is first being accessed. Clicking on <literal>Make Default</literal> will
+ specify that the associated portal will be displayed to users by default. The portal list will be
+ refreshed and the selected portal status will be refreshed, its action now showing its
+ <literal>Default</literal> status.
</para>
<para>
In the next sections we will demonstrate the functionality of the management portlet by drilling
progressively further down this hierarchy to look at the default portal, one of its pages, show
- how to configure content on a page and finally, look at a specific window information.
+ how to configure content on a page and, finally, look at a specific window information.
</para>
</sect3>
@@ -139,28 +147,22 @@
</imageobject>
</mediaobject>
Note the breadcrumbs at the top of the screen indicating where in the hierachy you currently are.
- In this case, we are looking at the default portal.
+ In this case, we are looking at the <literal>default</literal> portal.
</para>
<para>
Links to more information and operations that
- affect this portal instance are located beneath the breadcrumbs. We will look at them in turn later.
- We won't look at the <literal>Destroy</literal> operation, which as its name implies, allows an
- administrator to destroy the current portal instance (after a confirmation screen, as the operation is
- <emphasis role="bold">NOT</emphasis> undoable). Note that these links mirror the links that were
- available in the portal instances list on the top level page.
+ affect this portal instance are located beneath the breadcrumbs. We will look at them in turn later,
+ excluding the <literal>Destroy</literal> operation, which as its name implies, allows an
+ administrator to destroy the current portal instance. Note that these links mirror the links that were
+ available in the portal instances list on the top level page, <literal>Make Default/Default</literal>
+ excepted.
</para>
<para>
- It is also possible to designate one of the portal page as the default page that users are directed
- to when they first access the portal instance. This is done by clicking on the <literal>Make Default</literal>
- action.
- </para>
-
- <para>
It is possible to create new pages using the page creation form located under the portal-wide
- operation links. Enter the new page name and click on <literal>Add</literal> and the new page will
- appear in the pages list, ready to be configured.
+ operation links. Enter the new page name and click on <literal>Create page</literal> and the new page
+ will appear in the pages list, ready to be configured.
</para>
<para>
@@ -169,7 +171,10 @@
hierachy and display the information specific to that particular page. The second column, on the other
hand, provides a list of action links on the associated page. These links
will be also appearing on individual page screens, as we shall see, just like portal action links
- appearing in the portal instances list also appeared on individual portal pages.
+ appearing in the portal instances list also appeared on individual portal pages. Once again, the
+ <literal>Make Default/Default</literal> action, which behaves as its portal counterpart, only appears
+ in this list: this is where you specify which page should be the default one when users first access
+ the portal instance.
</para>
<para>
@@ -183,7 +188,8 @@
</imageobject>
</mediaobject>
Please refer to the
- <ulink url="http://docs.jboss.com/jbportal/v2.6/reference-guide/en/html/security.html">Security</ulink>
+ <ulink
+ url="http://docs.jboss.com/jbportal/v2.6/reference-guide/en/html/security.html">Security</ulink>
chapter of the Reference Guide for more information about how to secure portal objects.
</para>
@@ -310,7 +316,7 @@
<para>
We can repeat this process to add content of different types. Let's add a window using a Google widget
- displaying the IP address of the user. First, give a name to your window (we'll use "google" here)
+ game. First, give a name to your window (we'll use "google" here)
and select <literal>widget/google</literal> from the content type drop-down menu:
<mediaobject>
<imageobject>
@@ -410,7 +416,7 @@
<para>
The <literal>Portlet Instances</literal> tab brings the administrator to the list of instances created
in the running portal. On this page, the user can either modify the security constraints for the portlet
- (to grant access only to certain roles), destoy an instance or override the portlet definition preferences
+ (to grant access only to certain roles), destroy an instance or override the portlet definition preferences
for a specific instance if there is any overridable preference.
<mediaobject>
<imageobject>
@@ -423,24 +429,14 @@
<title>Managing Portlet Definitions</title>
<para>
The <literal>Portlet Definitions</literal> tab brings the administrator to the list of portlet
- definitions. The id represent the portlet definition identifier as used in the XML descriptor.
- A more human readable name is following in the next column. For each portlet accessed through WSRP,
- the <literal>remote</literal> checkbox is selected. A <literal>remotable</literal> checkbox is used to show which
- portlet are exposed through WSRP to other consumers.
+ definitions, formatted as a table displaying name, description, whether the portlet is remote (i.e. accessed
+ via WSRP from a remote producer) or if it is remotable (i.e. if it is exposed to WSRP consumers by Portal's
+ producer).
</para>
+
<para>
- The <literal>Info</literal> action, will display the portlet definition title, description, supported languages
- and keywords. The <literal>Preferences</literal> action is used to edit preferences at the portlet definition level
- as explained in the JSR-168 specification.
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/management/portlets.png" format="png" align="center" valign="middle"/>
- </imageobject>
- </mediaobject>
- </para>
- <para>
Portlet definitions can be made available by different providers. You can select the provider you want to
- browse by selecting it in the drop-down menu and clicking <literal>Change</literal>.
+ browse by selecting it in the drop-down menu and clicking <literal>View portlets</literal>.
By default, two providers are available:
<itemizedlist>
<listitem>
@@ -458,12 +454,33 @@
<ulink url="http://docs.jboss.com/jbportal/v2.6/reference-guide/en/html/wsrp.html#con...">Consuming
remote WSRP portlets in JBoss Portal</ulink> chapter of the Reference Guide for more information on this
topic.
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/management/portlets.png" format="png" align="center" valign="middle"/>
+ </imageobject>
+ </mediaobject>
</para>
+
+ <para>
+ Clicking on a portlet name in the list will display the portlet definition title, description, supported
+ languages and keywords.
+
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/management/portlet_details.png" format="png" align="center"
+ valign="middle"/>
+ </imageobject>
+ </mediaobject>
+
+ The <literal>Preferences</literal> action (when available) is used to edit preferences at the portlet
+ definition level as explained in the JSR-168 specification.
+ </para>
+
</sect2>
<sect2 id="admin_dashboards">
<title>Managing Dashboards</title>
<para>
- The <literal>Dashboards</literal> tab allows the administrator to configure parameters for all the user dashboards.
+ The <literal>Dashboards</literal> tab allows the administrator to configure parameters for all user dashboards.
It also allows her to configure the error pages and theme properties as for the other portal objects.
</para>
</sect2>
18 years, 7 months
JBoss Portal SVN: r8596 - in modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl: generic and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-10-10 18:50:59 -0400 (Wed, 10 Oct 2007)
New Revision: 8596
Added:
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/generic/
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/generic/GenericTestRunner.java
Log:
- minor javadoc
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/generic/GenericTestRunner.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/generic/GenericTestRunner.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/generic/GenericTestRunner.java 2007-10-10 22:50:59 UTC (rev 8596)
@@ -0,0 +1,95 @@
+/******************************************************************************
+ * 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.runner.impl.generic;
+
+import org.jboss.unit.runner.AbstractTestRunner;
+import org.jboss.unit.runner.TestFilter;
+import org.jboss.unit.runner.ParametrizationSet;
+import org.jboss.unit.runner.event.TestRunnerLifeCycleFilter;
+import org.jboss.unit.runner.event.RunnerFailureEvent;
+import org.jboss.unit.runner.impl.driver.TestDriverRunner;
+import org.jboss.unit.runner.model.generic.GenericTestSuiteDef;
+import org.jboss.unit.runner.model.generic.TestDef;
+import org.jboss.unit.driver.TestDriver;
+import org.jboss.unit.TestId;
+import org.jboss.unit.Failure;
+
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class GenericTestRunner extends AbstractTestRunner
+{
+
+ /** . */
+ private final GenericTestSuiteDef def;
+
+ /** . */
+ private final TestRunnerLifeCycleFilter lifeCycleFilter;
+
+ public GenericTestRunner(GenericTestSuiteDef def)
+ {
+ this.def = def;
+ this.lifeCycleFilter = new TestRunnerLifeCycleFilter(broadcaster);
+ }
+
+ protected void internalRun(TestFilter filter)
+ {
+ String className = def.getClassName();
+
+ //
+ try
+ {
+ Class<TestDriver> clazz = (Class<TestDriver>)Thread.currentThread().getContextClassLoader().loadClass(className);
+ TestDriver driver = clazz.newInstance();
+
+ //
+ Collection<TestDef> testDefs = def.getTests();
+
+ // If nothing is provided we execute the whole suite
+ if (testDefs.isEmpty())
+ {
+ testDefs = Collections.singleton(new TestDef(new TestId("")));
+ }
+
+ for (TestDef testDef : testDefs)
+ {
+ // Create parametrization
+ ParametrizationSet parametrizations = def.getParameters().getParametrization();
+ parametrizations.merge(testDef.getParameters().getParametrization());
+
+ //
+ TestDriverRunner runner = new TestDriverRunner(driver, parametrizations, testDef.getRefId());
+ runner.addListener(lifeCycleFilter);
+ runner.run(filter);
+ }
+ }
+ catch (Exception e)
+ {
+ fireEvent(new RunnerFailureEvent(Failure.createErrorFailure("Cannot execute test class " + className,e)));
+ }
+ }
+}
18 years, 7 months
JBoss Portal SVN: r8595 - in modules/test/trunk/unit/src/main/org/jboss: unit/report/impl/console and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-10-10 18:23:30 -0400 (Wed, 10 Oct 2007)
New Revision: 8595
Modified:
modules/test/trunk/unit/src/main/org/jboss/test/unit/AllTests.java
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/console/PrintListener.java
Log:
in console reporter use exception.printStackTrace(System.out) instead of default which writes to err and interleave the console output with the normal standard output
Modified: modules/test/trunk/unit/src/main/org/jboss/test/unit/AllTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/AllTests.java 2007-10-10 22:19:45 UTC (rev 8594)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/AllTests.java 2007-10-10 22:23:30 UTC (rev 8595)
@@ -29,6 +29,7 @@
import org.jboss.test.unit.runner.CompositeTestRunnerTests;
import org.jboss.test.unit.runner.ParametrizationTests;
import org.jboss.test.unit.runner.TestDriverRunnerTests;
+import org.jboss.test.unit.runner.GenericTestRunnerTests;
import org.jboss.test.unit.runner.event.TestRunnerEventBroadcasterSupportTests;
import org.jboss.test.unit.runner.event.TestRunnerLifeCycleFilterTests;
import org.jboss.test.unit.runner.model.ModelTests;
@@ -48,6 +49,7 @@
JUnitPOJOTests.main(args);
CompositeTestRunnerTests.main(args);
TestDriverRunnerTests.main(args);
+ GenericTestRunnerTests.main(args);
//
TestRunnerLifeCycleFilterTests.main(args);
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/console/PrintListener.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/console/PrintListener.java 2007-10-10 22:19:45 UTC (rev 8594)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/console/PrintListener.java 2007-10-10 22:23:30 UTC (rev 8595)
@@ -57,7 +57,7 @@
RunnerFailureEvent failureEvent = (RunnerFailureEvent)event;
Failure failure = failureEvent.getFailure();
System.out.println("Runner failure: " + failure.getType() + " " + failure.getMessage());
- failure.getCause().printStackTrace();
+ failure.getCause().printStackTrace(System.out);
}
else if (event instanceof StartTestEvent)
{
@@ -80,7 +80,7 @@
System.out.println("Test id=" + testId + " " + failure.getType() + " failed " + failure.getMessage() + " (" + testResult.getDurationMillis() + "ms)");
if (failure.getCause() != null)
{
- failure.getCause().printStackTrace();
+ failure.getCause().printStackTrace(System.out);
}
}
}
18 years, 7 months
JBoss Portal SVN: r8594 - in docs: trunk/userGuide/en/modules and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-10-10 18:19:45 -0400 (Wed, 10 Oct 2007)
New Revision: 8594
Modified:
docs/branches/JBoss_Portal_Branch_2_6/userGuide/en/modules/intro.xml
docs/trunk/userGuide/en/modules/intro.xml
Log:
- Fixed typos and grammar errors.
Modified: docs/branches/JBoss_Portal_Branch_2_6/userGuide/en/modules/intro.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_6/userGuide/en/modules/intro.xml 2007-10-10 22:05:10 UTC (rev 8593)
+++ docs/branches/JBoss_Portal_Branch_2_6/userGuide/en/modules/intro.xml 2007-10-10 22:19:45 UTC (rev 8594)
@@ -36,7 +36,7 @@
<emphasis>http://[domain]/[context]/portal/[portal_name]</emphasis>
. In a default/local install, the
<emphasis>default</emphasis>
- portal instance can be reach by
+ portal instance can be reached at
<ulink url="http://localhost:8080/portal/portal/default">http://localhost:8080/portal/portal/default</ulink>
.
</para>
@@ -55,11 +55,11 @@
<emphasis>http://[domain]/[context]/portal/[portal_name]/[page_name]</emphasis>
. In a default/local install, the
<emphasis>default</emphasis>
- page can be reach by
+ page can be reached at
<ulink url="http://localhost:8080/portal/portal/default">
http://localhost:8080/portal/portal/default/default
</ulink>
- . Likewise, the News Page in a default install can be reached by
+ . Likewise, the News Page in a default install can be reached at
<ulink url="http://localhost:8080/portal/portal/default/News">
http://localhost:8080/portal/portal/default/News
</ulink>
@@ -96,11 +96,11 @@
<para>
<emphasis role="bold">Window Controls:</emphasis>
Window controls are divided into two categories and control different aspects of how the user can
- impact the generated markup. Each window control can be click to interact with the window in
- specific way. <emphasis role="bold">Window State</emphasis> icons control how much room the window
+ impact the generated markup. Each window control can be clicked on to interact with the window in
+ specific ways. <emphasis role="bold">Window State</emphasis> icons control how much room the window
will take on the page and how much markup will be shown.
<emphasis role="bold">Portlet Mode</emphasis> icons, on the other hand, control the mode in which
- the portlet operate, thus impacting the type of generated markup. Note that not all portlets
+ the portlet operates, thus impacting the type of generated markup. Note that not all portlets
support all defined window states and/or portlet modes.
<itemizedlist>
<listitem>
@@ -114,8 +114,8 @@
</imageobject>
<emphasis role="bold">(Normal)</emphasis>
- Normal window state, is the most common state for portlets (portlets in the
- above image are in the normal window state). All portlet
- windows occupy a similar amount of space on the page.
+ above image are in the normal window state). The portlet window will occupy only
+ enough space to show the portlet content on the page.
</para>
</listitem>
<listitem>
@@ -141,7 +141,7 @@
<para>
<emphasis role="bold">Portlet Modes and their meaning:</emphasis>
Portlet modes are not always available (it depends on the portlet support for a given mode).
- Moreover, the Edit mode is only available to logged in users, as in this mode, the portlet
+ Moreover, the Edit mode is only available to logged-in users, as in this mode, the portlet
preferences can be modified to be individually suited to a particular user's needs.
<itemizedlist>
<listitem>
@@ -320,7 +320,7 @@
<mediaobject>
<imageobject>
<imagedata fileref="images/intro/user_portlet_lost.png" format="png" align="center"
- valign="middle"/>
+ valign="middle"/>
</imageobject>
</mediaobject>
</para>
@@ -330,7 +330,7 @@
<emphasis role="bold">View profile</emphasis>
</para>
<para>
- The default page after login is the view profile, which shows a summary of the most important properties of a user.
+ The default page after login is the view profile, which shows a summary of the most important properties of a user.
</para>
</listitem>
<listitem>
@@ -338,7 +338,7 @@
<emphasis role="bold">Edit personal information</emphasis>
</para>
<para>A user has the ability to edit his personal information, change his password and e-mail address at any time by clicking on the
- <emphasis>"Edit profile"</emphasis> link, when logged in.
+ <emphasis>"Edit profile"</emphasis> link, when logged in.
</para>
</listitem>
</itemizedlist>
@@ -359,7 +359,8 @@
Displaying content is done by the portal using a path mapper. For example, if we wanted to display a zip
file, located in <emphasis>/default/foo/bar.zip</emphasis>, we would type in the URL
<emphasis>http://localhost:8080/content/default/foo/bar.zip</emphasis>.
- <emphasis role="bold">Notice how the path to the content, is prefixed with the '/content' term.</emphasis>
+ <emphasis
+ role="bold">Notice how the path to the content, is prefixed with the '/content' term.</emphasis>
Although in this example we are describing binary content retrieval, the same is to be said for text/html
files. Keep in mind, however, that binary files are displayed outside of the portal pages, but text/html
are displayed inside the CMSPortlet Window.
@@ -521,7 +522,7 @@
location, if the administrator allows this functionality. Changes made in this fashion will also be persisted.
</para>
<para>
- It is also possible to copy the content of a shared page to your dashboard so you can customize it to your
+ It is also possible to copy the content of a shared page to your dashboard so you can customize it to your
liking. Just click the <emphasis>'Copy to my dashboard'</emphasis> link at the top right of the page.
This will clone the page and add it to your personal dashboard as a page with the same name.
<mediaobject>
@@ -564,7 +565,8 @@
at the bottom of the screen. We will note that users are not able to delete the default dashboard page.
<mediaobject>
<imageobject>
- <imagedata fileref="images/intro/dashboard_deletepage.png" format="png" align="center" valign="middle"/>
+ <imagedata fileref="images/intro/dashboard_deletepage.png" format="png" align="center"
+ valign="middle"/>
</imageobject>
</mediaobject>
<warning>
@@ -592,7 +594,7 @@
<sect1 id="adminportal">
<title>Admin Portal</title>
<para>
- <note>You <emphasis role="bold">must be</emphasis> logged in as an administrator, or have proper priviledges
+ <note>You <emphasis role="bold">must be</emphasis> logged in as an administrator, or have proper privileges
to see this portal.
</note>
<mediaobject>
@@ -600,8 +602,8 @@
<imagedata fileref="images/intro/adminportal.png" format="png" align="center" valign="middle"/>
</imageobject>
</mediaobject>
- The Admin Portal's purpose is to allow an administrator to manage all aspects of the portal (Follow the links
- for in-depth reviews of these functions):
+ The Admin Portal's purpose is to allow an administrator to manage all aspects of the portal. Follow the links
+ for in-depth reviews of these functions:
<itemizedlist>
<listitem>Users/Roles (See: <xref linkend="useradmin"/>, <xref linkend="roleadmin"/>)</listitem>
<listitem>Content Management System (See: <xref linkend="admincmsPortlet"/>)</listitem>
Modified: docs/trunk/userGuide/en/modules/intro.xml
===================================================================
--- docs/trunk/userGuide/en/modules/intro.xml 2007-10-10 22:05:10 UTC (rev 8593)
+++ docs/trunk/userGuide/en/modules/intro.xml 2007-10-10 22:19:45 UTC (rev 8594)
@@ -36,7 +36,7 @@
<emphasis>http://[domain]/[context]/portal/[portal_name]</emphasis>
. In a default/local install, the
<emphasis>default</emphasis>
- portal instance can be reach by
+ portal instance can be reached at
<ulink url="http://localhost:8080/portal/portal/default">http://localhost:8080/portal/portal/default</ulink>
.
</para>
@@ -55,11 +55,11 @@
<emphasis>http://[domain]/[context]/portal/[portal_name]/[page_name]</emphasis>
. In a default/local install, the
<emphasis>default</emphasis>
- page can be reach by
+ page can be reached at
<ulink url="http://localhost:8080/portal/portal/default">
http://localhost:8080/portal/portal/default/default
</ulink>
- . Likewise, the News Page in a default install can be reached by
+ . Likewise, the News Page in a default install can be reached at
<ulink url="http://localhost:8080/portal/portal/default/News">
http://localhost:8080/portal/portal/default/News
</ulink>
@@ -96,11 +96,11 @@
<para>
<emphasis role="bold">Window Controls:</emphasis>
Window controls are divided into two categories and control different aspects of how the user can
- impact the generated markup. Each window control can be click to interact with the window in
- specific way. <emphasis role="bold">Window State</emphasis> icons control how much room the window
+ impact the generated markup. Each window control can be clicked on to interact with the window in
+ specific ways. <emphasis role="bold">Window State</emphasis> icons control how much room the window
will take on the page and how much markup will be shown.
<emphasis role="bold">Portlet Mode</emphasis> icons, on the other hand, control the mode in which
- the portlet operate, thus impacting the type of generated markup. Note that not all portlets
+ the portlet operates, thus impacting the type of generated markup. Note that not all portlets
support all defined window states and/or portlet modes.
<itemizedlist>
<listitem>
@@ -114,8 +114,8 @@
</imageobject>
<emphasis role="bold">(Normal)</emphasis>
- Normal window state, is the most common state for portlets (portlets in the
- above image are in the normal window state). All portlet
- windows occupy a similar amount of space on the page.
+ above image are in the normal window state). The portlet window will occupy only
+ enough space to show the portlet content on the page.
</para>
</listitem>
<listitem>
@@ -141,7 +141,7 @@
<para>
<emphasis role="bold">Portlet Modes and their meaning:</emphasis>
Portlet modes are not always available (it depends on the portlet support for a given mode).
- Moreover, the Edit mode is only available to logged in users, as in this mode, the portlet
+ Moreover, the Edit mode is only available to logged-in users, as in this mode, the portlet
preferences can be modified to be individually suited to a particular user's needs.
<itemizedlist>
<listitem>
@@ -320,7 +320,7 @@
<mediaobject>
<imageobject>
<imagedata fileref="images/intro/user_portlet_lost.png" format="png" align="center"
- valign="middle"/>
+ valign="middle"/>
</imageobject>
</mediaobject>
</para>
@@ -359,7 +359,8 @@
Displaying content is done by the portal using a path mapper. For example, if we wanted to display a zip
file, located in <emphasis>/default/foo/bar.zip</emphasis>, we would type in the URL
<emphasis>http://localhost:8080/content/default/foo/bar.zip</emphasis>.
- <emphasis role="bold">Notice how the path to the content, is prefixed with the '/content' term.</emphasis>
+ <emphasis
+ role="bold">Notice how the path to the content, is prefixed with the '/content' term.</emphasis>
Although in this example we are describing binary content retrieval, the same is to be said for text/html
files. Keep in mind, however, that binary files are displayed outside of the portal pages, but text/html
are displayed inside the CMSPortlet Window.
@@ -564,7 +565,8 @@
at the bottom of the screen. We will note that users are not able to delete the default dashboard page.
<mediaobject>
<imageobject>
- <imagedata fileref="images/intro/dashboard_deletepage.png" format="png" align="center" valign="middle"/>
+ <imagedata fileref="images/intro/dashboard_deletepage.png" format="png" align="center"
+ valign="middle"/>
</imageobject>
</mediaobject>
<warning>
@@ -592,7 +594,7 @@
<sect1 id="adminportal">
<title>Admin Portal</title>
<para>
- <note>You <emphasis role="bold">must be</emphasis> logged in as an administrator, or have proper priviledges
+ <note>You <emphasis role="bold">must be</emphasis> logged in as an administrator, or have proper privileges
to see this portal.
</note>
<mediaobject>
@@ -600,8 +602,8 @@
<imagedata fileref="images/intro/adminportal.png" format="png" align="center" valign="middle"/>
</imageobject>
</mediaobject>
- The Admin Portal's purpose is to allow an administrator to manage all aspects of the portal (Follow the links
- for in-depth reviews of these functions):
+ The Admin Portal's purpose is to allow an administrator to manage all aspects of the portal. Follow the links
+ for in-depth reviews of these functions:
<itemizedlist>
<listitem>Users/Roles (See: <xref linkend="useradmin"/>, <xref linkend="roleadmin"/>)</listitem>
<listitem>Content Management System (See: <xref linkend="admincmsPortlet"/>)</listitem>
18 years, 7 months
JBoss Portal SVN: r8593 - in modules/test/trunk/unit/src: main/org/jboss/unit/runner/model and 2 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-10-10 18:05:10 -0400 (Wed, 10 Oct 2007)
New Revision: 8593
Added:
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/TestDef.java
Removed:
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestDef.java
Modified:
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/model/ModelTests.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ModelBuilder.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/GenericTestSuiteDef.java
modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/model/f2.xml
Log:
added test case for test ref id in generic test
Modified: modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/model/ModelTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/model/ModelTests.java 2007-10-10 21:56:06 UTC (rev 8592)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/model/ModelTests.java 2007-10-10 22:05:10 UTC (rev 8593)
@@ -27,6 +27,7 @@
import org.jboss.unit.runner.model.ParameterValueDef;
import org.jboss.unit.runner.model.ParametersDef;
import org.jboss.unit.runner.model.TestSuiteDef;
+import org.jboss.unit.runner.model.generic.TestDef;
import org.jboss.unit.runner.model.generic.GenericTestSuiteDef;
import org.jboss.unit.runner.model.composite.CompositeTestSuiteDef;
import org.jboss.unit.runner.model.pojo.POJOTestSuiteDef;
@@ -34,10 +35,12 @@
import org.jboss.unit.runner.model.pojo.TestCaseDef;
import static org.jboss.unit.util.CollectionTools.list;
import static org.jboss.unit.util.CollectionTools.set;
+import org.jboss.unit.TestId;
import org.xml.sax.InputSource;
import java.io.InputStream;
import java.util.Iterator;
+import java.util.List;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -82,6 +85,14 @@
//
ParametersDef parameters = assertNotNull(generic.getParameters());
assertEquals(set("red"), parameters.getNames());
+
+ //
+ List<TestDef> tests = assertNotNull(generic.getTests());
+ assertEquals(2, tests.size());
+ TestDef foo = assertNotNull(tests.get(0));
+ assertEquals(new TestId("foo"), foo.getRefId());
+ TestDef fooBar = assertNotNull(tests.get(1));
+ assertEquals(new TestId("foo", "bar"), fooBar.getRefId());
}
private static void buildFromXML1()
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ModelBuilder.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ModelBuilder.java 2007-10-10 21:56:06 UTC (rev 8592)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ModelBuilder.java 2007-10-10 22:05:10 UTC (rev 8593)
@@ -34,6 +34,7 @@
import org.jboss.unit.runner.model.pojo.TestCaseDef;
import org.jboss.unit.runner.model.composite.CompositeTestSuiteDef;
import org.jboss.unit.runner.model.generic.GenericTestSuiteDef;
+import org.jboss.unit.runner.model.generic.TestDef;
import org.jboss.unit.TestIdFormat;
import org.jboss.unit.TestId;
import org.xml.sax.InputSource;
Deleted: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestDef.java 2007-10-10 21:56:06 UTC (rev 8592)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestDef.java 2007-10-10 22:05:10 UTC (rev 8593)
@@ -1,63 +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.runner.model;
-
-import org.jboss.unit.TestId;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class TestDef
-{
-
- /** . */
- private TestId refId;
-
- /** . */
- private ParametersDef parameters = new ParametersDef();
-
- public TestDef(TestId refId)
- {
- if (refId == null)
- {
- throw new IllegalArgumentException("No null ref id accepted");
- }
- this.refId = refId;
- }
-
- public TestId getRefId()
- {
- return refId;
- }
-
- public ParametersDef getParameters()
- {
- return parameters;
- }
-
- public void setParameters(ParametersDef parameters)
- {
- this.parameters = parameters;
- }
-}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/GenericTestSuiteDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/GenericTestSuiteDef.java 2007-10-10 21:56:06 UTC (rev 8592)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/GenericTestSuiteDef.java 2007-10-10 22:05:10 UTC (rev 8593)
@@ -24,13 +24,12 @@
import org.jboss.unit.runner.model.TestSuiteDef;
import org.jboss.unit.runner.model.BuilderException;
-import org.jboss.unit.runner.model.TestDef;
+import org.jboss.unit.runner.model.generic.TestDef;
import org.jboss.unit.runner.TestRunner;
import org.jboss.unit.runner.impl.generic.GenericTestRunner;
import java.util.List;
import java.util.ArrayList;
-import java.util.Collection;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -69,7 +68,7 @@
tests.add(test);
}
- public Collection<TestDef> getTests()
+ public List<TestDef> getTests()
{
return tests;
}
Copied: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/TestDef.java (from rev 8592, modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestDef.java)
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/TestDef.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/TestDef.java 2007-10-10 22:05:10 UTC (rev 8593)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * 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.runner.model.generic;
+
+import org.jboss.unit.TestId;
+import org.jboss.unit.runner.model.ParametersDef;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestDef
+{
+
+ /** . */
+ private TestId refId;
+
+ /** . */
+ private ParametersDef parameters = new ParametersDef();
+
+ public TestDef(TestId refId)
+ {
+ if (refId == null)
+ {
+ throw new IllegalArgumentException("No null ref id accepted");
+ }
+ this.refId = refId;
+ }
+
+ public TestId getRefId()
+ {
+ return refId;
+ }
+
+ public ParametersDef getParameters()
+ {
+ return parameters;
+ }
+
+ public void setParameters(ParametersDef parameters)
+ {
+ this.parameters = parameters;
+ }
+}
Modified: modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/model/f2.xml
===================================================================
--- modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/model/f2.xml 2007-10-10 21:56:06 UTC (rev 8592)
+++ modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/model/f2.xml 2007-10-10 22:05:10 UTC (rev 8593)
@@ -6,5 +6,7 @@
<generic>
<class name="foo_generic"/>
<parameter name="red" value="blue"/>
+ <test refid="foo"/>
+ <test refid="foo.bar"/>
</generic>
</jboss-unit>
18 years, 7 months
JBoss Portal SVN: r8592 - in modules/test/trunk/unit/src: main/org/jboss/unit and 8 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-10-10 17:56:06 -0400 (Wed, 10 Oct 2007)
New Revision: 8592
Added:
modules/test/trunk/unit/src/main/org/jboss/unit/TestIdFormat.java
Removed:
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestDefDef.java
Modified:
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/model/ModelTests.java
modules/test/trunk/unit/src/main/org/jboss/unit/TestId.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/pojo/POJOTestRunner.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ModelBuilder.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestSuiteDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/GenericTestSuiteDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/POJOTestSuiteDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestClassDef.java
modules/test/trunk/unit/src/main/org/jboss/unit/util/CollectionTools.java
modules/test/trunk/unit/src/resources/jboss-unit-jar/org/jboss/unit/runner/model/jboss-unit_1_0.xsd
modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/blah/f1.xml
modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/model/f1.xml
Log:
simplified and consolidated pojo test test model and its underlying xml schema
Modified: modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/model/ModelTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/model/ModelTests.java 2007-10-10 20:55:52 UTC (rev 8591)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/model/ModelTests.java 2007-10-10 21:56:06 UTC (rev 8592)
@@ -26,20 +26,17 @@
import org.jboss.unit.runner.model.ModelBuilder;
import org.jboss.unit.runner.model.ParameterValueDef;
import org.jboss.unit.runner.model.ParametersDef;
-import org.jboss.unit.runner.model.TestDef;
import org.jboss.unit.runner.model.TestSuiteDef;
import org.jboss.unit.runner.model.generic.GenericTestSuiteDef;
import org.jboss.unit.runner.model.composite.CompositeTestSuiteDef;
import org.jboss.unit.runner.model.pojo.POJOTestSuiteDef;
-import org.jboss.unit.runner.model.pojo.TestDefDef;
+import org.jboss.unit.runner.model.pojo.TestClassDef;
+import org.jboss.unit.runner.model.pojo.TestCaseDef;
import static org.jboss.unit.util.CollectionTools.list;
import static org.jboss.unit.util.CollectionTools.set;
import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import javax.xml.parsers.ParserConfigurationException;
import java.io.InputStream;
-import java.io.IOException;
import java.util.Iterator;
/**
@@ -97,66 +94,32 @@
POJOTestSuiteDef pojoSuite = assertInstanceOf(composite.getSuites().iterator().next(), POJOTestSuiteDef.class);
- TestDefDef myTestDef = pojoSuite.getTestDef("MyTest");
- assertNotNull(myTestDef);
- assertEquals("MyTest", myTestDef.getId());
- assertNotNull(myTestDef.getTestClass());
- assertEquals("org.foo.bar.MyTest", myTestDef.getTestClass().getName());
- assertNotNull(myTestDef.getTestClass().getTestCases());
- assertEquals(0, myTestDef.getTestClass().getTestCases().size());
+ Iterator<TestClassDef> testClasses = pojoSuite.getTestClasses().iterator();
- TestDefDef myTestDef2 = pojoSuite.getTestDef("MyTest2");
- assertNotNull(myTestDef2);
- assertEquals("MyTest2", myTestDef2.getId());
- assertNotNull(myTestDef2.getTestClass());
- assertEquals("org.foo.bar.MyTest2", myTestDef2.getTestClass().getName());
- assertNotNull(myTestDef2.getTestClass().getTestCases());
- assertEquals(2, myTestDef2.getTestClass().getTestCases().size());
- assertNotNull(myTestDef2.getTestClass().getTestCase("foo"));
- assertEquals("foo", myTestDef2.getTestClass().getTestCase("foo").getName());
- assertNotNull(myTestDef2.getTestClass().getTestCase("bar"));
- assertEquals("bar", myTestDef2.getTestClass().getTestCase("bar").getName());
-
- assertEquals(2, pojoSuite.getTests().size());
-
//
- Iterator<TestDef> iterator = pojoSuite.getTests().iterator();
- TestDef test1 = iterator.next();
- assertEquals("MyTest", test1.getRefId());
- ParametersDef parameters = test1.getParameters();
- assertNotNull(parameters);
- assertEquals(set("blah", "foo"), parameters.getNames());
- ParameterValueDef blah = parameters.getParameter("blah");
- assertEquals(list("bluh"), blah.list());
- ParameterValueDef foo = parameters.getParameter("foo");
- assertEquals(list("bar1", null), foo.list());
+ assertTrue(testClasses.hasNext());
+ TestClassDef otherTestClass = assertNotNull(testClasses.next());
+ assertEquals("org.foo.bar.OtherTest", otherTestClass.getName());
+ assertEquals(0, otherTestClass.getTestCases().size());
+ assertNotNull(otherTestClass.getParameters());
+ assertEquals(set("foo"), otherTestClass.getParameters().getNames());
+ ParameterValueDef fooParam = assertNotNull(otherTestClass.getParameters().getParameter("foo"));
+ assertEquals(list("bar"), fooParam.list());
//
- TestDef test2 = iterator.next();
- assertNotNull(test2.getRefId());
- ParametersDef test2Parameters = test2.getParameters();
- assertNotNull(test2Parameters);
- assertEquals(set("foo"), test2Parameters.getNames());
- ParameterValueDef fff = test2Parameters.getParameter("foo");
- assertEquals(list("bar"), fff.list());
-
- //
- TestDefDef myTestDef3 = pojoSuite.getTestDef(test2.getRefId());
- assertNotNull(myTestDef3);
-
- assertEquals(test2.getRefId(), myTestDef3.getId());
- assertNotNull(myTestDef3.getTestClass());
- assertEquals("org.foo.bar.OtherTest", myTestDef3.getTestClass().getName());
- assertNotNull(myTestDef3.getTestClass().getTestCases());
- assertEquals(0, myTestDef3.getTestClass().getTestCases().size());
-
-
- //
-// ParametersDef suiteParams = pojoSuite.getParameters();
-// assertNotNull(suiteParams);
-// assertEquals(set("red"), suiteParams.getMap().keySet());
-// ParameterValueDef blue = suiteParams.getMap().get("red");
-// assertEquals(list("blue"), blue.list());
+ assertTrue(testClasses.hasNext());
+ TestClassDef barClass = assertNotNull(testClasses.next());
+ assertEquals("org.Bar", barClass.getName());
+ assertEquals(2, barClass.getTestCases().size());
+ TestCaseDef barFooCase = assertNotNull(barClass.getTestCase("foo"));
+ assertEquals("foo", barFooCase.getName());
+ TestCaseDef barBarCase = assertNotNull(barClass.getTestCase("bar"));
+ assertEquals("bar", barBarCase.getName());
+ assertEquals(set("foo", "blah"), barClass.getParameters().getNames());
+ ParameterValueDef barClassFooParam = assertNotNull(barClass.getParameters().getParameter("foo"));
+ assertEquals(list("bar1", null), barClassFooParam.list());
+ ParameterValueDef barClassBlahParam = assertNotNull(barClass.getParameters().getParameter("blah"));
+ assertEquals(list("bluh"), barClassBlahParam.list());
}
private static void testParameterValueDef()
@@ -181,5 +144,4 @@
{
}
}
-
}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/TestId.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/TestId.java 2007-10-10 20:55:52 UTC (rev 8591)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/TestId.java 2007-10-10 21:56:06 UTC (rev 8592)
@@ -35,7 +35,7 @@
*/
public final class TestId implements Serializable
{
-
+
/** . */
private final String[] names;
Added: modules/test/trunk/unit/src/main/org/jboss/unit/TestIdFormat.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/TestIdFormat.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/TestIdFormat.java 2007-10-10 21:56:06 UTC (rev 8592)
@@ -0,0 +1,111 @@
+/******************************************************************************
+ * 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;
+
+import org.jboss.unit.util.CollectionTools;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class TestIdFormat
+{
+
+ /**
+ * Parse a fqn representation of a test id.
+ *
+ * @param fqn the fqn to parse
+ * @return the test id value
+ * @throws IllegalArgumentException if the argument is not valid
+ */
+ public abstract TestId parse(String fqn) throws IllegalArgumentException;
+
+ public abstract String toString(TestId testId) throws IllegalArgumentException;
+
+ public static final TestIdFormat CLASSIC = new TestIdFormat()
+ {
+ public TestId parse(String fqn)
+ {
+ if (fqn == null)
+ {
+ throw new IllegalArgumentException("No null fqn accepted");
+ }
+
+ //
+ int from = 0;
+ List<String> names = new ArrayList<String>();
+
+ //
+ do
+ {
+ int pos = fqn.indexOf('.', from);
+
+ //
+ if (pos == -1)
+ {
+ names.add(fqn.substring(from));
+ break;
+ }
+
+ //
+ names.add(fqn.substring(from, pos));
+
+ //
+ from = pos + 1;
+ }
+ while (true);
+
+ //
+ return new TestId(names);
+ }
+
+ public String toString(TestId testId)
+ {
+ if (testId == null)
+ {
+ throw new IllegalArgumentException("No null test id accepted");
+ }
+
+ //
+ if (testId.getLength() == 0)
+ {
+ return "";
+ }
+
+ //
+ StringBuilder builder = new StringBuilder();
+ for (String name : CollectionTools.iterable(testId.iterator()))
+ {
+ builder.append(name);
+ builder.append('.');
+ }
+
+ //
+ return builder.substring(0, builder.length() - 1);
+ }
+ };
+
+}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/pojo/POJOTestRunner.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/pojo/POJOTestRunner.java 2007-10-10 20:55:52 UTC (rev 8591)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/pojo/POJOTestRunner.java 2007-10-10 21:56:06 UTC (rev 8592)
@@ -29,14 +29,11 @@
import org.jboss.unit.runner.event.RunnerFailureEvent;
import org.jboss.unit.runner.event.TestRunnerLifeCycleFilter;
import org.jboss.unit.runner.model.pojo.POJOTestSuiteDef;
-import org.jboss.unit.runner.model.pojo.TestDefDef;
import org.jboss.unit.runner.model.pojo.TestClassDef;
import org.jboss.unit.runner.model.pojo.TestCaseDef;
-import org.jboss.unit.runner.model.TestDef;
import org.jboss.unit.TestId;
import org.jboss.unit.Failure;
import org.jboss.unit.info.TestSuiteInfo;
-import org.jboss.unit.info.TestCaseInfo;
import org.jboss.unit.driver.impl.pojo.POJOTestSuiteDriver;
import org.jboss.unit.driver.TestDriver;
@@ -64,70 +61,46 @@
protected void internalRun(TestFilter filter)
{
- for (TestDef test : suite.getTests())
+ for (TestClassDef testClass : suite.getTestClasses())
{
- // Get def id
- String testDefId = test.getRefId();
+ String className = testClass.getName();
//
- if (testDefId != null)
+ try
{
- // Get related test definition
- TestDefDef testDef = suite.getTestDef(testDefId);
+ Class clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
//
- if (testDef != null)
+ TestDriver driver = new POJOTestSuiteDriver(clazz);
+ TestSuiteInfo testSuiteInfo = (TestSuiteInfo)driver.getInfo();
+
+ //
+ List<String> testCaseNames = new ArrayList<String>();
+ for (TestCaseDef testCase : testClass.getTestCases())
{
- TestClassDef testClass = testDef.getTestClass();
- String className = testClass.getName();
+ testCaseNames.add(testCase.getName());
+ }
+ if (testCaseNames.size() == 0)
+ {
+ testCaseNames.addAll(testSuiteInfo.getNames());
+ }
- //
- try
- {
- Class clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
+ // Create parametrization
+ ParametrizationSet parametrizations = suite.getParameters().getParametrization();
+ parametrizations.merge(testClass.getParameters().getParametrization());
- //
- TestDriver driver = new POJOTestSuiteDriver(clazz);
- TestSuiteInfo testSuiteInfo = (TestSuiteInfo)driver.getInfo();
-
- //
- List<String> testCaseNames = new ArrayList<String>();
- for (TestCaseDef testCase : testClass.getTestCases())
- {
- testCaseNames.add(testCase.getName());
- }
- if (testCaseNames.size() == 0)
- {
- testCaseNames.addAll(testSuiteInfo.getNames());
- }
-
- // Create parametrization
- ParametrizationSet parametrizations = suite.getParameters().getParametrization();
- parametrizations.merge(test.getParameters().getParametrization());
-
- //
- for (String testCaseName : testCaseNames)
- {
- TestId testCaseId = new TestId(testCaseName);
- TestCaseInfo testCaseInfo = (TestCaseInfo)testSuiteInfo.findTest(testCaseId);
- TestDriverRunner runner = new TestDriverRunner(driver, parametrizations, testCaseId);
- runner.addListener(lifeCycleFilter);
- runner.run(filter);
- }
- }
- catch (Exception e)
- {
- fireEvent(new RunnerFailureEvent(Failure.createErrorFailure("Cannot execute test id " + testDefId,e)));
- }
- }
- else
+ //
+ for (String testCaseName : testCaseNames)
{
- fireEvent(new RunnerFailureEvent(Failure.createErrorFailure("No test definition found for id " + testDefId)));
+ TestId testCaseId = new TestId(testCaseName);
+ TestDriverRunner runner = new TestDriverRunner(driver, parametrizations, testCaseId);
+ runner.addListener(lifeCycleFilter);
+ runner.run(filter);
}
}
- else
+ catch (Exception e)
{
- fireEvent(new RunnerFailureEvent(Failure.createErrorFailure("No test definition found for id " + testDefId)));
+ fireEvent(new RunnerFailureEvent(Failure.createErrorFailure("Cannot execute test class " + className,e)));
}
}
}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ModelBuilder.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ModelBuilder.java 2007-10-10 20:55:52 UTC (rev 8591)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ModelBuilder.java 2007-10-10 21:56:06 UTC (rev 8592)
@@ -32,9 +32,10 @@
import org.jboss.unit.runner.model.pojo.POJOTestSuiteDef;
import org.jboss.unit.runner.model.pojo.TestClassDef;
import org.jboss.unit.runner.model.pojo.TestCaseDef;
-import org.jboss.unit.runner.model.pojo.TestDefDef;
import org.jboss.unit.runner.model.composite.CompositeTestSuiteDef;
import org.jboss.unit.runner.model.generic.GenericTestSuiteDef;
+import org.jboss.unit.TestIdFormat;
+import org.jboss.unit.TestId;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
@@ -180,12 +181,15 @@
}
//
- String refid = refidAttr.getValue();
+ String refIdLitteral = refidAttr.getValue();
//
- TestDef test = new TestDef(refid);
+ TestId refId = TestIdFormat.CLASSIC.parse(refIdLitteral);
//
+ TestDef test = new TestDef(refId);
+
+ //
test.setParameters(buildParameters(testElt));
//
@@ -199,111 +203,45 @@
return suite;
}
- private TestClassDef buildTestClassDef(Element classElt)
- {
- Attr nameAttr = classElt.getAttributeNode("name");
- if (nameAttr == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- String classname = nameAttr.getValue();
- TestClassDef testClass = new TestClassDef(classname);
-
- //
- for (Element caseElt : children(classElt, "case"))
- {
-
- Attr caseNameAttr = caseElt.getAttributeNode("name");
- if (caseNameAttr == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- testClass.addTestCase(new TestCaseDef(caseNameAttr.getValue()));
- }
-
- //
- return testClass;
- }
-
private TestSuiteDef buildPOJOTestSuite(Element suiteElt)
{
POJOTestSuiteDef suite = new POJOTestSuiteDef();
-
+
//
- for (Element testDefElt : children(suiteElt, "test-def"))
+ for (Element testElt : children(suiteElt, "test"))
{
- Attr idAttr = testDefElt.getAttributeNode("id");
- if (idAttr == null)
- {
- throw new IllegalArgumentException();
- }
+ Element classElt = child(testElt, "class");
//
- String id = idAttr.getValue();
-
- //
- Element classElt = child(testDefElt, "class");
- if (classElt == null)
+ Attr nameAttr = classElt.getAttributeNode("name");
+ if (nameAttr == null)
{
throw new IllegalArgumentException();
}
//
- TestClassDef testClass = buildTestClassDef(classElt);
+ String classname = nameAttr.getValue();
+ TestClassDef testClass = new TestClassDef(classname);
- //
- TestDefDef testDef = new TestDefDef(id);
- testDef.setTestClass(testClass);
+ testClass.setParameters(buildParameters(testElt));
//
- suite.addDef(testDef);
- }
-
- //
- for (Element testElt : children(suiteElt, "test"))
- {
- Attr refidAttr = testElt.getAttributeNode("refid");
- Element classElt = child(testElt, "class");
-
- //
- String refid;
-
- //
- if (refidAttr != null)
+ for (Element caseElt : children(classElt, "case"))
{
- refid = refidAttr.getValue();
- }
- else if (classElt != null)
- {
- String id = "blah";
+ Attr caseNameAttr = caseElt.getAttributeNode("name");
+ if (caseNameAttr == null)
+ {
+ throw new IllegalArgumentException();
+ }
- TestClassDef testClass = buildTestClassDef(classElt);
-
- TestDefDef testDef = new TestDefDef(id);
-
- testDef.setTestClass(testClass);
-
- suite.addDef(testDef);
-
- refid = id;
+ //
+ String testCaseName = caseNameAttr.getValue();
+ TestCaseDef testCase = new TestCaseDef(testCaseName);
+ testClass.addTestCase(testCase);
}
- else
- {
- throw new IllegalArgumentException();
- }
//
- TestDef test = new TestDef(refid);
-
- //
- test.setParameters(buildParameters(testElt));
-
- //
- suite.addTest(test);
+ suite.addClass(testClass);
}
//
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestDef.java 2007-10-10 20:55:52 UTC (rev 8591)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestDef.java 2007-10-10 21:56:06 UTC (rev 8592)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.unit.runner.model;
+import org.jboss.unit.TestId;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -30,21 +32,21 @@
{
/** . */
- private String refId;
+ private TestId refId;
/** . */
private ParametersDef parameters = new ParametersDef();
- public TestDef(String testId)
+ public TestDef(TestId refId)
{
- if (testId == null)
+ if (refId == null)
{
- throw new IllegalArgumentException("No null test id accepted");
+ throw new IllegalArgumentException("No null ref id accepted");
}
- this.refId = testId;
+ this.refId = refId;
}
- public String getRefId()
+ public TestId getRefId()
{
return refId;
}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestSuiteDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestSuiteDef.java 2007-10-10 20:55:52 UTC (rev 8591)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestSuiteDef.java 2007-10-10 21:56:06 UTC (rev 8592)
@@ -35,26 +35,9 @@
public abstract class TestSuiteDef
{
- /** The tests. */
- protected final List<TestDef> tests = new ArrayList<TestDef>();
-
/** . */
protected ParametersDef parameters = new ParametersDef();
- public void addTest(TestDef test)
- {
- if (test == null)
- {
- throw new IllegalArgumentException();
- }
- tests.add(test);
- }
-
- public Collection<TestDef> getTests()
- {
- return tests;
- }
-
public ParametersDef getParameters()
{
return parameters;
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/GenericTestSuiteDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/GenericTestSuiteDef.java 2007-10-10 20:55:52 UTC (rev 8591)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/GenericTestSuiteDef.java 2007-10-10 21:56:06 UTC (rev 8592)
@@ -24,9 +24,14 @@
import org.jboss.unit.runner.model.TestSuiteDef;
import org.jboss.unit.runner.model.BuilderException;
+import org.jboss.unit.runner.model.TestDef;
import org.jboss.unit.runner.TestRunner;
import org.jboss.unit.runner.impl.generic.GenericTestRunner;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collection;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -34,6 +39,9 @@
public class GenericTestSuiteDef extends TestSuiteDef
{
+ /** The tests. */
+ private List<TestDef> tests = new ArrayList<TestDef>();
+
/** . */
private String className;
@@ -51,4 +59,18 @@
{
return new GenericTestRunner(this);
}
+
+ public void addTest(TestDef test)
+ {
+ if (test == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ tests.add(test);
+ }
+
+ public Collection<TestDef> getTests()
+ {
+ return tests;
+ }
}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/POJOTestSuiteDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/POJOTestSuiteDef.java 2007-10-10 20:55:52 UTC (rev 8591)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/POJOTestSuiteDef.java 2007-10-10 21:56:06 UTC (rev 8592)
@@ -28,8 +28,8 @@
import org.jboss.unit.runner.impl.pojo.POJOTestRunner;
import java.util.Collection;
-import java.util.Map;
-import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -39,31 +39,22 @@
{
/** The definitions. */
- private Map<String, TestDefDef> testDefs = new HashMap<String, TestDefDef>();
+ private List<TestClassDef> testClasses = new ArrayList<TestClassDef>();
- public void addDef(TestDefDef testDef)
+ public void addClass(TestClassDef testDef)
{
if (testDef == null)
{
- throw new IllegalArgumentException("No null test def accepted");
+ throw new IllegalArgumentException("No null test class accepted");
}
- testDefs.put(testDef.getId(), testDef);
+ testClasses.add(testDef);
}
- public Collection<TestDefDef> getTestDefs()
+ public Collection<TestClassDef> getTestClasses()
{
- return testDefs.values();
+ return testClasses;
}
- public TestDefDef getTestDef(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("No null test def name accepted");
- }
- return testDefs.get(name);
- }
-
public TestRunner createRunner() throws BuilderException
{
return new POJOTestRunner(this);
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestClassDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestClassDef.java 2007-10-10 20:55:52 UTC (rev 8591)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestClassDef.java 2007-10-10 21:56:06 UTC (rev 8592)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.unit.runner.model.pojo;
+import org.jboss.unit.runner.model.ParametersDef;
+
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
@@ -39,6 +41,9 @@
/** . */
private Map<String,TestCaseDef> testCases = new HashMap<String, TestCaseDef>();
+ /** . */
+ private ParametersDef parameters = new ParametersDef();
+
public TestClassDef(String name)
{
if (name == null)
@@ -77,4 +82,14 @@
}
return testCases.get(name);
}
+
+ public ParametersDef getParameters()
+ {
+ return parameters;
+ }
+
+ public void setParameters(ParametersDef parameters)
+ {
+ this.parameters = parameters;
+ }
}
Deleted: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestDefDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestDefDef.java 2007-10-10 20:55:52 UTC (rev 8591)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestDefDef.java 2007-10-10 21:56:06 UTC (rev 8592)
@@ -1,65 +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.runner.model.pojo;
-
-/**
- * The definition of a tested class.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class TestDefDef
-{
-
- /** . */
- private final String id;
-
- /** . */
- private TestClassDef testClass;
-
- public TestDefDef(String id)
- {
- if (id == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- this.id = id;
- }
-
- public String getId()
- {
- return id;
- }
-
- public TestClassDef getTestClass()
- {
- return testClass;
- }
-
- public void setTestClass(TestClassDef testClass)
- {
- this.testClass = testClass;
- }
-}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/util/CollectionTools.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/util/CollectionTools.java 2007-10-10 20:55:52 UTC (rev 8591)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/util/CollectionTools.java 2007-10-10 21:56:06 UTC (rev 8592)
@@ -27,6 +27,7 @@
import java.util.HashSet;
import java.util.Set;
import java.util.List;
+import java.util.Iterator;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -35,6 +36,17 @@
public class CollectionTools
{
+ public static <U> Iterable<U> iterable(final Iterator<U> iterator)
+ {
+ return new Iterable<U>()
+ {
+ public Iterator<U> iterator()
+ {
+ return iterator;
+ }
+ };
+ }
+
public static <U> Set<U> set()
{
return new HashSet<U>();
Modified: modules/test/trunk/unit/src/resources/jboss-unit-jar/org/jboss/unit/runner/model/jboss-unit_1_0.xsd
===================================================================
--- modules/test/trunk/unit/src/resources/jboss-unit-jar/org/jboss/unit/runner/model/jboss-unit_1_0.xsd 2007-10-10 20:55:52 UTC (rev 8591)
+++ modules/test/trunk/unit/src/resources/jboss-unit-jar/org/jboss/unit/runner/model/jboss-unit_1_0.xsd 2007-10-10 21:56:06 UTC (rev 8592)
@@ -70,10 +70,9 @@
nested class element or it can refer to an existing test definition. The nested parameters are used to parameterize
the test configuration, they override any existing parameter defined at the pojo level.</xsd:documentation></xsd:annotation>
<xsd:sequence>
+ <xsd:element name="class" type="pojo_classType" minOccurs="1" maxOccurs="1"/>
<xsd:element name="parameter" type="parameterType" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="class" type="pojo_classType" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
- <xsd:attribute name="refid" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="genericType">
Modified: modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/blah/f1.xml
===================================================================
--- modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/blah/f1.xml 2007-10-10 20:55:52 UTC (rev 8591)
+++ modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/blah/f1.xml 2007-10-10 21:56:06 UTC (rev 8592)
@@ -4,31 +4,24 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
<pojo>
- <test-def id="blahblah">
+ <test>
<class name="org.jboss.test.unit.blah.TestedClass1"/>
- </test-def>
- <test-def id="bluh">
+ </test>
+ <test>
<class name="org.jboss.test.unit.blah.TestedClass1">
<case name="testFoo"/>
</class>
- </test-def>
- <test-def id="blih">
- <class name="org.jboss.test.unit.blah.TestedClass2"/>
- </test-def>
- <test refid="blahblah">
</test>
- <test refid="XYZ">
- </test>
- <test refid="bluh">
- </test>
<test>
- <class name="blah"/>
- </test>
- <test refid="blih">
+ <class name="org.jboss.test.unit.blah.TestedClass2">
+ </class>
<parameter name="foo">
<value>foo</value>
<value>fii</value>
</parameter>
</test>
+ <test>
+ <class name="XYZ"/>
+ </test>
</pojo>
</jboss-unit>
Modified: modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/model/f1.xml
===================================================================
--- modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/model/f1.xml 2007-10-10 20:55:52 UTC (rev 8591)
+++ modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/model/f1.xml 2007-10-10 21:56:06 UTC (rev 8592)
@@ -7,21 +7,16 @@
<parameter name="red" value="blue"/>
- <test-def id="MyTest">
- <class name="org.foo.bar.MyTest"/>
- <!--
- <parameters>
- </parameters>
- -->
- </test-def>
- <test-def id="MyTest2">
- <class name="org.foo.bar.MyTest2">
+ <test>
+ <class name="org.foo.bar.OtherTest"/>
+ <parameter name="foo" value="bar"/>
+ </test>
+
+ <test>
+ <class name="org.Bar">
<case name="foo"/>
<case name="bar"/>
</class>
- </test-def>
-
- <test refid="MyTest">
<parameter name="blah" value="bluh"/>
<parameter name="foo">
<value>bar1</value>
@@ -29,25 +24,5 @@
</parameter>
</test>
- <test>
- <parameter name="foo" value="bar"/>
- <class name="org.foo.bar.OtherTest"/>
- </test>
-
- <!--
- <test>
- <class name="">
- <case name="abc"/>
- </class>
- <parameters>
- <parameter name="blah" value="bluh"/>
- <parameter name="foo">
- <value>bar1</value>
- <null/>
- </parameter>
- </parameters>
- </test>
- -->
-
</pojo>
</jboss-unit>
18 years, 7 months
JBoss Portal SVN: r8591 - modules/test/trunk/build.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2007-10-10 16:55:52 -0400 (Wed, 10 Oct 2007)
New Revision: 8591
Modified:
modules/test/trunk/build/build.xml
Log:
add tooling to main build
Modified: modules/test/trunk/build/build.xml
===================================================================
--- modules/test/trunk/build/build.xml 2007-10-10 17:00:10 UTC (rev 8590)
+++ modules/test/trunk/build/build.xml 2007-10-10 20:55:52 UTC (rev 8591)
@@ -115,12 +115,13 @@
<module name="unit"/>
<module name="mc"/>
<module name="remote"/>
+ <module name="tooling"/>
<!-- Module groups -->
<group name="test">
<include
- modules="test,unit,mc,remote"/>
+ modules="test,unit,mc,remote,tooling"/>
</group>
<group name="default">
18 years, 7 months
JBoss Portal SVN: r8590 - in modules/test/trunk/unit/src: main/org/jboss/unit/api and 5 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-10-10 13:00:10 -0400 (Wed, 10 Oct 2007)
New Revision: 8590
Added:
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/GenericTestSuiteDef.java
modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/model/f2.xml
Modified:
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/model/ModelTests.java
modules/test/trunk/unit/src/main/org/jboss/unit/api/Assert.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ModelBuilder.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/composite/CompositeTestSuiteDef.java
modules/test/trunk/unit/src/resources/jboss-unit-jar/org/jboss/unit/runner/model/jboss-unit_1_0.xsd
Log:
started to work on generic test suite
Modified: modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/model/ModelTests.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/model/ModelTests.java 2007-10-10 15:34:37 UTC (rev 8589)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/model/ModelTests.java 2007-10-10 17:00:10 UTC (rev 8590)
@@ -28,14 +28,18 @@
import org.jboss.unit.runner.model.ParametersDef;
import org.jboss.unit.runner.model.TestDef;
import org.jboss.unit.runner.model.TestSuiteDef;
+import org.jboss.unit.runner.model.generic.GenericTestSuiteDef;
import org.jboss.unit.runner.model.composite.CompositeTestSuiteDef;
import org.jboss.unit.runner.model.pojo.POJOTestSuiteDef;
import org.jboss.unit.runner.model.pojo.TestDefDef;
import static org.jboss.unit.util.CollectionTools.list;
import static org.jboss.unit.util.CollectionTools.set;
import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import javax.xml.parsers.ParserConfigurationException;
import java.io.InputStream;
+import java.io.IOException;
import java.util.Iterator;
/**
@@ -48,87 +52,111 @@
{
testParameterValueDef();
+ buildFromXML1();
+ buildFromXML2();
+
+
+ }
+
+ private static TestSuiteDef buildTestSuite(String resourceId)
+ {
try
{
- InputStream in = ModelTests.class.getResourceAsStream("f1.xml");
+ InputStream in = ModelTests.class.getResourceAsStream(resourceId);
ModelBuilder builder = new ModelBuilder(new InputSource(in));
- TestSuiteDef suite = builder.build();
+ return builder.build();
+ }
+ catch (Exception e)
+ {
+ throw createFailure(e);
+ }
+ }
- CompositeTestSuiteDef composite = assertInstanceOf(suite, CompositeTestSuiteDef.class);
+ private static void buildFromXML2()
+ {
+ TestSuiteDef suite = buildTestSuite("f2.xml");
- assertNotNull(composite.getSuites());
- assertFalse(composite.getSuites().isEmpty());
+ CompositeTestSuiteDef composite = assertInstanceOf(suite, CompositeTestSuiteDef.class);
+ assertNotNull(composite.getSuites());
+ assertEquals(1, composite.getSuites().size());
+ GenericTestSuiteDef generic = assertInstanceOf(composite.getSuites().get(0), GenericTestSuiteDef.class);
+ assertEquals("foo_generic", generic.getClassName());
- POJOTestSuiteDef pojoSuite = assertInstanceOf(composite.getSuites().iterator().next(), POJOTestSuiteDef.class);
+ //
+ ParametersDef parameters = assertNotNull(generic.getParameters());
+ assertEquals(set("red"), parameters.getNames());
+ }
- TestDefDef myTestDef = pojoSuite.getTestDef("MyTest");
- assertNotNull(myTestDef);
- assertEquals("MyTest", myTestDef.getId());
- assertNotNull(myTestDef.getTestClass());
- assertEquals("org.foo.bar.MyTest", myTestDef.getTestClass().getName());
- assertNotNull(myTestDef.getTestClass().getTestCases());
- assertEquals(0, myTestDef.getTestClass().getTestCases().size());
+ private static void buildFromXML1()
+ {
+ TestSuiteDef suite = buildTestSuite("f1.xml");
- TestDefDef myTestDef2 = pojoSuite.getTestDef("MyTest2");
- assertNotNull(myTestDef2);
- assertEquals("MyTest2", myTestDef2.getId());
- assertNotNull(myTestDef2.getTestClass());
- assertEquals("org.foo.bar.MyTest2", myTestDef2.getTestClass().getName());
- assertNotNull(myTestDef2.getTestClass().getTestCases());
- assertEquals(2, myTestDef2.getTestClass().getTestCases().size());
- assertNotNull(myTestDef2.getTestClass().getTestCase("foo"));
- assertEquals("foo", myTestDef2.getTestClass().getTestCase("foo").getName());
- assertNotNull(myTestDef2.getTestClass().getTestCase("bar"));
- assertEquals("bar", myTestDef2.getTestClass().getTestCase("bar").getName());
+ CompositeTestSuiteDef composite = assertInstanceOf(suite, CompositeTestSuiteDef.class);
+ assertNotNull(composite.getSuites());
+ assertFalse(composite.getSuites().isEmpty());
- assertEquals(2, pojoSuite.getTests().size());
+ POJOTestSuiteDef pojoSuite = assertInstanceOf(composite.getSuites().iterator().next(), POJOTestSuiteDef.class);
- //
- Iterator<TestDef> iterator = pojoSuite.getTests().iterator();
- TestDef test1 = iterator.next();
- assertEquals("MyTest", test1.getRefId());
- ParametersDef parameters = test1.getParameters();
- assertNotNull(parameters);
- assertEquals(set("blah", "foo"), parameters.getNames());
- ParameterValueDef blah = parameters.getParameter("blah");
- assertEquals(list("bluh"), blah.list());
- ParameterValueDef foo = parameters.getParameter("foo");
- assertEquals(list("bar1", null), foo.list());
+ TestDefDef myTestDef = pojoSuite.getTestDef("MyTest");
+ assertNotNull(myTestDef);
+ assertEquals("MyTest", myTestDef.getId());
+ assertNotNull(myTestDef.getTestClass());
+ assertEquals("org.foo.bar.MyTest", myTestDef.getTestClass().getName());
+ assertNotNull(myTestDef.getTestClass().getTestCases());
+ assertEquals(0, myTestDef.getTestClass().getTestCases().size());
- //
- TestDef test2 = iterator.next();
- assertNotNull(test2.getRefId());
- ParametersDef test2Parameters = test2.getParameters();
- assertNotNull(test2Parameters);
- assertEquals(set("foo"), test2Parameters.getNames());
- ParameterValueDef fff = test2Parameters.getParameter("foo");
- assertEquals(list("bar"), fff.list());
+ TestDefDef myTestDef2 = pojoSuite.getTestDef("MyTest2");
+ assertNotNull(myTestDef2);
+ assertEquals("MyTest2", myTestDef2.getId());
+ assertNotNull(myTestDef2.getTestClass());
+ assertEquals("org.foo.bar.MyTest2", myTestDef2.getTestClass().getName());
+ assertNotNull(myTestDef2.getTestClass().getTestCases());
+ assertEquals(2, myTestDef2.getTestClass().getTestCases().size());
+ assertNotNull(myTestDef2.getTestClass().getTestCase("foo"));
+ assertEquals("foo", myTestDef2.getTestClass().getTestCase("foo").getName());
+ assertNotNull(myTestDef2.getTestClass().getTestCase("bar"));
+ assertEquals("bar", myTestDef2.getTestClass().getTestCase("bar").getName());
- //
- TestDefDef myTestDef3 = pojoSuite.getTestDef(test2.getRefId());
- assertNotNull(myTestDef3);
+ assertEquals(2, pojoSuite.getTests().size());
- assertEquals(test2.getRefId(), myTestDef3.getId());
- assertNotNull(myTestDef3.getTestClass());
- assertEquals("org.foo.bar.OtherTest", myTestDef3.getTestClass().getName());
- assertNotNull(myTestDef3.getTestClass().getTestCases());
- assertEquals(0, myTestDef3.getTestClass().getTestCases().size());
+ //
+ Iterator<TestDef> iterator = pojoSuite.getTests().iterator();
+ TestDef test1 = iterator.next();
+ assertEquals("MyTest", test1.getRefId());
+ ParametersDef parameters = test1.getParameters();
+ assertNotNull(parameters);
+ assertEquals(set("blah", "foo"), parameters.getNames());
+ ParameterValueDef blah = parameters.getParameter("blah");
+ assertEquals(list("bluh"), blah.list());
+ ParameterValueDef foo = parameters.getParameter("foo");
+ assertEquals(list("bar1", null), foo.list());
+ //
+ TestDef test2 = iterator.next();
+ assertNotNull(test2.getRefId());
+ ParametersDef test2Parameters = test2.getParameters();
+ assertNotNull(test2Parameters);
+ assertEquals(set("foo"), test2Parameters.getNames());
+ ParameterValueDef fff = test2Parameters.getParameter("foo");
+ assertEquals(list("bar"), fff.list());
- //
+ //
+ TestDefDef myTestDef3 = pojoSuite.getTestDef(test2.getRefId());
+ assertNotNull(myTestDef3);
+
+ assertEquals(test2.getRefId(), myTestDef3.getId());
+ assertNotNull(myTestDef3.getTestClass());
+ assertEquals("org.foo.bar.OtherTest", myTestDef3.getTestClass().getName());
+ assertNotNull(myTestDef3.getTestClass().getTestCases());
+ assertEquals(0, myTestDef3.getTestClass().getTestCases().size());
+
+
+ //
// ParametersDef suiteParams = pojoSuite.getParameters();
// assertNotNull(suiteParams);
// assertEquals(set("red"), suiteParams.getMap().keySet());
// ParameterValueDef blue = suiteParams.getMap().get("red");
// assertEquals(list("blue"), blue.list());
-
- }
- catch (Exception e)
- {
- fail(e);
- }
-
-
}
private static void testParameterValueDef()
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/api/Assert.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/api/Assert.java 2007-10-10 15:34:37 UTC (rev 8589)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/api/Assert.java 2007-10-10 17:00:10 UTC (rev 8590)
@@ -53,14 +53,22 @@
}
}
- public static void assertNotNull(Object actual)
+ public static <T> T assertNotNull(T actual)
{
- assertNotSame(null, actual);
+ return assertNotNull(null, actual);
}
- public static void assertNotNull(String msg, Object actual)
+ public static <T> T assertNotNull(String msg, T actual)
{
- assertNotSame(msg, null, actual);
+ if (actual == null)
+ {
+ if (msg != null)
+ {
+ msg = "Expected a non null object";
+ }
+ fail(msg);
+ }
+ return actual;
}
public static void assertNull(Object actual)
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ModelBuilder.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ModelBuilder.java 2007-10-10 15:34:37 UTC (rev 8589)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ModelBuilder.java 2007-10-10 17:00:10 UTC (rev 8590)
@@ -32,7 +32,9 @@
import org.jboss.unit.runner.model.pojo.POJOTestSuiteDef;
import org.jboss.unit.runner.model.pojo.TestClassDef;
import org.jboss.unit.runner.model.pojo.TestCaseDef;
+import org.jboss.unit.runner.model.pojo.TestDefDef;
import org.jboss.unit.runner.model.composite.CompositeTestSuiteDef;
+import org.jboss.unit.runner.model.generic.GenericTestSuiteDef;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
@@ -123,7 +125,10 @@
private TestSuiteDef buildTestSuite(Element suiteElt)
{
- if (suiteElt.getNodeName().equals("jboss-unit") || suiteElt.getNodeName().equals("suite"))
+ String suiteName = suiteElt.getNodeName();
+
+ //
+ if (suiteName.equals("jboss-unit") || suiteName.equals("suite"))
{
CompositeTestSuiteDef composite = new CompositeTestSuiteDef();
for (Element childSuiteElt : children(suiteElt))
@@ -133,39 +138,91 @@
}
return composite;
}
- else if (suiteElt.getNodeName().equals("pojo"))
+ else if (suiteName.equals("pojo"))
{
return buildPOJOTestSuite(suiteElt);
}
+ else if (suiteName.equals("generic"))
+ {
+ return buildGenericTestSuite(suiteElt);
+ }
//
throw new AssertionError();
}
+ private TestSuiteDef buildGenericTestSuite(Element suiteElt)
+ {
+ Element classElt = child(suiteElt, "class");
+ if (classElt == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ Attr attr = classElt.getAttributeNode("name");
+ if (attr == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ String className = attr.getValue();
+ GenericTestSuiteDef suite = new GenericTestSuiteDef(className);
+
+ //
+ for (Element testElt : children(suiteElt, "test"))
+ {
+ Attr refidAttr = testElt.getAttributeNode("refid");
+ if (refidAttr == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ String refid = refidAttr.getValue();
+
+ //
+ TestDef test = new TestDef(refid);
+
+ //
+ test.setParameters(buildParameters(testElt));
+
+ //
+ suite.addTest(test);
+ }
+
+ //
+ suite.setParameters(buildParameters(suiteElt));
+
+ //
+ return suite;
+ }
+
private TestClassDef buildTestClassDef(Element classElt)
{
- Node nameAttr = classElt.getAttributes().getNamedItem("name");
- if (nameAttr == null || !(nameAttr instanceof Attr))
+ Attr nameAttr = classElt.getAttributeNode("name");
+ if (nameAttr == null)
{
throw new IllegalArgumentException();
}
//
- String classname = ((Attr)nameAttr).getValue();
+ String classname = nameAttr.getValue();
TestClassDef testClass = new TestClassDef(classname);
//
for (Element caseElt : children(classElt, "case"))
{
- Node caseNameAttr = caseElt.getAttributes().getNamedItem("name");
- if (caseNameAttr == null || !(caseNameAttr instanceof Attr))
+ Attr caseNameAttr = caseElt.getAttributeNode("name");
+ if (caseNameAttr == null)
{
throw new IllegalArgumentException();
}
//
- testClass.addTestCase(new TestCaseDef(((Attr)caseNameAttr).getValue()));
+ testClass.addTestCase(new TestCaseDef(caseNameAttr.getValue()));
}
//
@@ -179,14 +236,14 @@
//
for (Element testDefElt : children(suiteElt, "test-def"))
{
- Node idAttr = testDefElt.getAttributes().getNamedItem("id");
- if (idAttr == null || !(idAttr instanceof Attr))
+ Attr idAttr = testDefElt.getAttributeNode("id");
+ if (idAttr == null)
{
throw new IllegalArgumentException();
}
//
- String id = ((Attr)idAttr).getValue();
+ String id = idAttr.getValue();
//
Element classElt = child(testDefElt, "class");
@@ -199,7 +256,7 @@
TestClassDef testClass = buildTestClassDef(classElt);
//
- org.jboss.unit.runner.model.pojo.TestDefDef testDef = new org.jboss.unit.runner.model.pojo.TestDefDef(id);
+ TestDefDef testDef = new TestDefDef(id);
testDef.setTestClass(testClass);
//
@@ -209,7 +266,7 @@
//
for (Element testElt : children(suiteElt, "test"))
{
- Node refidAttr = testElt.getAttributes().getNamedItem("refid");
+ Attr refidAttr = testElt.getAttributeNode("refid");
Element classElt = child(testElt, "class");
//
@@ -218,11 +275,7 @@
//
if (refidAttr != null)
{
- if (!(refidAttr instanceof Attr))
- {
- throw new IllegalArgumentException();
- }
- refid = ((Attr)refidAttr).getValue();
+ refid = refidAttr.getValue();
}
else if (classElt != null)
{
@@ -230,7 +283,7 @@
TestClassDef testClass = buildTestClassDef(classElt);
- org.jboss.unit.runner.model.pojo.TestDefDef testDef = new org.jboss.unit.runner.model.pojo.TestDefDef(id);
+ TestDefDef testDef = new TestDefDef(id);
testDef.setTestClass(testClass);
@@ -273,7 +326,7 @@
List<String> values = new ArrayList<String>();
- Attr attr = (Attr)parameterElt.getAttributes().getNamedItem("value");
+ Attr attr = parameterElt.getAttributeNode("value");
int src = NO_SOURCE;
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/composite/CompositeTestSuiteDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/composite/CompositeTestSuiteDef.java 2007-10-10 15:34:37 UTC (rev 8589)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/composite/CompositeTestSuiteDef.java 2007-10-10 17:00:10 UTC (rev 8590)
@@ -50,7 +50,7 @@
suites.add(suite);
}
- public Collection<TestSuiteDef> getSuites()
+ public List<TestSuiteDef> getSuites()
{
return suites;
}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/GenericTestSuiteDef.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/GenericTestSuiteDef.java (rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/GenericTestSuiteDef.java 2007-10-10 17:00:10 UTC (rev 8590)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * 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.runner.model.generic;
+
+import org.jboss.unit.runner.model.TestSuiteDef;
+import org.jboss.unit.runner.model.BuilderException;
+import org.jboss.unit.runner.TestRunner;
+import org.jboss.unit.runner.impl.generic.GenericTestRunner;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class GenericTestSuiteDef extends TestSuiteDef
+{
+
+ /** . */
+ private String className;
+
+ public GenericTestSuiteDef(String className)
+ {
+ this.className = className;
+ }
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public TestRunner createRunner() throws BuilderException
+ {
+ return new GenericTestRunner(this);
+ }
+}
Modified: modules/test/trunk/unit/src/resources/jboss-unit-jar/org/jboss/unit/runner/model/jboss-unit_1_0.xsd
===================================================================
--- modules/test/trunk/unit/src/resources/jboss-unit-jar/org/jboss/unit/runner/model/jboss-unit_1_0.xsd 2007-10-10 15:34:37 UTC (rev 8589)
+++ modules/test/trunk/unit/src/resources/jboss-unit-jar/org/jboss/unit/runner/model/jboss-unit_1_0.xsd 2007-10-10 17:00:10 UTC (rev 8590)
@@ -26,6 +26,7 @@
<xsd:sequence>
<xsd:element name="suite" type="suiteType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="pojo" type="pojoType" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element name="generic" type="genericType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
@@ -75,6 +76,29 @@
<xsd:attribute name="refid" type="xsd:string"/>
</xsd:complexType>
+ <xsd:complexType name="genericType">
+ <xsd:annotation><xsd:documentation>The generic element defines a generic test suite. It contains a global parameter set
+ and a set of tests to execute.</xsd:documentation></xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="class" minOccurs="1" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="parameter" type="parameterType" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element name="test" type="generic_testType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="generic_testType">
+ <xsd:annotation><xsd:documentation>A test element specifies a test to execute. It must refer to an existing test definition.
+ The nested parameters are used to parameterize the test configuration.</xsd:documentation></xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="parameter" type="parameterType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="refid" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
<xsd:complexType name="parameterType">
<xsd:annotation><xsd:documentation>A parameter element.</xsd:documentation></xsd:annotation>
<xsd:sequence>
Added: modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/model/f2.xml
===================================================================
--- modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/model/f2.xml (rev 0)
+++ modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/runner/model/f2.xml 2007-10-10 17:00:10 UTC (rev 8590)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jboss-unit
+ xmlns="urn:jboss:jboss-unit:1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
+ <generic>
+ <class name="foo_generic"/>
+ <parameter name="red" value="blue"/>
+ </generic>
+</jboss-unit>
18 years, 7 months
JBoss Portal SVN: r8589 - modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit.
by portal-commits@lists.jboss.org
Author: emuckenhuber
Date: 2007-10-10 11:34:37 -0400 (Wed, 10 Oct 2007)
New Revision: 8589
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitTestReport.java
Log:
- checking of TestCase Events
Modified: 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/JUnitTestReport.java 2007-10-10 14:53:42 UTC (rev 8588)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitTestReport.java 2007-10-10 15:34:37 UTC (rev 8589)
@@ -32,7 +32,9 @@
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -49,6 +51,7 @@
import org.jboss.unit.Failure;
import org.jboss.unit.FailureType;
import org.jboss.unit.TestId;
+import org.jboss.unit.info.TestInfo;
import org.jboss.unit.runner.TestResult;
import org.jboss.unit.runner.event.EndRunnerEvent;
import org.jboss.unit.runner.event.EndTestEvent;
@@ -72,9 +75,6 @@
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;
@@ -82,6 +82,9 @@
/** The root element */
private Element rootElement;
+ /** The started Tests */
+ private Map<TestId, TestInfo> startedTests = new HashMap<TestId, TestInfo>();
+
/** The system error */
private StringBuffer systemErr = new StringBuffer();
@@ -112,28 +115,37 @@
public void startTestSuite(StartRunnerEvent event)
{
+ /** Create root element */
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());
+ this.rootElement.setAttribute(XMLConstants.ATTR_NAME, this.testSuiteName);
+ /** Create properties element */
Element properties = document.createElement(XMLConstants.PROPERTIES);
this.rootElement.appendChild(properties);
- // add properties list
-
+ /**
+ * TODO - set properties
+ */
}
public void startTest(StartTestEvent event)
{
+ this.startedTests.put(event.getTestId(), event.getTestInfo());
this.tests++;
}
public void runnerFailed(RunnerFailureEvent event)
{
- this.tests++;
+ this.tests++;
this.errors++;
Element e = document.createElement(XMLConstants.ERROR);
- e.appendChild(document.createCDATASection(ls + event.getFailure().getMessage() + ls + stackToString(event.getFailure().getCause())));
+ e.setAttribute(XMLConstants.ATTR_TYPE, event.getFailure().getType().name());
+ e.setAttribute(XMLConstants.ATTR_MESSAGE, event.getFailure().getMessage());
+ if ( event.getFailure().getCause() != null)
+ {
+ e.appendChild(document.createCDATASection(stackToString(event.getFailure().getCause())));
+ }
rootElement.appendChild(e);
}
@@ -142,7 +154,7 @@
TestId testId = event.getTestId();
TestResult result = event.getTestResult();
Element test = document.createElement(XMLConstants.TESTCASE);
- // The test name
+ /** The testcase name */
StringBuffer nb = new StringBuffer();
for(int i = 0; i < testId.getLength(); i ++)
{
@@ -153,22 +165,41 @@
nb.append(testId.getName(i));
}
String testName = nb.toString();
- // Test parameters
+ /** The testcase parameters */
StringBuffer parameters = new StringBuffer();
- for(Iterator<String> i = result.getParametrization().values().iterator(); i.hasNext(); )
+ for(Iterator<String> i = result.getParametrization().keySet().iterator(); i.hasNext(); )
{
String name = i.next();
String value = result.getParametrization().get(name);
- parameters.append(name + "=" + value + "?");
+ parameters.append( name + "=" + value );
+ if(i.hasNext())
+ {
+ parameters.append("&");
+ }
}
-
+ // append parameters
if ( parameters.length() > 0)
testName = testName + "?" + parameters.toString();
+ /** Test case attributes */
test.setAttribute(XMLConstants.ATTR_NAME, testName);
- // Testcase time
test.setAttribute(XMLConstants.ATTR_TIME, new Long(result.getDurationMillis()).toString());
- // If test failed
+ /** Check if test was started */
+ TestInfo info = this.startedTests.get(testId);
+ if ( info != null)
+ {
+ // remove test from started List
+ this.startedTests.remove(testId);
+ }
+ else
+ {
+ // If test is not started - add error message
+ Element errorNotStarted = document.createElement(XMLConstants.ERROR);
+ errorNotStarted.setAttribute(XMLConstants.ATTR_MESSAGE, "TestCase: " + testName + " was not started properly. (No StartTestEvent)");
+ test.appendChild(errorNotStarted);
+ }
+
+ /** If testcase failed */
if (result instanceof TestFailure)
{
TestFailure testFailure = (TestFailure) result;
@@ -194,6 +225,16 @@
public void endTestSuite(EndRunnerEvent event)
{
+ if( this.startedTests.size() > 0 )
+ {
+ for(TestId id : this.startedTests.keySet())
+ {
+ Element errorNotEnded = document.createElement(XMLConstants.ERROR);
+ errorNotEnded.setAttribute(XMLConstants.ATTR_MESSAGE, "Testcase: " + id + " was not ended properly. (No EndTestEvent)");
+ this.rootElement.appendChild(errorNotEnded);
+ }
+ }
+
// 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));
@@ -208,8 +249,6 @@
this.rootElement.appendChild(systemError);
this.rootElement.appendChild(systemOutElement);
-
- // System.out.println(exportXML());
}
public void appendSystemOutput(String output)
@@ -231,7 +270,7 @@
// If no test suite name is specified use default and add timestamp
filePath.append(toDir)
- .append("/")
+ .append(File.separator)
.append(TEST_FILE_NAME_START)
.append(getTestSuiteName())
.append(getTestSuiteName().equals(DEFAULT_TEST_SUITE_NAME) ? "-" + getTimestamp() : "" )
18 years, 7 months
JBoss Portal SVN: r8588 - in modules/test/trunk: tooling/src/main/org/jboss/unit/tooling/ant and 7 other directories.
by portal-commits@lists.jboss.org
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;
+ }
+}
18 years, 7 months