Author: sohil.shah(a)jboss.com
Date: 2008-03-24 10:29:56 -0400 (Mon, 24 Mar 2008)
New Revision: 10368
Added:
modules/test/trunk/.settings/org.eclipse.jdt.ui.prefs
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/ClickLinkCommand.java
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/ClickLinkResponse.java
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/GetPageCommand.java
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/GetPageResponse.java
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/WebPageConversation.java
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/WebPageData.java
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/WebPageDriverCommand.java
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/WebPageDriverResponse.java
modules/test/trunk/remote/src/test/build.xml
modules/test/trunk/remote/src/test/java/org/jboss/unit/
modules/test/trunk/remote/src/test/java/org/jboss/unit/test/
modules/test/trunk/remote/src/test/java/org/jboss/unit/test/remote/
modules/test/trunk/remote/src/test/java/org/jboss/unit/test/remote/ActualBootstrap.java
modules/test/trunk/remote/src/test/java/org/jboss/unit/test/remote/WebBootstrap.java
modules/test/trunk/remote/src/test/java/org/jboss/unit/test/remote/webpage/
modules/test/trunk/remote/src/test/java/org/jboss/unit/test/remote/webpage/ClickLinkCommandTestCase.java
modules/test/trunk/remote/src/test/java/org/jboss/unit/test/remote/webpage/GetPageCommandTestCase.java
modules/test/trunk/remote/src/test/resources/ear/
modules/test/trunk/remote/src/test/resources/ear/META-INF/
modules/test/trunk/remote/src/test/resources/ear/META-INF/application.xml
modules/test/trunk/remote/src/test/resources/ear/META-INF/jboss-app.xml
modules/test/trunk/remote/src/test/resources/remote-jboss-unit.xml
modules/test/trunk/remote/src/test/resources/server-beans.xml
modules/test/trunk/remote/src/test/resources/servers.xml
modules/test/trunk/remote/src/test/resources/war/
modules/test/trunk/remote/src/test/resources/war/WEB-INF/
modules/test/trunk/remote/src/test/resources/war/WEB-INF/web.xml
modules/test/trunk/remote/src/test/resources/war/index.html
modules/test/trunk/remote/src/test/resources/war/link1.html
Modified:
modules/test/trunk/
modules/test/trunk/.classpath
modules/test/trunk/.settings/org.eclipse.jdt.core.prefs
modules/test/trunk/build/pom.xml
modules/test/trunk/docs/
modules/test/trunk/docs/user-guide/
modules/test/trunk/mc/
modules/test/trunk/remote/
modules/test/trunk/remote/pom.xml
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/handler/http/HTTPHandler.java
modules/test/trunk/test/agent/
modules/test/trunk/test/core/
modules/test/trunk/test/generic/
modules/test/trunk/test/jboss/
modules/test/trunk/test/opends/
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/impl/generic/agent/GenericTestAgent.java
modules/test/trunk/tooling/ant/
modules/test/trunk/tooling/core/
modules/test/trunk/tooling/examples/ant/
modules/test/trunk/tooling/maven2/
modules/test/trunk/unit/
Log:
core selenium integration for web browser based test cases
Property changes on: modules/test/trunk
___________________________________________________________________
Name: svn:ignore
- thirdparty
+ thirdparty
bin
Modified: modules/test/trunk/.classpath
===================================================================
--- modules/test/trunk/.classpath 2008-03-23 00:15:32 UTC (rev 10367)
+++ modules/test/trunk/.classpath 2008-03-24 14:29:56 UTC (rev 10368)
@@ -1,27 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="test/src/main"/>
- <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
- <classpathentry kind="lib"
path="thirdparty/junit/lib/junit.jar"/>
- <classpathentry kind="lib"
path="thirdparty/apache-log4j/lib/log4j.jar"/>
- <classpathentry kind="lib"
path="thirdparty/jboss-portal/modules/common/lib/portal-common-lib.jar"/>
- <classpathentry kind="lib"
path="thirdparty/apache-httpclient/lib/commons-httpclient.jar"/>
- <classpathentry kind="lib"
path="test/selenium-java-client-driver.jar"/>
- <classpathentry kind="lib"
path="thirdparty/jbossas/core-libs/lib/jboss-j2ee.jar"/>
- <classpathentry kind="lib"
path="thirdparty/jbossas/core-libs/lib/jboss-jca.jar"/>
- <classpathentry kind="lib"
path="thirdparty/jbossas/core-libs/lib/jboss-local-jdbc.jar"/>
- <classpathentry kind="lib"
path="thirdparty/hibernate/lib/hibernate3.jar"/>
- <classpathentry kind="lib"
path="thirdparty/jbossas/core-libs/lib/jnp-client.jar"/>
- <classpathentry kind="lib"
path="thirdparty/jbossas/core-libs/lib/jnpserver.jar"/>
- <classpathentry kind="lib"
path="thirdparty/jbossas/core-libs/lib/jboss-common.jar"/>
- <classpathentry kind="lib"
path="thirdparty/jbossas/core-libs/lib/jboss-transaction.jar"/>
- <classpathentry kind="lib"
path="thirdparty/jbossas/core-libs/lib/jboss.jar"/>
- <classpathentry kind="lib"
path="thirdparty/jbossas/core-libs/lib/jboss-system.jar"/>
- <classpathentry kind="lib"
path="thirdparty/jbossas/core-libs/lib/jboss-jmx.jar"/>
- <classpathentry kind="lib"
path="thirdparty/sun-opends/lib/OpenDS.jar"/>
- <classpathentry kind="lib"
path="thirdparty/codehaus/cargo/lib/cargo-core-uberjar-0.9.jar"/>
- <classpathentry kind="lib"
path="thirdparty/jboss/remoting/lib/jboss-remoting.jar"/>
- <classpathentry kind="lib"
path="thirdparty/jboss/microcontainer/lib/jboss-microcontainer.jar"/>
- <classpathentry kind="lib"
path="thirdparty/jboss/microcontainer/lib/jboss-dependency.jar"/>
+ <classpathentry kind="src" path="test/src/main/java"/>
+ <classpathentry kind="src" path="mc/src/main/java"/>
+ <classpathentry kind="src" path="mc/src/test/java"/>
+ <classpathentry kind="src" path="remote/src/main/java"/>
+ <classpathentry kind="src" path="remote/src/test/java"/>
+ <classpathentry kind="src" path="unit/src/main/java"/>
+ <classpathentry kind="src" path="unit/src/test/java"/>
+ <classpathentry kind="lib"
path="/home/soshah/.m2/repository/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar"/>
+ <classpathentry kind="lib"
path="/home/soshah/.m2/repository/apache-httpclient/commons-httpclient/3.0.1/commons-httpclient-3.0.1.jar"/>
+ <classpathentry kind="lib"
path="/home/soshah/.m2/repository/org/jboss/microcontainer/jboss-kernel/2.0.0.Beta9/jboss-kernel-2.0.0.Beta9.jar"/>
+ <classpathentry kind="lib"
path="/home/soshah/.m2/repository/org/jboss/microcontainer/jboss-dependency/2.0.0.Beta9/jboss-dependency-2.0.0.Beta9.jar"/>
+ <classpathentry kind="lib"
path="/home/soshah/.m2/repository/jboss/jbossas/core-libs/jboss-transaction/4.0.4.GA/jboss-transaction-4.0.4.GA.jar"/>
+ <classpathentry kind="lib"
path="/home/soshah/.m2/repository/jboss/jbossas/core-libs/jboss-jca/4.0.4.GA/jboss-jca-4.0.4.GA.jar"/>
+ <classpathentry kind="lib"
path="/home/soshah/.m2/repository/jboss/jbossas/core-libs/jnpserver/4.0.4.GA/jnpserver-4.0.4.GA.jar"/>
+ <classpathentry kind="lib"
path="/home/soshah/.m2/repository/jboss/jbossas/core-libs/jboss-local-jdbc/4.0.4.GA/jboss-local-jdbc-4.0.4.GA.jar"/>
+ <classpathentry kind="lib"
path="/home/soshah/.m2/repository/jboss/jbossas/core-libs/jboss/4.0.4.GA/jboss-4.0.4.GA.jar"/>
+ <classpathentry kind="lib"
path="/home/soshah/.m2/repository/jboss/jboss-j2ee/4.2.0.GA/jboss-j2ee-4.2.0.GA.jar"/>
+ <classpathentry kind="lib"
path="/home/soshah/.m2/repository/jboss/jboss-common-core/2.2.0.GA/jboss-common-core-2.2.0.GA.jar"/>
+ <classpathentry kind="lib"
path="/home/soshah/.m2/repository/jboss/jboss-jmx/4.2.0.GA/jboss-jmx-4.2.0.GA.jar"/>
+ <classpathentry kind="lib"
path="/home/soshah/.m2/repository/jboss/jboss-system/4.2.0.GA/jboss-system-4.2.0.GA.jar"/>
+ <classpathentry kind="lib"
path="/home/soshah/.m2/repository/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA.jar"/>
+ <classpathentry kind="lib"
path="/home/soshah/.m2/repository/jboss/jboss-remoting/2.2.1.GA/jboss-remoting-2.2.1.GA.jar"/>
+ <classpathentry kind="lib"
path="/home/soshah/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar"/>
+ <classpathentry kind="lib"
path="/home/soshah/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar"/>
+ <classpathentry kind="lib"
path="/home/soshah/.m2/repository/org/openqa/selenium/client-drivers/selenium-java-client-driver/0.9.2/selenium-java-client-driver-0.9.2.jar"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: modules/test/trunk/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- modules/test/trunk/.settings/org.eclipse.jdt.core.prefs 2008-03-23 00:15:32 UTC (rev
10367)
+++ modules/test/trunk/.settings/org.eclipse.jdt.core.prefs 2008-03-24 14:29:56 UTC (rev
10368)
@@ -1,12 +1,12 @@
-#Thu Sep 20 15:11:39 CEST 2007
+#Mon Mar 03 17:40:33 EST 2008
eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
-org.eclipse.jdt.core.compiler.source=1.3
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Added: modules/test/trunk/.settings/org.eclipse.jdt.ui.prefs
===================================================================
--- modules/test/trunk/.settings/org.eclipse.jdt.ui.prefs (rev 0)
+++ modules/test/trunk/.settings/org.eclipse.jdt.ui.prefs 2008-03-24 14:29:56 UTC (rev
10368)
@@ -0,0 +1,3 @@
+#Mon Mar 03 17:40:33 EST 2008
+eclipse.preferences.version=1
+internal.default.compliance=default
Modified: modules/test/trunk/build/pom.xml
===================================================================
--- modules/test/trunk/build/pom.xml 2008-03-23 00:15:32 UTC (rev 10367)
+++ modules/test/trunk/build/pom.xml 2008-03-24 14:29:56 UTC (rev 10368)
@@ -66,7 +66,12 @@
<releases>
<enabled>false</enabled>
</releases>
- </repository>
+ </repository>
+ <repository>
+ <id>openqa-releases</id>
+ <name>OpenQA Selenium Repository</name>
+ <
url>http://archiva.openqa.org/repository/releases/</url>
+ </repository>
</repositories>
<pluginRepositories>
<pluginRepository>
@@ -75,8 +80,7 @@
<snapshots>
<enabled>true</enabled>
</snapshots>
- </pluginRepository>
-
+ </pluginRepository>
</pluginRepositories>
<build>
Property changes on: modules/test/trunk/docs
___________________________________________________________________
Name: svn:ignore
+ docbook-support
Property changes on: modules/test/trunk/docs/user-guide
___________________________________________________________________
Name: svn:ignore
+ build
target
Property changes on: modules/test/trunk/mc
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: modules/test/trunk/remote
___________________________________________________________________
Name: svn:ignore
+ target
Modified: modules/test/trunk/remote/pom.xml
===================================================================
--- modules/test/trunk/remote/pom.xml 2008-03-23 00:15:32 UTC (rev 10367)
+++ modules/test/trunk/remote/pom.xml 2008-03-24 14:29:56 UTC (rev 10368)
@@ -14,43 +14,187 @@
<dependencies>
<dependency>
<groupId>org.jboss.unit</groupId>
- <artifactId>jboss-unit</artifactId>
+ <artifactId>jboss-unit</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.unit</groupId>
- <artifactId>portal-test</artifactId>
- <version>${project.version}</version>
+ <artifactId>portal-test</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
</dependency>
<dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-container</artifactId>
+ <version>${version.jboss.microcontainer}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ <version>${version.jboss.microcontainer}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openqa.selenium.client-drivers</groupId>
+ <artifactId>selenium-java-client-driver</artifactId>
+ <version>0.9.2</version>
+ </dependency>
+ <!--
+ <dependency>
<groupId>apache-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
</dependency>
<dependency>
- <groupId>org.jboss.microcontainer</groupId>
- <artifactId>jboss-kernel</artifactId>
- </dependency>
+ <groupId>apache-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
+ </dependency>
+ -->
+
+ <!-- test scope dependencies -->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.unit</groupId>
+ <artifactId>portal-test-generic</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.unit</groupId>
+ <artifactId>jboss-unit-mc</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <version>2.2.3.GA</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-remoting</artifactId>
+ <version>2.2.1.GA</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
- <plugins>
+ <plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skip>false</skip>
- <includes>
- <include>**/*Tests.java</include>
- </includes>
- </configuration>
- </plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>selenium-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>start</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>start-server</goal>
+ </goals>
+ <configuration>
+ <background>true</background>
+ <port>12345</port>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>stop</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>stop-server</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.jvnet.maven-antrun-extended-plugin</groupId>
+ <artifactId>maven-antrun-extended-plugin</artifactId>
+ <version>1.13</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.unit</groupId>
+ <artifactId>jboss-unit-tooling-ant</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.unit</groupId>
+ <artifactId>jboss-unit-tooling-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!--stuff to run servers for tests-->
+ <dependency>
+ <groupId>cargo</groupId>
+ <artifactId>cargo-ant</artifactId>
+ <version>${version.cargo}</version>
+ </dependency>
+ <dependency>
+ <groupId>cargo</groupId>
+ <artifactId>cargo-core-uberjar</artifactId>
+ <version>${version.cargo}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>test</id>
+ <phase>integration-test</phase>
+ <configuration>
+ <tasks>
+ <property name="test_classpath"
refid="maven.test.classpath"/>
+ <property name="plugin_classpath"
refid="maven.plugin.classpath"/>
+ <property name="project.version"
value="${project.version}"/>
+
+ <property name="dependency.jboss-unit.jar"
value="${maven.dependency.org.jboss.unit.jboss-unit.jar.path}"/>
+ <property name="dependency.portal-test-generic.jar"
value="${maven.dependency.org.jboss.unit.portal-test-generic.jar.path}"/>
+ <property name="dependency.portal-test.jar"
value="${maven.dependency.org.jboss.unit.portal-test.jar.path}"/>
+ <property name="dependency.jboss-unit-mc.jar"
value="${maven.dependency.org.jboss.unit.jboss-unit-mc.jar.path}"/>
+ <property name="dependency.jboss-kernel.jar"
value="${maven.dependency.org.jboss.microcontainer.jboss-kernel.jar.path}"/>
+ <property name="dependency.jboss-container.jar"
value="${maven.dependency.org.jboss.microcontainer.jboss-container.jar.path}"/>
+ <property name="dependency.jboss-dependency.jar"
value="${maven.dependency.org.jboss.microcontainer.jboss-dependency.jar.path}"/>
+ <property name="dependency.jboss-common-core.jar"
value="${maven.dependency.org.jboss.jboss-common-core.jar.path}"/>
+ <property name="dependency.jboss-remoting.jar"
value="${maven.dependency.jboss.jboss-remoting.jar.path}"/>
+
+
+ <ant antfile="${basedir}/src/test/build.xml">
+ <target name="run.test.remote"/>
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
<properties>
-
</properties>
</project>
Modified:
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/handler/http/HTTPHandler.java
===================================================================
---
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/handler/http/HTTPHandler.java 2008-03-23
00:15:32 UTC (rev 10367)
+++
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/handler/http/HTTPHandler.java 2008-03-24
14:29:56 UTC (rev 10368)
@@ -34,6 +34,13 @@
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;
+import org.jboss.unit.remote.driver.webpage.WebPageDriverResponse;
+import org.jboss.unit.remote.driver.webpage.GetPageResponse;
+import org.jboss.unit.remote.driver.webpage.GetPageCommand;
+import org.jboss.unit.remote.driver.webpage.ClickLinkResponse;
+import org.jboss.unit.remote.driver.webpage.ClickLinkCommand;
+import org.jboss.unit.remote.driver.webpage.WebPageDriverCommand;
+import org.jboss.unit.remote.driver.webpage.WebPageConversation;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -75,6 +82,20 @@
}
}
}
+ else if(responseContext.getResponse() instanceof WebPageDriverResponse)
+ {
+ WebPageDriverResponse resp =
(WebPageDriverResponse)responseContext.getResponse();
+ if(resp instanceof GetPageResponse)
+ {
+ GetPageResponse pr = (GetPageResponse)resp;
+ return new RemoteDriverCommandContext(responseContext, new
GetPageCommand(pr.getUri()));
+ }
+ else if(resp instanceof ClickLinkResponse)
+ {
+ ClickLinkResponse pr = (ClickLinkResponse)resp;
+ return new RemoteDriverCommandContext(responseContext, new
ClickLinkCommand(pr.getUri(), pr.getLink()));
+ }
+ }
//
if (nextHandler != null)
@@ -102,6 +123,18 @@
//
return httpConversation.invoke(commandContext);
}
+ else if(commandContext.getCommand() instanceof WebPageDriverCommand)
+ {
+ WebPageConversation webConversation =
(WebPageConversation)conversation.getAttribute("web.conversation");
+
+ if(webConversation == null)
+ {
+ webConversation = new WebPageConversation(conversation);
+ conversation.setAttribute("web.conversation", webConversation);
+ }
+
+ return webConversation.invoke(commandContext);
+ }
//
if (nextHandler != null)
Added:
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/ClickLinkCommand.java
===================================================================
---
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/ClickLinkCommand.java
(rev 0)
+++
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/ClickLinkCommand.java 2008-03-24
14:29:56 UTC (rev 10368)
@@ -0,0 +1,88 @@
+/******************************************************************************
+ * 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.webpage;
+
+import java.net.URI;
+
+import org.jboss.unit.remote.driver.RemoteDriverCommandContext;
+
+import com.thoughtworks.selenium.DefaultSelenium;
+import com.thoughtworks.selenium.Selenium;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class ClickLinkCommand extends WebPageDriverCommand
+{
+ private String link = null;
+
+ /**
+ *
+ * @param uri
+ * @param link
+ */
+ public ClickLinkCommand(URI uri, String link)
+ {
+ super(uri);
+ this.link = link;
+ }
+
+
+ public String getLink()
+ {
+ return link;
+ }
+
+
+ /**
+ *
+ */
+ public void execute(RemoteDriverCommandContext webPageCommandContext)
+ {
+ Selenium browser = null;
+ try
+ {
+ browser = new DefaultSelenium("localhost",12345, "*firefox
/home/soshah/firefox/firefox-bin", uri.toString());
+ browser.start();
+ browser.open(uri.toString());
+
+
+ //Now click the link on this page
+ browser.click(this.link);
+
+ //Get the page data now
+ WebPageData pageData = this.extractPageData(browser);
+
+
+ webPageCommandContext.getPayload().put("pageData", pageData);
+ }
+ finally
+ {
+ if(browser != null)
+ {
+ browser.stop();
+ }
+ }
+ }
+}
Added:
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/ClickLinkResponse.java
===================================================================
---
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/ClickLinkResponse.java
(rev 0)
+++
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/ClickLinkResponse.java 2008-03-24
14:29:56 UTC (rev 10368)
@@ -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.driver.webpage;
+
+import java.net.URI;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class ClickLinkResponse extends WebPageDriverResponse
+{
+ private String link = null;
+
+ /**
+ *
+ * @param pageUrl
+ */
+ public ClickLinkResponse(URI uri, String link)
+ {
+ super(uri);
+ this.link = link;
+ }
+
+ public String getLink()
+ {
+ return link;
+ }
+
+}
Added:
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/GetPageCommand.java
===================================================================
---
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/GetPageCommand.java
(rev 0)
+++
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/GetPageCommand.java 2008-03-24
14:29:56 UTC (rev 10368)
@@ -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.driver.webpage;
+
+import java.net.URI;
+
+import org.jboss.unit.remote.driver.RemoteDriverCommandContext;
+
+import com.thoughtworks.selenium.Selenium;
+import com.thoughtworks.selenium.DefaultSelenium;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class GetPageCommand extends WebPageDriverCommand
+{
+ /**
+ *
+ * @param uri
+ */
+ public GetPageCommand(URI uri)
+ {
+ super(uri);
+ }
+
+
+ /**
+ *
+ * @param webPageCommandContext
+ * @return
+ */
+ public void execute(RemoteDriverCommandContext webPageCommandContext)
+ {
+ Selenium browser = null;
+ try
+ {
+ browser = new DefaultSelenium("localhost",12345, "*firefox
/home/soshah/firefox/firefox-bin", uri.toString());
+ browser.start();
+ browser.open(uri.toString());
+
+ WebPageData pageData = this.extractPageData(browser);
+
+ webPageCommandContext.getPayload().put("pageData", pageData);
+ }
+ finally
+ {
+ if(browser != null)
+ {
+ browser.stop();
+ }
+ }
+ }
+}
Added:
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/GetPageResponse.java
===================================================================
---
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/GetPageResponse.java
(rev 0)
+++
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/GetPageResponse.java 2008-03-24
14:29:56 UTC (rev 10368)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * 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.webpage;
+
+import java.net.URI;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class GetPageResponse extends WebPageDriverResponse
+{
+ /**
+ *
+ * @param pageUrl
+ */
+ public GetPageResponse(URI uri)
+ {
+ super(uri);
+ }
+}
Added:
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/WebPageConversation.java
===================================================================
---
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/WebPageConversation.java
(rev 0)
+++
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/WebPageConversation.java 2008-03-24
14:29:56 UTC (rev 10368)
@@ -0,0 +1,112 @@
+/******************************************************************************
+ * 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.webpage;
+
+import org.jboss.portal.test.framework.server.Node;
+import org.jboss.unit.driver.DriverCommand;
+import org.jboss.portal.test.framework.server.NodeId;
+import org.jboss.unit.remote.driver.RemoteDriverCommandContext;
+import org.jboss.unit.remote.driver.RemoteDriverResponseContext;
+import org.jboss.unit.remote.driver.TestConversation;
+import org.jboss.unit.remote.ResponseContext;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class WebPageConversation
+{
+ private TestConversation currentConversation = null;
+
+ /**
+ *
+ * @param currentConversation
+ */
+ public WebPageConversation(TestConversation currentConversation)
+ {
+ this.currentConversation = currentConversation;
+ }
+
+ /**
+ *
+ * @param commandContext
+ * @return
+ * @throws Exception
+ */
+ public RemoteDriverResponseContext invoke(RemoteDriverCommandContext commandContext)
throws Exception
+ {
+ RemoteDriverResponseContext responseContext = null;
+
+ DriverCommand command = commandContext.getCommand();
+ if(command instanceof WebPageDriverCommand)
+ {
+ ((WebPageDriverCommand)command).execute(commandContext);
+
+ //Push the data extracted from executing the command over to the Server Side
Extension of the Test
+ this.pushContext(commandContext);
+
+ //Generate a Response
+ responseContext = this.generateResponse(commandContext);
+ }
+
+ return responseContext;
+ }
+
+ /**
+ *
+ * @param commandContext
+ */
+ private void pushContext(RemoteDriverCommandContext commandContext)
+ {
+ NodeId nodeId = NodeId.locate();
+
+ //Update to the next node
+ Node node = this.currentConversation.getDriver().getNodeManager().getNode(nodeId);
+ if (node == null)
+ {
+ throw new RuntimeException("Server Side Node could not be located. Make
sure the Server Side Test Driver is deployed");
+ }
+ this.currentConversation.setNode(node);
+
+ // Push context to the node
+ this.currentConversation.pushContext(commandContext);
+ }
+
+ /**
+ *
+ * @param commandContext
+ */
+ private RemoteDriverResponseContext generateResponse(RemoteDriverCommandContext
commandContext)
+ {
+ RemoteDriverResponseContext remoteResponseContext = null;
+
+ ResponseContext responseContext = this.currentConversation.popContext();
+
+ if(responseContext != null)
+ {
+ remoteResponseContext =
commandContext.createResponseContext(responseContext.getResponse());
+ }
+
+ return remoteResponseContext;
+ }
+}
Added:
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/WebPageData.java
===================================================================
---
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/WebPageData.java
(rev 0)
+++
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/WebPageData.java 2008-03-24
14:29:56 UTC (rev 10368)
@@ -0,0 +1,176 @@
+/******************************************************************************
+ * 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.webpage;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class WebPageData implements Serializable
+{
+ private String alert = null;
+ private String[] buttons = null;
+ private String[] fields = null;
+ private String[] links = null;
+ private String[] windowIds = null;
+ private String[] windowNames = null;
+ private String[] windowTitles = null;
+ private String bodyText = null;
+ private String confirmation = null;
+ private String cookie = null;
+ private String htmlSource = null;
+ private String location = null;
+ private String prompt = null;
+
+ public String getAlert()
+ {
+ return alert;
+ }
+
+ public void setAlert(String alert)
+ {
+ this.alert = alert;
+ }
+
+ public String getBodyText()
+ {
+ return bodyText;
+ }
+
+ public void setBodyText(String bodyText)
+ {
+ this.bodyText = bodyText;
+ }
+
+ public String[] getButtons()
+ {
+ return buttons;
+ }
+
+ public void setButtons(String[] buttons)
+ {
+ this.buttons = buttons;
+ }
+
+ public String getConfirmation()
+ {
+ return confirmation;
+ }
+
+ public void setConfirmation(String confirmation)
+ {
+ this.confirmation = confirmation;
+ }
+
+ public String getCookie()
+ {
+ return cookie;
+ }
+
+ public void setCookie(String cookie)
+ {
+ this.cookie = cookie;
+ }
+
+ public String[] getFields()
+ {
+ return fields;
+ }
+
+ public void setFields(String[] fields)
+ {
+ this.fields = fields;
+ }
+
+ public String getPrompt()
+ {
+ return prompt;
+ }
+
+ public void setPrompt(String prompt)
+ {
+ this.prompt = prompt;
+ }
+
+ public String getHtmlSource()
+ {
+ return htmlSource;
+ }
+
+ public void setHtmlSource(String htmlSource)
+ {
+ this.htmlSource = htmlSource;
+ }
+
+ public String[] getLinks()
+ {
+ return links;
+ }
+
+ public void setLinks(String[] links)
+ {
+ this.links = links;
+ }
+
+ public String getLocation()
+ {
+ return location;
+ }
+
+ public void setLocation(String location)
+ {
+ this.location = location;
+ }
+
+ public String[] getWindowIds()
+ {
+ return windowIds;
+ }
+
+ public void setWindowIds(String[] windowIds)
+ {
+ this.windowIds = windowIds;
+ }
+
+ public String[] getWindowNames()
+ {
+ return windowNames;
+ }
+
+ public void setWindowNames(String[] windowNames)
+ {
+ this.windowNames = windowNames;
+ }
+
+ public String[] getWindowTitles()
+ {
+ return windowTitles;
+ }
+
+ public void setWindowTitles(String[] windowTitles)
+ {
+ this.windowTitles = windowTitles;
+ }
+}
Added:
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/WebPageDriverCommand.java
===================================================================
---
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/WebPageDriverCommand.java
(rev 0)
+++
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/WebPageDriverCommand.java 2008-03-24
14:29:56 UTC (rev 10368)
@@ -0,0 +1,111 @@
+/******************************************************************************
+ * 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.webpage;
+
+import java.net.URI;
+
+import com.thoughtworks.selenium.Selenium;
+
+import org.jboss.unit.remote.driver.RemoteDriverCommandContext;
+
+import org.jboss.unit.driver.DriverCommand;
+
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public abstract class WebPageDriverCommand extends DriverCommand
+{
+ /**
+ *
+ */
+ protected URI uri = null;
+
+ public WebPageDriverCommand(URI uri)
+ {
+ this.uri = uri;
+ }
+
+ /**
+ *
+ * @param webPageCommandContext
+ * @return
+ */
+ public abstract void execute(RemoteDriverCommandContext webPageCommandContext);
+
+ /**
+ *
+ * @return
+ */
+ public URI getUri()
+ {
+ return this.uri;
+ }
+
+ /**
+ *
+ * @param browser
+ * @return
+ */
+ public WebPageData extractPageData(Selenium browser)
+ {
+ WebPageData pageData = new WebPageData();
+ if(browser.isAlertPresent())
+ {
+ pageData.setAlert(browser.getAlert());
+ }
+
+ pageData.setButtons(browser.getAllButtons());
+
+ pageData.setLinks(browser.getAllLinks());
+
+ pageData.setFields(browser.getAllFields());
+
+ pageData.setWindowIds(browser.getAllWindowIds());
+
+ pageData.setWindowNames(browser.getAllWindowNames());
+
+ pageData.setWindowTitles(browser.getAllWindowTitles());
+
+ pageData.setBodyText(browser.getBodyText());
+
+ if(browser.isConfirmationPresent())
+ {
+ pageData.setConfirmation(browser.getConfirmation());
+ }
+
+ pageData.setCookie(browser.getCookie());
+
+ pageData.setHtmlSource(browser.getHtmlSource());
+
+ pageData.setLocation(browser.getLocation());
+
+ if(browser.isPromptPresent())
+ {
+ pageData.setPrompt(browser.getPrompt());
+ }
+
+ return pageData;
+ }
+}
Added:
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/WebPageDriverResponse.java
===================================================================
---
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/WebPageDriverResponse.java
(rev 0)
+++
modules/test/trunk/remote/src/main/java/org/jboss/unit/remote/driver/webpage/WebPageDriverResponse.java 2008-03-24
14:29:56 UTC (rev 10368)
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * 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.webpage;
+
+import org.jboss.unit.driver.DriverResponse;
+
+import java.net.URI;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public abstract class WebPageDriverResponse extends DriverResponse
+{
+ /**
+ *
+ */
+ protected URI uri = null;
+
+ /**
+ *
+ * @param uri
+ */
+ public WebPageDriverResponse(URI uri)
+ {
+ this.uri = uri;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public URI getUri()
+ {
+ return this.uri;
+ }
+}
Added: modules/test/trunk/remote/src/test/build.xml
===================================================================
--- modules/test/trunk/remote/src/test/build.xml (rev 0)
+++ modules/test/trunk/remote/src/test/build.xml 2008-03-24 14:29:56 UTC (rev 10368)
@@ -0,0 +1,159 @@
+<?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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<project default="" name="JBoss Unit Remote Tests">
+ <target name="prepare_env" depends="evaluate_properties">
+ <property name="target" value="${basedir}/target"/>
+ </target>
+
+ <!--Lets make the check in one place so the build fail in the beggining instead of
end-->
+ <target name="evaluate_properties">
+
+ <property environment="env"/>
+
+ <!--If properties are not in command line check if they are set in env-->
+ <condition property="JBOSS_4_2_1_HOME"
value="${env.JBOSS_4_2_1_HOME}">
+ <and>
+ <isset property="env.JBOSS_4_2_1_HOME"/>
+ <not>
+ <isset property="JBOSS_4_2_1_HOME"/>
+ </not>
+ </and>
+ </condition>
+
+ <fail message="Please set the environment variable
JBOSS_4_2_1_HOME">
+ <condition>
+ <and>
+ <not>
+ <isset property="JBOSS_4_2_1_HOME"/>
+ </not>
+ </and>
+ </condition>
+ </fail>
+ </target>
+
+ <target name="package-tests" depends="prepare_env">
+ <mkdir dir="${target}/test"/>
+
+ <jar jarfile="${target}/test/test-remote.jar">
+ <fileset dir="${target}/test-classes" includes="**/*.class,
server-beans.xml, servers.xml"/>
+ </jar>
+
+ <war jarfile="${target}/test/test-remote.war"
needxmlfile="false">
+ <fileset dir="${basedir}/src/test/resources/war"/>
+ <classes dir="${target}/classes"/>
+ <lib file="${target}/test/test-remote.jar"/>
+ <lib file="${dependency.jboss-unit.jar}"/>
+ <lib file="${dependency.portal-test-generic.jar}"/>
+ <lib file="${dependency.portal-test.jar}"/>
+ <lib file="${dependency.jboss-unit-mc.jar}"/>
+ <lib file="${dependency.jboss-kernel.jar}"/>
+ <lib file="${dependency.jboss-container.jar}"/>
+ <lib file="${dependency.jboss-dependency.jar}"/>
+ <lib file="${dependency.jboss-common-core.jar}"/>
+ <lib file="${dependency.jboss-remoting.jar}"/>
+ </war>
+
+ <jar jarfile="${target}/test/test-remote.ear">
+ <fileset dir="${basedir}/src/test/resources/ear"/>
+ <fileset file="${target}/test/test-remote.war"/>
+ </jar>
+ </target>
+
+ <target name="test.remote">
+ <taskdef name="jboss-unit"
classname="org.jboss.unit.tooling.ant.JBossUnitTask"
classpath="${plugin_classpath}"/>
+ <jboss-unit jpda="${clientDebug}" jpdaPort="5005"
jpdaSuspend="true">
+ <tests
config="${basedir}/src/test/resources/remote-jboss-unit.xml">
+ <property name="serverName"
value="RemoteJBoss_4_2_1"/>
+ <property name="archivePath" value="${target}/test"/>
+ <property name="archiveId" value="test-remote.ear"/>
+
+ <classpath>
+ <pathelement path="${test_classpath}"/>
+ </classpath>
+ </tests>
+ </jboss-unit>
+ </target>
+
+ <target name="cargo.jboss4x.start" depends="cargo.setup">
+ <cargo
+ containerId="jboss42x"
+ home="${JBOSS_4_2_1_HOME}"
+ log="${cargo.log.dir}/cargo.shutdown.log"
+ output="${cargo.log.dir}/cargo.server.log"
+ action="start"
+ wait="false">
+ <sharedClasspath>
+ </sharedClasspath>
+ <configuration>
+ <property name="cargo.servlet.port" value="8080"/>
+ <property name="cargo.logging" value="high"/>
+ <property name="cargo.jvmargs"
value="${cargo.jvmargs.value}"/>
+ </configuration>
+ </cargo>
+ </target>
+
+ <target name="cargo.jboss4x.stop" depends="cargo.setup">
+ <cargo
+ containerId="jboss42x"
+ home="${JBOSS_4_2_1_HOME}"
+ log="${cargo.log.dir}/cargo.startup.log"
+ action="stop">
+ <configuration>
+ <property name="cargo.rmi.port" value="1099"/>
+ </configuration>
+ </cargo>
+ </target>
+
+ <target name="run.test.remote" depends="package-tests">
+ <!-- turn serverside debugging on and off here -->
+ <property name="serverDebug" value="false"/>
+
+ <!-- start the jboss unit remote server side components -->
+ <condition property="debug" value="-Xdebug -Xnoagent
-Xrunjdwp:transport=dt_socket,server=y,address=8787,suspend=y" else="">
+ <istrue value="${serverDebug}"/>
+ </condition>
+ <antcall target="cargo.jboss4x.start">
+ <param name="cargo.jvmargs.value" value="${debug}"/>
+ </antcall>
+
+ <!-- run the actual jboss unit remote test suite -->
+ <antcall target="test.remote">
+ <!-- turn client side debugging on and off here -->
+ <param name="clientDebug" value="false"/>
+ </antcall>
+
+ <!-- stop the jboss unit remote server side components -->
+ <antcall target="cargo.jboss4x.stop"/>
+ </target>
+
+ <target name="cargo.setup" depends="prepare_env">
+ <property name="cargo.log.dir"
value="${target}/test/cargo"/>
+ <mkdir dir="${cargo.log.dir}"/>
+ <taskdef resource="cargo.tasks">
+ <classpath>
+ <pathelement path="${plugin_classpath}"/>
+ </classpath>
+ </taskdef>
+ </target>
+</project>
Property changes on: modules/test/trunk/remote/src/test/build.xml
___________________________________________________________________
Name: svn:executable
+ *
Added:
modules/test/trunk/remote/src/test/java/org/jboss/unit/test/remote/ActualBootstrap.java
===================================================================
---
modules/test/trunk/remote/src/test/java/org/jboss/unit/test/remote/ActualBootstrap.java
(rev 0)
+++
modules/test/trunk/remote/src/test/java/org/jboss/unit/test/remote/ActualBootstrap.java 2008-03-24
14:29:56 UTC (rev 10368)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * 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.test.remote;
+
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ActualBootstrap extends BasicBootstrap
+{
+
+ /** . */
+ private final WebBootstrap callback;
+
+ // I don't know why we need to declare it since super() does not declare it
+ public ActualBootstrap(WebBootstrap callback) throws Exception
+ {
+ super();
+
+ //
+ this.callback = callback;
+ }
+
+ protected void bootstrap() throws Throwable
+ {
+ super.bootstrap();
+
+ //
+ callback.boostrap();
+ }
+
+}
+
Added:
modules/test/trunk/remote/src/test/java/org/jboss/unit/test/remote/WebBootstrap.java
===================================================================
--- modules/test/trunk/remote/src/test/java/org/jboss/unit/test/remote/WebBootstrap.java
(rev 0)
+++
modules/test/trunk/remote/src/test/java/org/jboss/unit/test/remote/WebBootstrap.java 2008-03-24
14:29:56 UTC (rev 10368)
@@ -0,0 +1,246 @@
+/******************************************************************************
+ * 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.test.remote;
+
+import org.jboss.kernel.plugins.deployment.xml.BeanXMLDeployer;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.kernel.spi.event.KernelEventListener;
+import org.jboss.kernel.spi.event.KernelEvent;
+import org.jboss.kernel.spi.registry.KernelRegistry;
+import org.jboss.kernel.spi.registry.KernelRegistryEntry;
+import org.apache.log4j.Logger;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletContextEvent;
+import java.net.URL;
+import java.net.MalformedURLException;
+
+/**
+ * A kernel bootstrap with a life cycle triggered by the
<code>ServletContextListener</code> interface.
+ * All beans will be injected as servlet context attributes. The bean xml file must be
available as
+ * a servlet context resource under the path
<i>/WEB-INF/jboss-beans.xml</i>.
+ *
+ * @todo specify an alternative logger name
+ * @todo implement the specification of an alternative xml file path
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class WebBootstrap implements ServletContextListener, KernelEventListener
+{
+
+ /**
+ * The servlet context init parameter name for the bean resource location. For
instance for a web application
+ * resource it could be <i>/WEB-INF/my-beans.xml</i>, for the web
application classloader resource it could be
+ * <i>org/jboss/portal/my-beans.xml</i>. If no init parameter is declared
then the litteral value
+ * <i>/WEB-INF/jboss-beans.xml</i> is used and the lookup is done in the
servlet context resourcees.
+ */
+ public static final String BEANS_RESOURCE_LOCATION_KEY =
"jboss.portal.mc.beans_resource_location";
+
+ /**
+ * The servlet context init parameter name for the bean resource type which can be the
servlet context
+ * or the web application classloader. If no value is specified the servlet context
will be used for
+ * resource lookup. The legal values are <i>context</i> for the servlet
context and <i>classloader</i>
+ * for the web application classloader.
+ */
+ public static final String BEANS_RESOURCE_TYPE_KEY =
"jboss.portal.mc.beans_resource_type";
+
+ /** Default value for the bean resource location. */
+ public static final String DEFAULT_JBOSS_BEANS_RESOURCE_LOCATION =
"/WEB-INF/jboss-beans.xml";
+
+ /** Servlet context resource type. */
+ public static final String CONTEXT_RESOURCE_TYPE = "context";
+
+ /** Classloader resource type. */
+ public static final String CLASSLOADER_RESOURCE_TYPE = "classloader";
+
+ /** . */
+ private final static Logger log = Logger.getLogger(WebBootstrap.class);
+
+ /** . */
+ private ServletContext servletContext;
+
+ /** . */
+ private BeanXMLDeployer deployer;
+
+ /** . */
+ private KernelDeployment deployment;
+
+ /** . */
+ private boolean registered;
+
+ /** . */
+ private ActualBootstrap bootstrap;
+
+ public void contextInitialized(ServletContextEvent event)
+ {
+ servletContext = event.getServletContext();
+
+ //
+ try
+ {
+ bootstrap = new ActualBootstrap(this);
+
+ //
+ bootstrap.run();
+
+ //
+ log.info("Web kernel started");
+ }
+ catch (Exception e)
+ {
+ log.info("Web kernel boostrap failed", e);
+ }
+ }
+
+ public void contextDestroyed(ServletContextEvent event)
+ {
+ log.info("Web kernel shutdown");
+
+ //
+ if (deployment != null)
+ {
+ deployer.undeploy(deployment);
+ }
+
+ //
+ if (registered)
+ {
+ registered = false;
+ try
+ {
+ KernelRegistry registry = bootstrap.getKernel().getRegistry();
+ registry.unregisterListener(this, null, "ABC");
+ }
+ catch (Throwable throwable)
+ {
+ log.error("Cannot unregister kernel registry listener",
throwable);
+ }
+ }
+
+ //
+ servletContext = null;
+
+ //
+ log.info("Web kernel stopped");
+ }
+
+ public void onEvent(KernelEvent event, Object object)
+ {
+ Object context = event.getContext();
+ if (context instanceof String)
+ {
+ String key = (String)context;
+ String type = event.getType();
+ if ("KERNEL_REGISTRY_REGISTERED".equals(type))
+ {
+ KernelRegistryEntry entry =
bootstrap.getKernel().getRegistry().getEntry(context);
+ Object target = entry.getTarget();
+ servletContext.setAttribute(key, target);
+ }
+ else if ("KERNEL_REGISTRY_UNREGISTERED".equals(type))
+ {
+ servletContext.removeAttribute(key);
+ }
+ }
+ }
+
+ void boostrap() throws Throwable
+ {
+ //
+ bootstrap.getKernel().getRegistry().registerListener(WebBootstrap.this, null,
"ABC");
+ registered = true;
+
+ //
+ deployer = new BeanXMLDeployer(bootstrap.getKernel());
+
+ //
+ URL url = getBeansURL();
+
+ //
+ if (url != null)
+ {
+ log.debug("About to deploy beans url=" + url);
+ deployment = deployer.deploy(url);
+ }
+ else
+ {
+ log.error("No valid beans URL was determined");
+ }
+ }
+
+ protected URL getBeansURL()
+ {
+ String location = servletContext.getInitParameter(BEANS_RESOURCE_LOCATION_KEY);
+ String type = servletContext.getInitParameter(BEANS_RESOURCE_TYPE_KEY);
+
+ //
+ if (location == null)
+ {
+ location = DEFAULT_JBOSS_BEANS_RESOURCE_LOCATION;
+ type = CONTEXT_RESOURCE_TYPE;
+ }
+ else if (type == null)
+ {
+ type = CONTEXT_RESOURCE_TYPE;
+ }
+
+ //
+ if (CONTEXT_RESOURCE_TYPE.equals(type))
+ {
+ try
+ {
+ return servletContext.getResource(location);
+ }
+ catch (MalformedURLException e)
+ {
+ log.error("Cannot obtain beans definition file from servlet context with
location=" + location, e);
+
+ //
+ return null;
+ }
+ }
+ else if (CLASSLOADER_RESOURCE_TYPE.equals(type))
+ {
+ URL resource =
Thread.currentThread().getContextClassLoader().getResource(location);
+
+ //
+ if (resource == null)
+ {
+ log.error("Cannot obtain bean definition file from thread context
classloader with location=" + location);
+ }
+
+ //
+ return resource;
+ }
+ else
+ {
+ log.error("Cannot obtain bean definition file since the context type cannot
be determined type=" + type);
+
+ //
+ return null;
+ }
+ }
+}
+
Added:
modules/test/trunk/remote/src/test/java/org/jboss/unit/test/remote/webpage/ClickLinkCommandTestCase.java
===================================================================
---
modules/test/trunk/remote/src/test/java/org/jboss/unit/test/remote/webpage/ClickLinkCommandTestCase.java
(rev 0)
+++
modules/test/trunk/remote/src/test/java/org/jboss/unit/test/remote/webpage/ClickLinkCommandTestCase.java 2008-03-24
14:29:56 UTC (rev 10368)
@@ -0,0 +1,169 @@
+/******************************************************************************
+ * 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.test.remote.webpage;
+
+import org.jboss.unit.TestId;
+import org.jboss.unit.driver.DriverCommand;
+import org.jboss.unit.driver.DriverContext;
+import org.jboss.unit.driver.DriverException;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.command.StartTestCommand;
+import static org.jboss.unit.api.Assert.*;
+import org.jboss.unit.info.TestInfo;
+import org.jboss.unit.info.impl.SimpleTestCaseInfo;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.remote.RequestContext;
+import org.jboss.unit.remote.ResponseContext;
+import org.jboss.unit.remote.driver.RemoteTestDriver;
+
+import org.jboss.unit.remote.driver.webpage.ClickLinkResponse;
+import org.jboss.unit.remote.driver.webpage.WebPageData;
+
+import org.jboss.logging.Logger;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.net.URI;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class ClickLinkCommandTestCase implements RemoteTestDriver
+{
+ private static Logger log = Logger.getLogger(ClickLinkCommandTestCase.class);
+
+ private TestInfo info = null;
+ private DriverResponse activeResponse = null;
+ private RequestContext testContext = null;
+
+ private String uri = null;
+ private String link = null;
+
+ /**
+ *
+ *
+ */
+ public ClickLinkCommandTestCase()
+ {
+
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getUri()
+ {
+ return uri;
+ }
+
+ /**
+ *
+ * @param uri
+ */
+ public void setUri(String uri)
+ {
+ this.uri = uri;
+ }
+
+
+ public String getLink()
+ {
+ return link;
+ }
+
+ public void setLink(String link)
+ {
+ this.link = link;
+ }
+
//----------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ */
+ public void initDriver(DriverContext context) throws DriverException
+ {
+ this.info = new SimpleTestCaseInfo(this.getClass().getName());
+ }
+
+ /**
+ *
+ */
+ public void destroyDriver()
+ {
+ }
+
+ /**
+ *
+ */
+ public TestInfo getInfo()
+ {
+ return this.info;
+ }
+
+ /**
+ *
+ */
+ public DriverResponse invoke(TestId id, DriverCommand command)
+ {
+ try
+ {
+ if(command instanceof StartTestCommand)
+ {
+ this.activeResponse = new ClickLinkResponse(new URI(this.uri), this.link);
+ }
+ else
+ {
+ //assess data after extracting data from client side
+ WebPageData pageData =
(WebPageData)testContext.getPayload().get("pageData");
+ assertNotNull(pageData);
+
+ this.activeResponse = new EndTestResponse();
+ }
+
+ return this.activeResponse;
+ }
+ catch(Exception e)
+ {
+ log.error(e);
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ *
+ */
+ public void pushContext(TestId testId, RequestContext testContext)
+ {
+ this.testContext = testContext;
+ }
+
+ /**
+ *
+ */
+ public ResponseContext popContext(TestId testId)
+ {
+ DriverResponse response = this.invoke(testId, null);
+ return new ResponseContext(response, new HashMap<String, Serializable>());
+ }
+}
Added:
modules/test/trunk/remote/src/test/java/org/jboss/unit/test/remote/webpage/GetPageCommandTestCase.java
===================================================================
---
modules/test/trunk/remote/src/test/java/org/jboss/unit/test/remote/webpage/GetPageCommandTestCase.java
(rev 0)
+++
modules/test/trunk/remote/src/test/java/org/jboss/unit/test/remote/webpage/GetPageCommandTestCase.java 2008-03-24
14:29:56 UTC (rev 10368)
@@ -0,0 +1,157 @@
+/******************************************************************************
+ * 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.test.remote.webpage;
+
+import org.jboss.unit.TestId;
+import org.jboss.unit.driver.DriverCommand;
+import org.jboss.unit.driver.DriverContext;
+import org.jboss.unit.driver.DriverException;
+import org.jboss.unit.driver.DriverResponse;
+import org.jboss.unit.driver.command.StartTestCommand;
+import static org.jboss.unit.api.Assert.*;
+import org.jboss.unit.info.TestInfo;
+import org.jboss.unit.info.impl.SimpleTestCaseInfo;
+import org.jboss.unit.driver.response.EndTestResponse;
+import org.jboss.unit.remote.RequestContext;
+import org.jboss.unit.remote.ResponseContext;
+import org.jboss.unit.remote.driver.RemoteTestDriver;
+
+import org.jboss.unit.remote.driver.webpage.GetPageResponse;
+import org.jboss.unit.remote.driver.webpage.WebPageData;
+
+import org.jboss.logging.Logger;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.net.URI;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class GetPageCommandTestCase implements RemoteTestDriver
+{
+ private static Logger log = Logger.getLogger(GetPageCommandTestCase.class);
+
+ private TestInfo info = null;
+ private DriverResponse activeResponse = null;
+ private RequestContext testContext = null;
+
+ private String uri = null;
+
+ /**
+ *
+ *
+ */
+ public GetPageCommandTestCase()
+ {
+
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getUri()
+ {
+ return uri;
+ }
+
+ /**
+ *
+ * @param uri
+ */
+ public void setUri(String uri)
+ {
+ this.uri = uri;
+ }
+
//----------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ */
+ public void initDriver(DriverContext context) throws DriverException
+ {
+ this.info = new SimpleTestCaseInfo(this.getClass().getName());
+ }
+
+ /**
+ *
+ */
+ public void destroyDriver()
+ {
+ }
+
+ /**
+ *
+ */
+ public TestInfo getInfo()
+ {
+ return this.info;
+ }
+
+ /**
+ *
+ */
+ public DriverResponse invoke(TestId id, DriverCommand command)
+ {
+ try
+ {
+ if(command instanceof StartTestCommand)
+ {
+ this.activeResponse = new GetPageResponse(new URI(this.uri));
+ }
+ else
+ {
+ //assess data after extracting data from client side
+ WebPageData pageData =
(WebPageData)testContext.getPayload().get("pageData");
+ assertNotNull(pageData);
+
+ this.activeResponse = new EndTestResponse();
+ }
+
+ return this.activeResponse;
+ }
+ catch(Exception e)
+ {
+ log.error(e);
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ *
+ */
+ public void pushContext(TestId testId, RequestContext testContext)
+ {
+ this.testContext = testContext;
+ }
+
+ /**
+ *
+ */
+ public ResponseContext popContext(TestId testId)
+ {
+ DriverResponse response = this.invoke(testId, null);
+ return new ResponseContext(response, new HashMap<String, Serializable>());
+ }
+}
Added: modules/test/trunk/remote/src/test/resources/ear/META-INF/application.xml
===================================================================
--- modules/test/trunk/remote/src/test/resources/ear/META-INF/application.xml
(rev 0)
+++ modules/test/trunk/remote/src/test/resources/ear/META-INF/application.xml 2008-03-24
14:29:56 UTC (rev 10368)
@@ -0,0 +1,9 @@
+<application>
+ <module>
+ <web>
+ <web-uri>
+ test-remote.war
+ </web-uri>
+ </web>
+ </module>
+</application>
\ No newline at end of file
Added: modules/test/trunk/remote/src/test/resources/ear/META-INF/jboss-app.xml
===================================================================
--- modules/test/trunk/remote/src/test/resources/ear/META-INF/jboss-app.xml
(rev 0)
+++ modules/test/trunk/remote/src/test/resources/ear/META-INF/jboss-app.xml 2008-03-24
14:29:56 UTC (rev 10368)
@@ -0,0 +1,3 @@
+<jboss-app>
+ <loader-repository>test:loader=test-remote</loader-repository>
+</jboss-app>
\ No newline at end of file
Added: modules/test/trunk/remote/src/test/resources/remote-jboss-unit.xml
===================================================================
--- modules/test/trunk/remote/src/test/resources/remote-jboss-unit.xml
(rev 0)
+++ modules/test/trunk/remote/src/test/resources/remote-jboss-unit.xml 2008-03-24 14:29:56
UTC (rev 10368)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jboss-unit
+ xmlns="urn:jboss:jboss-unit:1.0"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
+ <generic>
+ <class
name="org.jboss.unit.remote.driver.RemoteTestDriverClient"/>
+ </generic>
+</jboss-unit>
\ No newline at end of file
Added: modules/test/trunk/remote/src/test/resources/server-beans.xml
===================================================================
--- modules/test/trunk/remote/src/test/resources/server-beans.xml
(rev 0)
+++ modules/test/trunk/remote/src/test/resources/server-beans.xml 2008-03-24 14:29:56 UTC
(rev 10368)
@@ -0,0 +1,77 @@
+<?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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<deployment
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_2_0.xsd"
+ xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- Setting up remoting infrastructure -->
+ <bean name="RemoteTestSuite"
class="org.jboss.unit.remote.driver.CompositeRemoteTestDriver">
+ <constructor>
+ <parameter
class="org.jboss.unit.driver.impl.composite.AbstractCompositeTestDriver"><inject
bean="TestSuite"/></parameter>
+ </constructor>
+ </bean>
+
+ <bean name="TestDriverServer"
class="org.jboss.unit.remote.driver.RemoteTestDriverServer">
+ <property name="delegate"><inject
bean="RemoteTestSuite"/></property>
+ </bean>
+
+ <bean name="TestDriverServerExporter"
class="org.jboss.portal.test.framework.impl.generic.server.GenericServiceExporter">
+ <constructor>
+ <parameter>socket://localhost:5400</parameter>
+ <parameter><inject
bean="TestDriverServer"/></parameter>
+
<parameter>org.jboss.unit.remote.driver.RemoteTestDriver</parameter>
+ </constructor>
+ </bean>
+
+ <!-- Setting up the TestSuite to be run on the Server -->
+ <bean name="TestSuite"
class="org.jboss.unit.driver.impl.composite.CompositeTestDriver"/>
+
+ <!-- GetPageCommandTestCase -->
+ <bean name="GetPageCommandTestCase"
class="org.jboss.unit.test.remote.webpage.GetPageCommandTestCase">
+ <install bean="TestSuite" method="mount">
+ <parameter><this/></parameter>
+ </install>
+ <uninstall bean="TestSuite" method="unmount">
+ <parameter><this/></parameter>
+ </uninstall>
+ <!-- Configuration for the test case -->
+ <!-- url of the web page to be accessed/asserted -->
+ <property
name="uri">http://localhost:8080/test-remote</property>
+ </bean>
+
+ <!-- GetPageCommandTestCase -->
+ <bean name="ClickLinkCommandTestCase"
class="org.jboss.unit.test.remote.webpage.ClickLinkCommandTestCase">
+ <install bean="TestSuite" method="mount">
+ <parameter><this/></parameter>
+ </install>
+ <uninstall bean="TestSuite" method="unmount">
+ <parameter><this/></parameter>
+ </uninstall>
+ <!-- Configuration for the test case -->
+ <property
name="uri">http://localhost:8080/test-remote</property>
+ <property name="link">link1</property>
+ </bean>
+</deployment>
\ No newline at end of file
Added: modules/test/trunk/remote/src/test/resources/servers.xml
===================================================================
--- modules/test/trunk/remote/src/test/resources/servers.xml (rev
0)
+++ modules/test/trunk/remote/src/test/resources/servers.xml 2008-03-24 14:29:56 UTC (rev
10368)
@@ -0,0 +1,42 @@
+<server>
+ <server>
+ <server-name>RemoteJBoss_4_2_1</server-name>
+ <node>
+ <node-id>default</node-id>
+ <service>
+ <service-name>TestDriverServer</service-name>
+ <interface>org.jboss.unit.remote.driver.RemoteTestDriver</interface>
+ <uri>socket://localhost:5400</uri>
+ </service>
+ <deployer>
+ <remote>
+ <name>jboss4x</name>
+ <host>localhost</host>
+ <port>8080</port>
+ </remote>
+ </deployer>
+ </node>
+ </server>
+ <server>
+ <server-name>RemoteTomcat_6_0</server-name>
+ <node>
+ <node-id>default</node-id>
+ <service>
+ <service-name>TestDriverServer</service-name>
+
<interface>org.jboss.unit.remote.driver.RemoteTestDriver</interface>
+ <uri>socket://localhost:5400</uri>
+ </service>
+ <deployer>
+ <remote>
+ <name>tomcat5x</name>
+ <host>localhost</host>
+ <port>8080</port>
+ </remote>
+ <authentication>
+ <username>admin</username>
+ <password>admin</password>
+ </authentication>
+ </deployer>
+ </node>
+ </server>
+</server>
\ No newline at end of file
Added: modules/test/trunk/remote/src/test/resources/war/WEB-INF/web.xml
===================================================================
--- modules/test/trunk/remote/src/test/resources/war/WEB-INF/web.xml
(rev 0)
+++ modules/test/trunk/remote/src/test/resources/war/WEB-INF/web.xml 2008-03-24 14:29:56
UTC (rev 10368)
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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 web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <context-param>
+ <param-name>jboss.portal.mc.beans_resource_location</param-name>
+ <param-value>server-beans.xml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>jboss.portal.mc.beans_resource_type</param-name>
+ <param-value>classloader</param-value>
+ </context-param>
+ <listener>
+
<listener-class>org.jboss.unit.test.remote.WebBootstrap</listener-class>
+ </listener>
+</web-app>
Added: modules/test/trunk/remote/src/test/resources/war/index.html
===================================================================
--- modules/test/trunk/remote/src/test/resources/war/index.html
(rev 0)
+++ modules/test/trunk/remote/src/test/resources/war/index.html 2008-03-24 14:29:56 UTC
(rev 10368)
@@ -0,0 +1,10 @@
+<html>
+ <head>
+ <title>JBoss Unit Test Framework</title>
+ </head>
+ <body>
+ <h1 id="h1">JBoss Unit Test Framework - Remoting Component</h1>
+
+ <a id="link1" href="link1.html">Link 1</a>
+ </body>
+</html>
\ No newline at end of file
Added: modules/test/trunk/remote/src/test/resources/war/link1.html
===================================================================
--- modules/test/trunk/remote/src/test/resources/war/link1.html
(rev 0)
+++ modules/test/trunk/remote/src/test/resources/war/link1.html 2008-03-24 14:29:56 UTC
(rev 10368)
@@ -0,0 +1,8 @@
+<html>
+ <head>
+ <title>JBoss Unit Test Framework - Link1</title>
+ </head>
+ <body>
+ <h1 id="h1">JBoss Unit Test Framework - Remoting Component -
Link1.html</h1>
+ </body>
+</html>
\ No newline at end of file
Property changes on: modules/test/trunk/test/agent
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: modules/test/trunk/test/core
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: modules/test/trunk/test/generic
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: modules/test/trunk/test/jboss
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: modules/test/trunk/test/opends
___________________________________________________________________
Name: svn:ignore
+ target
Modified:
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/impl/generic/agent/GenericTestAgent.java
===================================================================
---
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/impl/generic/agent/GenericTestAgent.java 2008-03-23
00:15:32 UTC (rev 10367)
+++
modules/test/trunk/test/src/main/java/org/jboss/portal/test/framework/impl/generic/agent/GenericTestAgent.java 2008-03-24
14:29:56 UTC (rev 10368)
@@ -30,6 +30,7 @@
import org.codehaus.cargo.container.deployer.Deployer;
import org.codehaus.cargo.container.deployable.Deployable;
import org.codehaus.cargo.container.deployable.WAR;
+import org.codehaus.cargo.container.deployable.EAR;
import org.codehaus.cargo.container.configuration.Configuration;
import org.codehaus.cargo.container.property.RemotePropertySet;
import org.codehaus.cargo.container.Container;
@@ -143,6 +144,10 @@
{
return new WAR(f.getAbsolutePath());
}
+ else if(f.getName().endsWith(".ear"))
+ {
+ return new EAR(f.getAbsolutePath());
+ }
}
}
throw new IllegalArgumentException("Illegal URL " + url);
Property changes on: modules/test/trunk/tooling/ant
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: modules/test/trunk/tooling/core
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: modules/test/trunk/tooling/examples/ant
___________________________________________________________________
Name: svn:ignore
+ output
Property changes on: modules/test/trunk/tooling/maven2
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: modules/test/trunk/unit
___________________________________________________________________
Name: svn:ignore
+ output
target