Author: julien(a)jboss.com
Date: 2007-10-12 09:04:19 -0400 (Fri, 12 Oct 2007)
New Revision: 8613
Added:
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/PropertyType.java
modules/test/trunk/unit/src/main/org/jboss/unit/driver/AbstractTestDriver.java
modules/test/trunk/unit/src/main/org/jboss/unit/driver/DriverContext.java
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/SimpleDriverContext.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/NullTestRunnerContext.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunnerContext.java
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/MainTestRunnerContext.java
Modified:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/ResponseContext.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteTestDriverClient.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteTestDriverServer.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/deployer/DeployerHandler.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/deployer/response/DeployerResponse.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/HTTPConversation.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/command/HTTPDriverCommand.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/response/HTTPDriverResponse.java
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/TestsType.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/CompositeTestRunnerTests.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/GenericTestRunnerTests.java
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/TestDriverRunnerTests.java
modules/test/trunk/unit/src/main/org/jboss/unit/driver/DriverResponse.java
modules/test/trunk/unit/src/main/org/jboss/unit/driver/TestDriver.java
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOTestSuiteDriver.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/AbstractTestRunner.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunner.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/composite/CompositeTestRunner.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/event/EventDrivenTestRunner.java
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/failure/FailureTestRunner.java
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/pojo/POJOTestRunner.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:
start to add property support + introduced TestRunnerContext + introduced TestDriver life
cycle and contextualization
Modified: modules/test/trunk/remote/src/main/org/jboss/unit/remote/ResponseContext.java
===================================================================
---
modules/test/trunk/remote/src/main/org/jboss/unit/remote/ResponseContext.java 2007-10-12
10:24:41 UTC (rev 8612)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/ResponseContext.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -31,7 +31,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class ResponseContext
+public class ResponseContext implements Serializable
{
/** The test response. */
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-12
10:24:41 UTC (rev 8612)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteTestDriverClient.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -25,12 +25,12 @@
import org.jboss.unit.driver.TestDriver;
import org.jboss.unit.driver.DriverCommand;
import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.DriverContext;
import org.jboss.unit.driver.response.FailureResponse;
import org.jboss.unit.driver.command.StartTestCommand;
import org.jboss.unit.info.TestInfo;
import org.jboss.unit.info.TestSuiteInfo;
import org.jboss.unit.info.impl.SimpleTestSuiteInfo;
-import org.jboss.unit.info.impl.SimpleParameterInfo;
import org.jboss.unit.TestId;
import org.jboss.unit.Failure;
import org.jboss.portal.test.framework.server.NodeId;
@@ -45,8 +45,6 @@
import org.jboss.beans.metadata.plugins.annotations.Inject;
import java.net.URL;
-import java.util.Map;
-import java.util.HashMap;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -63,6 +61,9 @@
// Services
/** . */
+ private DriverContext context;
+
+ /** . */
private NodeManager nodeManager;
/** . */
@@ -86,11 +87,6 @@
return archivePath;
}
- public void setArchivePath(String archivePath)
- {
- this.archivePath = archivePath;
- }
-
public NodeManager getNodeManager()
{
return nodeManager;
@@ -118,62 +114,71 @@
return (RemoteTestDriver)node.lookupService(RemoteTestDriver.SERVICE_ID);
}
- private boolean started = false;
private FailureResponse failed;
private KernelDeployment deployment;
private BeanXMLDeployer beanDeployer;
- private void start()
+ public void initDriver(DriverContext context)
{
- if (!started && failed == null)
- {
+ this.context = context;
- //
- run();
+ // Get this property
+ this.archivePath = context.getProperty("archivePath");
- // Install our self first
- try
- {
- AbstractBeanMetaData bmd = new AbstractBeanMetaData("TestDriver",
getClass().getName());
- AbstractConstructorMetaData cmd = new AbstractConstructorMetaData();
- bmd.setConstructor(cmd);
- TestCaseFactory factory = new TestCaseFactory(this);
- AbstractValueMetaData vmd = new AbstractValueMetaData(factory);
- cmd.setFactory(vmd);
- cmd.setFactoryMethod("getTestCase");
- getKernel().getController().install(bmd);
- }
- catch (Throwable throwable)
- {
- throwable.printStackTrace();
- failed = new FailureResponse(Failure.createErrorFailure("Could not
startup kernel", throwable));
- return;
- }
+ //
+ run();
- // Now deploy beans
- try
- {
- URL url =
getClass().getResource("/org/jboss/unit/remote/driver/jboss-beans.xml");
- beanDeployer = new BeanXMLDeployer(getKernel());
- deployment = beanDeployer.deploy(url);
- beanDeployer.validate();
- }
- catch (Throwable throwable)
- {
- throwable.printStackTrace();
- failed = new FailureResponse(Failure.createErrorFailure("Could not
deploy beans", throwable));
- return;
- }
+ // Install our self first
+ try
+ {
+ AbstractBeanMetaData bmd = new AbstractBeanMetaData("TestDriver",
getClass().getName());
+ AbstractConstructorMetaData cmd = new AbstractConstructorMetaData();
+ bmd.setConstructor(cmd);
+ TestCaseFactory factory = new TestCaseFactory(this);
+ AbstractValueMetaData vmd = new AbstractValueMetaData(factory);
+ cmd.setFactory(vmd);
+ cmd.setFactoryMethod("getTestCase");
+ getKernel().getController().install(bmd);
+ }
+ catch (Throwable throwable)
+ {
+ throwable.printStackTrace();
+ failed = new FailureResponse(Failure.createErrorFailure("Could not startup
kernel", throwable));
+ return;
+ }
- //
- started = true;
+ // Now deploy beans
+ try
+ {
+ URL url =
getClass().getResource("/org/jboss/unit/remote/driver/jboss-beans.xml");
+ beanDeployer = new BeanXMLDeployer(getKernel());
+ deployment = beanDeployer.deploy(url);
+ beanDeployer.validate();
}
+ catch (Throwable throwable)
+ {
+ throwable.printStackTrace();
+ failed = new FailureResponse(Failure.createErrorFailure("Could not deploy
beans", throwable));
+ }
}
- public TestInfo getInfo()
+ public void destroyDriver()
{
- start();
+ try
+ {
+ beanDeployer.undeploy(deployment);
+ }
+ catch (Throwable ignore)
+ {
+ ignore.printStackTrace();
+ }
+ //
+ this.context = null;
+ }
+
+ public TestInfo getInfo()
+ {
// Always retrieve meta data from the default node
Node node = nodeManager.getNode(NodeId.DEFAULT);
@@ -181,33 +186,13 @@
TestDriver server = getServer(node);
//
- SimpleTestSuiteInfo testInfo = new
SimpleTestSuiteInfo((TestSuiteInfo)server.getInfo());
-
- System.out.println("testInfo = " + testInfo);
-
- //
- Map<String, SimpleParameterInfo> parameters = new HashMap<String,
SimpleParameterInfo>(testInfo.getParameters());
-
- //
- parameters.put("archivePath", new
SimpleParameterInfo("archivePath"));
-
- //
- testInfo.setParameters(parameters);
-
- //
- return testInfo;
+ return new SimpleTestSuiteInfo((TestSuiteInfo)server.getInfo());
}
public DriverResponse invoke(TestId testId, DriverCommand command)
{
- start();
-
- //
if (command instanceof StartTestCommand)
{
- StartTestCommand start = (StartTestCommand)command;
- archivePath = start.getParametrization().get("archivePath");
-
try
{
Node node = nodeManager.getNode(NodeId.DEFAULT);
@@ -222,17 +207,6 @@
{
return new FailureResponse(Failure.createErrorFailure(e));
}
- finally
- {
- try
- {
- beanDeployer.undeploy(deployment);
- }
- catch (Throwable ignore)
- {
- ignore.printStackTrace();
- }
- }
}
else
{
Modified:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteTestDriverServer.java
===================================================================
---
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteTestDriverServer.java 2007-10-12
10:24:41 UTC (rev 8612)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteTestDriverServer.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -27,6 +27,7 @@
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.DriverCommand;
import org.jboss.unit.driver.TestDriver;
+import org.jboss.unit.driver.AbstractTestDriver;
import org.jboss.unit.driver.response.FailureResponse;
import org.jboss.unit.info.TestInfo;
import org.jboss.unit.info.impl.SimpleTestSuiteInfo;
@@ -40,7 +41,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 5636 $
*/
-public class RemoteTestDriverServer implements RemoteTestDriver
+public class RemoteTestDriverServer extends AbstractTestDriver implements
RemoteTestDriver
{
/** . */
Modified:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/deployer/DeployerHandler.java
===================================================================
---
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/deployer/DeployerHandler.java 2007-10-12
10:24:41 UTC (rev 8612)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/deployer/DeployerHandler.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -119,11 +119,24 @@
return new RemoteDriverCommandContext(responseContext.getCommandContext());
}
+ //
+ if (nextHandler != null)
+ {
+ return nextHandler.handleResponse(testConversation, responseContext);
+ }
+
+ //
return null;
}
public RemoteDriverResponseContext handleCommand(TestConversation conversation,
RemoteDriverCommandContext commandContext) throws Exception
{
- return nextHandler.handleCommand(conversation, commandContext);
+ if (nextHandler != null)
+ {
+ return nextHandler.handleCommand(conversation, commandContext);
+ }
+
+ //
+ return null;
}
}
Modified:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/deployer/response/DeployerResponse.java
===================================================================
---
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/deployer/response/DeployerResponse.java 2007-10-12
10:24:41 UTC (rev 8612)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/deployer/response/DeployerResponse.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -24,12 +24,10 @@
import org.jboss.unit.driver.DriverResponse;
-import java.io.Serializable;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class DeployerResponse extends DriverResponse implements Serializable
+public class DeployerResponse extends DriverResponse
{
}
Modified:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/HTTPConversation.java
===================================================================
---
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/HTTPConversation.java 2007-10-12
10:24:41 UTC (rev 8612)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/HTTPConversation.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -189,8 +189,16 @@
private RemoteDriverResponseContext decodeHTTPResponse(RemoteDriverCommandContext
commandContext, HttpMethod httpMethod) throws Exception
{
+ DriverResponse response = null;
+
+ //
ResponseContext ctx = conversation.popContext();
- DriverResponse response = ctx.getResponse();
+ if (ctx != null)
+ {
+ response = ctx.getResponse();
+ }
+
+ //
int status = httpMethod.getStatusCode();
switch (status)
{
Modified:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/command/HTTPDriverCommand.java
===================================================================
---
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/command/HTTPDriverCommand.java 2007-10-12
10:24:41 UTC (rev 8612)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/command/HTTPDriverCommand.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -24,12 +24,10 @@
import org.jboss.unit.driver.DriverCommand;
-import java.io.Serializable;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class HTTPDriverCommand extends DriverCommand implements Serializable
+public class HTTPDriverCommand extends DriverCommand
{
}
Modified:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/response/HTTPDriverResponse.java
===================================================================
---
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/response/HTTPDriverResponse.java 2007-10-12
10:24:41 UTC (rev 8612)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/response/HTTPDriverResponse.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -24,12 +24,10 @@
import org.jboss.unit.driver.DriverResponse;
-import java.io.Serializable;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public abstract class HTTPDriverResponse extends DriverResponse implements Serializable
+public abstract class HTTPDriverResponse extends DriverResponse
{
}
Added: modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/PropertyType.java
===================================================================
--- modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/PropertyType.java
(rev 0)
+++
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/PropertyType.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * A property.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PropertyType
+{
+
+ /** . */
+ private String name;
+
+ /** . */
+ private String value;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+}
Modified: modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/TestsType.java
===================================================================
---
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/TestsType.java 2007-10-12
10:24:41 UTC (rev 8612)
+++
modules/test/trunk/tooling/src/main/org/jboss/unit/tooling/ant/TestsType.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -35,6 +35,7 @@
import java.util.List;
import java.util.LinkedList;
import java.util.Set;
+import java.util.ArrayList;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
@@ -46,9 +47,9 @@
private boolean fork = true;
- private List<IncludeType> includes = new LinkedList();
+ private List<IncludeType> includes = new LinkedList<IncludeType>();
- private List<ExcludeType> excludes = new LinkedList();
+ private List<ExcludeType> excludes = new LinkedList<ExcludeType>();
private ReportsType reports;
@@ -60,7 +61,9 @@
private boolean jpda;
+ private List<PropertyType> properties = new ArrayList<PropertyType>();
+
public TestsType()
{
}
@@ -256,6 +259,11 @@
{
javaTask.createArg().setValue(generateArgument(excludeFilter.getKeywords(),
Main.OPT_EX_KEYWORDS));
}
+
+ for (PropertyType property : properties)
+ {
+ javaTask.createArg().setValue(Main.OPT_PROPERTY + "=" +
property.getName() + "=" + property.getValue());
+ }
}
private String generateArgument(Set<String> values, String argumentName)
@@ -289,6 +297,11 @@
this.reports = reports;
}
+ public void addConfiguredProperty(PropertyType property)
+ {
+ this.properties.add(property);
+ }
+
public void addTask(Task task)
{
//To change body of implemented methods use File | Settings | File Templates.
Modified:
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/CompositeTestRunnerTests.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/CompositeTestRunnerTests.java 2007-10-12
10:24:41 UTC (rev 8612)
+++
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/CompositeTestRunnerTests.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -27,6 +27,7 @@
import org.jboss.unit.runner.TestFilter;
import org.jboss.unit.runner.TestRunnerEvent;
import org.jboss.unit.runner.TestRunnerEventListener;
+import org.jboss.unit.runner.TestRunnerContext;
import org.jboss.unit.runner.impl.composite.CompositeTestRunner;
import static org.jboss.unit.api.Assert.*;
@@ -181,7 +182,7 @@
boolean invoked;
- protected void internalRun(TestFilter filter)
+ protected void internalRun(TestRunnerContext context)
{
invoked = true;
fireEvent(event);
@@ -194,7 +195,7 @@
/** . */
final RuntimeException exception = new RuntimeException();
- protected void internalRun(TestFilter filter)
+ protected void internalRun(TestRunnerContext context)
{
throw exception;
}
@@ -206,7 +207,7 @@
/** . */
final Error error = new Error();
- protected void internalRun(TestFilter filter)
+ protected void internalRun(TestRunnerContext context)
{
throw error;
}
Modified:
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/GenericTestRunnerTests.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/GenericTestRunnerTests.java 2007-10-12
10:24:41 UTC (rev 8612)
+++
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/GenericTestRunnerTests.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -28,6 +28,7 @@
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.command.StartTestCommand;
import org.jboss.unit.driver.response.EndTestResponse;
import org.jboss.unit.info.TestInfo;
@@ -105,7 +106,7 @@
assertEquals(list(new HashMap(), new HashMap()), Driver1.parametrizations);
}
- public static class Driver1 implements TestDriver
+ public static class Driver1 extends AbstractTestDriver
{
static SimpleTestSuiteInfo testSuiteInfo;
Modified:
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/TestDriverRunnerTests.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/TestDriverRunnerTests.java 2007-10-12
10:24:41 UTC (rev 8612)
+++
modules/test/trunk/unit/src/main/org/jboss/test/unit/runner/TestDriverRunnerTests.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -36,6 +36,7 @@
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.command.StartTestCommand;
import org.jboss.unit.driver.response.EndTestResponse;
import org.jboss.unit.driver.response.FailureResponse;
@@ -376,7 +377,7 @@
assertStartTestEvent(listener.events.get(1), new TestId("Foo"));
}
- private static class TestDriverImpl implements TestDriver
+ private static class TestDriverImpl extends AbstractTestDriver
{
List<TestId> ids = new ArrayList<TestId>();
Added: modules/test/trunk/unit/src/main/org/jboss/unit/driver/AbstractTestDriver.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/driver/AbstractTestDriver.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/driver/AbstractTestDriver.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractTestDriver implements TestDriver
+{
+
+ /** . */
+ private DriverContext context;
+
+ public void initDriver(DriverContext context)
+ {
+ this.context = context;
+
+ //
+ doInit();
+ }
+
+ protected void doInit()
+ {
+ }
+
+ protected void doDestroy()
+ {
+ }
+
+ protected DriverContext getContext()
+ {
+ return context;
+ }
+
+ public void destroyDriver()
+ {
+ try
+ {
+ doDestroy();
+ }
+ finally
+ {
+ this.context = null;
+ }
+ }
+}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/driver/DriverContext.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/driver/DriverContext.java
(rev 0)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/driver/DriverContext.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * The context in which a driver is placed.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface DriverContext
+{
+
+ /**
+ * Return a property of the context.
+ *
+ * @param name
+ * @return
+ */
+ String getProperty(String name);
+
+}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/driver/DriverResponse.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/driver/DriverResponse.java 2007-10-12
10:24:41 UTC (rev 8612)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/driver/DriverResponse.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -22,10 +22,12 @@
******************************************************************************/
package org.jboss.unit.driver;
+import java.io.Serializable;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public abstract class DriverResponse
+public abstract class DriverResponse implements Serializable
{
}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/driver/TestDriver.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/driver/TestDriver.java 2007-10-12
10:24:41 UTC (rev 8612)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/driver/TestDriver.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -35,6 +35,18 @@
{
/**
+ * Initialize the test driver.
+ *
+ * @param context the driver context
+ */
+ void initDriver(DriverContext context);
+
+ /**
+ * Destroy the test driver.
+ */
+ void destroyDriver();
+
+ /**
* Return a runtime meta data about this test driver.
*
* @return the description
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOTestSuiteDriver.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOTestSuiteDriver.java 2007-10-12
10:24:41 UTC (rev 8612)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/POJOTestSuiteDriver.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -31,6 +31,7 @@
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.response.EndTestResponse;
import org.jboss.unit.driver.response.FailureResponse;
import org.jboss.unit.driver.command.StartTestCommand;
@@ -49,7 +50,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class POJOTestSuiteDriver implements TestDriver
+public class POJOTestSuiteDriver extends AbstractTestDriver
{
/** . */
Added:
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
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/driver/impl/pojo/SimpleDriverContext.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * 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.pojo;
+
+import org.jboss.unit.driver.DriverContext;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class SimpleDriverContext implements DriverContext
+{
+
+ /** . */
+ private final Map<String,String> properties;
+
+ public SimpleDriverContext(Map<String, String> properties)
+ {
+ if (properties == null)
+ {
+ throw new IllegalArgumentException("No null property name accepted");
+ }
+ this.properties = properties;
+ }
+
+ public SimpleDriverContext()
+ {
+ this(new HashMap<String, String>());
+ }
+
+ public String getProperty(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null property name accepted");
+ }
+ return properties.get(name);
+ }
+}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/AbstractTestRunner.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/runner/AbstractTestRunner.java 2007-10-12
10:24:41 UTC (rev 8612)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/AbstractTestRunner.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -22,7 +22,6 @@
******************************************************************************/
package org.jboss.unit.runner;
-import org.jboss.unit.runner.filter.NullFilter;
import org.jboss.unit.runner.event.TestRunnerEventBroadcasterSupport;
import org.jboss.unit.runner.event.EndRunnerEvent;
import org.jboss.unit.runner.event.StartRunnerEvent;
@@ -64,15 +63,15 @@
public final void run()
{
- run(NullFilter.getInstance());
+ run(NullTestRunnerContext.getInstance());
}
- public final void run(TestFilter filter)
+ public final void run(TestRunnerContext context)
{
fireEvent(new StartRunnerEvent());
- internalRun(filter);
+ internalRun(context);
fireEvent(new EndRunnerEvent());
}
- protected abstract void internalRun(TestFilter filter);
+ protected abstract void internalRun(TestRunnerContext context);
}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/NullTestRunnerContext.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/NullTestRunnerContext.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/NullTestRunnerContext.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -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;
+
+import org.jboss.unit.runner.filter.NullFilter;
+
+import java.util.Map;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NullTestRunnerContext implements TestRunnerContext
+{
+
+ /** . */
+ private static final NullTestRunnerContext instance = new NullTestRunnerContext();
+
+ public static NullTestRunnerContext getInstance()
+ {
+ return instance;
+ }
+
+ public Map<String, String> getProperties()
+ {
+ return Collections.emptyMap();
+ }
+
+ public TestFilter getFilter()
+ {
+ return NullFilter.getInstance();
+ }
+}
Modified: modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunner.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunner.java 2007-10-12
10:24:41 UTC (rev 8612)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunner.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -37,6 +37,6 @@
void run();
- void run(TestFilter filter);
+ void run(TestRunnerContext context);
}
Added: modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunnerContext.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunnerContext.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/TestRunnerContext.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * 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;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface TestRunnerContext
+{
+
+ Map<String,String> getProperties();
+
+ TestFilter getFilter();
+
+}
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/composite/CompositeTestRunner.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/composite/CompositeTestRunner.java 2007-10-12
10:24:41 UTC (rev 8612)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/composite/CompositeTestRunner.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -25,6 +25,7 @@
import org.jboss.unit.runner.AbstractTestRunner;
import org.jboss.unit.runner.TestRunner;
import org.jboss.unit.runner.TestFilter;
+import org.jboss.unit.runner.TestRunnerContext;
import org.jboss.unit.runner.event.TestRunnerLifeCycleFilter;
import java.util.Collection;
@@ -52,7 +53,7 @@
this.lifeCycleFilter = new TestRunnerLifeCycleFilter(broadcaster);
}
- protected void internalRun(TestFilter filter)
+ protected void internalRun(TestRunnerContext context)
{
for (TestRunner runner : runners)
{
@@ -61,7 +62,7 @@
runner.addListener(lifeCycleFilter);
//
- runner.run(filter);
+ runner.run(context);
}
finally
{
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-12
10:24:41 UTC (rev 8612)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/driver/TestDriverRunner.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -24,6 +24,7 @@
import org.jboss.unit.driver.TestDriver;
import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.impl.pojo.SimpleDriverContext;
import org.jboss.unit.driver.response.EndTestResponse;
import org.jboss.unit.driver.response.FailureResponse;
import org.jboss.unit.driver.command.StartTestCommand;
@@ -39,12 +40,11 @@
import org.jboss.unit.runner.event.EndTestEvent;
import org.jboss.unit.runner.event.RunnerFailureEvent;
import org.jboss.unit.runner.AbstractTestRunner;
-import org.jboss.unit.runner.TestFilter;
import org.jboss.unit.runner.TestResult;
import org.jboss.unit.runner.ParametrizationSet;
+import org.jboss.unit.runner.TestRunnerContext;
import java.util.Map;
-import java.util.HashMap;
/**
* An implementation that uses a test driver and transform test driver
@@ -70,7 +70,7 @@
private final ParametrizationSet parametrizationSet;
/** . */
- private final TestId testId;
+ private TestId testId;
public TestDriverRunner(TestDriver driver, ParametrizationSet parametrizationSet,
TestId testId)
{
@@ -79,25 +79,73 @@
this.testId = testId;
}
+ public TestDriverRunner(TestDriver driver,ParametrizationSet parametrizationSet)
+ {
+ this(driver, parametrizationSet, null);
+ }
+
public TestDriverRunner(TestDriver driver, TestId testId)
{
this(driver, new ParametrizationSet(), testId);
}
- protected void internalRun(TestFilter filter)
+ public TestId getTestId()
{
- TestSuiteInfo info = (TestSuiteInfo)driver.getInfo();
+ return testId;
+ }
- //
- TestInfo testInfo = info.findTest(testId);
+ public void setTestId(TestId testId)
+ {
+ this.testId = testId;
+ }
- //
- internalRun(filter, testInfo, testId);
+ protected void internalRun(TestRunnerContext context)
+ {
+ if (testId == null)
+ {
+ fireEvent(new RunnerFailureEvent(Failure.createErrorFailure("No test id
specified")));
+ }
+ else
+ {
+ // Init the test driver
+ try
+ {
+ driver.initDriver(new SimpleDriverContext(context.getProperties()));
+ }
+ catch (Exception e)
+ {
+ fireEvent(new RunnerFailureEvent(Failure.createErrorFailure("Was not
able to start the test driver properly", e)));
+ return;
+ }
+
+ //
+ try
+ {
+ TestSuiteInfo info = (TestSuiteInfo)driver.getInfo();
+
+ //
+ TestInfo testInfo = info.findTest(testId);
+
+ //
+ internalRun(context, testInfo, testId);
+ }
+ finally
+ {
+ // Perform cleanup of life cycle
+ try
+ {
+ driver.destroyDriver();
+ }
+ catch (Throwable ignore)
+ {
+ }
+ }
+ }
}
- private void internalRun(TestFilter filter, TestInfo testInfo, TestId testId)
+ private void internalRun(TestRunnerContext context, TestInfo testInfo, TestId testId)
{
- if (filter.include(testId, testInfo))
+ if (context.getFilter().include(testId, testInfo))
{
if (testInfo instanceof TestSuiteInfo)
{
@@ -107,7 +155,7 @@
for (String name : testSuiteInfo.getNames())
{
TestInfo childTestInfo = testSuiteInfo.getTest(name);
- internalRun(filter, childTestInfo, new TestId(testId, name));
+ internalRun(context, childTestInfo, new TestId(testId, name));
}
}
else
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/event/EventDrivenTestRunner.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/event/EventDrivenTestRunner.java 2007-10-12
10:24:41 UTC (rev 8612)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/event/EventDrivenTestRunner.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -25,6 +25,7 @@
import org.jboss.unit.runner.AbstractTestRunner;
import org.jboss.unit.runner.TestRunnerEvent;
import org.jboss.unit.runner.TestFilter;
+import org.jboss.unit.runner.TestRunnerContext;
import java.util.Collection;
import java.util.Arrays;
@@ -49,7 +50,7 @@
this.events = events;
}
- protected void internalRun(TestFilter filter)
+ protected void internalRun(TestRunnerContext context)
{
for (TestRunnerEvent event : events)
{
Modified:
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/failure/FailureTestRunner.java
===================================================================
---
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/failure/FailureTestRunner.java 2007-10-12
10:24:41 UTC (rev 8612)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/failure/FailureTestRunner.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -25,6 +25,7 @@
import org.jboss.unit.runner.AbstractTestRunner;
import org.jboss.unit.runner.TestResult;
import org.jboss.unit.runner.TestFilter;
+import org.jboss.unit.runner.TestRunnerContext;
import org.jboss.unit.TestId;
import org.jboss.unit.info.TestInfo;
@@ -49,9 +50,9 @@
this.testInfo = new FailureTestCaseInfo(name);
}
- public void internalRun(TestFilter filter)
+ protected void internalRun(TestRunnerContext context)
{
- if (filter.include(testId, null, testInfo))
+ if (context.getFilter().include(testId, null, testInfo))
{
// failures.add(new StartTestEvent(tmp, new ));
// failures.add(new EndTestEvent(blah, new TestError(e, 0)));
Modified:
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 2007-10-12
10:24:41 UTC (rev 8612)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/generic/GenericTestRunner.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -23,8 +23,8 @@
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.TestRunnerContext;
import org.jboss.unit.runner.event.TestRunnerLifeCycleFilter;
import org.jboss.unit.runner.event.RunnerFailureEvent;
import org.jboss.unit.runner.impl.driver.TestDriverRunner;
@@ -56,7 +56,7 @@
this.lifeCycleFilter = new TestRunnerLifeCycleFilter(broadcaster);
}
- protected void internalRun(TestFilter filter)
+ protected void internalRun(TestRunnerContext context)
{
String className = def.getClassName();
@@ -84,7 +84,7 @@
//
TestDriverRunner runner = new TestDriverRunner(driver, parametrizations,
testDef.getRefId());
runner.addListener(lifeCycleFilter);
- runner.run(filter);
+ runner.run(context);
}
}
catch (Exception e)
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-12
10:24:41 UTC (rev 8612)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/runner/impl/pojo/POJOTestRunner.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -23,8 +23,8 @@
package org.jboss.unit.runner.impl.pojo;
import org.jboss.unit.runner.AbstractTestRunner;
-import org.jboss.unit.runner.TestFilter;
import org.jboss.unit.runner.ParametrizationSet;
+import org.jboss.unit.runner.TestRunnerContext;
import org.jboss.unit.runner.impl.driver.TestDriverRunner;
import org.jboss.unit.runner.event.RunnerFailureEvent;
import org.jboss.unit.runner.event.TestRunnerLifeCycleFilter;
@@ -59,7 +59,7 @@
this.lifeCycleFilter = new TestRunnerLifeCycleFilter(broadcaster);
}
- protected void internalRun(TestFilter filter)
+ protected void internalRun(TestRunnerContext context)
{
for (TestClassDef testClass : suite.getTestClasses())
{
@@ -90,12 +90,15 @@
parametrizations.merge(testClass.getParameters().getParametrization());
//
+ TestDriverRunner runner = new TestDriverRunner(driver, parametrizations);
+
+ //
for (String testCaseName : testCaseNames)
{
TestId testCaseId = new TestId(testCaseName);
- TestDriverRunner runner = new TestDriverRunner(driver, parametrizations,
testCaseId);
+ runner.setTestId(testCaseId);
runner.addListener(lifeCycleFilter);
- runner.run(filter);
+ runner.run(context);
}
}
catch (Exception e)
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-12 10:24:41
UTC (rev 8612)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/tooling/Main.java 2007-10-12 13:04:19
UTC (rev 8613)
@@ -48,6 +48,8 @@
private final TestSuiteDef suiteDef;
+ private final Map<String,String> properties;
+
// public static final String JBOSS_UNIT_NAMES = "jboss.unit.names";
//
// public static final String JBOSS_UNIT_KEYWORDS = "jboss.unit.keywords";
@@ -78,12 +80,19 @@
public static final String OPT_SUITE_NAME = "--suite_name";
- public static final String OPT_NO_CONSOLE = "--noconsole";
+ public static final String OPT_NO_CONSOLE = "--no_console";
public static final String OPT_XML_REPORT_DIR = "--xml_report_dir";
public static final String OPT_HTML_REPORT_DIR = "--html_report_dir";
+ /**
+ * For now usage should be like
+ *
+ * --property name=value .
+ */
+ public static final String OPT_PROPERTY = "--property";
+
public static final Set options;
public static final Set options_no_arg;
@@ -103,6 +112,7 @@
opts.add(OPT_NO_CONSOLE);
opts.add(OPT_XML_REPORT_DIR);
opts.add(OPT_HTML_REPORT_DIR);
+ opts.add(OPT_PROPERTY);
options = Collections.unmodifiableSet(opts);
@@ -117,9 +127,10 @@
listeners = null;
runner = null;
suiteDef = null;
+ properties = null;
}
- public Main(TestRunner runner, MainTestFilter mainFilter,
Set<TestRunnerEventListener> listeners, TestSuiteDef suiteDef)
+ public Main(TestRunner runner, MainTestFilter mainFilter,
Set<TestRunnerEventListener> listeners, TestSuiteDef suiteDef,
Map<String,String> properties)
{
if (runner == null)
{
@@ -141,15 +152,22 @@
throw new IllegalArgumentException("suiteDef cannot be null");
}
+ if (properties == null)
+ {
+ throw new IllegalArgumentException("properties cannot be null");
+ }
+
this.mainFilter = mainFilter;
this.listeners = listeners;
this.runner = runner;
this.suiteDef = suiteDef;
+ this.properties = properties;
}
public void execute()
{
- runner.run(mainFilter);
+ MainTestRunnerContext runnerContext = new MainTestRunnerContext(properties,
mainFilter);
+ runner.run(runnerContext);
}
public static void main(String[] args) throws Exception
@@ -237,21 +255,21 @@
if (arguments.keySet().contains(OPT_XML_REPORT_DIR))
{
- builder.setXmlReportDir(arguments.get(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));
+ builder.setHTMLReportDir(arguments.get(OPT_HTML_REPORT_DIR));
}
+ if (arguments.keySet().contains(OPT_PROPERTY))
+ {
+ builder.addUnparsedProperty(arguments.get(OPT_PROPERTY));
+ }
-
-
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-12
10:24:41 UTC (rev 8612)
+++ modules/test/trunk/unit/src/main/org/jboss/unit/tooling/MainBuilder.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -36,6 +36,8 @@
import java.util.Set;
import java.util.HashSet;
+import java.util.Map;
+import java.util.HashMap;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.File;
@@ -47,19 +49,19 @@
public class MainBuilder
{
- private Set<String> keywords = new HashSet();
+ private Set<String> keywords = new HashSet<String>();
- private Set<String> names = new HashSet();
+ private Set<String> names = new HashSet<String>();
- private Set<String> namePatterns = new HashSet();
+ private Set<String> namePatterns = new HashSet<String>();
- private Set<String> excludeKeywords = new HashSet();
+ private Set<String> excludeKeywords = new HashSet<String>();
- private Set<String> excludeNames = new HashSet();
+ private Set<String> excludeNames = new HashSet<String>();
- private Set<String> excludeNamePatterns = new HashSet();
+ private Set<String> excludeNamePatterns = new HashSet<String>();
- private Set<TestRunnerEventListener> listeners = new HashSet();
+ private Set<TestRunnerEventListener> listeners = new
HashSet<TestRunnerEventListener>();
private String suiteName;
@@ -71,7 +73,9 @@
private String htmlReportDir;
+ private Map<String,String> properties = new HashMap<String, String>();
+
private MainBuilder()
{
@@ -251,7 +255,7 @@
return this;
}
- public MainBuilder addJunitReporting(String directory)
+ public MainBuilder addJUnitReporting(String directory)
{
if (directory == null)
{
@@ -263,7 +267,44 @@
return this;
}
+ public MainBuilder addUnparsedProperty(String propertyString)
+ {
+ if (propertyString == null)
+ {
+ throw new IllegalArgumentException("No null property name accepted");
+ }
+ //
+ String[] patternValues = propertyString.split("=");
+
+ //
+ if (patternValues.length != 2)
+ {
+ throw new IllegalArgumentException("Property not accepted, it should match
a=b and it is " + propertyString);
+ }
+
+ //
+ properties.put(patternValues[0], patternValues[1]);
+
+ //
+ return this;
+ }
+
+ public MainBuilder addProperty(String propertyName, String propertyValue)
+ {
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException("No null property name accepted");
+ }
+
+ //
+ properties.put(propertyName, propertyValue);
+
+ //
+ return this;
+ }
+
+
public String getSuiteName()
{
return suiteName;
@@ -279,12 +320,12 @@
this.noConsole = noConsole;
}
- public void setXmlReportDir(String xmlReportDir)
+ public void setXMLReportDir(String xmlReportDir)
{
this.xmlReportDir = xmlReportDir;
}
- public void setHtmlReportDir(String htmlReportDir)
+ public void setHTMLReportDir(String htmlReportDir)
{
this.htmlReportDir = htmlReportDir;
}
@@ -324,7 +365,7 @@
}
else
{
- xmlReporter = new JUnitReporter(xmlReportDir);
+ xmlReporter = new JUnitReporter(xmlReportDir);
}
reporter.setXmlReporter(xmlReporter);
@@ -356,7 +397,7 @@
}
- return new Main(runner, filter, listeners, suite);
+ return new Main(runner, filter, listeners, suite, properties);
}
public static void checkCreateOutputDirectory(String dir) throws Exception
Added: modules/test/trunk/unit/src/main/org/jboss/unit/tooling/MainTestRunnerContext.java
===================================================================
--- modules/test/trunk/unit/src/main/org/jboss/unit/tooling/MainTestRunnerContext.java
(rev 0)
+++
modules/test/trunk/unit/src/main/org/jboss/unit/tooling/MainTestRunnerContext.java 2007-10-12
13:04:19 UTC (rev 8613)
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * 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.TestRunnerContext;
+import org.jboss.unit.runner.TestFilter;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MainTestRunnerContext implements TestRunnerContext
+{
+
+ /** . */
+ private Map<String,String> properties;
+
+ /** . */
+ private TestFilter filter;
+
+ public MainTestRunnerContext(Map<String, String> properties, TestFilter filter)
+ {
+ this.properties = properties;
+ this.filter = filter;
+ }
+
+ public Map<String, String> getProperties()
+ {
+ return properties;
+ }
+
+ public TestFilter getFilter()
+ {
+ return filter;
+ }
+}