[jboss-svn-commits] JBoss Common SVN: r4354 - in arquillian/trunk: containers/jbossas-embedded-60 and 12 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri May 7 06:16:15 EDT 2010
Author: aslak
Date: 2010-05-07 06:16:11 -0400 (Fri, 07 May 2010)
New Revision: 4354
Added:
arquillian/trunk/protocols/servlet-ee5/
arquillian/trunk/protocols/servlet-ee5/src/main/java/org/jboss/arquillian/protocol/servlet/ServletTestRunner.java
arquillian/trunk/protocols/servlet-ee5/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolTestCase.java
arquillian/trunk/protocols/servlet-ee6/
arquillian/trunk/protocols/servlet-ee6/src/main/java/org/jboss/arquillian/protocol/servlet/ServletTestRunner.java
arquillian/trunk/protocols/servlet-ee6/src/main/resources/org/jboss/arquillian/protocol/servlet/web-fragment.xml
arquillian/trunk/protocols/servlet-ee6/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolTestCase.java
Removed:
arquillian/trunk/protocols/servlet-ee5/src/main/java/org/jboss/arquillian/protocol/servlet/ServletTestRunner.java
arquillian/trunk/protocols/servlet-ee5/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolTestCase.java
arquillian/trunk/protocols/servlet-ee6/src/main/java/org/jboss/arquillian/protocol/servlet/ServletTestRunner.java
arquillian/trunk/protocols/servlet-ee6/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolTestCase.java
arquillian/trunk/protocols/servlet/pom.xml
arquillian/trunk/protocols/servlet/src/main/
arquillian/trunk/protocols/servlet/src/test/
Modified:
arquillian/trunk/containers/glassfish-embedded-30/pom.xml
arquillian/trunk/containers/jbossas-embedded-60/pom.xml
arquillian/trunk/containers/jbossas-remote-51/pom.xml
arquillian/trunk/containers/jbossas-remote-60/pom.xml
arquillian/trunk/protocols/pom.xml
arquillian/trunk/protocols/servlet-ee5/pom.xml
arquillian/trunk/protocols/servlet-ee6/pom.xml
arquillian/trunk/protocols/servlet-ee6/src/main/java/org/jboss/arquillian/protocol/servlet/ProtocolDeploymentAppender.java
arquillian/trunk/protocols/servlet-ee6/src/main/java/org/jboss/arquillian/protocol/servlet/ServletMethodExecutor.java
arquillian/trunk/protocols/servlet-ee6/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolDeploymentAppenderTestCase.java
Log:
ARQ-132 Splitted Servlet-Protocol into EE5(web.xml) and EE6(web-fragment.xml) support. Updated the different containers dependency depending on supported EE stack.
Modified: arquillian/trunk/containers/glassfish-embedded-30/pom.xml
===================================================================
--- arquillian/trunk/containers/glassfish-embedded-30/pom.xml 2010-05-05 17:42:04 UTC (rev 4353)
+++ arquillian/trunk/containers/glassfish-embedded-30/pom.xml 2010-05-07 10:16:11 UTC (rev 4354)
@@ -52,7 +52,7 @@
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
- <artifactId>arquillian-protocol-servlet</artifactId>
+ <artifactId>arquillian-protocol-servlet-ee6</artifactId>
<version>${project.version}</version>
</dependency>
Modified: arquillian/trunk/containers/jbossas-embedded-60/pom.xml
===================================================================
--- arquillian/trunk/containers/jbossas-embedded-60/pom.xml 2010-05-05 17:42:04 UTC (rev 4353)
+++ arquillian/trunk/containers/jbossas-embedded-60/pom.xml 2010-05-07 10:16:11 UTC (rev 4354)
@@ -46,7 +46,7 @@
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
- <artifactId>arquillian-protocol-servlet</artifactId>
+ <artifactId>arquillian-protocol-servlet-ee6</artifactId>
<version>${project.version}</version>
</dependency>
Modified: arquillian/trunk/containers/jbossas-remote-51/pom.xml
===================================================================
--- arquillian/trunk/containers/jbossas-remote-51/pom.xml 2010-05-05 17:42:04 UTC (rev 4353)
+++ arquillian/trunk/containers/jbossas-remote-51/pom.xml 2010-05-07 10:16:11 UTC (rev 4354)
@@ -40,7 +40,7 @@
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
- <artifactId>arquillian-protocol-servlet</artifactId>
+ <artifactId>arquillian-protocol-servlet-ee5</artifactId>
<version>${project.version}</version>
</dependency>
Modified: arquillian/trunk/containers/jbossas-remote-60/pom.xml
===================================================================
--- arquillian/trunk/containers/jbossas-remote-60/pom.xml 2010-05-05 17:42:04 UTC (rev 4353)
+++ arquillian/trunk/containers/jbossas-remote-60/pom.xml 2010-05-07 10:16:11 UTC (rev 4354)
@@ -40,7 +40,7 @@
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
- <artifactId>arquillian-protocol-servlet</artifactId>
+ <artifactId>arquillian-protocol-servlet-ee6</artifactId>
<version>${project.version}</version>
</dependency>
Modified: arquillian/trunk/protocols/pom.xml
===================================================================
--- arquillian/trunk/protocols/pom.xml 2010-05-05 17:42:04 UTC (rev 4353)
+++ arquillian/trunk/protocols/pom.xml 2010-05-07 10:16:11 UTC (rev 4354)
@@ -26,7 +26,8 @@
<!-- Aggregate Modules -->
<modules>
- <module>servlet</module>
+ <module>servlet-ee5</module>
+ <module>servlet-ee6</module>
<module>local</module>
</modules>
Deleted: arquillian/trunk/protocols/servlet/pom.xml
===================================================================
--- arquillian/trunk/protocols/servlet/pom.xml 2010-05-05 17:42:04 UTC (rev 4353)
+++ arquillian/trunk/protocols/servlet/pom.xml 2010-05-07 10:16:11 UTC (rev 4354)
@@ -1,72 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <!-- Parent -->
- <parent>
- <groupId>org.jboss.arquillian</groupId>
- <artifactId>arquillian-build</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <relativePath>../../build/pom.xml</relativePath>
- </parent>
-
- <!-- Model Version -->
- <modelVersion>4.0.0</modelVersion>
-
- <!-- Artifact Configuration -->
- <groupId>org.jboss.arquillian.protocol</groupId>
- <artifactId>arquillian-protocol-servlet</artifactId>
- <name>Arquillian Protocol Servlet</name>
- <description>Protocol handler for communicating using a servlet / http</description>
-
-
- <!-- Properties -->
- <properties>
-
- <!-- Versioning -->
-
- </properties>
-
- <!-- Dependencies -->
- <dependencies>
-
- <!--
- org.jboss.arquillian
- -->
- <dependency>
- <groupId>org.jboss.arquillian</groupId>
- <artifactId>arquillian-spi</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <!--
- servlet api
- -->
- <dependency>
- <groupId>jboss.web</groupId>
- <artifactId>servlet-api</artifactId>
- <version>3.0.0.alpha-25</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty-embedded</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.shrinkwrap</groupId>
- <artifactId>shrinkwrap-impl-base</artifactId>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-</project>
-
Copied: arquillian/trunk/protocols/servlet-ee5 (from rev 4348, arquillian/trunk/protocols/servlet)
Modified: arquillian/trunk/protocols/servlet-ee5/pom.xml
===================================================================
--- arquillian/trunk/protocols/servlet/pom.xml 2010-05-04 16:43:22 UTC (rev 4348)
+++ arquillian/trunk/protocols/servlet-ee5/pom.xml 2010-05-07 10:16:11 UTC (rev 4354)
@@ -15,9 +15,9 @@
<!-- Artifact Configuration -->
<groupId>org.jboss.arquillian.protocol</groupId>
- <artifactId>arquillian-protocol-servlet</artifactId>
- <name>Arquillian Protocol Servlet</name>
- <description>Protocol handler for communicating using a servlet / http</description>
+ <artifactId>arquillian-protocol-servlet-ee5</artifactId>
+ <name>Arquillian Protocol Servlet EE5</name>
+ <description>Protocol handler for communicating using a servlet / http. WebArchive containing web.xml.</description>
<!-- Properties -->
Deleted: arquillian/trunk/protocols/servlet-ee5/src/main/java/org/jboss/arquillian/protocol/servlet/ServletTestRunner.java
===================================================================
--- arquillian/trunk/protocols/servlet/src/main/java/org/jboss/arquillian/protocol/servlet/ServletTestRunner.java 2010-05-04 16:43:22 UTC (rev 4348)
+++ arquillian/trunk/protocols/servlet-ee5/src/main/java/org/jboss/arquillian/protocol/servlet/ServletTestRunner.java 2010-05-07 10:16:11 UTC (rev 4354)
@@ -1,178 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.arquillian.protocol.servlet;
-
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.io.PrintWriter;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.jboss.arquillian.spi.TestResult;
-import org.jboss.arquillian.spi.TestRunner;
-import org.jboss.arquillian.spi.util.TestRunners;
-
-/**
- * ServletTestRunner
- *
- * The server side executor for the Servlet protocol impl.
- *
- * Supports multiple output modes ("outputmode"):
- * - html
- * - serializedObject
- *
- * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
- * @version $Revision: $
- */
-public class ServletTestRunner extends HttpServlet
-{
- private static final long serialVersionUID = 1L;
-
- public static final String PARA_METHOD_NAME = "methodName";
- public static final String PARA_CLASS_NAME = "className";
- public static final String PARA_OUTPUT_MODE = "outputMode";
-
- public static final String OUTPUT_MODE_SERIALIZED = "serializedObject";
- public static final String OUTPUT_MODE_HTML = "html";
-
- @Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
- {
- String outputMode = OUTPUT_MODE_HTML;
- try
- {
- String className = null;
- String methodName = null;
-
- if (request.getParameter(PARA_OUTPUT_MODE) != null)
- {
- outputMode = request.getParameter(PARA_OUTPUT_MODE);
- }
- className = request.getParameter(PARA_CLASS_NAME);
- if (className == null)
- {
- throw new IllegalArgumentException(PARA_CLASS_NAME + " must be specified");
- }
- methodName = request.getParameter(PARA_METHOD_NAME);
- if ( methodName == null)
- {
- throw new IllegalArgumentException(PARA_METHOD_NAME + " must be specified");
- }
-
- Class<?> testClass = SecurityActions.getThreadContextClassLoader().loadClass(className);
-
- TestRunner runner = TestRunners.getTestRunner();
-
- TestResult testResult = runner.execute(testClass, methodName);
-
- if(OUTPUT_MODE_SERIALIZED.equalsIgnoreCase(outputMode))
- {
- writeObject(testResult, response);
- }
- else
- {
- // TODO: implement a html view of the result
- response.setContentType("text/html");
- response.setStatus(HttpServletResponse.SC_OK);
- PrintWriter writer = response.getWriter();
- writer.write("<html>\n");
- writer.write("<head><title>TCK Report</title></head>\n");
- writer.write("<body>\n");
- writer.write("<h2>Configuration</h2>\n");
- writer.write("<table>\n");
- writer.write("<tr>\n");
- writer.write("<td><b>Method</b></td><td><b>Status</b></td>\n");
- writer.write("</tr>\n");
-
- writer.write("</table>\n");
- writer.write("<h2>Tests</h2>\n");
- writer.write("<table>\n");
- writer.write("<tr>\n");
- writer.write("<td><b>Method</b></td><td><b>Status</b></td>\n");
- writer.write("</tr>\n");
-
- writer.write("</table>\n");
- writer.write("</body>\n");
- }
-
- }
- catch(Exception e)
- {
- if(OUTPUT_MODE_SERIALIZED.equalsIgnoreCase(outputMode))
- {
- writeObject(createFailedResult(e), response);
- }
- else
- {
- response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
- }
- }
- }
-
- private void writeObject(Object object, HttpServletResponse response)
- {
- try
- {
- ObjectOutputStream oos = new ObjectOutputStream(response.getOutputStream());
- oos.writeObject(object);
- response.setStatus(HttpServletResponse.SC_OK);
- oos.flush();
- oos.close();
- }
- catch (Exception e)
- {
- try
- {
- response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
- }
- catch (Exception e2)
- {
- throw new RuntimeException("Could not write to output", e2);
- }
- }
- }
-
- private TestResult createFailedResult(Throwable throwable)
- {
- return new FailedResult(throwable);
- }
-
- public static class FailedResult implements TestResult {
-
- private static final long serialVersionUID = 1L;
-
- private Throwable throwable;
-
- public FailedResult(Throwable throwable)
- {
- this.throwable = throwable;
- }
-
- public Status getStatus()
- {
- return Status.FAILED;
- }
-
- public Throwable getThrowable()
- {
- return throwable;
- }
- }
-}
Copied: arquillian/trunk/protocols/servlet-ee5/src/main/java/org/jboss/arquillian/protocol/servlet/ServletTestRunner.java (from rev 4349, arquillian/trunk/protocols/servlet/src/main/java/org/jboss/arquillian/protocol/servlet/ServletTestRunner.java)
===================================================================
--- arquillian/trunk/protocols/servlet-ee5/src/main/java/org/jboss/arquillian/protocol/servlet/ServletTestRunner.java (rev 0)
+++ arquillian/trunk/protocols/servlet-ee5/src/main/java/org/jboss/arquillian/protocol/servlet/ServletTestRunner.java 2010-05-07 10:16:11 UTC (rev 4354)
@@ -0,0 +1,157 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.protocol.servlet;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.arquillian.spi.TestResult;
+import org.jboss.arquillian.spi.TestRunner;
+import org.jboss.arquillian.spi.TestResult.Status;
+import org.jboss.arquillian.spi.util.TestRunners;
+
+/**
+ * ServletTestRunner
+ *
+ * The server side executor for the Servlet protocol impl.
+ *
+ * Supports multiple output modes ("outputmode"):
+ * - html
+ * - serializedObject
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class ServletTestRunner extends HttpServlet
+{
+ private static final long serialVersionUID = 1L;
+
+ public static final String PARA_METHOD_NAME = "methodName";
+ public static final String PARA_CLASS_NAME = "className";
+ public static final String PARA_OUTPUT_MODE = "outputMode";
+
+ public static final String OUTPUT_MODE_SERIALIZED = "serializedObject";
+ public static final String OUTPUT_MODE_HTML = "html";
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+ String outputMode = OUTPUT_MODE_HTML;
+ try
+ {
+ String className = null;
+ String methodName = null;
+
+ if (request.getParameter(PARA_OUTPUT_MODE) != null)
+ {
+ outputMode = request.getParameter(PARA_OUTPUT_MODE);
+ }
+ className = request.getParameter(PARA_CLASS_NAME);
+ if (className == null)
+ {
+ throw new IllegalArgumentException(PARA_CLASS_NAME + " must be specified");
+ }
+ methodName = request.getParameter(PARA_METHOD_NAME);
+ if ( methodName == null)
+ {
+ throw new IllegalArgumentException(PARA_METHOD_NAME + " must be specified");
+ }
+
+ Class<?> testClass = SecurityActions.getThreadContextClassLoader().loadClass(className);
+
+ TestRunner runner = TestRunners.getTestRunner();
+
+ TestResult testResult = runner.execute(testClass, methodName);
+
+ if(OUTPUT_MODE_SERIALIZED.equalsIgnoreCase(outputMode))
+ {
+ writeObject(testResult, response);
+ }
+ else
+ {
+ // TODO: implement a html view of the result
+ response.setContentType("text/html");
+ response.setStatus(HttpServletResponse.SC_OK);
+ PrintWriter writer = response.getWriter();
+ writer.write("<html>\n");
+ writer.write("<head><title>TCK Report</title></head>\n");
+ writer.write("<body>\n");
+ writer.write("<h2>Configuration</h2>\n");
+ writer.write("<table>\n");
+ writer.write("<tr>\n");
+ writer.write("<td><b>Method</b></td><td><b>Status</b></td>\n");
+ writer.write("</tr>\n");
+
+ writer.write("</table>\n");
+ writer.write("<h2>Tests</h2>\n");
+ writer.write("<table>\n");
+ writer.write("<tr>\n");
+ writer.write("<td><b>Method</b></td><td><b>Status</b></td>\n");
+ writer.write("</tr>\n");
+
+ writer.write("</table>\n");
+ writer.write("</body>\n");
+ }
+
+ }
+ catch(Exception e)
+ {
+ if(OUTPUT_MODE_SERIALIZED.equalsIgnoreCase(outputMode))
+ {
+ writeObject(createFailedResult(e), response);
+ }
+ else
+ {
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
+ }
+ }
+ }
+
+ private void writeObject(Object object, HttpServletResponse response)
+ {
+ try
+ {
+ ObjectOutputStream oos = new ObjectOutputStream(response.getOutputStream());
+ oos.writeObject(object);
+ response.setStatus(HttpServletResponse.SC_OK);
+ oos.flush();
+ oos.close();
+ }
+ catch (Exception e)
+ {
+ try
+ {
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
+ }
+ catch (Exception e2)
+ {
+ throw new RuntimeException("Could not write to output", e2);
+ }
+ }
+ }
+
+ private TestResult createFailedResult(Throwable throwable)
+ {
+ return new TestResult(Status.FAILED, throwable);
+ }
+}
Deleted: arquillian/trunk/protocols/servlet-ee5/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolTestCase.java
===================================================================
--- arquillian/trunk/protocols/servlet/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolTestCase.java 2010-05-04 16:43:22 UTC (rev 4348)
+++ arquillian/trunk/protocols/servlet-ee5/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolTestCase.java 2010-05-07 10:16:11 UTC (rev 4354)
@@ -1,237 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.arquillian.protocol.servlet;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.net.URL;
-
-import org.jboss.arquillian.spi.TestMethodExecutor;
-import org.jboss.arquillian.spi.TestResult;
-import org.jboss.arquillian.spi.TestResult.Status;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.servlet.Context;
-
-
-/**
- * ProtocolTestCase
- *
- * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
- * @version $Revision: $
- */
- at Ignore // need to fix the javaee api dep
-public class ProtocolTestCase
-{
-
- private Server server;
-
- @Before
- public void setup() throws Exception
- {
- server = new Server(8181);
- Context root = new Context(server, "/arquillian-protocol", Context.SESSIONS);
- root.addServlet(ServletTestRunner.class, "/*");
- server.start();
- }
-
- @After
- public void cleanup() throws Exception
- {
- server.stop();
- }
-
- @Test
- public void shouldReturnTestResult() throws Exception
- {
- MockTestRunner.add(new TestResultImpl(Status.PASSED, null));
-
- ServletMethodExecutor executor = new ServletMethodExecutor(createBaseURL());
- TestResult result = executor.invoke(new MockTestExecutor());
-
- Assert.assertEquals(
- "Should have returned a passed test",
- MockTestRunner.wantedResults.get(0).getStatus(),
- result.getStatus());
-
- Assert.assertNull(
- "No Exception should have been thrown",
- result.getThrowable());
- }
-
- @Test
- public void shouldReturnThrownException() throws Exception
- {
- MockTestRunner.add(new TestResultImpl(Status.FAILED, new Exception().fillInStackTrace()));
-
- ServletMethodExecutor executor = new ServletMethodExecutor(createBaseURL());
- TestResult result = executor.invoke(new MockTestExecutor());
-
- Assert.assertEquals(
- "Should have returned a passed test",
- MockTestRunner.wantedResults.get(0).getStatus(),
- result.getStatus());
-
- Assert.assertNotNull(
- "No Exception should have been thrown",
- result.getThrowable());
-
- }
-
- @Test
- public void shouldReturnExceptionWhenMissingTestClassParameter() throws Exception
- {
- URL url = createURL(ServletTestRunner.OUTPUT_MODE_SERIALIZED, null, null);
- TestResult result = (TestResult)TestUtil.execute(url);
-
- Assert.assertEquals(
- "Should have returned a passed test",
- Status.FAILED,
- result.getStatus());
-
- Assert.assertTrue(
- "No Exception should have been thrown",
- result.getThrowable() instanceof IllegalArgumentException);
- }
-
- @Test
- public void shouldReturnExceptionWhenMissingMethodParameter() throws Exception
- {
- URL url = createURL(ServletTestRunner.OUTPUT_MODE_SERIALIZED, "org.my.test", null);
- TestResult result = (TestResult)TestUtil.execute(url);
-
- Assert.assertEquals(
- "Should have returned a passed test",
- Status.FAILED,
- result.getStatus());
-
- Assert.assertTrue(
- "No Exception should have been thrown",
- result.getThrowable() instanceof IllegalArgumentException);
- }
-
- @Test
- public void shouldReturnExceptionWhenErrorLoadingClass() throws Exception
- {
- URL url = createURL(ServletTestRunner.OUTPUT_MODE_SERIALIZED, "org.my.test", "test");
- TestResult result = (TestResult)TestUtil.execute(url);
-
- Assert.assertEquals(
- "Should have returned a passed test",
- Status.FAILED,
- result.getStatus());
-
- Assert.assertTrue(
- "No Exception should have been thrown",
- result.getThrowable() instanceof ClassNotFoundException);
- }
-
- private URL createBaseURL() {
- try
- {
- return new URL("http", "localhost", server.getConnectors()[0].getPort(), "/");
- }
- catch (Exception e)
- {
- throw new RuntimeException("Could not create URL", e);
- }
- }
-
- private URL createURL(String outputMode, String testClass, String methodName)
- {
- StringBuilder url = new StringBuilder(createBaseURL().toExternalForm()).append("arquillian-protocol/");
- boolean first = true;
- if(outputMode != null)
- {
- if(first) {first = false; url.append("?"); } else { url.append("&"); }
- url.append(ServletTestRunner.PARA_OUTPUT_MODE).append("=").append(outputMode);
- }
- if(testClass != null)
- {
- if(first) {first = false; url.append("?"); } else { url.append("&"); }
- url.append(ServletTestRunner.PARA_CLASS_NAME).append("=").append(testClass);
- }
- if(methodName != null)
- {
- if(first) {first = false; url.append("?"); } else { url.append("&"); }
- url.append(ServletTestRunner.PARA_METHOD_NAME).append("=").append(methodName);
- }
-
- try
- {
- return new URL(url.toString());
- }
- catch (Exception e)
- {
- throw new RuntimeException("Could not create url", e);
- }
- }
-
- public static class TestResultImpl implements TestResult {
-
- private static final long serialVersionUID = 1L;
-
- private Status status;
- private Throwable throwable;
-
- public TestResultImpl(Status status, Throwable throwable)
- {
- this.status = status;
- this.throwable = throwable;
- }
-
- public Status getStatus()
- {
- return status;
- }
-
- public Throwable getThrowable()
- {
- return throwable;
- }
- }
-
- public static class MockTestExecutor implements TestMethodExecutor, Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public void invoke() throws Throwable
- {
- }
-
- public Method getMethod()
- {
- try
- {
- return this.getClass().getMethod("getMethod");
- }
- catch (Exception e)
- {
- throw new RuntimeException("Could not find my own method ?? ");
- }
- }
-
- public Object getInstance()
- {
- return this;
- }
- }
-}
Copied: arquillian/trunk/protocols/servlet-ee5/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolTestCase.java (from rev 4349, arquillian/trunk/protocols/servlet/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolTestCase.java)
===================================================================
--- arquillian/trunk/protocols/servlet-ee5/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolTestCase.java (rev 0)
+++ arquillian/trunk/protocols/servlet-ee5/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolTestCase.java 2010-05-07 10:16:11 UTC (rev 4354)
@@ -0,0 +1,213 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.protocol.servlet;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.net.URL;
+
+import org.jboss.arquillian.spi.TestMethodExecutor;
+import org.jboss.arquillian.spi.TestResult;
+import org.jboss.arquillian.spi.TestResult.Status;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.servlet.Context;
+
+
+/**
+ * ProtocolTestCase
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at Ignore // need to fix the javaee api dep
+public class ProtocolTestCase
+{
+
+ private Server server;
+
+ @Before
+ public void setup() throws Exception
+ {
+ server = new Server(8181);
+ Context root = new Context(server, "/arquillian-protocol", Context.SESSIONS);
+ root.addServlet(ServletTestRunner.class, "/*");
+ server.start();
+ }
+
+ @After
+ public void cleanup() throws Exception
+ {
+ server.stop();
+ }
+
+ @Test
+ public void shouldReturnTestResult() throws Exception
+ {
+ MockTestRunner.add(new TestResult(Status.PASSED, null));
+
+ ServletMethodExecutor executor = new ServletMethodExecutor(createBaseURL());
+ TestResult result = executor.invoke(new MockTestExecutor());
+
+ Assert.assertEquals(
+ "Should have returned a passed test",
+ MockTestRunner.wantedResults.get(0).getStatus(),
+ result.getStatus());
+
+ Assert.assertNull(
+ "No Exception should have been thrown",
+ result.getThrowable());
+ }
+
+ @Test
+ public void shouldReturnThrownException() throws Exception
+ {
+ MockTestRunner.add(new TestResult(Status.FAILED, new Exception().fillInStackTrace()));
+
+ ServletMethodExecutor executor = new ServletMethodExecutor(createBaseURL());
+ TestResult result = executor.invoke(new MockTestExecutor());
+
+ Assert.assertEquals(
+ "Should have returned a passed test",
+ MockTestRunner.wantedResults.get(0).getStatus(),
+ result.getStatus());
+
+ Assert.assertNotNull(
+ "No Exception should have been thrown",
+ result.getThrowable());
+
+ }
+
+ @Test
+ public void shouldReturnExceptionWhenMissingTestClassParameter() throws Exception
+ {
+ URL url = createURL(ServletTestRunner.OUTPUT_MODE_SERIALIZED, null, null);
+ TestResult result = (TestResult)TestUtil.execute(url);
+
+ Assert.assertEquals(
+ "Should have returned a passed test",
+ Status.FAILED,
+ result.getStatus());
+
+ Assert.assertTrue(
+ "No Exception should have been thrown",
+ result.getThrowable() instanceof IllegalArgumentException);
+ }
+
+ @Test
+ public void shouldReturnExceptionWhenMissingMethodParameter() throws Exception
+ {
+ URL url = createURL(ServletTestRunner.OUTPUT_MODE_SERIALIZED, "org.my.test", null);
+ TestResult result = (TestResult)TestUtil.execute(url);
+
+ Assert.assertEquals(
+ "Should have returned a passed test",
+ Status.FAILED,
+ result.getStatus());
+
+ Assert.assertTrue(
+ "No Exception should have been thrown",
+ result.getThrowable() instanceof IllegalArgumentException);
+ }
+
+ @Test
+ public void shouldReturnExceptionWhenErrorLoadingClass() throws Exception
+ {
+ URL url = createURL(ServletTestRunner.OUTPUT_MODE_SERIALIZED, "org.my.test", "test");
+ TestResult result = (TestResult)TestUtil.execute(url);
+
+ Assert.assertEquals(
+ "Should have returned a passed test",
+ Status.FAILED,
+ result.getStatus());
+
+ Assert.assertTrue(
+ "No Exception should have been thrown",
+ result.getThrowable() instanceof ClassNotFoundException);
+ }
+
+ private URL createBaseURL() {
+ try
+ {
+ return new URL("http", "localhost", server.getConnectors()[0].getPort(), "/");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Could not create URL", e);
+ }
+ }
+
+ private URL createURL(String outputMode, String testClass, String methodName)
+ {
+ StringBuilder url = new StringBuilder(createBaseURL().toExternalForm()).append("arquillian-protocol/");
+ boolean first = true;
+ if(outputMode != null)
+ {
+ if(first) {first = false; url.append("?"); } else { url.append("&"); }
+ url.append(ServletTestRunner.PARA_OUTPUT_MODE).append("=").append(outputMode);
+ }
+ if(testClass != null)
+ {
+ if(first) {first = false; url.append("?"); } else { url.append("&"); }
+ url.append(ServletTestRunner.PARA_CLASS_NAME).append("=").append(testClass);
+ }
+ if(methodName != null)
+ {
+ if(first) {first = false; url.append("?"); } else { url.append("&"); }
+ url.append(ServletTestRunner.PARA_METHOD_NAME).append("=").append(methodName);
+ }
+
+ try
+ {
+ return new URL(url.toString());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Could not create url", e);
+ }
+ }
+
+ public static class MockTestExecutor implements TestMethodExecutor, Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public void invoke() throws Throwable
+ {
+ }
+
+ public Method getMethod()
+ {
+ try
+ {
+ return this.getClass().getMethod("getMethod");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Could not find my own method ?? ");
+ }
+ }
+
+ public Object getInstance()
+ {
+ return this;
+ }
+ }
+}
Copied: arquillian/trunk/protocols/servlet-ee6 (from rev 4348, arquillian/trunk/protocols/servlet)
Modified: arquillian/trunk/protocols/servlet-ee6/pom.xml
===================================================================
--- arquillian/trunk/protocols/servlet/pom.xml 2010-05-04 16:43:22 UTC (rev 4348)
+++ arquillian/trunk/protocols/servlet-ee6/pom.xml 2010-05-07 10:16:11 UTC (rev 4354)
@@ -15,9 +15,9 @@
<!-- Artifact Configuration -->
<groupId>org.jboss.arquillian.protocol</groupId>
- <artifactId>arquillian-protocol-servlet</artifactId>
- <name>Arquillian Protocol Servlet</name>
- <description>Protocol handler for communicating using a servlet / http</description>
+ <artifactId>arquillian-protocol-servlet-ee6</artifactId>
+ <name>Arquillian Protocol Servlet EE6</name>
+ <description>Protocol handler for communicating using a servlet / http. JavaArchive containing web-fragment.xml</description>
<!-- Properties -->
Modified: arquillian/trunk/protocols/servlet-ee6/src/main/java/org/jboss/arquillian/protocol/servlet/ProtocolDeploymentAppender.java
===================================================================
--- arquillian/trunk/protocols/servlet/src/main/java/org/jboss/arquillian/protocol/servlet/ProtocolDeploymentAppender.java 2010-05-04 16:43:22 UTC (rev 4348)
+++ arquillian/trunk/protocols/servlet-ee6/src/main/java/org/jboss/arquillian/protocol/servlet/ProtocolDeploymentAppender.java 2010-05-07 10:16:11 UTC (rev 4354)
@@ -19,7 +19,7 @@
import org.jboss.arquillian.spi.AuxiliaryArchiveAppender;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
/**
* ProtocolDeploymentAppender
@@ -32,16 +32,17 @@
*/
public class ProtocolDeploymentAppender implements AuxiliaryArchiveAppender
{
-
+ /* (non-Javadoc)
+ * @see org.jboss.arquillian.spi.AuxiliaryArchiveAppender#createAuxiliaryArchive()
+ */
public Archive<?> createAuxiliaryArchive()
{
- WebArchive archive = ShrinkWrap.create("arquillian-protocol.war", WebArchive.class)
- .setWebXML("org/jboss/arquillian/protocol/servlet/web.xml")
+ return ShrinkWrap.create("arquillian-protocol.jar", JavaArchive.class)
.addClasses(
SecurityActions.class,
- ServletTestRunner.class
- );
- return archive;
+ ServletTestRunner.class)
+ .addManifestResource(
+ "org/jboss/arquillian/protocol/servlet/web-fragment.xml",
+ "web-fragment.xml");
}
-
-}
+}
\ No newline at end of file
Modified: arquillian/trunk/protocols/servlet-ee6/src/main/java/org/jboss/arquillian/protocol/servlet/ServletMethodExecutor.java
===================================================================
--- arquillian/trunk/protocols/servlet/src/main/java/org/jboss/arquillian/protocol/servlet/ServletMethodExecutor.java 2010-05-04 16:43:22 UTC (rev 4348)
+++ arquillian/trunk/protocols/servlet-ee6/src/main/java/org/jboss/arquillian/protocol/servlet/ServletMethodExecutor.java 2010-05-07 10:16:11 UTC (rev 4354)
@@ -48,14 +48,10 @@
}
Class<?> testClass = testMethodExecutor.getInstance().getClass();
-// String url = baseURL.toExternalForm() + "test/ArquillianServletRunner" +
-// "?outputMode=serializedObject&className=" + testClass.getName() +
-// "&methodName=" + testMethodExecutor.getMethod().getName();
+ String url = baseURL.toExternalForm() + "test/ArquillianServletRunner" +
+ "?outputMode=serializedObject&className=" + testClass.getName() +
+ "&methodName=" + testMethodExecutor.getMethod().getName();
- String url = baseURL.toExternalForm() + "arquillian-protocol/" +
- "?outputMode=serializedObject&className=" + testClass.getName() +
- "&methodName=" + testMethodExecutor.getMethod().getName();
-
try
{
return execute(url);
Deleted: arquillian/trunk/protocols/servlet-ee6/src/main/java/org/jboss/arquillian/protocol/servlet/ServletTestRunner.java
===================================================================
--- arquillian/trunk/protocols/servlet/src/main/java/org/jboss/arquillian/protocol/servlet/ServletTestRunner.java 2010-05-04 16:43:22 UTC (rev 4348)
+++ arquillian/trunk/protocols/servlet-ee6/src/main/java/org/jboss/arquillian/protocol/servlet/ServletTestRunner.java 2010-05-07 10:16:11 UTC (rev 4354)
@@ -1,178 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.arquillian.protocol.servlet;
-
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.io.PrintWriter;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.jboss.arquillian.spi.TestResult;
-import org.jboss.arquillian.spi.TestRunner;
-import org.jboss.arquillian.spi.util.TestRunners;
-
-/**
- * ServletTestRunner
- *
- * The server side executor for the Servlet protocol impl.
- *
- * Supports multiple output modes ("outputmode"):
- * - html
- * - serializedObject
- *
- * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
- * @version $Revision: $
- */
-public class ServletTestRunner extends HttpServlet
-{
- private static final long serialVersionUID = 1L;
-
- public static final String PARA_METHOD_NAME = "methodName";
- public static final String PARA_CLASS_NAME = "className";
- public static final String PARA_OUTPUT_MODE = "outputMode";
-
- public static final String OUTPUT_MODE_SERIALIZED = "serializedObject";
- public static final String OUTPUT_MODE_HTML = "html";
-
- @Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
- {
- String outputMode = OUTPUT_MODE_HTML;
- try
- {
- String className = null;
- String methodName = null;
-
- if (request.getParameter(PARA_OUTPUT_MODE) != null)
- {
- outputMode = request.getParameter(PARA_OUTPUT_MODE);
- }
- className = request.getParameter(PARA_CLASS_NAME);
- if (className == null)
- {
- throw new IllegalArgumentException(PARA_CLASS_NAME + " must be specified");
- }
- methodName = request.getParameter(PARA_METHOD_NAME);
- if ( methodName == null)
- {
- throw new IllegalArgumentException(PARA_METHOD_NAME + " must be specified");
- }
-
- Class<?> testClass = SecurityActions.getThreadContextClassLoader().loadClass(className);
-
- TestRunner runner = TestRunners.getTestRunner();
-
- TestResult testResult = runner.execute(testClass, methodName);
-
- if(OUTPUT_MODE_SERIALIZED.equalsIgnoreCase(outputMode))
- {
- writeObject(testResult, response);
- }
- else
- {
- // TODO: implement a html view of the result
- response.setContentType("text/html");
- response.setStatus(HttpServletResponse.SC_OK);
- PrintWriter writer = response.getWriter();
- writer.write("<html>\n");
- writer.write("<head><title>TCK Report</title></head>\n");
- writer.write("<body>\n");
- writer.write("<h2>Configuration</h2>\n");
- writer.write("<table>\n");
- writer.write("<tr>\n");
- writer.write("<td><b>Method</b></td><td><b>Status</b></td>\n");
- writer.write("</tr>\n");
-
- writer.write("</table>\n");
- writer.write("<h2>Tests</h2>\n");
- writer.write("<table>\n");
- writer.write("<tr>\n");
- writer.write("<td><b>Method</b></td><td><b>Status</b></td>\n");
- writer.write("</tr>\n");
-
- writer.write("</table>\n");
- writer.write("</body>\n");
- }
-
- }
- catch(Exception e)
- {
- if(OUTPUT_MODE_SERIALIZED.equalsIgnoreCase(outputMode))
- {
- writeObject(createFailedResult(e), response);
- }
- else
- {
- response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
- }
- }
- }
-
- private void writeObject(Object object, HttpServletResponse response)
- {
- try
- {
- ObjectOutputStream oos = new ObjectOutputStream(response.getOutputStream());
- oos.writeObject(object);
- response.setStatus(HttpServletResponse.SC_OK);
- oos.flush();
- oos.close();
- }
- catch (Exception e)
- {
- try
- {
- response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
- }
- catch (Exception e2)
- {
- throw new RuntimeException("Could not write to output", e2);
- }
- }
- }
-
- private TestResult createFailedResult(Throwable throwable)
- {
- return new FailedResult(throwable);
- }
-
- public static class FailedResult implements TestResult {
-
- private static final long serialVersionUID = 1L;
-
- private Throwable throwable;
-
- public FailedResult(Throwable throwable)
- {
- this.throwable = throwable;
- }
-
- public Status getStatus()
- {
- return Status.FAILED;
- }
-
- public Throwable getThrowable()
- {
- return throwable;
- }
- }
-}
Copied: arquillian/trunk/protocols/servlet-ee6/src/main/java/org/jboss/arquillian/protocol/servlet/ServletTestRunner.java (from rev 4349, arquillian/trunk/protocols/servlet/src/main/java/org/jboss/arquillian/protocol/servlet/ServletTestRunner.java)
===================================================================
--- arquillian/trunk/protocols/servlet-ee6/src/main/java/org/jboss/arquillian/protocol/servlet/ServletTestRunner.java (rev 0)
+++ arquillian/trunk/protocols/servlet-ee6/src/main/java/org/jboss/arquillian/protocol/servlet/ServletTestRunner.java 2010-05-07 10:16:11 UTC (rev 4354)
@@ -0,0 +1,157 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.protocol.servlet;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.arquillian.spi.TestResult;
+import org.jboss.arquillian.spi.TestRunner;
+import org.jboss.arquillian.spi.TestResult.Status;
+import org.jboss.arquillian.spi.util.TestRunners;
+
+/**
+ * ServletTestRunner
+ *
+ * The server side executor for the Servlet protocol impl.
+ *
+ * Supports multiple output modes ("outputmode"):
+ * - html
+ * - serializedObject
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class ServletTestRunner extends HttpServlet
+{
+ private static final long serialVersionUID = 1L;
+
+ public static final String PARA_METHOD_NAME = "methodName";
+ public static final String PARA_CLASS_NAME = "className";
+ public static final String PARA_OUTPUT_MODE = "outputMode";
+
+ public static final String OUTPUT_MODE_SERIALIZED = "serializedObject";
+ public static final String OUTPUT_MODE_HTML = "html";
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+ String outputMode = OUTPUT_MODE_HTML;
+ try
+ {
+ String className = null;
+ String methodName = null;
+
+ if (request.getParameter(PARA_OUTPUT_MODE) != null)
+ {
+ outputMode = request.getParameter(PARA_OUTPUT_MODE);
+ }
+ className = request.getParameter(PARA_CLASS_NAME);
+ if (className == null)
+ {
+ throw new IllegalArgumentException(PARA_CLASS_NAME + " must be specified");
+ }
+ methodName = request.getParameter(PARA_METHOD_NAME);
+ if ( methodName == null)
+ {
+ throw new IllegalArgumentException(PARA_METHOD_NAME + " must be specified");
+ }
+
+ Class<?> testClass = SecurityActions.getThreadContextClassLoader().loadClass(className);
+
+ TestRunner runner = TestRunners.getTestRunner();
+
+ TestResult testResult = runner.execute(testClass, methodName);
+
+ if(OUTPUT_MODE_SERIALIZED.equalsIgnoreCase(outputMode))
+ {
+ writeObject(testResult, response);
+ }
+ else
+ {
+ // TODO: implement a html view of the result
+ response.setContentType("text/html");
+ response.setStatus(HttpServletResponse.SC_OK);
+ PrintWriter writer = response.getWriter();
+ writer.write("<html>\n");
+ writer.write("<head><title>TCK Report</title></head>\n");
+ writer.write("<body>\n");
+ writer.write("<h2>Configuration</h2>\n");
+ writer.write("<table>\n");
+ writer.write("<tr>\n");
+ writer.write("<td><b>Method</b></td><td><b>Status</b></td>\n");
+ writer.write("</tr>\n");
+
+ writer.write("</table>\n");
+ writer.write("<h2>Tests</h2>\n");
+ writer.write("<table>\n");
+ writer.write("<tr>\n");
+ writer.write("<td><b>Method</b></td><td><b>Status</b></td>\n");
+ writer.write("</tr>\n");
+
+ writer.write("</table>\n");
+ writer.write("</body>\n");
+ }
+
+ }
+ catch(Exception e)
+ {
+ if(OUTPUT_MODE_SERIALIZED.equalsIgnoreCase(outputMode))
+ {
+ writeObject(createFailedResult(e), response);
+ }
+ else
+ {
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
+ }
+ }
+ }
+
+ private void writeObject(Object object, HttpServletResponse response)
+ {
+ try
+ {
+ ObjectOutputStream oos = new ObjectOutputStream(response.getOutputStream());
+ oos.writeObject(object);
+ response.setStatus(HttpServletResponse.SC_OK);
+ oos.flush();
+ oos.close();
+ }
+ catch (Exception e)
+ {
+ try
+ {
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
+ }
+ catch (Exception e2)
+ {
+ throw new RuntimeException("Could not write to output", e2);
+ }
+ }
+ }
+
+ private TestResult createFailedResult(Throwable throwable)
+ {
+ return new TestResult(Status.FAILED, throwable);
+ }
+}
Added: arquillian/trunk/protocols/servlet-ee6/src/main/resources/org/jboss/arquillian/protocol/servlet/web-fragment.xml
===================================================================
--- arquillian/trunk/protocols/servlet-ee6/src/main/resources/org/jboss/arquillian/protocol/servlet/web-fragment.xml (rev 0)
+++ arquillian/trunk/protocols/servlet-ee6/src/main/resources/org/jboss/arquillian/protocol/servlet/web-fragment.xml 2010-05-07 10:16:11 UTC (rev 4354)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-fragment version="3.0"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd">
+
+ <servlet>
+ <servlet-name>ServletTestRunner</servlet-name>
+ <servlet-class>org.jboss.arquillian.protocol.servlet.ServletTestRunner</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>ServletTestRunner</servlet-name>
+ <url-pattern>/ArquillianServletRunner</url-pattern>
+ </servlet-mapping>
+</web-fragment>
Modified: arquillian/trunk/protocols/servlet-ee6/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolDeploymentAppenderTestCase.java
===================================================================
--- arquillian/trunk/protocols/servlet/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolDeploymentAppenderTestCase.java 2010-05-04 16:43:22 UTC (rev 4348)
+++ arquillian/trunk/protocols/servlet-ee6/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolDeploymentAppenderTestCase.java 2010-05-07 10:16:11 UTC (rev 4354)
@@ -37,7 +37,7 @@
Assert.assertTrue(
"Should have added web.xml",
- archive.contains(ArchivePaths.create("WEB-INF/web.xml"))
+ archive.contains(ArchivePaths.create("META-INF/web-fragment.xml"))
);
System.out.println(archive.toString(true));
Deleted: arquillian/trunk/protocols/servlet-ee6/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolTestCase.java
===================================================================
--- arquillian/trunk/protocols/servlet/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolTestCase.java 2010-05-04 16:43:22 UTC (rev 4348)
+++ arquillian/trunk/protocols/servlet-ee6/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolTestCase.java 2010-05-07 10:16:11 UTC (rev 4354)
@@ -1,237 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.arquillian.protocol.servlet;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.net.URL;
-
-import org.jboss.arquillian.spi.TestMethodExecutor;
-import org.jboss.arquillian.spi.TestResult;
-import org.jboss.arquillian.spi.TestResult.Status;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.servlet.Context;
-
-
-/**
- * ProtocolTestCase
- *
- * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
- * @version $Revision: $
- */
- at Ignore // need to fix the javaee api dep
-public class ProtocolTestCase
-{
-
- private Server server;
-
- @Before
- public void setup() throws Exception
- {
- server = new Server(8181);
- Context root = new Context(server, "/arquillian-protocol", Context.SESSIONS);
- root.addServlet(ServletTestRunner.class, "/*");
- server.start();
- }
-
- @After
- public void cleanup() throws Exception
- {
- server.stop();
- }
-
- @Test
- public void shouldReturnTestResult() throws Exception
- {
- MockTestRunner.add(new TestResultImpl(Status.PASSED, null));
-
- ServletMethodExecutor executor = new ServletMethodExecutor(createBaseURL());
- TestResult result = executor.invoke(new MockTestExecutor());
-
- Assert.assertEquals(
- "Should have returned a passed test",
- MockTestRunner.wantedResults.get(0).getStatus(),
- result.getStatus());
-
- Assert.assertNull(
- "No Exception should have been thrown",
- result.getThrowable());
- }
-
- @Test
- public void shouldReturnThrownException() throws Exception
- {
- MockTestRunner.add(new TestResultImpl(Status.FAILED, new Exception().fillInStackTrace()));
-
- ServletMethodExecutor executor = new ServletMethodExecutor(createBaseURL());
- TestResult result = executor.invoke(new MockTestExecutor());
-
- Assert.assertEquals(
- "Should have returned a passed test",
- MockTestRunner.wantedResults.get(0).getStatus(),
- result.getStatus());
-
- Assert.assertNotNull(
- "No Exception should have been thrown",
- result.getThrowable());
-
- }
-
- @Test
- public void shouldReturnExceptionWhenMissingTestClassParameter() throws Exception
- {
- URL url = createURL(ServletTestRunner.OUTPUT_MODE_SERIALIZED, null, null);
- TestResult result = (TestResult)TestUtil.execute(url);
-
- Assert.assertEquals(
- "Should have returned a passed test",
- Status.FAILED,
- result.getStatus());
-
- Assert.assertTrue(
- "No Exception should have been thrown",
- result.getThrowable() instanceof IllegalArgumentException);
- }
-
- @Test
- public void shouldReturnExceptionWhenMissingMethodParameter() throws Exception
- {
- URL url = createURL(ServletTestRunner.OUTPUT_MODE_SERIALIZED, "org.my.test", null);
- TestResult result = (TestResult)TestUtil.execute(url);
-
- Assert.assertEquals(
- "Should have returned a passed test",
- Status.FAILED,
- result.getStatus());
-
- Assert.assertTrue(
- "No Exception should have been thrown",
- result.getThrowable() instanceof IllegalArgumentException);
- }
-
- @Test
- public void shouldReturnExceptionWhenErrorLoadingClass() throws Exception
- {
- URL url = createURL(ServletTestRunner.OUTPUT_MODE_SERIALIZED, "org.my.test", "test");
- TestResult result = (TestResult)TestUtil.execute(url);
-
- Assert.assertEquals(
- "Should have returned a passed test",
- Status.FAILED,
- result.getStatus());
-
- Assert.assertTrue(
- "No Exception should have been thrown",
- result.getThrowable() instanceof ClassNotFoundException);
- }
-
- private URL createBaseURL() {
- try
- {
- return new URL("http", "localhost", server.getConnectors()[0].getPort(), "/");
- }
- catch (Exception e)
- {
- throw new RuntimeException("Could not create URL", e);
- }
- }
-
- private URL createURL(String outputMode, String testClass, String methodName)
- {
- StringBuilder url = new StringBuilder(createBaseURL().toExternalForm()).append("arquillian-protocol/");
- boolean first = true;
- if(outputMode != null)
- {
- if(first) {first = false; url.append("?"); } else { url.append("&"); }
- url.append(ServletTestRunner.PARA_OUTPUT_MODE).append("=").append(outputMode);
- }
- if(testClass != null)
- {
- if(first) {first = false; url.append("?"); } else { url.append("&"); }
- url.append(ServletTestRunner.PARA_CLASS_NAME).append("=").append(testClass);
- }
- if(methodName != null)
- {
- if(first) {first = false; url.append("?"); } else { url.append("&"); }
- url.append(ServletTestRunner.PARA_METHOD_NAME).append("=").append(methodName);
- }
-
- try
- {
- return new URL(url.toString());
- }
- catch (Exception e)
- {
- throw new RuntimeException("Could not create url", e);
- }
- }
-
- public static class TestResultImpl implements TestResult {
-
- private static final long serialVersionUID = 1L;
-
- private Status status;
- private Throwable throwable;
-
- public TestResultImpl(Status status, Throwable throwable)
- {
- this.status = status;
- this.throwable = throwable;
- }
-
- public Status getStatus()
- {
- return status;
- }
-
- public Throwable getThrowable()
- {
- return throwable;
- }
- }
-
- public static class MockTestExecutor implements TestMethodExecutor, Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public void invoke() throws Throwable
- {
- }
-
- public Method getMethod()
- {
- try
- {
- return this.getClass().getMethod("getMethod");
- }
- catch (Exception e)
- {
- throw new RuntimeException("Could not find my own method ?? ");
- }
- }
-
- public Object getInstance()
- {
- return this;
- }
- }
-}
Copied: arquillian/trunk/protocols/servlet-ee6/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolTestCase.java (from rev 4349, arquillian/trunk/protocols/servlet/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolTestCase.java)
===================================================================
--- arquillian/trunk/protocols/servlet-ee6/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolTestCase.java (rev 0)
+++ arquillian/trunk/protocols/servlet-ee6/src/test/java/org/jboss/arquillian/protocol/servlet/ProtocolTestCase.java 2010-05-07 10:16:11 UTC (rev 4354)
@@ -0,0 +1,213 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.protocol.servlet;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.net.URL;
+
+import org.jboss.arquillian.spi.TestMethodExecutor;
+import org.jboss.arquillian.spi.TestResult;
+import org.jboss.arquillian.spi.TestResult.Status;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.servlet.Context;
+
+
+/**
+ * ProtocolTestCase
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ at Ignore // need to fix the javaee api dep
+public class ProtocolTestCase
+{
+
+ private Server server;
+
+ @Before
+ public void setup() throws Exception
+ {
+ server = new Server(8181);
+ Context root = new Context(server, "/arquillian-protocol", Context.SESSIONS);
+ root.addServlet(ServletTestRunner.class, "/*");
+ server.start();
+ }
+
+ @After
+ public void cleanup() throws Exception
+ {
+ server.stop();
+ }
+
+ @Test
+ public void shouldReturnTestResult() throws Exception
+ {
+ MockTestRunner.add(new TestResult(Status.PASSED, null));
+
+ ServletMethodExecutor executor = new ServletMethodExecutor(createBaseURL());
+ TestResult result = executor.invoke(new MockTestExecutor());
+
+ Assert.assertEquals(
+ "Should have returned a passed test",
+ MockTestRunner.wantedResults.get(0).getStatus(),
+ result.getStatus());
+
+ Assert.assertNull(
+ "No Exception should have been thrown",
+ result.getThrowable());
+ }
+
+ @Test
+ public void shouldReturnThrownException() throws Exception
+ {
+ MockTestRunner.add(new TestResult(Status.FAILED, new Exception().fillInStackTrace()));
+
+ ServletMethodExecutor executor = new ServletMethodExecutor(createBaseURL());
+ TestResult result = executor.invoke(new MockTestExecutor());
+
+ Assert.assertEquals(
+ "Should have returned a passed test",
+ MockTestRunner.wantedResults.get(0).getStatus(),
+ result.getStatus());
+
+ Assert.assertNotNull(
+ "No Exception should have been thrown",
+ result.getThrowable());
+
+ }
+
+ @Test
+ public void shouldReturnExceptionWhenMissingTestClassParameter() throws Exception
+ {
+ URL url = createURL(ServletTestRunner.OUTPUT_MODE_SERIALIZED, null, null);
+ TestResult result = (TestResult)TestUtil.execute(url);
+
+ Assert.assertEquals(
+ "Should have returned a passed test",
+ Status.FAILED,
+ result.getStatus());
+
+ Assert.assertTrue(
+ "No Exception should have been thrown",
+ result.getThrowable() instanceof IllegalArgumentException);
+ }
+
+ @Test
+ public void shouldReturnExceptionWhenMissingMethodParameter() throws Exception
+ {
+ URL url = createURL(ServletTestRunner.OUTPUT_MODE_SERIALIZED, "org.my.test", null);
+ TestResult result = (TestResult)TestUtil.execute(url);
+
+ Assert.assertEquals(
+ "Should have returned a passed test",
+ Status.FAILED,
+ result.getStatus());
+
+ Assert.assertTrue(
+ "No Exception should have been thrown",
+ result.getThrowable() instanceof IllegalArgumentException);
+ }
+
+ @Test
+ public void shouldReturnExceptionWhenErrorLoadingClass() throws Exception
+ {
+ URL url = createURL(ServletTestRunner.OUTPUT_MODE_SERIALIZED, "org.my.test", "test");
+ TestResult result = (TestResult)TestUtil.execute(url);
+
+ Assert.assertEquals(
+ "Should have returned a passed test",
+ Status.FAILED,
+ result.getStatus());
+
+ Assert.assertTrue(
+ "No Exception should have been thrown",
+ result.getThrowable() instanceof ClassNotFoundException);
+ }
+
+ private URL createBaseURL() {
+ try
+ {
+ return new URL("http", "localhost", server.getConnectors()[0].getPort(), "/");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Could not create URL", e);
+ }
+ }
+
+ private URL createURL(String outputMode, String testClass, String methodName)
+ {
+ StringBuilder url = new StringBuilder(createBaseURL().toExternalForm()).append("arquillian-protocol/");
+ boolean first = true;
+ if(outputMode != null)
+ {
+ if(first) {first = false; url.append("?"); } else { url.append("&"); }
+ url.append(ServletTestRunner.PARA_OUTPUT_MODE).append("=").append(outputMode);
+ }
+ if(testClass != null)
+ {
+ if(first) {first = false; url.append("?"); } else { url.append("&"); }
+ url.append(ServletTestRunner.PARA_CLASS_NAME).append("=").append(testClass);
+ }
+ if(methodName != null)
+ {
+ if(first) {first = false; url.append("?"); } else { url.append("&"); }
+ url.append(ServletTestRunner.PARA_METHOD_NAME).append("=").append(methodName);
+ }
+
+ try
+ {
+ return new URL(url.toString());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Could not create url", e);
+ }
+ }
+
+ public static class MockTestExecutor implements TestMethodExecutor, Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public void invoke() throws Throwable
+ {
+ }
+
+ public Method getMethod()
+ {
+ try
+ {
+ return this.getClass().getMethod("getMethod");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Could not find my own method ?? ");
+ }
+ }
+
+ public Object getInstance()
+ {
+ return this;
+ }
+ }
+}
More information about the jboss-svn-commits
mailing list