Author: mwringe
Date: 2011-06-23 10:49:20 -0400 (Thu, 23 Jun 2011)
New Revision: 6725
Modified:
components/wci/trunk/test/core/pom.xml
components/wci/trunk/test/core/src/main/java/org/gatein/wci/ServletTestCase.java
components/wci/trunk/test/core/src/main/java/org/gatein/wci/TestServlet.java
components/wci/trunk/test/servers/jetty6/pom.xml
components/wci/trunk/test/servers/tomcat6/pom.xml
Log:
GTNWCI-25: synchronize the test and the retrieval of the test ResponseContext object. This
will force the tests to be completed before the jboss unit client can retrieve the test
response.
Modified: components/wci/trunk/test/core/pom.xml
===================================================================
--- components/wci/trunk/test/core/pom.xml 2011-06-23 12:44:34 UTC (rev 6724)
+++ components/wci/trunk/test/core/pom.xml 2011-06-23 14:49:20 UTC (rev 6725)
@@ -29,10 +29,12 @@
<dependency>
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit</artifactId>
+ <version>${version.jboss.unit}</version>
</dependency>
<dependency>
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit-remote</artifactId>
+ <version>${version.jboss.unit}</version>
<exclusions>
<exclusion>
<groupId>hibernate</groupId>
@@ -72,12 +74,12 @@
<plugin>
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit-tooling-maven2</artifactId>
- <version>1.2.3</version>
+ <version>${version.jboss.unit}</version>
<dependencies>
<dependency>
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit</artifactId>
- <version>1.2.3</version>
+ <version>${version.jboss.unit}</version>
</dependency>
</dependencies>
<configuration>
Modified:
components/wci/trunk/test/core/src/main/java/org/gatein/wci/ServletTestCase.java
===================================================================
---
components/wci/trunk/test/core/src/main/java/org/gatein/wci/ServletTestCase.java 2011-06-23
12:44:34 UTC (rev 6724)
+++
components/wci/trunk/test/core/src/main/java/org/gatein/wci/ServletTestCase.java 2011-06-23
14:49:20 UTC (rev 6725)
@@ -25,9 +25,11 @@
import org.jboss.unit.driver.DriverResponse;
import org.jboss.unit.driver.DriverCommand;
import org.jboss.unit.driver.AbstractTestDriver;
+import org.jboss.unit.driver.response.FailureResponse;
import org.jboss.unit.info.TestCaseInfo;
import org.jboss.unit.info.ParameterInfo;
import org.jboss.unit.info.TestInfo;
+import org.jboss.unit.Failure;
import org.jboss.unit.TestId;
import org.jboss.unit.remote.ResponseContext;
import org.jboss.unit.remote.RequestContext;
@@ -37,6 +39,8 @@
import javax.servlet.ServletException;
import java.io.IOException;
+import java.io.Serializable;
+import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.Collections;
@@ -99,7 +103,7 @@
this.requestContext = requestContext;
}
- public ResponseContext popContext(TestId testId)
+ public synchronized ResponseContext popContext(TestId testId)
{
return responseContext;
}
@@ -114,6 +118,21 @@
this.responseContext = responseContext;
}
+ public synchronized void runTest(TestServlet testServlet, WebRequest req, WebResponse
resp) throws ServletException, IOException
+ {
+ DriverResponse response;
+ try
+ {
+ response = service(testServlet, req, resp);
+ }
+ catch (AssertionError e)
+ {
+ response = new FailureResponse(Failure.createFailure(e));
+ }
+ setResponseContext(new ResponseContext(response, new HashMap<String,
Serializable>()));
+ resp.setStatus(200);
+ }
+
public abstract DriverResponse service(TestServlet testServlet, WebRequest req,
WebResponse resp) throws ServletException, IOException;
public abstract DriverResponse invoke(TestServlet testServlet, DriverCommand
driverCommand);
Modified: components/wci/trunk/test/core/src/main/java/org/gatein/wci/TestServlet.java
===================================================================
---
components/wci/trunk/test/core/src/main/java/org/gatein/wci/TestServlet.java 2011-06-23
12:44:34 UTC (rev 6724)
+++
components/wci/trunk/test/core/src/main/java/org/gatein/wci/TestServlet.java 2011-06-23
14:49:20 UTC (rev 6725)
@@ -67,17 +67,7 @@
protected void service(WebRequest req, WebResponse resp) throws ServletException,
IOException
{
- DriverResponse response;
- try
- {
- response = currentTestCase.service(this, req, resp);
- }
- catch (AssertionError e)
- {
- response = new FailureResponse(Failure.createFailure(e));
- }
- currentTestCase.setResponseContext(new ResponseContext(response, new
HashMap<String, Serializable>()));
- resp.setStatus(200);
+ currentTestCase.runTest(this, req, resp);
}
public void destroy()
Modified: components/wci/trunk/test/servers/jetty6/pom.xml
===================================================================
--- components/wci/trunk/test/servers/jetty6/pom.xml 2011-06-23 12:44:34 UTC (rev 6724)
+++ components/wci/trunk/test/servers/jetty6/pom.xml 2011-06-23 14:49:20 UTC (rev 6725)
@@ -89,11 +89,13 @@
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit</artifactId>
<scope>test</scope>
+ <version>${version.jboss.unit}</version>
</dependency>
<dependency>
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit-remote</artifactId>
<scope>test</scope>
+ <version>${version.jboss.unit}</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.cargo</groupId>
@@ -109,16 +111,19 @@
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit-mc</artifactId>
<scope>test</scope>
+ <version>${version.jboss.unit}</version>
</dependency>
<dependency>
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit-tooling-ant</artifactId>
<scope>test</scope>
+ <version>${version.jboss.unit}</version>
</dependency>
<dependency>
<groupId>org.jboss.unit</groupId>
<artifactId>portal-test</artifactId>
<scope>test</scope>
+ <version>${version.jboss.unit}</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.cargo</groupId>
@@ -146,6 +151,7 @@
<groupId>org.jboss.unit</groupId>
<artifactId>portal-test-generic</artifactId>
<scope>test</scope>
+ <version>${version.jboss.unit}</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.cargo</groupId>
Modified: components/wci/trunk/test/servers/tomcat6/pom.xml
===================================================================
--- components/wci/trunk/test/servers/tomcat6/pom.xml 2011-06-23 12:44:34 UTC (rev 6724)
+++ components/wci/trunk/test/servers/tomcat6/pom.xml 2011-06-23 14:49:20 UTC (rev 6725)
@@ -89,11 +89,13 @@
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit</artifactId>
<scope>test</scope>
+ <version>${version.jboss.unit}</version>
</dependency>
<dependency>
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit-remote</artifactId>
<scope>test</scope>
+ <version>${version.jboss.unit}</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.cargo</groupId>
@@ -109,16 +111,19 @@
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit-mc</artifactId>
<scope>test</scope>
+ <version>${version.jboss.unit}</version>
</dependency>
<dependency>
<groupId>org.jboss.unit</groupId>
<artifactId>jboss-unit-tooling-ant</artifactId>
<scope>test</scope>
+ <version>${version.jboss.unit}</version>
</dependency>
<dependency>
<groupId>org.jboss.unit</groupId>
<artifactId>portal-test</artifactId>
<scope>test</scope>
+ <version>${version.jboss.unit}</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.cargo</groupId>
@@ -146,6 +151,7 @@
<groupId>org.jboss.unit</groupId>
<artifactId>portal-test-generic</artifactId>
<scope>test</scope>
+ <version>${version.jboss.unit}</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.cargo</groupId>