Author: julien(a)jboss.com
Date: 2007-10-08 12:09:32 -0400 (Mon, 08 Oct 2007)
New Revision: 8564
Added:
modules/test/trunk/remote/
modules/test/trunk/remote/build.bat
modules/test/trunk/remote/build.sh
modules/test/trunk/remote/build.xml
modules/test/trunk/remote/src/
modules/test/trunk/remote/src/main/
modules/test/trunk/remote/src/main/org/
modules/test/trunk/remote/src/main/org/jboss/
modules/test/trunk/remote/src/main/org/jboss/test/
modules/test/trunk/remote/src/main/org/jboss/test/AllTests.java
modules/test/trunk/remote/src/main/org/jboss/unit/
modules/test/trunk/remote/src/main/org/jboss/unit/remote/
modules/test/trunk/remote/src/main/org/jboss/unit/remote/RequestContext.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/ResponseContext.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/ProtocolHandler.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteDriverCommandContext.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteDriverResponseContext.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteTestDriver.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/TestConversation.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/deployer/
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/
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/deployer/response/DeployResponse.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/deployer/response/UndeployResponse.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/
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/HTTPHandler.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/command/
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/command/DoGetCommand.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/command/DoMethodCommand.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/command/DoPostCommand.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/
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/InvokeGetResponse.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/response/InvokeMethodResponse.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/response/InvokePostResponse.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/server/
modules/test/trunk/remote/src/main/org/jboss/unit/remote/server/Node.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/server/NodeId.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/server/NodeManager.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/server/ServiceLookup.java
modules/test/trunk/remote/src/main/org/jboss/unit/remote/server/ServiceLookupFailedException.java
modules/test/trunk/remote/src/resources/
Log:
reimported remote as an extension of jboss unit
Added: modules/test/trunk/remote/build.bat
===================================================================
--- modules/test/trunk/remote/build.bat (rev 0)
+++ modules/test/trunk/remote/build.bat 2007-10-08 16:09:32 UTC (rev 8564)
@@ -0,0 +1,54 @@
+@echo off
+rem
+rem Invokes a script of the same name in the 'tools' module.
+rem
+rem The 'tools' module is expected to be a peer directory of the directory
+rem in which this script lives.
+rem
+rem @author Jason Dillon <jason(a)planet57.com>
+rem
+
+rem $Id: build.bat 1829 2006-03-05 13:20:08Z julien $
+
+setlocal
+
+set PROGNAME=%~nx0
+set DIRNAME=%~dp0
+
+rem Legacy shell support
+if x%PROGNAME%==x set PROGNAME=build.bat
+if x%DIRNAME%==x set DIRNAME=.\
+
+set MODULE_ROOT=%DIRNAME%
+if x%TOOLS_ROOT%==x set TOOLS_ROOT=%DIRNAME%..\tools
+set TARGET=%TOOLS_ROOT%\bin\build.bat
+set ARGS=%*
+
+rem Start'er up yo
+goto main
+
+:debug
+if not x%DEBUG%==x echo %PROGNAME%: %*
+goto :EOF
+
+:main
+call :debug PROGNAME=%PROGNAME%
+call :debug DIRNAME=%DIRNAME%
+call :debug TOOLS_ROOT=%TOOLS_ROOT%
+call :debug TARGET=%TARGET%
+
+if exist %TARGET% call :call-script & goto :EOF
+rem else fail, we can not go on
+
+echo %PROGNAME%: *ERROR* The target executable does not exist:
+echo %PROGNAME%:
+echo %PROGNAME%: %TARGET%
+echo %PROGNAME%:
+echo %PROGNAME%: Please make sure you have checked out the 'tools' module
+echo %PROGNAME%: and make sure it is up to date.
+goto :EOF
+
+:call-script
+call :debug Executing %TARGET% %ARGS%
+call %TARGET% %ARGS%
+goto :EOF
Property changes on: modules/test/trunk/remote/build.bat
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/test/trunk/remote/build.sh
===================================================================
--- modules/test/trunk/remote/build.sh (rev 0)
+++ modules/test/trunk/remote/build.sh 2007-10-08 16:09:32 UTC (rev 8564)
@@ -0,0 +1,49 @@
+#!/bin/sh
+##
+## Invokes a script of the same name in the 'tools' module.
+##
+## The 'tools' module is expected to be a peer directory of the directory
+## in which this script lives.
+##
+## @author Jason Dillon <jason(a)planet57.com>
+##
+
+# $Id: build.sh 1829 2006-03-05 13:20:08Z julien $
+
+PROGNAME=`basename $0`
+DIRNAME=`dirname $0`
+
+# Buss it yo
+main() {
+ if [ "x$TOOLS_ROOT" = "x" ]; then
+ TOOLS_ROOT=`cd $DIRNAME/../tools && pwd`
+ fi
+
+ MODULE_ROOT=`cd $DIRNAME; pwd`
+ export TOOLS_ROOT MODULE_ROOT DEBUG TRACE
+
+ # Where is the target script?
+ target="$TOOLS_ROOT/bin/$PROGNAME"
+ if [ ! -f "$target" ]; then
+ echo "${PROGNAME}: *ERROR* The target executable does not exist:"
+ echo "${PROGNAME}:"
+ echo "${PROGNAME}: $target"
+ echo "${PROGNAME}:"
+ echo "${PROGNAME}: Please make sure you have checked out the 'tools'
module"
+ echo "${PROGNAME}: and make sure it is up to date."
+ exit 2
+ fi
+
+ # Get busy yo!
+ if [ "x$DEBUG" != "x" ]; then
+ echo "${PROGNAME}: Executing: /bin/sh $target $@"
+ fi
+ if [ "x$TRACE" = "x" ]; then
+ exec /bin/sh $target "$@"
+ else
+ exec /bin/sh -x $target "$@"
+ fi
+}
+
+# Lets get ready to rumble!
+main "$@"
Property changes on: modules/test/trunk/remote/build.sh
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/test/trunk/remote/build.xml
===================================================================
--- modules/test/trunk/remote/build.xml (rev 0)
+++ modules/test/trunk/remote/build.xml 2007-10-08 16:09:32 UTC (rev 8564)
@@ -0,0 +1,210 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE project [
+ <!ENTITY buildmagic SYSTEM
"../tools/etc/buildfragments/buildmagic.ent">
+ <!ENTITY tools SYSTEM "../tools/etc/buildfragments/tools.ent">
+ <!ENTITY libraries SYSTEM "../thirdparty/libraries.ent">
+ <!ENTITY modules SYSTEM "../tools/etc/buildfragments/modules.ent">
+ <!ENTITY defaults SYSTEM
"../tools/etc/buildfragments/defaults.ent">
+ <!ENTITY targets SYSTEM "../tools/etc/buildfragments/targets.ent">
+ ]>
+
+<!-- $Id: build.xml 7954 2007-08-16 14:51:00Z julien(a)jboss.com $ -->
+
+<!--+======================================================================+-->
+<!--| JBoss Portal (The OpenSource Portal) Build File |-->
+<!--| |-->
+<!--| Distributable under LGPL license. |-->
+<!--| See terms of license at
http://www.gnu.org. |-->
+<!--| |-->
+<!--| This file has been designed to work with the 'tools' module and
|-->
+<!--| Buildmagic extentions. |-->
+<!--+======================================================================+-->
+
+<project default="main" name="JBoss Portal">
+
+ <!--+====================================================================+-->
+ <!--| Setup |-->
+ <!--| |-->
+ <!--| Include the common build elements. |-->
+ <!--| |-->
+ <!--| This defines several different targets, properties and paths. |-->
+ <!--| It also sets up the basic extention tasks amoung other things. |-->
+ <!--+====================================================================+-->
+
+ &buildmagic;
+ &modules;
+ &defaults;
+ &tools;
+ &targets;
+
+
+ <!-- ================================================================== -->
+ <!-- Initialization -->
+ <!-- ================================================================== -->
+
+ <!--
+ | Initialize the build system. Must depend on '_buildmagic:init'.
+ | Other targets should depend on 'init' or things will mysteriously fail.
+ -->
+
+ <target name="init" unless="init.disable"
depends="_buildmagic:init">
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Configuration |-->
+ <!--| |-->
+ <!--| This target is invoked by the Buildmagic initialization logic |-->
+ <!--| and should contain module specific configuration elements. |-->
+ <!--+====================================================================+-->
+
+ <target name="configure" unless="configure.disable">
+
+ <!-- Configure thirdparty libraries -->
+ &libraries;
+ <path id="library.classpath">
+ <path refid="jboss.portal/modules/common.classpath"/>
+ <path refid="apache.httpclient.classpath"/>
+ <path refid="apache.codec.classpath"/>
+ <path refid="apache.logging.classpath"/>
+ <path refid="apache.log4j.classpath"/>
+ </path>
+
+ <!-- Configure modules -->
+ <call target="configure-modules"/>
+ <path id="dependentmodule.classpath">
+ <path refid="portal.test.classpath"/>
+ <path refid="jboss.unit.classpath"/>
+ </path>
+
+ <!--+=======================================+-->
+ <!--| Override any default properties here. |-->
+ <!--+=======================================+-->
+
+ <!--+=======================================+-->
+ <!--| Define module specific elements here. |-->
+ <!--+=======================================+-->
+ <property name="javadoc.private" value="false"/>
+ <property name="javadoc.protected" value="false"/>
+ <property name="javadoc.packages"
value="org.jboss.unit.*"/>
+
+ <!-- Configure defaults & build tools -->
+ <call target="configure-defaults"/>
+ <call target="configure-tools"/>
+
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Compile |-->
+ <!--| |-->
+ <!--| This target should depend on other compile-* targets for each |-->
+ <!--| different type of compile that needs to be performed, short of |-->
+ <!--| documentation compiles. |-->
+ <!--+====================================================================+-->
+
+ <target name="compile"
+ description="Compile all source files."
+ depends="_default:compile-classes,
+ _default:compile-etc,
+ _default:compile-resources">
+ <!-- Add module specific elements here. -->
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Generate Output |-->
+ <!--| |-->
+ <!--| Generates the target output for this module. Target output is |-->
+ <!--| the output which is ment to be released or used by external |-->
+ <!--| modules. |-->
+ <!--+====================================================================+-->
+
+ <target name="output"
+ description="Generate all target output."
+ depends="compile">
+
+ <mkdir dir="${build.lib}"/>
+
+<!--
+ <jar jarfile="${build.lib}/jboss-unit-lib.jar">
+ <fileset dir="${build.classes}">
+ <exclude name="org/jboss/test/**"/>
+ </fileset>
+ <fileset dir="${build.resources}/jboss-unit-jar"/>
+ </jar>
+
+ <jar jarfile="${build.lib}/jboss-unit-test.jar">
+ <fileset dir="${build.classes}">
+ <exclude name="org/jboss/unit/**"/>
+ </fileset>
+ </jar>
+-->
+
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Cleaning -->
+ <!-- ================================================================== -->
+
+ <!-- Clean up all build output -->
+ <target name="clean" depends="_default:clean">
+ <!-- Add module specific elements here. -->
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Documents |-->
+ <!--| |-->
+ <!--| Generate all documentation for this module. |-->
+ <!--+====================================================================+-->
+
+ <target name="docs" depends="_default:docs">
+ <!-- Add module specific elements here. -->
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Misc. -->
+ <!-- ================================================================== -->
+
+ <target name="main" depends="most"/>
+ <target name="all" depends="_default:all"/>
+ <target name="most" depends="_default:most"/>
+ <target name="help" depends="_default:help"/>
+
+ <target name="test" depends="output">
+
+ <java classname="org.jboss.test.unit.AllTests"
fork="true">
+<!--
+ <jvmarg value="-Xdebug"/>
+ <jvmarg
value="-Xrunjdwp:transport=dt_socket,address=7878,server=y,suspend=y"/>
+-->
+ <classpath>
+ <path location="${build.lib}/jboss-unit-lib.jar"/>
+ <path location="${build.lib}/jboss-unit-test.jar"/>
+ <path location="${build.resources}/test"/>
+ </classpath>
+ </java>
+
+ </target>
+
+</project>
Property changes on: modules/test/trunk/remote/build.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/test/trunk/remote/src/main/org/jboss/test/AllTests.java
===================================================================
--- modules/test/trunk/remote/src/main/org/jboss/test/AllTests.java
(rev 0)
+++ modules/test/trunk/remote/src/main/org/jboss/test/AllTests.java 2007-10-08 16:09:32
UTC (rev 8564)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * 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.test;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class AllTests
+{
+
+ public static void main(String[] args)
+ {
+
+ }
+
+}
Added: modules/test/trunk/remote/src/main/org/jboss/unit/remote/RequestContext.java
===================================================================
--- modules/test/trunk/remote/src/main/org/jboss/unit/remote/RequestContext.java
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/RequestContext.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * 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.remote;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class RequestContext implements Serializable
+{
+
+ /** The phase count. */
+ protected int requestCount; // todo rename to phase count
+
+ /** The parametrization. */
+ protected Map<String, String> parametrization;
+
+ /** The payload. */
+ protected Map<String, Serializable> payload;
+
+ public RequestContext(int requestCount, Map<String, String> parametrization,
Map<String, Serializable> payload)
+ {
+ this.requestCount = requestCount;
+ this.parametrization = parametrization;
+ this.payload = payload;
+ }
+}
Added: modules/test/trunk/remote/src/main/org/jboss/unit/remote/ResponseContext.java
===================================================================
--- modules/test/trunk/remote/src/main/org/jboss/unit/remote/ResponseContext.java
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/ResponseContext.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -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.remote;
+
+import org.jboss.unit.driver.DriverResponse;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ResponseContext
+{
+
+ /** The test response. */
+ protected DriverResponse response;
+
+ /** The payload. */
+ protected Map<String, Serializable> payload;
+
+ public ResponseContext(DriverResponse response, Map<String, Serializable>
payload)
+ {
+ this.response = response;
+ this.payload = payload;
+ }
+
+ public DriverResponse getResponse()
+ {
+ return response;
+ }
+
+ public Map<String, Serializable> getPayload()
+ {
+ return payload;
+ }
+}
Added:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/ProtocolHandler.java
===================================================================
--- modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/ProtocolHandler.java
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/ProtocolHandler.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * 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.remote.driver;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ProtocolHandler
+{
+
+ RemoteDriverCommandContext handleResponse(TestConversation testConversation,
RemoteDriverResponseContext responseContext);
+
+ RemoteDriverResponseContext handleCommand(TestConversation conversation,
RemoteDriverCommandContext commandContext) throws Exception;
+}
Added:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteDriverCommandContext.java
===================================================================
---
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteDriverCommandContext.java
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteDriverCommandContext.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,113 @@
+/******************************************************************************
+ * 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.remote.driver;
+
+import org.jboss.unit.driver.DriverCommand;
+import org.jboss.unit.driver.DriverResponse;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class RemoteDriverCommandContext
+{
+
+ /** The previous response if not null. */
+ private RemoteDriverResponseContext responseContext;
+
+ /** . */
+ private final int requestCount;
+
+ /** The command to invoke. */
+ private DriverCommand command;
+
+ /** . */
+ private final Map<String, Serializable> payload;
+
+ public RemoteDriverCommandContext(RemoteDriverResponseContext responseContext,
DriverCommand command)
+ {
+ this.responseContext = responseContext;
+ this.requestCount = responseContext.getCommandContext().requestCount + 1;
+ this.command = command;
+ this.payload = new HashMap<String,
Serializable>(responseContext.getPayload());
+ }
+
+ public RemoteDriverCommandContext(DriverCommand command)
+ {
+ this.responseContext = null;
+ this.requestCount = -1;
+ this.command = command;
+ this.payload = new HashMap<String, Serializable>();
+ }
+
+ public RemoteDriverCommandContext(RemoteDriverCommandContext commandContext,
DriverCommand command)
+ {
+ Map<String, Serializable> payload = commandContext.responseContext != null ?
new HashMap<String, Serializable>(commandContext.responseContext.getPayload()) : new
HashMap<String, Serializable>();
+
+ //
+ this.responseContext = commandContext.responseContext;
+ this.requestCount = commandContext.requestCount + 1;
+ this.command = command;
+ this.payload = payload;
+ }
+
+ public RemoteDriverCommandContext(RemoteDriverCommandContext commandContext)
+ {
+ Map<String, Serializable> payload = commandContext.responseContext != null ?
new HashMap<String, Serializable>(commandContext.responseContext.getPayload()) : new
HashMap<String, Serializable>();
+
+ //
+ this.responseContext = commandContext.responseContext;
+ this.requestCount = commandContext.requestCount + 1;
+ this.command = commandContext.command;
+ this.payload = payload;
+ }
+
+ public Map<String, Serializable> getPayload()
+ {
+ return payload;
+ }
+
+ public int getRequestCount()
+ {
+ return requestCount;
+ }
+
+ public RemoteDriverResponseContext createResponseContext(DriverResponse response)
+ {
+ return new RemoteDriverResponseContext(this, response);
+ }
+
+ public RemoteDriverResponseContext getResponseContext()
+ {
+ return responseContext;
+ }
+
+ public DriverCommand getCommand()
+ {
+ return command;
+ }
+}
Added:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteDriverResponseContext.java
===================================================================
---
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteDriverResponseContext.java
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteDriverResponseContext.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,98 @@
+/******************************************************************************
+ * 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.remote.driver;
+
+import org.jboss.unit.driver.DriverResponse;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class RemoteDriverResponseContext
+{
+
+ /** . */
+ private final RemoteDriverCommandContext commandContext;
+
+ /** . */
+ private final DriverResponse response;
+
+ /** . */
+ private final Map<String, Serializable> payload;
+
+ RemoteDriverResponseContext(RemoteDriverCommandContext commandContext, DriverResponse
response)
+ {
+ this.commandContext = commandContext;
+ this.response = response;
+ this.payload = new HashMap<String, Serializable>();
+ }
+
+ public RemoteDriverCommandContext getCommandContext()
+ {
+ return commandContext;
+ }
+
+ public Map<String, Serializable> getPayload()
+ {
+ return payload;
+ }
+
+ public Object getPayload(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return payload.get(name);
+ }
+
+ public void setPayload(String name, Object value)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (value == null)
+ {
+ payload.remove(name);
+ }
+ else
+ {
+ payload.put(name, (Serializable)value);
+ }
+ }
+
+ public void removePayload(String name)
+ {
+ setPayload(name, null);
+ }
+
+ public DriverResponse getResponse()
+ {
+ return response;
+ }
+}
Added:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteTestDriver.java
===================================================================
--- modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteTestDriver.java
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteTestDriver.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * 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.remote.driver;
+
+import org.jboss.unit.remote.RequestContext;
+import org.jboss.unit.remote.ResponseContext;
+import org.jboss.unit.driver.TestDriver;
+import org.jboss.unit.TestId;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface RemoteTestDriver extends TestDriver
+{
+
+ /** . */
+ String SERVICE_ID = "TestDriverServer";
+
+ /**
+ * A client side push of the test context for a specific test.
+ */
+ void pushContext(TestId testId, RequestContext testContext);
+
+ /**
+ * A client pop of the test context for a specific test.
+ */
+ ResponseContext popContext(TestId testId);
+}
Added:
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
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteTestDriverClient.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,181 @@
+/******************************************************************************
+ * 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.remote.driver;
+
+import org.jboss.unit.remote.server.NodeId;
+import org.jboss.unit.remote.server.NodeManager;
+import org.jboss.unit.remote.server.Node;
+import org.jboss.unit.driver.TestDriver;
+import org.jboss.unit.driver.DriverCommand;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.info.TestInfo;
+import org.jboss.unit.TestId;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class RemoteTestDriverClient implements TestDriver
+{
+
+ // Config
+
+ /** . */
+ private NodeId initialNodeId;
+
+ /** . */
+ private String archivePath;
+
+ // Services
+
+ /** . */
+ private NodeManager nodeManager;
+
+ /** . */
+ private ProtocolHandler protocolHandler;
+
+ /** . */
+// private Deployer deployer;
+
+ public NodeId getInitialNodeId()
+ {
+ return initialNodeId;
+ }
+
+ public void setInitialNodeId(NodeId initialNodeId)
+ {
+ this.initialNodeId = initialNodeId;
+ }
+
+ public String getArchivePath()
+ {
+ return archivePath;
+ }
+
+ public void setArchivePath(String archivePath)
+ {
+ this.archivePath = archivePath;
+ }
+
+ public NodeManager getNodeManager()
+ {
+ return nodeManager;
+ }
+
+ public void setNodeManager(NodeManager nodeManager)
+ {
+ this.nodeManager = nodeManager;
+ }
+
+ public ProtocolHandler getProtocolHandler()
+ {
+ return protocolHandler;
+ }
+
+ public void setProtocolHandler(ProtocolHandler protocolHandler)
+ {
+ this.protocolHandler = protocolHandler;
+ }
+
+// public Deployer getDeployer()
+// {
+// return deployer;
+// }
+//
+// public void setDeployer(Deployer deployer)
+// {
+// this.deployer = deployer;
+// }
+
+ public RemoteTestDriver getServer(Node node)
+ {
+ return (RemoteTestDriver)node.lookupService(RemoteTestDriver.SERVICE_ID);
+ }
+
+ public TestInfo getInfo()
+ {
+ Node node = nodeManager.getNode(initialNodeId);
+ TestDriver server = getServer(node);
+ return server.getInfo();
+ }
+
+ public DriverResponse invoke(TestId testId, DriverCommand command) // throws
TestDriverException
+ {
+ try
+ {
+ Node node = nodeManager.getNode(initialNodeId);
+
+ // Create conversation
+ TestConversation conversation = createConversation(testId, node);
+
+ //
+ return conversation.handleCommand(command);
+ }
+ catch (Exception e)
+ {
+// throw new TestDriverException(e);
+ throw new Error(e);
+ }
+ }
+
+ protected TestConversation createConversation(TestId testId, Node node)
+ {
+ return new TestConversation(protocolHandler, this, testId, node);
+ }
+
+ public Node getNode(int port)
+ {
+ NodeId nodeId = null;
+ switch (port)
+ {
+ case 8080:
+ nodeId = NodeId.DEFAULT;
+ break;
+ case 8180:
+ nodeId = NodeId.PORTS_01;
+ break;
+ case 8280:
+ nodeId = NodeId.PORTS_02;
+ break;
+ }
+ return nodeManager.getNode(nodeId);
+ }
+
+ public int getPort(Node node)
+ {
+ NodeId nodeId = node.getId();
+ if (NodeId.DEFAULT.equals(nodeId))
+ {
+ return 8080;
+ }
+ if (NodeId.PORTS_01.equals(nodeId))
+ {
+ return 8180;
+ }
+ if (NodeId.PORTS_02.equals(nodeId))
+ {
+ return 8280;
+ }
+ return -1;
+ }
+}
Added:
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
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/RemoteTestDriverServer.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,153 @@
+/******************************************************************************
+ * 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.remote.driver;
+
+import org.jboss.unit.TestId;
+import org.jboss.unit.Failure;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.DriverCommand;
+import org.jboss.unit.driver.TestDriver;
+import org.jboss.unit.driver.response.FailureResponse;
+import org.jboss.unit.info.TestInfo;
+import org.jboss.unit.info.impl.SimpleTestSuiteInfo;
+import org.jboss.unit.remote.RequestContext;
+import org.jboss.unit.remote.ResponseContext;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5636 $
+ */
+public class RemoteTestDriverServer implements RemoteTestDriver
+{
+
+ /** . */
+ private SimpleTestSuiteInfo info = new SimpleTestSuiteInfo("Main");
+
+ /** . */
+ private Map<String, TestDriver> drivers = new HashMap<String,
TestDriver>();
+
+ /** . */
+ private RequestContext requestContext;
+
+ /** . */
+ private ResponseContext responseContext;
+
+ public void pushContext(TestId testId, RequestContext testContext)
+ {
+ this.requestContext = testContext;
+ }
+
+ public ResponseContext popContext(TestId testId)
+ {
+ return responseContext;
+ }
+
+ public TestInfo getInfo()
+ {
+ return info;
+ }
+
+ public DriverResponse invoke(TestId id, DriverCommand command)
+ {
+ if (id.getLength() == 0)
+ {
+ return new FailureResponse(Failure.createErrorFailure("No null test id
accepted"));
+ }
+
+ //
+ String name = id.getName(0);
+
+ //
+ TestDriver driver = drivers.get(name);
+
+ //
+ if (driver == null)
+ {
+ return new FailureResponse(Failure.createErrorFailure("No test driver found
for name " + name));
+ }
+
+ //
+ TestId driverId = id.range(1);
+
+ //
+ return driver.invoke(driverId, command);
+ }
+
+ public void addDriver(TestDriver driver)
+ {
+ synchronized(RemoteTestDriverServer.class)
+ {
+ info.addTest(driver.getInfo());
+
+ String name = driver.getInfo().getName();
+
+ drivers.put(name, driver);
+ }
+ }
+
+ public synchronized void removeDriver(TestDriver driver)
+ {
+ synchronized(RemoteTestDriverServer.class)
+ {
+ String name = driver.getInfo().getName();
+
+ drivers.remove(name);
+
+ info.removeTest(name);
+ }
+ }
+
+
+
+
+
+
+// /** . */
+// private String initialPath = "/test";
+//
+// public String getInitialPath()
+// {
+// return initialPath;
+// }
+//
+// public void setInitialPath(String initialPath)
+// {
+// this.initialPath = initialPath;
+// }
+//
+// public void pushContext(String testId, TestContext testContext)
+// {
+// if (testContext instanceof HTTPTestContext)
+// {
+// HTTPTestContext httpTestContext = (HTTPTestContext)testContext;
+// httpTestContext.initialPath = initialPath;
+// }
+//
+// //
+// super.pushContext(testId, testContext);
+// }
+
+}
Added:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/TestConversation.java
===================================================================
--- modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/TestConversation.java
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/TestConversation.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,209 @@
+/******************************************************************************
+ * 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.remote.driver;
+
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.DriverCommand;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.remote.server.Node;
+import org.jboss.unit.remote.RequestContext;
+import org.jboss.unit.remote.ResponseContext;
+import org.jboss.unit.TestId;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public final class TestConversation
+{
+
+ /** . */
+// private final Logger log = Logger.getLogger(getClass());
+
+ /** The test name. */
+ private final TestId testId;
+
+ /** . */
+ private final RemoteTestDriverClient driver;
+
+ /** . */
+ private final Map<String, Object> attributes;
+
+ /** The node to invoke. */
+ private Node node;
+
+ /** The test parametrization. */
+ private Map<String, String> parametrization;
+
+ /** . */
+ private ProtocolHandler protocolHandler;
+
+ public TestConversation(ProtocolHandler protocolHandler, RemoteTestDriverClient
driver, TestId testId, Node node)
+ {
+ this.protocolHandler = protocolHandler;
+ this.driver = driver;
+ this.testId = testId;
+ this.node = node;
+ this.attributes = new HashMap<String, Object>();
+ }
+
+ DriverResponse handleCommand(DriverCommand command) throws Exception
+ {
+ RemoteDriverCommandContext commandContext = new
RemoteDriverCommandContext(command);
+
+ //
+ return handleCommand(commandContext);
+ }
+
+ /**
+ * Trigger an interaction with the server here.
+ *
+ * @param commandContext the command context
+ * @return the driver response
+ * @throws Exception for now any exception
+ */
+ public final DriverResponse handleCommand(RemoteDriverCommandContext commandContext)
throws Exception
+ {
+ //
+// if (command instanceof StartTestCommand)
+// {
+// StartTestCommand start = (StartTestCommand)command;
+// parametrization = start.getParametrization();
+// pushContext(commandContext);
+// DriverResponse response = getDriver().getServer(node).invoke(testId,
command);
+// return commandContext.createResponseContext(response);
+// }
+// else if (command instanceof HTTPDriverCommand)
+// {
+// return new HTTPTestDriverHandler().invoke(this, commandContext);
+// }
+// else
+// {
+// throw new IllegalArgumentException("Not yet handled " + command);
+// }
+
+ RemoteDriverResponseContext respCtx = protocolHandler.handleCommand(this,
commandContext);
+
+ //
+ DriverResponse response = respCtx.getResponse();
+
+ //
+ if (response instanceof EndTestResponse)
+ {
+ return response;
+ }
+
+ //
+ commandContext = protocolHandler.handleResponse(this, respCtx);
+
+ //
+ return handleCommand(commandContext);
+ }
+
+ public Object getAttribute(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return attributes.get(name);
+ }
+
+ public void setAttribute(String name, Object value)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (value == null)
+ {
+ attributes.remove(name);
+ }
+ else
+ {
+ attributes.put(name, value);
+ }
+ }
+
+ public void removeAttribute(String name)
+ {
+ setAttribute(name, null);
+ }
+
+ public RemoteTestDriverClient getDriver()
+ {
+ return driver;
+ }
+
+ public TestId getTestId()
+ {
+ return testId;
+ }
+
+ public Node getNode()
+ {
+ return node;
+ }
+
+ public void setNode(Node node)
+ {
+ this.node = node;
+ }
+
+ public Map<String, String> getParametrization()
+ {
+ return parametrization;
+ }
+
+ public void setParametrization(Map<String, String> parametrization)
+ {
+ this.parametrization = parametrization;
+ }
+
+ public void pushContext(RemoteDriverCommandContext commandContext)
+ {
+ RequestContext ctx = new RequestContext(commandContext.getRequestCount(),
parametrization, commandContext.getPayload());
+
+// new TestContext(
+// commandContext.getRequestCount(),
+// driver.getArchivePath(),
+// parametrization,
+// commandContext.getPayload());
+
+ //
+// log.info("# Updating test case context of : " + node + " : "
+ ctx);
+ RemoteTestDriver agent = driver.getServer(node);
+ agent.pushContext(testId, ctx);
+ }
+
+ public ResponseContext popContext()
+ {
+ RemoteTestDriver agent = driver.getServer(node);
+
+ //
+ return agent.popContext(testId);
+ }
+}
Added:
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
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/deployer/DeployerHandler.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,113 @@
+/******************************************************************************
+ * 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.remote.driver.handler.deployer;
+
+import org.jboss.unit.remote.driver.ProtocolHandler;
+import org.jboss.unit.remote.driver.RemoteDriverResponseContext;
+import org.jboss.unit.remote.driver.TestConversation;
+import org.jboss.unit.remote.driver.RemoteDriverCommandContext;
+import org.jboss.unit.remote.driver.handler.deployer.response.UndeployResponse;
+import org.jboss.unit.remote.driver.handler.deployer.response.DeployResponse;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.portal.test.framework.deployment.Deployer;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeployerHandler implements ProtocolHandler
+{
+
+ /** . */
+ private ProtocolHandler nextHandler;
+
+ /** . */
+ private Deployer deployer;
+
+ /** . */
+ private String archivePath;
+
+ public ProtocolHandler getNextHandler()
+ {
+ return nextHandler;
+ }
+
+ public void setNextHandler(ProtocolHandler nextHandler)
+ {
+ this.nextHandler = nextHandler;
+ }
+
+ public Deployer getDeployer()
+ {
+ return deployer;
+ }
+
+ public void setDeployer(Deployer deployer)
+ {
+ this.deployer = deployer;
+ }
+
+ public String getArchivePath()
+ {
+ return archivePath;
+ }
+
+ public void setArchivePath(String archivePath)
+ {
+ this.archivePath = archivePath;
+ }
+
+ public RemoteDriverCommandContext handleResponse(TestConversation testConversation,
RemoteDriverResponseContext responseContext)
+ {
+ DriverResponse response = responseContext.getResponse();
+
+ if (response instanceof DeployResponse)
+ {
+ DeployResponse deploy = (DeployResponse)response;
+
+ //
+// deployer.deploy(archivePath, deploy.getId(), node);
+
+ //
+ return new RemoteDriverCommandContext(responseContext.getCommandContext());
+ }
+ else if (response instanceof UndeployResponse)
+ {
+ UndeployResponse undeploy = (UndeployResponse)response;
+
+ //
+// Deployer deployer = driver.getDeployer();
+// deployer.undeploy(driver.getArchivePath(), undeploy.getId());
+
+ //
+ return new RemoteDriverCommandContext(responseContext.getCommandContext());
+ }
+
+ return null; //To change body of implemented methods use File | Settings | File
Templates.
+ }
+
+ public RemoteDriverResponseContext handleCommand(TestConversation conversation,
RemoteDriverCommandContext commandContext) throws Exception
+ {
+ return nextHandler.handleCommand(conversation, commandContext);
+ }
+}
Added:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/deployer/response/DeployResponse.java
===================================================================
---
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/deployer/response/DeployResponse.java
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/deployer/response/DeployResponse.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * 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.remote.driver.handler.deployer.response;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeployResponse extends DeployerResponse
+{
+
+ /** . */
+ private final String id;
+
+ public DeployResponse(String id)
+ {
+ if (id == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.id = id;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+}
Added:
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
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/deployer/response/DeployerResponse.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * 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.remote.driver.handler.deployer.response;
+
+import org.jboss.unit.driver.DriverResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeployerResponse extends DriverResponse
+{
+}
Added:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/deployer/response/UndeployResponse.java
===================================================================
---
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/deployer/response/UndeployResponse.java
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/deployer/response/UndeployResponse.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * 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.remote.driver.handler.deployer.response;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class UndeployResponse extends DeployerResponse
+{
+
+ /** . */
+ private final String id;
+
+ public UndeployResponse(String id)
+ {
+ if (id == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.id = id;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+}
Added:
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
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/HTTPConversation.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,313 @@
+/******************************************************************************
+ * 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.remote.driver.handler.http;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.SimpleHttpConnectionManager;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.HeaderElement;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.auth.AuthScope;
+import org.apache.commons.httpclient.params.HttpMethodParams;
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.http.HttpRequest;
+import org.jboss.portal.common.http.HttpHeaders;
+import org.jboss.portal.common.http.HttpHeader;
+import org.jboss.unit.remote.driver.handler.http.command.DoMethodCommand;
+import org.jboss.unit.remote.driver.handler.http.command.DoPostCommand;
+import org.jboss.unit.remote.driver.handler.http.command.DoGetCommand;
+import org.jboss.unit.remote.driver.TestConversation;
+import org.jboss.unit.remote.driver.RemoteDriverCommandContext;
+import org.jboss.unit.remote.driver.RemoteDriverResponseContext;
+import org.jboss.unit.remote.server.Node;
+import org.jboss.unit.remote.ResponseContext;
+import org.jboss.unit.driver.DriverCommand;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.response.FailureResponse;
+import org.jboss.unit.Failure;
+
+import java.net.URI;
+import java.net.URL;
+import java.net.URISyntaxException;
+import java.net.MalformedURLException;
+import java.util.Collection;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class HTTPConversation
+{
+
+ /** . */
+ private final Logger log = Logger.getLogger(getClass());
+
+ /** . */
+ private final HttpClient client;
+
+ /** . */
+ private final TestConversation conversation;
+
+ public HTTPConversation(TestConversation conversation)
+ {
+ HttpClient client = new HttpClient(new SimpleHttpConnectionManager());
+ client.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, null);
+ client.getState().setCredentials(AuthScope.ANY, new
UsernamePasswordCredentials("test", "test"));
+
+ //
+ this.conversation = conversation;
+ this.client = client;
+ }
+
+ public RemoteDriverResponseContext invoke(RemoteDriverCommandContext commandContext)
throws Exception
+ {
+ DriverCommand command = commandContext.getCommand();
+
+ //
+ if (command instanceof DoMethodCommand)
+ {
+ DoMethodCommand method = (DoMethodCommand)command;
+ URI uri = method.getURI();
+ URL url = getURL(uri);
+ if (command instanceof DoPostCommand)
+ {
+ DoPostCommand doPostCmd = (DoPostCommand)command;
+ PostMethod post = null;
+ try
+ {
+ post = new PostMethod(url.toString());
+ post.setFollowRedirects(false);
+ HttpRequest.Body body = doPostCmd.getBody();
+ if (doPostCmd.getContentType() != null)
+ {
+ post.addRequestHeader("Content-Type",
doPostCmd.getContentType());
+ }
+ if (body instanceof HttpRequest.Raw)
+ {
+ HttpRequest.Raw rb = (HttpRequest.Raw)body;
+ ByteArrayRequestEntity entity = new
ByteArrayRequestEntity(rb.getBytes());
+ post.setRequestEntity(entity);
+ }
+ else if (body instanceof HttpRequest.Form)
+ {
+ HttpRequest.Form fb = (HttpRequest.Form)body;
+ Collection<NameValuePair> tmp = new
ArrayList<NameValuePair>();
+ for (Object o : fb.getParameterNames())
+ {
+ String name = (String)o;
+ String[] values = fb.getParameterValues(name);
+ for (String value : values)
+ {
+ NameValuePair nvp = new NameValuePair(name, value);
+ tmp.add(nvp);
+ }
+ }
+ NameValuePair[] nvps = tmp.toArray(new NameValuePair[tmp.size()]);
+ post.setRequestBody(nvps);
+ }
+ executeHTTPMethod(commandContext, post);
+ return decodeHTTPResponse(commandContext, post);
+ }
+ finally
+ {
+ if (post != null)
+ {
+ post.releaseConnection();
+ }
+ }
+ }
+ else
+ {
+ DoGetCommand doGetCmd = (DoGetCommand)command;
+ GetMethod get = null;
+ try
+ {
+ get = new GetMethod(url.toString());
+ HttpHeaders headers = doGetCmd.getHeaders();
+ for (Iterator i = headers.headers();i.hasNext();)
+ {
+ HttpHeader header = (HttpHeader)i.next();
+ Header _header = new Header(header.getName(), header.getValue());
+ get.addRequestHeader(_header);
+ }
+ get.setFollowRedirects(false);
+ executeHTTPMethod(commandContext, get);
+ return decodeHTTPResponse(commandContext, get);
+ }
+ finally
+ {
+ if (get != null)
+ {
+ get.releaseConnection();
+ }
+ }
+ }
+ }
+ else
+ {
+ return commandContext.createResponseContext(new
FailureResponse(Failure.createErrorFailure("Unexpected response")));
+ }
+ }
+
+ private URL getURL(URI uri) throws URISyntaxException, MalformedURLException
+ {
+ if (!uri.isAbsolute())
+ {
+ Node node = conversation.getNode();
+ int port = conversation.getDriver().getPort(node);
+ uri = new URI("http://localhost:" + port).resolve(uri);
+ }
+ return uri.toURL();
+ }
+
+ private RemoteDriverResponseContext decodeHTTPResponse(RemoteDriverCommandContext
commandContext, HttpMethod httpMethod) throws Exception
+ {
+ ResponseContext ctx = conversation.popContext();
+ DriverResponse response = ctx.getResponse();
+ int status = httpMethod.getStatusCode();
+ switch (status)
+ {
+ case 200:
+ // HTTP response is ok
+ if (response == null)
+ {
+ response = new FailureResponse(Failure.createErrorFailure("No result
for test " + conversation.getTestId() + " in the response"));
+ }
+
+ //
+ log.info("# Received '200' code");
+ break;
+ case 302:
+ // Send redirect
+ if (response == null)
+ {
+ // Satisfy the 302 code
+ Header locationHeader =
httpMethod.getResponseHeader("location");
+ if (locationHeader != null)
+ {
+ String redirectLocation = locationHeader.getValue();
+ log.info("# Received '302' code --> " +
redirectLocation);
+ DoGetCommand cmd = new DoGetCommand(new URI(redirectLocation));
+
+ // We should somehow stuff the response in the next payload
+ // but it's not yet proven it's usefull
+
+ // For now we don't add any contextual payload as
+ // 302 is some kind of implicit redirect response
+ return invoke(new
RemoteDriverCommandContext(commandContext.getResponseContext(), cmd));
+ }
+ else
+ {
+ // The response is invalid
+ response = new FailureResponse(Failure.createErrorFailure("302
Code with corrupted data"));
+ }
+ }
+ else
+ {
+ // If any result has been setup during the action it overrides the 302
code
+ log.info("# Received Result object which overrides the 302");
+ }
+ break;
+ case 500:
+ log.info("# Received '500' code");
+ response = new FailureResponse(Failure.createErrorFailure("Received
'500' code at " + httpMethod.getURI()));
+ break;
+ case 404:
+ log.info("# Received '404' code");
+ response = new FailureResponse(Failure.createErrorFailure("Received
'404' code at " + httpMethod.getURI()));
+ break;
+ default:
+ response = new FailureResponse(Failure.createErrorFailure("Unexpected
http code " + status + " at " + httpMethod.getURI()));
+ break;
+ }
+
+ //
+ RemoteDriverResponseContext responseCtx =
commandContext.createResponseContext(response);
+
+ //
+ byte[] body = httpMethod.getResponseBody();
+ responseCtx.setPayload("http.response.body", body);
+
+ //
+ HttpHeaders _headers = new HttpHeaders();
+ Header[] headers = httpMethod.getResponseHeaders();
+ for (Header header : headers)
+ {
+ HttpHeader _header = _headers.addHeader(header.getName());
+ HeaderElement[] elts = header.getElements();
+ if (elts != null)
+ {
+ for (HeaderElement elt : elts)
+ {
+ HttpHeader.Element _elt = _header.addElement(elt.getName(),
elt.getValue());
+ NameValuePair[] params = elt.getParameters();
+ if (params != null)
+ {
+ for (NameValuePair param : params)
+ {
+ _elt.addParam(param.getName(), param.getValue());
+ }
+ }
+ }
+ }
+ }
+ responseCtx.setPayload("http.response.headers", _headers);
+
+ //
+ return responseCtx;
+ }
+
+ private int executeHTTPMethod(RemoteDriverCommandContext commandContext, HttpMethod
method) throws Exception
+ {
+ int port = method.getURI().getPort();
+
+ // Update to the next node
+ Node node = conversation.getDriver().getNode(port);
+ if (node == null)
+ {
+ throw new IllegalArgumentException("Wrong port " +
method.getURI().getPort() + " in URI " + method.getURI());
+ }
+ conversation.setNode(node);
+
+ // Push context to the node
+ conversation.pushContext(commandContext);
+
+ //
+ log.info("# Invoking test case over http " + method.getURI());
+ int status = client.executeMethod(method);
+
+ // Force to read the response body before we close the connection
+ // otherwise the content will be lost
+ method.getResponseBody();
+
+ //
+ return status;
+ }
+}
Added:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/HTTPHandler.java
===================================================================
---
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/HTTPHandler.java
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/HTTPHandler.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,115 @@
+/******************************************************************************
+ * 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.remote.driver.handler.http;
+
+import org.jboss.portal.common.http.HttpRequest;
+import org.jboss.unit.remote.driver.RemoteDriverResponseContext;
+import org.jboss.unit.remote.driver.RemoteDriverCommandContext;
+import org.jboss.unit.remote.driver.ProtocolHandler;
+import org.jboss.unit.remote.driver.TestConversation;
+import org.jboss.unit.remote.driver.handler.http.response.InvokePostResponse;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeGetResponse;
+import org.jboss.unit.remote.driver.handler.http.response.HTTPDriverResponse;
+import org.jboss.unit.remote.driver.handler.http.response.InvokeMethodResponse;
+import org.jboss.unit.remote.driver.handler.http.command.DoPostCommand;
+import org.jboss.unit.remote.driver.handler.http.command.DoGetCommand;
+import org.jboss.unit.remote.driver.handler.http.command.HTTPDriverCommand;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class HTTPHandler implements ProtocolHandler
+{
+
+ /** . */
+ private ProtocolHandler nextHandler;
+
+ public ProtocolHandler getNextHandler()
+ {
+ return nextHandler;
+ }
+
+ public void setNextHandler(ProtocolHandler nextHandler)
+ {
+ this.nextHandler = nextHandler;
+ }
+
+ public RemoteDriverCommandContext handleResponse(TestConversation testConversation,
RemoteDriverResponseContext responseContext)
+ {
+ if (responseContext.getResponse() instanceof HTTPDriverResponse)
+ {
+ HTTPDriverResponse resp = (HTTPDriverResponse)responseContext.getResponse();
+ if (resp instanceof InvokeMethodResponse)
+ {
+ if (resp instanceof InvokeGetResponse)
+ {
+ InvokeGetResponse igr = (InvokeGetResponse)resp;
+ return new RemoteDriverCommandContext(responseContext, new
DoGetCommand(igr.getURI(), igr.getHeaders()));
+ }
+ else
+ {
+ InvokePostResponse ipr = (InvokePostResponse)resp;
+ HttpRequest.Body dpcb = ipr.getBody();
+ return new RemoteDriverCommandContext(responseContext, new
DoPostCommand(ipr.getURI(), ipr.getContentType(), dpcb));
+ }
+ }
+ }
+
+ //
+ if (nextHandler != null)
+ {
+ return nextHandler.handleResponse(testConversation, responseContext);
+ }
+
+ //
+ return null;
+ }
+
+ public RemoteDriverResponseContext handleCommand(TestConversation conversation,
RemoteDriverCommandContext commandContext) throws Exception
+ {
+ if (commandContext.getCommand() instanceof HTTPDriverCommand)
+ {
+ HTTPConversation httpConversation =
(HTTPConversation)conversation.getAttribute("http.conversation");
+
+ //
+ if (httpConversation == null)
+ {
+ httpConversation = new HTTPConversation(conversation);
+ conversation.setAttribute("http.conversation", httpConversation);
+ }
+
+ //
+ return httpConversation.invoke(commandContext);
+ }
+
+ //
+ if (nextHandler != null)
+ {
+ return nextHandler.handleCommand(conversation, commandContext);
+ }
+
+ //
+ return null;
+ }
+}
Added:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/command/DoGetCommand.java
===================================================================
---
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/command/DoGetCommand.java
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/command/DoGetCommand.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * 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.remote.driver.handler.http.command;
+
+import org.jboss.portal.common.http.HttpHeaders;
+
+import java.net.URI;
+
+/**
+ * Perform a get.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public class DoGetCommand extends DoMethodCommand
+{
+
+ public DoGetCommand(URI uri, HttpHeaders headers)
+ {
+ super(uri, headers);
+ }
+
+ public DoGetCommand(URI uri)
+ {
+ super(uri);
+ }
+}
Added:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/command/DoMethodCommand.java
===================================================================
---
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/command/DoMethodCommand.java
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/command/DoMethodCommand.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -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.remote.driver.handler.http.command;
+
+import org.jboss.portal.common.http.HttpHeaders;
+
+import java.net.URI;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class DoMethodCommand extends HTTPDriverCommand
+{
+
+ /** . */
+ private URI uri;
+
+ /** . */
+ private HttpHeaders headers;
+
+ public DoMethodCommand(URI uri, HttpHeaders headers)
+ {
+ this.uri = uri;
+ this.headers = headers;
+ }
+
+ public DoMethodCommand(URI uri)
+ {
+ this(uri, new HttpHeaders());
+ }
+
+ public URI getURI()
+ {
+ return uri;
+ }
+
+ public HttpHeaders getHeaders()
+ {
+ return headers;
+ }
+}
Added:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/command/DoPostCommand.java
===================================================================
---
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/command/DoPostCommand.java
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/command/DoPostCommand.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * 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.remote.driver.handler.http.command;
+
+import org.jboss.portal.common.http.HttpRequest;
+
+import java.net.URI;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public class DoPostCommand extends DoMethodCommand
+{
+
+ /** . */
+ private String contentType;
+
+ /** . */
+ private HttpRequest.Body body;
+
+ public DoPostCommand(URI uri, String contentType, HttpRequest.Body body)
+ {
+ super(uri);
+
+ //
+ if (body == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.contentType = contentType;
+ this.body = body;
+ }
+
+ public String getContentType()
+ {
+ return contentType;
+ }
+
+ public HttpRequest.Body getBody()
+ {
+ return body;
+ }
+}
Added:
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
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/command/HTTPDriverCommand.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * 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.remote.driver.handler.http.command;
+
+import org.jboss.unit.driver.DriverCommand;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class HTTPDriverCommand extends DriverCommand
+{
+}
Added:
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
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/response/HTTPDriverResponse.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * 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.remote.driver.handler.http.response;
+
+import org.jboss.unit.driver.DriverResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class HTTPDriverResponse extends DriverResponse
+{
+}
Added:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/response/InvokeGetResponse.java
===================================================================
---
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/response/InvokeGetResponse.java
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/response/InvokeGetResponse.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * 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.remote.driver.handler.http.response;
+
+import java.net.URI;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.com">Boleslaw
Dawidowicz</a>
+ * @version $Revision: 5448 $
+ */
+public class InvokeGetResponse extends InvokeMethodResponse
+{
+
+ public InvokeGetResponse(String url)
+ {
+ super(url);
+ }
+
+ public InvokeGetResponse(URI uri)
+ {
+ super(uri);
+ }
+
+ public String toString()
+ {
+ return "InvokeGet[uri=" + getURI() + "]";
+ }
+}
Added:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/response/InvokeMethodResponse.java
===================================================================
---
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/response/InvokeMethodResponse.java
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/response/InvokeMethodResponse.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,103 @@
+/******************************************************************************
+ * 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.remote.driver.handler.http.response;
+
+import org.jboss.portal.common.http.HttpHeaders;
+import org.jboss.portal.common.http.HttpHeader;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class InvokeMethodResponse extends HTTPDriverResponse
+{
+
+ /** . */
+ private URI uri;
+
+ /** . */
+ private HttpHeaders headers;
+
+ public InvokeMethodResponse(String uri) throws IllegalArgumentException
+ {
+ if (uri == null)
+ {
+ throw new IllegalArgumentException("Cannot invoke against a null
URL");
+ }
+
+ //
+ URI tmp;
+ try
+ {
+ tmp = new URI(uri);
+ }
+ catch (URISyntaxException e)
+ {
+ IllegalArgumentException iae = new IllegalArgumentException("Wrong URI
syntax");
+ iae.initCause(e);
+ throw iae;
+ }
+
+ //
+ if (tmp.isOpaque())
+ {
+ throw new IllegalArgumentException("No opaque URI accepted");
+ }
+
+ //
+ this.uri = tmp;
+ this.headers = new HttpHeaders();
+ }
+
+ public InvokeMethodResponse(URI uri) throws IllegalArgumentException
+ {
+ if (uri == null)
+ {
+ throw new IllegalArgumentException("Cannot invoke against a null
URL");
+ }
+ this.uri = uri;
+ this.headers = new HttpHeaders();
+ }
+
+ public URI getURI()
+ {
+ return uri;
+ }
+
+ public HttpHeader addHeader(String headerName)
+ {
+ if (headerName == null)
+ {
+ throw new IllegalArgumentException("No null header name accepted");
+ }
+ return headers.addHeader(headerName);
+ }
+
+ public HttpHeaders getHeaders()
+ {
+ return headers;
+ }
+}
Added:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/response/InvokePostResponse.java
===================================================================
---
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/response/InvokePostResponse.java
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/driver/handler/http/response/InvokePostResponse.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * 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.remote.driver.handler.http.response;
+
+import org.jboss.portal.common.http.HttpRequest;
+
+import java.net.URI;
+
+/**
+ * The portlet wants to invoke a post.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public class InvokePostResponse extends InvokeMethodResponse
+{
+
+ /** . */
+ public static final String APPLICATION_X_WWW_FORM_URLENCODED =
"application/x-www-form-urlencoded";
+
+ /** . */
+ public static final String MULTIPART_FORM_DATA = "multipart/form-data";
+
+ /** The content type. */
+ private String contentType;
+
+ /** The post body. */
+ private HttpRequest.Body body;
+
+ public InvokePostResponse(String uri)
+ {
+ super(uri);
+ }
+
+ public InvokePostResponse(URI uri)
+ {
+ super(uri);
+ }
+
+ public HttpRequest.Body getBody()
+ {
+ return body;
+ }
+
+ public void setBody(HttpRequest.Body body)
+ {
+ this.body = body;
+ }
+
+ public String getContentType()
+ {
+ return contentType;
+ }
+
+ public void setContentType(String contentType)
+ {
+ this.contentType = contentType;
+ }
+
+ public String toString()
+ {
+ return "InvokePost[uri=" + getURI() + "]";
+ }
+}
Added: modules/test/trunk/remote/src/main/org/jboss/unit/remote/server/Node.java
===================================================================
--- modules/test/trunk/remote/src/main/org/jboss/unit/remote/server/Node.java
(rev 0)
+++ modules/test/trunk/remote/src/main/org/jboss/unit/remote/server/Node.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * 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.remote.server;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6136 $
+ */
+public class Node
+{
+
+ /** . */
+ protected final NodeId id;
+
+ /** . */
+ protected final Map serviceLookups;
+
+ public Node(String id, Map serviceLookups)
+ {
+ this.id = new NodeId(id);
+ this.serviceLookups = serviceLookups;
+ }
+
+ /**
+ * Returns the node id.
+ *
+ * @return the node id
+ */
+ public NodeId getId()
+ {
+ return id;
+ }
+
+ public Object lookupService(String serviceId) throws ServiceLookupFailedException
+ {
+ ServiceLookup lookup = (ServiceLookup)serviceLookups.get(serviceId);
+
+ //
+ if (lookup == null)
+ {
+ throw new ServiceLookupFailedException("No service lookup bound under the
service id " + serviceId);
+ }
+
+ //
+ return lookup.lookupService();
+ }
+
+ public String toString()
+ {
+ return "Node[" + id + "]";
+ }
+}
Added: modules/test/trunk/remote/src/main/org/jboss/unit/remote/server/NodeId.java
===================================================================
--- modules/test/trunk/remote/src/main/org/jboss/unit/remote/server/NodeId.java
(rev 0)
+++ modules/test/trunk/remote/src/main/org/jboss/unit/remote/server/NodeId.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,120 @@
+/******************************************************************************
+ * 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.remote.server;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6136 $
+ */
+public class NodeId implements Serializable
+{
+
+ /** . */
+ public static final NodeId DEFAULT = new NodeId("default");
+
+ /** . */
+ public static final NodeId PORTS_01 = new NodeId("ports-01");
+
+ /** . */
+ public static final NodeId PORTS_02 = new NodeId("ports-02");
+
+ /** . */
+ private final String value;
+
+ public NodeId(String value)
+ {
+ if (value == null)
+ {
+ throw new IllegalArgumentException("No null value accepted");
+ }
+ this.value = value;
+ }
+
+ public String toString()
+ {
+ return value;
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o instanceof NodeId)
+ {
+ NodeId that = (NodeId)o;
+ return value.equals(that.value);
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ return value.hashCode();
+ }
+
+ /**
+ * Return the current node id.
+ *
+ * @return the current node id
+ * @throws IllegalStateException if not in a node context
+ */
+ public static NodeId locate() throws IllegalStateException
+ {
+ // Legacy jboss server name
+ String nodeName = System.getProperty("jboss.server.name");
+
+ // Otherwise use a system property specified in the command line
+ if (nodeName != null)
+ {
+ nodeName = System.getProperty("test.node.name");
+ }
+
+ // If nothing is specified we assume it is the default one
+ if (nodeName == null)
+ {
+ nodeName = "default";
+ }
+
+ //
+ if ("default".equals(nodeName))
+ {
+ return NodeId.DEFAULT;
+ }
+ else if ("ports-01".equals(nodeName))
+ {
+ return NodeId.PORTS_01;
+ }
+ else if ("ports-02".equals(nodeName))
+ {
+ return NodeId.PORTS_02;
+ }
+ else
+ {
+ throw new IllegalStateException("Cannot determine node id " +
nodeName);
+ }
+ }
+}
Added: modules/test/trunk/remote/src/main/org/jboss/unit/remote/server/NodeManager.java
===================================================================
--- modules/test/trunk/remote/src/main/org/jboss/unit/remote/server/NodeManager.java
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/server/NodeManager.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,81 @@
+/******************************************************************************
+ * 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.remote.server;
+
+import java.util.Map;
+import java.util.List;
+import java.util.HashMap;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6136 $
+ */
+public class NodeManager
+{
+
+ /** The nodes. */
+ private final Map<NodeId,Node> nodeMap;
+
+ public NodeManager(List<Node> nodes)
+ {
+ this.nodeMap = new HashMap<NodeId,Node>();
+ for (Node node : nodes)
+ {
+ nodeMap.put(node.getId(), node);
+ }
+ }
+
+ public Collection getNodes()
+ {
+ return nodeMap.values();
+ }
+
+ public Node[] getNodes(NodeId[] nodeIds)
+ {
+ if (nodeIds == null)
+ {
+ throw new IllegalArgumentException("No null node ids accepted");
+ }
+ Node[] nodes = new Node[nodeIds.length];
+ for (int i = 0;i < nodeIds.length;i++)
+ {
+ NodeId nodeId = nodeIds[i];
+ if (nodeId == null)
+ {
+ throw new IllegalArgumentException("No null node id accepted");
+ }
+ nodes[i] = getNode(nodeId);
+ }
+ return nodes;
+ }
+
+ public Node getNode(NodeId nodeId)
+ {
+ if (nodeId == null)
+ {
+ throw new IllegalArgumentException("No null node id accepted");
+ }
+ return nodeMap.get(nodeId);
+ }
+}
Added: modules/test/trunk/remote/src/main/org/jboss/unit/remote/server/ServiceLookup.java
===================================================================
--- modules/test/trunk/remote/src/main/org/jboss/unit/remote/server/ServiceLookup.java
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/server/ServiceLookup.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * 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.remote.server;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ServiceLookup
+{
+
+ /**
+ * Returns a proxy for the underlying service.
+ *
+ * @return the service proxy
+ * @throws ServiceLookupFailedException
+ */
+ Object lookupService() throws ServiceLookupFailedException;
+
+}
Added:
modules/test/trunk/remote/src/main/org/jboss/unit/remote/server/ServiceLookupFailedException.java
===================================================================
---
modules/test/trunk/remote/src/main/org/jboss/unit/remote/server/ServiceLookupFailedException.java
(rev 0)
+++
modules/test/trunk/remote/src/main/org/jboss/unit/remote/server/ServiceLookupFailedException.java 2007-10-08
16:09:32 UTC (rev 8564)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * 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.remote.server;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServiceLookupFailedException extends RuntimeException
+{
+ public ServiceLookupFailedException()
+ {
+ }
+
+ public ServiceLookupFailedException(String message)
+ {
+ super(message);
+ }
+
+ public ServiceLookupFailedException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public ServiceLookupFailedException(Throwable cause)
+ {
+ super(cause);
+ }
+}