Author: pete.muir(a)jboss.org
Date: 2009-04-08 10:25:55 -0400 (Wed, 08 Apr 2009)
New Revision: 2351
Added:
test-harness/trunk/tomcat/
test-harness/trunk/tomcat/pom.xml
test-harness/trunk/tomcat/src/
test-harness/trunk/tomcat/src/main/
test-harness/trunk/tomcat/src/main/java/
test-harness/trunk/tomcat/src/main/java/org/
test-harness/trunk/tomcat/src/main/java/org/jboss/
test-harness/trunk/tomcat/src/main/java/org/jboss/testharness/
test-harness/trunk/tomcat/src/main/java/org/jboss/testharness/integration/
test-harness/trunk/tomcat/src/main/java/org/jboss/testharness/integration/tomcat/
test-harness/trunk/tomcat/src/main/java/org/jboss/testharness/integration/tomcat/TomcatConnector.java
test-harness/trunk/tomcat/src/main/resources/
test-harness/trunk/tomcat/src/main/resources/META-INF/
test-harness/trunk/tomcat/src/main/resources/META-INF/jboss-test-harness.properties
test-harness/trunk/tomcat/src/main/resources/log4j.xml
test-harness/trunk/tomcat/src/test/
test-harness/trunk/tomcat/src/test/debug-resources/
test-harness/trunk/tomcat/src/test/debug-resources/META-INF/
test-harness/trunk/tomcat/src/test/debug-resources/META-INF/web-beans-tck.properties
test-harness/trunk/tomcat/src/test/java/
test-harness/trunk/tomcat/src/test/resources/
Modified:
test-harness/trunk/api/src/main/java/org/jboss/testharness/spi/helpers/AbstractContainerConnector.java
test-harness/trunk/pom.xml
Log:
add tomcat connector - untested
Modified:
test-harness/trunk/api/src/main/java/org/jboss/testharness/spi/helpers/AbstractContainerConnector.java
===================================================================
---
test-harness/trunk/api/src/main/java/org/jboss/testharness/spi/helpers/AbstractContainerConnector.java 2009-04-08
14:11:07 UTC (rev 2350)
+++
test-harness/trunk/api/src/main/java/org/jboss/testharness/spi/helpers/AbstractContainerConnector.java 2009-04-08
14:25:55 UTC (rev 2351)
@@ -53,18 +53,31 @@
OutputStream os = new FileOutputStream(file);
try
{
- byte[] buf = new byte[1024];
- int i = 0;
- while ((i = inputStream.read(buf)) != -1)
- {
- os.write(buf, 0, i);
- }
- }
- finally
- {
+ copy(inputStream, os);
+ }
+ finally
+ {
os.close();
- }
+ }
}
+
+ public static void copy(InputStream source, OutputStream destination) throws
IOException
+ {
+ if (source == null)
+ {
+ throw new IllegalArgumentException("source cannot be null");
+ }
+ if (destination == null)
+ {
+ throw new IllegalArgumentException("destination cannot be null");
+ }
+ byte[] readBuffer = new byte[2156];
+ int bytesIn = 0;
+ while((bytesIn = source.read(readBuffer)) != -1)
+ {
+ destination.write(readBuffer, 0, bytesIn);
+ }
+ }
public AbstractContainerConnector() throws IOException
{
Modified: test-harness/trunk/pom.xml
===================================================================
--- test-harness/trunk/pom.xml 2009-04-08 14:11:07 UTC (rev 2350)
+++ test-harness/trunk/pom.xml 2009-04-08 14:25:55 UTC (rev 2351)
@@ -44,6 +44,7 @@
<module>impl</module>
<module>tests</module>
<module>jboss</module>
+ <module>tomcat</module>
</modules>
<dependencyManagement>
@@ -117,6 +118,12 @@
<version>5.0.1.GA</version>
<type>pom</type>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>catalina</artifactId>
+ <version>6.0.18</version>
+ </dependency>
</dependencies>
</dependencyManagement>
Added: test-harness/trunk/tomcat/pom.xml
===================================================================
--- test-harness/trunk/tomcat/pom.xml (rev 0)
+++ test-harness/trunk/tomcat/pom.xml 2009-04-08 14:25:55 UTC (rev 2351)
@@ -0,0 +1,33 @@
+<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>
+ <artifactId>jboss-test-harness-parent</artifactId>
+ <groupId>org.jboss.test-harness</groupId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.test-harness</groupId>
+ <artifactId>jboss-test-harness-tomcat</artifactId>
+ <name>JBoss Test Harness deployment for Apache Tomcat</name>
+ <description>Implements the JBoss Test Harness deployment SPI for Apache
Tomcat</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jboss.test-harness</groupId>
+ <artifactId>jboss-test-harness-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>catalina</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+
+ </dependencies>
+
+</project>
Added:
test-harness/trunk/tomcat/src/main/java/org/jboss/testharness/integration/tomcat/TomcatConnector.java
===================================================================
---
test-harness/trunk/tomcat/src/main/java/org/jboss/testharness/integration/tomcat/TomcatConnector.java
(rev 0)
+++
test-harness/trunk/tomcat/src/main/java/org/jboss/testharness/integration/tomcat/TomcatConnector.java 2009-04-08
14:25:55 UTC (rev 2351)
@@ -0,0 +1,122 @@
+package org.jboss.testharness.integration.tomcat;
+
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.jboss.testharness.api.DeploymentException;
+import org.jboss.testharness.spi.Containers;
+import org.jboss.testharness.spi.helpers.AbstractContainerConnector;
+
+/**
+ *
+ * @author jeffgenender
+ * @author Pete Muir
+ *
+ */
+public class TomcatConnector extends AbstractContainerConnector implements Containers
+{
+
+ private static final String SERVER_HOME_PROPERTY_NAME = "tomcat.home";
+
+ private String binDirectory;
+ private final File tmpdir;
+
+ public TomcatConnector() throws IOException
+ {
+ tmpdir = new File(System.getProperty("java.io.tmpdir"),
"org.jboss.webbeans.tck.integration.jbossas");
+ tmpdir.mkdir();
+ tmpdir.deleteOnExit();
+ }
+
+ @Override
+ protected String getServerHomePropertyName()
+ {
+ return SERVER_HOME_PROPERTY_NAME;
+ }
+
+ protected void shutdownServer() throws IOException
+ {
+ launch(getBinDirectory(), "shutdown", "");
+ }
+
+ @Override
+ protected void startServer() throws IOException
+ {
+ launch(getBinDirectory(), "startup", "");
+ }
+
+ protected String getBinDirectory()
+ {
+ if (binDirectory == null)
+ {
+ binDirectory = new File(getServerDirectory() + "/bin").getPath();
+ }
+ return binDirectory;
+ }
+
+ @Override
+ protected String getLogName()
+ {
+ return "tomcat.log";
+ }
+
+ public void deploy(InputStream stream, String name) throws DeploymentException,
IOException
+ {
+ String deployUrl = getManagerUrl("deploy", "path=/" + name,
"update=true");
+ URLConnection connection = new URL(deployUrl).openConnection();
+ if (!(connection instanceof HttpURLConnection))
+ {
+ throw new IllegalStateException("Not an http connection! " +
connection);
+ }
+ HttpURLConnection httpConnection = (HttpURLConnection) connection;
+ httpConnection.setRequestMethod("PUT");
+ httpConnection.connect();
+ copy(stream, httpConnection.getOutputStream());
+ httpConnection.disconnect();
+ if (httpConnection.getResponseCode() != HttpURLConnection.HTTP_OK)
+ {
+ throw new DeploymentException(httpConnection.getResponseMessage());
+ }
+ }
+
+ public void undeploy(String name) throws IOException
+ {
+ String deployUrl = getManagerUrl("undeploy", "path=/" + name);
+ URLConnection connection = new URL(deployUrl).openConnection();
+ if (!(connection instanceof HttpURLConnection))
+ {
+ throw new IllegalStateException("Not an http connection! " +
connection);
+ }
+ HttpURLConnection httpConnection = (HttpURLConnection) connection;
+ httpConnection.connect();
+ httpConnection.disconnect();
+ if (httpConnection.getResponseCode() != HttpURLConnection.HTTP_OK)
+ {
+ throw new IllegalStateException("Error undeploying app " +
httpConnection.getResponseMessage());
+ }
+ }
+
+ protected String getManagerUrl(String command, String... parameters)
+ {
+ String url = getHttpUrl() + "manager/" + command ;
+ for (int i = 0; i < parameters.length; i ++)
+ {
+ String parameter = parameters[i];
+ if (i == 0)
+ {
+ url += "?" + parameter;
+ }
+ else
+ {
+ url += "&" + parameter;
+ }
+ }
+ return url;
+ }
+
+}
\ No newline at end of file
Added:
test-harness/trunk/tomcat/src/main/resources/META-INF/jboss-test-harness.properties
===================================================================
--- test-harness/trunk/tomcat/src/main/resources/META-INF/jboss-test-harness.properties
(rev 0)
+++
test-harness/trunk/tomcat/src/main/resources/META-INF/jboss-test-harness.properties 2009-04-08
14:25:55 UTC (rev 2351)
@@ -0,0 +1 @@
+org.jboss.testharness.spi.Containers=org.jboss.testharness.integration.tomcat.TomcatConnector
Added: test-harness/trunk/tomcat/src/main/resources/log4j.xml
===================================================================
--- test-harness/trunk/tomcat/src/main/resources/log4j.xml (rev
0)
+++ test-harness/trunk/tomcat/src/main/resources/log4j.xml 2009-04-08 14:25:55 UTC (rev
2351)
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE
log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration
xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="false">
+
+ <appender name="CONSOLE"
class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p
[%c{2}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ############### JBoss ################# -->
+ <category name="org.jboss">
+ <priority value="ERROR"/>
+ </category>
+
+ <category name="org.jboss.test">
+ <priority value="ERROR"/>
+ </category>
+
+ <category name="com.arjuna">
+ <priority value="ERROR"/>
+ </category>
+
+ <!-- ############### Hibernate logging ################# -->
+
+ <category name="org.hibernate">
+ <priority value="ERROR"/>
+ </category>
+
+ <!--
+ <category name="org.hibernate.SQL">
+ <priority value="TRACE"/>
+ </category>
+
+ <category name="org.hibernate.type">
+ <priority value="TRACE"/>
+ </category>
+
+ <category name="org.hibernate.loader">
+ <priority value="TRACE"/>
+ </category>
+ <category name="org.hibernate.cache">
+ <priority value="TRACE"/>
+ </category>
+ -->
+
+ <category name="org.jboss.testharness">
+ <priority value="INFO"/>
+ </category>
+
+ <root>
+ <priority value="INFO"/>
+ <appender-ref ref="CONSOLE"/>
+ </root>
+
+</log4j:configuration>
Added:
test-harness/trunk/tomcat/src/test/debug-resources/META-INF/web-beans-tck.properties
===================================================================
--- test-harness/trunk/tomcat/src/test/debug-resources/META-INF/web-beans-tck.properties
(rev 0)
+++
test-harness/trunk/tomcat/src/test/debug-resources/META-INF/web-beans-tck.properties 2009-04-08
14:25:55 UTC (rev 2351)
@@ -0,0 +1,7 @@
+# Configuration for running incontainer tests from your IDE
+# Alter the path webbeans accordingly (relative from the tck/impl dir)
+org.jboss.testharness.standalone=false
+jboss-as.dir=../../webbeans/jboss-as
+jboss.force.restart=false
+org.jboss.testharness.libraryDirectory=../../webbeans/jboss-tck-runner/target/dependency/lib
+org.jboss.testharness.runIntegrationTests=true
\ No newline at end of file