Author: julien(a)jboss.com
Date: 2007-10-22 15:51:57 -0400 (Mon, 22 Oct 2007)
New Revision: 8741
Added:
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/composite/AbstractCompositeTestDriver.java
Modified:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/CompositeRemoteTestDriver.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteTestDriverClient.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/AllTests.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/sample/SampleTests.java
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/composite/CompositeTestDriver.java
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/SimpleDriverContext.java
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/AbstractJUnitReport.java
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitTestsuiteReport.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/StartTestSuiteEvent.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/driver/TestDriverRunner.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/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/TestClassDef.java
modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/sample/f1.xml
Log:
better support for test driver properties reporting
Modified:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/CompositeRemoteTestDriver.java
===================================================================
---
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/CompositeRemoteTestDriver.java 2007-10-22
17:06:49 UTC (rev 8740)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/CompositeRemoteTestDriver.java 2007-10-22
19:51:57 UTC (rev 8741)
@@ -24,9 +24,15 @@
import org.jboss.unit.Failure;
import org.jboss.unit.TestId;
+import org.jboss.unit.info.TestInfo;
import org.jboss.unit.driver.TestDriver;
+import org.jboss.unit.driver.DriverContext;
+import org.jboss.unit.driver.DriverException;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.DriverCommand;
+import org.jboss.unit.driver.impl.composite.AbstractCompositeTestDriver;
+import org.jboss.unit.driver.impl.composite.CompositeTestDriver;
import org.jboss.unit.driver.response.FailureResponse;
-import org.jboss.unit.driver.impl.composite.CompositeTestDriver;
import org.jboss.unit.remote.RequestContext;
import org.jboss.unit.remote.ResponseContext;
@@ -37,24 +43,48 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class CompositeRemoteTestDriver extends CompositeTestDriver implements
RemoteTestDriver
+public class CompositeRemoteTestDriver implements RemoteTestDriver
{
- public CompositeRemoteTestDriver()
+ /** . */
+ private AbstractCompositeTestDriver delegate;
+
+ public CompositeRemoteTestDriver(String name)
{
+ this(new CompositeTestDriver(name));
}
- public CompositeRemoteTestDriver(String name)
+ public CompositeRemoteTestDriver(AbstractCompositeTestDriver delegate)
{
- super(name);
+ this.delegate = delegate;
}
+ public void initDriver(DriverContext context) throws DriverException
+ {
+ delegate.initDriver(context);
+ }
+
+ public void destroyDriver()
+ {
+ delegate.destroyDriver();
+ }
+
+ public TestInfo getInfo()
+ {
+ return delegate.getInfo();
+ }
+
+ public DriverResponse invoke(TestId id, DriverCommand command)
+ {
+ return delegate.invoke(id, command);
+ }
+
public void pushContext(TestId testId, RequestContext requestContext)
{
String name = testId.getName(0);
//
- TestDriver driver = drivers.get(name);
+ TestDriver driver = delegate.getDriver(name);
//
if (driver instanceof RemoteTestDriver)
@@ -71,7 +101,7 @@
String name = testId.getName(0);
//
- TestDriver driver = drivers.get(name);
+ TestDriver driver = delegate.getDriver(name);
//
if (driver instanceof RemoteTestDriver)
Modified:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteTestDriverClient.java
===================================================================
---
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteTestDriverClient.java 2007-10-22
17:06:49 UTC (rev 8740)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteTestDriverClient.java 2007-10-22
19:51:57 UTC (rev 8741)
@@ -199,6 +199,9 @@
TestDriver server = getServer(node);
//
+ server.initDriver(context);
+
+ //
info = SimpleTestInfo.create(server.getInfo());
}
@@ -206,6 +209,23 @@
{
try
{
+ // Always retrieve meta data from the default node
+ Node node = nodeManager.getNode(NodeId.DEFAULT);
+
+ //
+ TestDriver server = getServer(node);
+
+ //
+ server.destroyDriver();
+ }
+ catch (Exception ignore)
+ {
+ ignore.printStackTrace();
+ }
+
+ //
+ try
+ {
beanDeployer.undeploy(deployment);
}
catch (Throwable ignore)
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-22 17:06:49
UTC (rev 8740)
+++ modules/test/trunk/unit/src/main/org/jboss/test/unit/AllTests.java 2007-10-22 19:51:57
UTC (rev 8741)
@@ -46,30 +46,30 @@
public static void main(String[] args) throws Exception
{
- AssertTests.main(args);
- TestIdTests.main(args);
+// AssertTests.main(args);
+// TestIdTests.main(args);
+//
+// //
+// AbstractPOJOTests.main(args);
+// JUnitPOJOTests.main(args);
+// CompositeTestRunnerTests.main(args);
+// TestDriverRunnerTests.main(args);
+// GenericTestRunnerTests.main(args);
+// POJOTestRunnerTests.main(args);
+//
+// //
+// TestRunnerLifeCycleFilterTests.main(args);
+// TestRunnerEventBroadcasterSupportTests.main(args);
+// ModelTests.main(args);
+// ParametrizationTests.main(args);
+//
+// //
+// InfoTests.main(args);
//
- AbstractPOJOTests.main(args);
- JUnitPOJOTests.main(args);
- CompositeTestRunnerTests.main(args);
- TestDriverRunnerTests.main(args);
- GenericTestRunnerTests.main(args);
- POJOTestRunnerTests.main(args);
-
- //
- TestRunnerLifeCycleFilterTests.main(args);
- TestRunnerEventBroadcasterSupportTests.main(args);
- ModelTests.main(args);
- ParametrizationTests.main(args);
-
- //
- InfoTests.main(args);
-
- //
SampleTests.main(args);
//
- JUnitReporterTests.main(args);
+// JUnitReporterTests.main(args);
}
}
Modified: modules/test/trunk/unit/src/main/org/jboss/test/unit/sample/SampleTests.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/test/unit/sample/SampleTests.java 2007-10-22
17:06:49 UTC (rev 8740)
+++
modules/test/trunk/unit/src/main/org/jboss/test/unit/sample/SampleTests.java 2007-10-22
19:51:57 UTC (rev 8741)
@@ -50,7 +50,7 @@
public static void main(String[] args) throws Exception
{
- test1();
+// test1();
test2();
}
Added:
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/composite/AbstractCompositeTestDriver.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/composite/AbstractCompositeTestDriver.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/composite/AbstractCompositeTestDriver.java 2007-10-22
19:51:57 UTC (rev 8741)
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * 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.driver.impl.composite;
+
+import org.jboss.unit.Failure;
+import org.jboss.unit.TestId;
+import org.jboss.unit.driver.AbstractTestDriver;
+import org.jboss.unit.driver.DriverCommand;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.TestDriver;
+import org.jboss.unit.driver.response.FailureResponse;
+import org.jboss.unit.info.TestInfo;
+import org.jboss.unit.info.impl.SimpleTestSuiteInfo;
+import org.jboss.unit.info.impl.SimpleTestInfo;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractCompositeTestDriver extends AbstractTestDriver
+{
+
+ public TestInfo getInfo()
+ {
+ SimpleTestSuiteInfo info = new SimpleTestSuiteInfo(getName());
+
+ //
+ for (String name : getNames())
+ {
+ TestDriver driver = getDriver(name);
+ info.addTest(SimpleTestInfo.create(driver.getInfo()));
+ }
+
+ return info;
+ }
+
+ public DriverResponse invoke(TestId id, DriverCommand command)
+ {
+ if (id.getLength() == 0)
+ {
+ return new FailureResponse(Failure.createErrorFailure("No null test id
accepted"));
+ }
+
+ //
+ String name = id.getName(0);
+
+ //
+ TestDriver driver = getDriver(name);
+
+ //
+ if (driver == null)
+ {
+ return new FailureResponse(Failure.createErrorFailure("No test driver found
for name " + name));
+ }
+
+ //
+ TestId driverId = id.range(1);
+
+ //
+ return driver.invoke(driverId, command);
+ }
+
+ public abstract String getName();
+
+ public abstract TestDriver getDriver(String name);
+
+ public abstract Set<String> getNames();
+
+}
\ No newline at end of file
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/composite/CompositeTestDriver.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/composite/CompositeTestDriver.java 2007-10-22
17:06:49 UTC (rev 8740)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/composite/CompositeTestDriver.java 2007-10-22
19:51:57 UTC (rev 8741)
@@ -23,33 +23,25 @@
package org.jboss.unit.driver.impl.composite;
import org.jboss.unit.driver.TestDriver;
-import org.jboss.unit.driver.DriverResponse;
-import org.jboss.unit.driver.DriverCommand;
-import org.jboss.unit.driver.AbstractTestDriver;
import org.jboss.unit.driver.DriverException;
-import org.jboss.unit.driver.response.FailureResponse;
-import org.jboss.unit.info.impl.SimpleTestSuiteInfo;
-import org.jboss.unit.info.TestInfo;
-import org.jboss.unit.TestId;
-import org.jboss.unit.Failure;
import java.util.Map;
import java.util.HashMap;
+import java.util.Set;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class CompositeTestDriver extends AbstractTestDriver
+public class CompositeTestDriver extends AbstractCompositeTestDriver
{
/** . */
- private final SimpleTestSuiteInfo info;
+ private final String name;
/** . */
protected final Map<String, TestDriver> drivers = new HashMap<String,
TestDriver>();
-
public CompositeTestDriver()
{
this("Main");
@@ -57,43 +49,22 @@
public CompositeTestDriver(String name)
{
- info = new SimpleTestSuiteInfo(name);
+ this.name = name;
}
- public TestInfo getInfo()
+ public String getName()
{
- return info;
+ return name;
}
- public DriverResponse invoke(TestId id, DriverCommand command)
+ public TestDriver getDriver(String name)
{
- if (id.getLength() == 0)
- {
- return new FailureResponse(Failure.createErrorFailure("No null test id
accepted"));
- }
-
- //
- String name = id.getName(0);
-
- //
- TestDriver driver = drivers.get(name);
-
- //
- if (driver == null)
- {
- return new FailureResponse(Failure.createErrorFailure("No test driver found
for name " + name));
- }
-
- //
- TestId driverId = id.range(1);
-
- //
- return driver.invoke(driverId, command);
+ return drivers.get(name);
}
- public TestDriver get(String name)
+ public Set<String> getNames()
{
- return drivers.get(name);
+ return drivers.keySet();
}
public void mount(TestDriver driver) throws DriverException
@@ -103,9 +74,6 @@
driver.initDriver(getContext());
//
- info.addTest(driver.getInfo());
-
- //
String name = driver.getInfo().getName();
//
@@ -123,9 +91,6 @@
drivers.remove(name);
//
- info.removeTest(name);
-
- //
driver.destroyDriver();
}
}
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/SimpleDriverContext.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/SimpleDriverContext.java 2007-10-22
17:06:49 UTC (rev 8740)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/SimpleDriverContext.java 2007-10-22
19:51:57 UTC (rev 8741)
@@ -24,16 +24,17 @@
import org.jboss.unit.driver.DriverContext;
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.Map;
-import java.util.HashMap;
import java.util.Set;
-import java.util.Collections;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class SimpleDriverContext implements DriverContext
+public class SimpleDriverContext implements DriverContext, Serializable
{
/** . */
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/AbstractJUnitReport.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/AbstractJUnitReport.java 2007-10-22
17:06:49 UTC (rev 8740)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/AbstractJUnitReport.java 2007-10-22
19:51:57 UTC (rev 8741)
@@ -101,7 +101,7 @@
private void handle(StartRunnerEvent event)
{
- current = new TestSuite(null, "");
+ current = new TestSuite(null, "", new HashMap<String, String>());
//
startTestSuite(current);
@@ -124,7 +124,7 @@
private void handle(StartTestSuiteEvent event)
{
- current = new TestSuite(current, event.getTestInfo().getName());
+ current = new TestSuite(current, event.getTestInfo().getName(),
event.getProperties());
//
startTestSuite(current);
@@ -162,30 +162,12 @@
// remove test from started List
current.startedTests.remove(testId);
- /** Adding testcase name */
- StringBuffer testName = new StringBuffer(info.getName());
- Iterator<String> i = result.getParametrization().keySet().iterator();
- if (i.hasNext())
- {
- testName.append("?");
- while (i.hasNext())
- {
- String parameterName = i.next();
- String value = result.getParametrization().get(parameterName);
- testName.append(parameterName).append("=").append(value);
- if(i.hasNext())
- {
- testName.append("&");
- }
- }
- }
-
//
current.durationMillis += result.getDurationMillis();
current.tests++;
//
- endTestCase(current, testName.toString(), result);
+ endTestCase(current, info.getName(), result);
}
public class TestSuite
@@ -198,6 +180,9 @@
final String name;
/** . */
+ Map<String, String> properties;
+
+ /** . */
long durationMillis;
/** The test count */
@@ -212,9 +197,6 @@
/** The started Tests */
Map<TestId, TestInfo> startedTests = new HashMap<TestId, TestInfo>();
-// /** . */
-// List<Element> children = new ArrayList<Element>();
-
/** The view of the system output. */
SystemOutputView view = SystemOutputManager.getInstance().createView(false);
@@ -223,10 +205,11 @@
*
* @param name
*/
- TestSuite(TestSuite parent, String name)
+ TestSuite(TestSuite parent, String name, Map<String, String> properties)
{
this.parent = parent;
this.name = name;
+ this.properties = properties;
}
public StringBuffer getFQN()
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitTestsuiteReport.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitTestsuiteReport.java 2007-10-22
17:06:49 UTC (rev 8740)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/report/impl/junit/JUnitTestsuiteReport.java 2007-10-22
19:51:57 UTC (rev 8741)
@@ -57,6 +57,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -105,6 +106,9 @@
testsuitesDocument.appendChild(testsuitesElement);
//
+ int counter = 0;
+
+ //
for (Map.Entry<TestSuiteKey, TestSuiteReport> entry : reportMap.entrySet())
{
TestSuiteReport report = entry.getValue();
@@ -126,7 +130,7 @@
//
testSuiteElt.setAttribute(XMLConstants.HOSTNAME, getHostName());
testSuiteElt.setAttribute(XMLConstants.ATTR_PACKAGE,
entry.getKey().packageName);
- testSuiteElt.setAttribute(XMLConstants.ATTR_NAME, entry.getKey().className);
+ testSuiteElt.setAttribute(XMLConstants.ATTR_NAME, appendURI(new
StringBuffer(), entry.getKey().className, entry.getKey().properties).toString());
testSuiteElt.setAttribute(XMLConstants.ATTR_TESTS,
Integer.toString(report.tests));
testSuiteElt.setAttribute(XMLConstants.ATTR_ERRORS,
Integer.toString(report.errors));
testSuiteElt.setAttribute(XMLConstants.ATTR_FAILURES,
Integer.toString(report.failures));
@@ -141,26 +145,34 @@
//
if (xmlReportDir != null)
{
- Document tmp = createDocument();
- Element copy = (Element)tmp.importNode(testSuiteElt, true);
- tmp.appendChild(copy);
- String a = copy.getAttribute("package");
- String b = copy.getAttribute("name");
- String c = a.length() == 0 ? b : a + "." + b;
- copy.setAttribute("name", c);
- copy.removeAttribute("package");
- try
+ if (xmlReportDir.exists())
{
- File f = new File(xmlReportDir, TEST_FILE_NAME_PREFIX + c +
".xml");
- if (!f.exists())
+ Document tmp = createDocument();
+ Element copy = (Element)tmp.importNode(testSuiteElt, true);
+ tmp.appendChild(copy);
+ String a = copy.getAttribute("package");
+ String b = copy.getAttribute("name");
+ String c = a.length() == 0 ? b : a + "." + b;
+ copy.setAttribute("name", c);
+ copy.removeAttribute("package");
+ File f = new File(xmlReportDir, TEST_FILE_NAME_PREFIX + (counter++) +
".xml");
+ try
{
- f.createNewFile();
+ if (!f.exists())
+ {
+ f.createNewFile();
+ }
+ serializeNode(tmp, f);
}
- serializeNode(tmp, f);
+ catch (IOException e)
+ {
+ System.out.println("Could not create file " +
f.getAbsolutePath());
+ e.printStackTrace();
+ }
}
- catch (IOException e)
+ else
{
- e.printStackTrace();
+ System.out.println("Cannot create report because parent dir "
+ xmlReportDir.getAbsolutePath() + " does not exist");
}
}
@@ -172,26 +184,33 @@
//
if (htmlReportDir != null)
{
- try
+ if (htmlReportDir.exists())
{
- InputStream xslIn =
getClass().getResourceAsStream("/org/jboss/unit/report/impl/junit/junit-frames.xsl");
- Source xmlSource = new DOMSource(testsuitesElement);
- Source xslSource = new StreamSource(xslIn);
- TransformerFactory transFact = TransformerFactory.newInstance();
- Transformer trans = transFact.newTransformer(xslSource);
- OutputStream os = new ByteArrayOutputStream();
- Result result = new StreamResult(os);
- trans.setParameter("output.dir", htmlReportDir.getAbsolutePath());
- trans.transform(xmlSource, result);
+ try
+ {
+ InputStream xslIn =
getClass().getResourceAsStream("/org/jboss/unit/report/impl/junit/junit-frames.xsl");
+ Source xmlSource = new DOMSource(testsuitesElement);
+ Source xslSource = new StreamSource(xslIn);
+ TransformerFactory transFact = TransformerFactory.newInstance();
+ Transformer trans = transFact.newTransformer(xslSource);
+ OutputStream os = new ByteArrayOutputStream();
+ Result result = new StreamResult(os);
+ trans.setParameter("output.dir",
htmlReportDir.getAbsolutePath());
+ trans.transform(xmlSource, result);
+ }
+ catch (TransformerException e)
+ {
+ e.printStackTrace();
+ }
+
+ //
+ File tmp = new File(htmlReportDir, "TESTS-TestSuites.xml");
+ serializeNode(testsuitesElement, tmp);
}
- catch (TransformerException e)
+ else
{
- e.printStackTrace();
+ System.out.println("Cannot create report because parent dir " +
htmlReportDir.getAbsolutePath() + " does not exist");
}
-
- //
- File tmp = new File(htmlReportDir, "TESTS-TestSuites.xml");
- serializeNode(testsuitesElement, tmp);
}
}
@@ -272,11 +291,32 @@
}
}
+ public static StringBuffer appendURI(StringBuffer buffer, String name, Map<String,
String> parameters)
+ {
+ buffer.append(name);
+ Iterator<String> i = parameters.keySet().iterator();
+ if (i.hasNext())
+ {
+ buffer.append("?");
+ while (i.hasNext())
+ {
+ String parameterName = i.next();
+ String value = parameters.get(parameterName);
+ buffer.append(parameterName).append("=").append(value);
+ if(i.hasNext())
+ {
+ buffer.append("&");
+ }
+ }
+ }
+ return buffer;
+ }
+
protected void endTestCase(TestSuite testSuite, String testName, TestResult result)
{
Element test = testsuitesDocument.createElement(XMLConstants.TESTCASE);
test.setAttribute(XMLConstants.ATTR_CLASSNAME, testSuite.getFQN().toString());
- test.setAttribute(XMLConstants.ATTR_NAME, testName);
+ test.setAttribute(XMLConstants.ATTR_NAME, appendURI(new StringBuffer(), testName,
result.getParametrization()).toString());
test.setAttribute(XMLConstants.ATTR_TIME,
DURATION_FORMAT.format(result.getDurationMillis() / 1000.0));
/** If testcase failed */
@@ -390,28 +430,18 @@
/** . */
private final String className;
+ /** . */
+ private final Map<String, String> properties;
+
private TestSuiteKey(TestSuite testSuite)
{
StringBuffer fqn = testSuite.getFQN();
int pos = fqn.lastIndexOf(".");
packageName = (pos == -1) ? "" : fqn.substring(0, pos);
className = (pos == -1) ? fqn.toString() : fqn.substring(pos + 1);
+ properties = testSuite.properties;
}
- private TestSuiteKey(String packageName, String className)
- {
- if (packageName == null)
- {
- throw new IllegalArgumentException();
- }
- if (className == null)
- {
- throw new IllegalArgumentException();
- }
- this.packageName = packageName;
- this.className = className;
- }
-
public boolean equals(Object o)
{
if (o == this)
@@ -421,7 +451,7 @@
if (o instanceof TestSuiteKey)
{
TestSuiteKey that = (TestSuiteKey)o;
- return that.packageName.equals(packageName) &&
that.className.equals(className);
+ return that.packageName.equals(packageName) &&
that.className.equals(className) && that.properties.equals(properties);
}
return false;
}
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/StartTestSuiteEvent.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/StartTestSuiteEvent.java 2007-10-22
17:06:49 UTC (rev 8740)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/event/StartTestSuiteEvent.java 2007-10-22
19:51:57 UTC (rev 8741)
@@ -22,10 +22,12 @@
******************************************************************************/
package org.jboss.unit.runner.event;
-import org.jboss.unit.runner.TestRunnerEvent;
import org.jboss.unit.TestId;
import org.jboss.unit.info.TestSuiteInfo;
+import org.jboss.unit.runner.TestRunnerEvent;
+import java.util.Map;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -39,10 +41,14 @@
/** . */
private final TestSuiteInfo testInfo;
- public StartTestSuiteEvent(TestId testId, TestSuiteInfo testInfo)
+ /** . */
+ private final Map<String, String> properties;
+
+ public StartTestSuiteEvent(TestId testId, TestSuiteInfo testInfo, Map<String,
String> properties)
{
this.testId = testId;
this.testInfo = testInfo;
+ this.properties = properties;
}
public TestId getTestId()
@@ -54,4 +60,9 @@
{
return testInfo;
}
+
+ public Map<String, String> getProperties()
+ {
+ return properties;
+ }
}
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/driver/TestDriverRunner.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/driver/TestDriverRunner.java 2007-10-22
17:06:49 UTC (rev 8740)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/driver/TestDriverRunner.java 2007-10-22
19:51:57 UTC (rev 8741)
@@ -143,7 +143,7 @@
TestSuiteInfo testSuiteInfo = (TestSuiteInfo)currentInfo;
//
- context.getEventListener().onEvent(new StartTestSuiteEvent(currentId,
testSuiteInfo));
+ context.getEventListener().onEvent(new StartTestSuiteEvent(currentId,
testSuiteInfo, context.getProperties()));
//
for (String name : testSuiteInfo.getNames())
@@ -228,7 +228,7 @@
TestId nextId = new TestId(currentId, name);
//
- context.getEventListener().onEvent(new StartTestSuiteEvent(currentId,
currentSuiteInfo));
+ context.getEventListener().onEvent(new StartTestSuiteEvent(currentId,
currentSuiteInfo, context.getProperties()));
//
internalRun(context, nextInfo, targetId, nextId);
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-22
17:06:49 UTC (rev 8740)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/pojo/POJOTestRunner.java 2007-10-22
19:51:57 UTC (rev 8741)
@@ -93,7 +93,7 @@
parametrizations.combine(context.getParametrizations());
// Compute properties
- Map<String, String> properties = new HashMap<String,
String>(def.getProperties());
+ Map<String, String> properties = new HashMap<String,
String>(testClass.getProperties());
properties.putAll(context.getProperties());
//
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-22
17:06:49 UTC (rev 8740)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/ModelBuilder.java 2007-10-22
19:51:57 UTC (rev 8741)
@@ -228,7 +228,9 @@
String classname = nameAttr.getValue();
TestClassDef testClass = new TestClassDef(classname);
+ //
testClass.setParameters(buildParameters(testElt));
+ testClass.setProperties(buildProperties(testElt));
//
for (Element caseElt : children(classElt, "case"))
@@ -250,9 +252,6 @@
}
//
- suite.setProperties(buildProperties(suiteElt));
-
- //
suite.setParameters(buildParameters(suiteElt));
//
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-22
17:06:49 UTC (rev 8740)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/TestSuiteDef.java 2007-10-22
19:51:57 UTC (rev 8741)
@@ -40,9 +40,6 @@
/** . */
protected ParametersDef parameters = new ParametersDef();
- /** . */
- protected Map<String, String> properties = new HashMap<String, String>();
-
public ParametersDef getParameters()
{
return parameters;
@@ -53,32 +50,6 @@
this.parameters = parameters;
}
- public Map<String, String> getProperties()
- {
- return properties;
- }
-
- public void setProperties(Map<String, String> properties)
- {
- this.properties = properties;
- }
-
- public void setProperty(String name, String value)
- {
- if (name == null)
- {
- throw new IllegalArgumentException();
- }
- if (value == null)
- {
- properties.remove(name);
- }
- else
- {
- properties.put(name, value);
- }
- }
-
public abstract TestRunner createRunner() throws BuilderException;
}
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-22
17:06:49 UTC (rev 8740)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/generic/GenericTestSuiteDef.java 2007-10-22
19:51:57 UTC (rev 8741)
@@ -29,6 +29,8 @@
import java.util.List;
import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -43,6 +45,9 @@
/** . */
private final String className;
+ /** . */
+ private Map<String, String> properties = new HashMap<String, String>();
+
public GenericTestSuiteDef(String className)
{
this.className = className;
@@ -71,4 +76,30 @@
{
return tests;
}
+
+ public Map<String, String> getProperties()
+ {
+ return properties;
+ }
+
+ public void setProperties(Map<String, String> properties)
+ {
+ this.properties = properties;
+ }
+
+ public void setProperty(String name, String value)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (value == null)
+ {
+ properties.remove(name);
+ }
+ else
+ {
+ properties.put(name, value);
+ }
+ }
}
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-22
17:06:49 UTC (rev 8740)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/model/pojo/TestClassDef.java 2007-10-22
19:51:57 UTC (rev 8741)
@@ -44,6 +44,9 @@
/** . */
private ParametersDef parameters = new ParametersDef();
+ /** . */
+ private Map<String, String> properties = new HashMap<String, String>();
+
public TestClassDef(String name)
{
if (name == null)
@@ -92,4 +95,30 @@
{
this.parameters = parameters;
}
+
+ public Map<String, String> getProperties()
+ {
+ return properties;
+ }
+
+ public void setProperties(Map<String, String> properties)
+ {
+ this.properties = properties;
+ }
+
+ public void setProperty(String name, String value)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (value == null)
+ {
+ properties.remove(name);
+ }
+ else
+ {
+ properties.put(name, value);
+ }
+ }
}
Modified: modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/sample/f1.xml
===================================================================
---
modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/sample/f1.xml 2007-10-22
17:06:49 UTC (rev 8740)
+++
modules/test/trunk/unit/src/resources/test/org/jboss/test/unit/sample/f1.xml 2007-10-22
19:51:57 UTC (rev 8741)
@@ -11,6 +11,7 @@
<class name="org.jboss.test.unit.sample.TestedClass1">
<case name="testFoo"/>
</class>
+ <property name="a" value="b"/>
</test>
<test>
<class name="org.jboss.test.unit.sample.TestedClass2">
@@ -28,6 +29,11 @@
<class name="org.jboss.test.unit.sample.TestDriver1"/>
</generic>
<generic>
+ <class name="org.jboss.test.unit.sample.TestDriver1"/>
+ <property name="c" value="d"/>
+ <property name="e" value="f"/>
+ </generic>
+ <generic>
<class name="org.jboss.test.unit.sample.TestDriver2"/>
</generic>
</jboss-unit>