You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2009/12/15 17:43:55 UTC
svn commit: r890879 - in /tapestry/tapestry5/trunk/tapestry-test: ./
src/main/java/org/apache/tapestry5/test/
Author: hlship
Date: Tue Dec 15 16:43:54 2009
New Revision: 890879
URL: http://svn.apache.org/viewvc?rev=890879&view=rev
Log:
Initial work on T5-951
Added:
tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/Jetty7Runner.java (with props)
tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumLauncher.java (with props)
tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java (with props)
Modified:
tapestry/tapestry5/trunk/tapestry-test/pom.xml
tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/AbstractIntegrationTestSuite.java
tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/JettyRunner.java
tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/TapestryTestConstants.java
Modified: tapestry/tapestry5/trunk/tapestry-test/pom.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-test/pom.xml?rev=890879&r1=890878&r2=890879&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-test/pom.xml (original)
+++ tapestry/tapestry5/trunk/tapestry-test/pom.xml Tue Dec 15 16:43:54 2009
@@ -1,75 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
- <modelVersion>4.0.0</modelVersion>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.tapestry</groupId>
+ <artifactId>tapestry-test</artifactId>
+ <name>Tapestry Test Utilities</name>
+ <inceptionYear>2007</inceptionYear>
+ <description>Test utilities needed by Tapestry</description>
+ <parent>
<groupId>org.apache.tapestry</groupId>
- <artifactId>tapestry-test</artifactId>
- <name>Tapestry Test Utilities</name>
- <inceptionYear>2007</inceptionYear>
- <description>Test utilities needed by Tapestry</description>
- <parent>
- <groupId>org.apache.tapestry</groupId>
- <artifactId>tapestry-project</artifactId>
- <version>5.2.0-SNAPSHOT</version>
- </parent>
+ <artifactId>tapestry-project</artifactId>
+ <version>5.2.0-SNAPSHOT</version>
+ </parent>
- <dependencies>
- <dependency>
- <groupId>org.seleniumhq.selenium.client-drivers</groupId>
- <artifactId>selenium-java-client-driver</artifactId>
- <version>${selenium-version}</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.seleniumhq.selenium.server</groupId>
- <artifactId>selenium-server</artifactId>
- <version>${selenium-version}</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.seleniumhq.selenium.server</groupId>
- <artifactId>selenium-server-coreless</artifactId>
- <version>${selenium-version}</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <version>${testng-version}</version>
- <classifier>jdk15</classifier>
- <scope>compile</scope>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <reportSets>
- <reportSet>
- <reports>
- <report>summary</report>
- <report>dependencies</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- </plugins>
- </reporting>
-
-
- <properties>
- <selenium-version>1.0.1</selenium-version>
- </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.seleniumhq.selenium.client-drivers</groupId>
+ <artifactId>selenium-java-client-driver</artifactId>
+ <version>${selenium-version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.seleniumhq.selenium.server</groupId>
+ <artifactId>selenium-server</artifactId>
+ <version>${selenium-version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.seleniumhq.selenium.server</groupId>
+ <artifactId>selenium-server-coreless</artifactId>
+ <version>${selenium-version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>${testng-version}</version>
+ <classifier>jdk15</classifier>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <version>${jetty-version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-jndi</artifactId>
+ <version>${jetty-version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-plus</artifactId>
+ <version>${jetty-version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-webapp</artifactId>
+ <version>${jetty-version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>summary</report>
+ <report>dependencies</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ </plugins>
+ </reporting>
+
+
+ <properties>
+ <selenium-version>1.0.1</selenium-version>
+ <jetty-version>7.0.0.v20091005</jetty-version>
+ </properties>
</project>
Modified: tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/AbstractIntegrationTestSuite.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/AbstractIntegrationTestSuite.java?rev=890879&r1=890878&r2=890879&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/AbstractIntegrationTestSuite.java (original)
+++ tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/AbstractIntegrationTestSuite.java Tue Dec 15 16:43:54 2009
@@ -25,24 +25,27 @@
import org.testng.annotations.BeforeClass;
/**
- * A base class for creating integration tests. Ths encapsulates starting up an in-process copy of Jetty, and in-process
+ * A base class for creating integration tests. Ths encapsulates starting up an in-process copy of
+ * Jetty, and in-process
* copy of {@link SeleniumServer}, and a Selenium client.
* <p/>
- * Unless you are <em>very, very clever</em>, you will want to run the tests sequentially. TestNG tends to run them in
- * an arbitrary order unless you explicitly set the order. If you have managed to get TestNG to run tests in parallel,
- * you may see further problems caused by a single client jumping all over your web application in an unpredictable
- * order.
+ * Unless you are <em>very, very clever</em>, you will want to run the tests sequentially. TestNG
+ * tends to run them in an arbitrary order unless you explicitly set the order. If you have managed
+ * to get TestNG to run tests in parallel, you may see further problems caused by a single client
+ * jumping all over your web application in an unpredictable order.
* <p/>
- * This class implements the {@link Selenium} interface, and delegates all those methods to the {@link DefaultSelenium}
- * instance it creates. It also extends the normal exception reporting for any failed command or query to produce a more
- * detailed report to the main console.
- *
+ * This class implements the {@link Selenium} interface, and delegates all those methods to the
+ * {@link DefaultSelenium} instance it creates. It also extends the normal exception reporting for
+ * any failed command or query to produce a more detailed report to the main console.
+ *
* @see org.apache.tapestry5.test.JettyRunner
+ * @deprecated Use {@link SeleniumLauncher} and {@link SeleniumTestCase} instead.
*/
public class AbstractIntegrationTestSuite extends Assert implements Selenium
{
/**
- * Default directory containing the web application to be tested (this conforms to Maven's default folder).
+ * Default directory containing the web application to be tested (this conforms to Maven's
+ * default folder).
*/
public static final String DEFAULT_WEB_APP_ROOT = "src/main/webapp";
@@ -67,7 +70,6 @@
public static final String SUBMIT = "//input[@type='submit']";
-
private String webappRoot;
private final String seleniumBrowserCommand;
@@ -77,7 +79,7 @@
private Selenium selenium;
private SeleniumServer server;
-
+
private String[] virtualHosts;
/**
@@ -89,7 +91,8 @@
}
/**
- * @param webAppRoot the directory containing the web application to be tested.
+ * @param webAppRoot
+ * the directory containing the web application to be tested.
*/
protected AbstractIntegrationTestSuite(String webAppRoot)
{
@@ -97,12 +100,17 @@
}
/**
- * @param webAppRoot web application root (default src/main/webapp)
- * @param browserCommand browser command to pass to selenium. Default is *firefox, syntax for custom browsers is
- * *custom <path_to_browser>, e.g. *custom /usr/lib/mozilla-firefox/firefox
- * @param virtualHosts an array with virtual hosts
+ * @param webAppRoot
+ * web application root (default src/main/webapp)
+ * @param browserCommand
+ * browser command to pass to selenium. Default is *firefox, syntax for custom
+ * browsers is
+ * *custom <path_to_browser>, e.g. *custom /usr/lib/mozilla-firefox/firefox
+ * @param virtualHosts
+ * an array with virtual hosts
*/
- protected AbstractIntegrationTestSuite(String webAppRoot, String browserCommand, String... virtualHosts)
+ protected AbstractIntegrationTestSuite(String webAppRoot, String browserCommand,
+ String... virtualHosts)
{
webappRoot = webAppRoot;
seleniumBrowserCommand = browserCommand;
@@ -115,7 +123,8 @@
for (String snippet : expected)
{
- if (source.contains(snippet)) continue;
+ if (source.contains(snippet))
+ continue;
System.err.printf("Source content '%s' not found in:\n%s\n\n", snippet, source);
@@ -125,9 +134,11 @@
/**
* Used when the locator identifies an attribute, not an element.
- *
- * @param locator identifies the attribute whose value is to be asserted
- * @param expected expected value for the attribute
+ *
+ * @param locator
+ * identifies the attribute whose value is to be asserted
+ * @param expected
+ * expected value for the attribute
*/
protected final void assertAttribute(String locator, String expected)
{
@@ -140,24 +151,27 @@
catch (RuntimeException ex)
{
System.err.printf("Error accessing %s: %s, in:\n\n%s\n\n", locator, ex.getMessage(),
- selenium.getHtmlSource());
+ selenium.getHtmlSource());
throw ex;
}
- if (actual.equals(expected)) return;
+ if (actual.equals(expected))
+ return;
- System.err.printf("Text for attribute %s should be '%s' but is '%s', in:\n\n%s\n\n", locator, expected, actual,
- getHtmlSource());
+ System.err.printf("Text for attribute %s should be '%s' but is '%s', in:\n\n%s\n\n",
+ locator, expected, actual, getHtmlSource());
throw new AssertionError(String.format("%s was '%s' not '%s'", locator, actual, expected));
}
/**
* Asserts the text of an element, identified by the locator.
- *
- * @param locator identifies the element whose text value is to be asserted
- * @param expected expected value for the element's text
+ *
+ * @param locator
+ * identifies the element whose text value is to be asserted
+ * @param expected
+ * expected value for the element's text
*/
protected final void assertText(String locator, String expected)
{
@@ -170,15 +184,16 @@
catch (RuntimeException ex)
{
System.err.printf("Error accessing %s: %s, in:\n\n%s\n\n", locator, ex.getMessage(),
- selenium.getHtmlSource());
+ selenium.getHtmlSource());
throw ex;
}
- if (actual.equals(expected)) return;
+ if (actual.equals(expected))
+ return;
- System.err.printf("Text for %s should be '%s' but is '%s', in:\n\n%s\n\n", locator, expected, actual,
- getHtmlSource());
+ System.err.printf("Text for %s should be '%s' but is '%s', in:\n\n%s\n\n", locator,
+ expected, actual, getHtmlSource());
throw new AssertionError(String.format("%s was '%s' not '%s'", locator, actual, expected));
}
@@ -187,7 +202,8 @@
{
for (String item : text)
{
- if (isTextPresent(item)) continue;
+ if (isTextPresent(item))
+ continue;
System.err.printf("Text pattern '%s' not found in:\n%s\n\n", item, selenium
.getHtmlSource());
@@ -236,7 +252,6 @@
}
}
-
protected final void assertFieldValueSeries(String idFormat, int startIndex, String... values)
{
for (int i = 0; i < values.length; i++)
@@ -246,11 +261,11 @@
assertFieldValue(id, values[i]);
}
}
-
+
protected void waitForCSSSelectedElementToAppear(String cssRule)
{
- String condition = String.format("selenium.browserbot.getCurrentWindow().$$(\"%s\").size() > 0",
- cssRule);
+ String condition = String.format(
+ "selenium.browserbot.getCurrentWindow().$$(\"%s\").size() > 0", cssRule);
waitForCondition(condition, PAGE_LOAD_TIMEOUT);
@@ -259,36 +274,37 @@
@AfterClass(alwaysRun = true)
public void cleanup() throws Exception
{
- if (selenium!=null)
- {
- selenium.stop();
- selenium = null;
- }
-
- if (server!=null)
- {
- server.stop();
- server = null;
- }
-
- if (jettyRunner!=null)
- {
- jettyRunner.stop();
- jettyRunner = null;
- }
+ if (selenium != null)
+ {
+ selenium.stop();
+ selenium = null;
+ }
+
+ if (server != null)
+ {
+ server.stop();
+ server = null;
+ }
+
+ if (jettyRunner != null)
+ {
+ jettyRunner.stop();
+ jettyRunner = null;
+ }
}
@BeforeClass(alwaysRun = true)
public void setup() throws Exception
{
- jettyRunner = new JettyRunner(TapestryTestConstants.MODULE_BASE_DIR, "/", JETTY_PORT, webappRoot, virtualHosts);
+ jettyRunner = new JettyRunner(TapestryTestConstants.MODULE_BASE_DIR, "/", JETTY_PORT,
+ webappRoot, virtualHosts);
server = new SeleniumServer();
server.start();
- CommandProcessor cp = new HttpCommandProcessor("localhost", RemoteControlConfiguration.DEFAULT_PORT,
- seleniumBrowserCommand, BASE_URL);
+ CommandProcessor cp = new HttpCommandProcessor("localhost",
+ RemoteControlConfiguration.DEFAULT_PORT, seleniumBrowserCommand, BASE_URL);
selenium = new DefaultSelenium(new ErrorReportingCommandProcessor(cp));
@@ -520,7 +536,8 @@
return selenium.getWhetherThisFrameMatchFrameExpression(currentFrameString, target);
}
- public boolean getWhetherThisWindowMatchWindowExpression(String currentWindowString, String target)
+ public boolean getWhetherThisWindowMatchWindowExpression(String currentWindowString,
+ String target)
{
return selenium.getWhetherThisWindowMatchWindowExpression(currentWindowString, target);
}
@@ -758,7 +775,8 @@
selenium.dragAndDrop(locator, movementsString);
}
- public void dragAndDropToObject(String locatorOfObjectToBeDragged, String locatorOfDragDestinationObject)
+ public void dragAndDropToObject(String locatorOfObjectToBeDragged,
+ String locatorOfDragDestinationObject)
{
selenium.dragAndDropToObject(locatorOfObjectToBeDragged, locatorOfDragDestinationObject);
}
@@ -959,10 +977,11 @@
}
/**
- * Used to start a typical test, by opening to the base URL and clicking through a series of links.
+ * Used to start a typical test, by opening to the base URL and clicking through a series of
+ * links.
* <p/>
- * Note: Selenium 1.0-beta-2 has introduced a method start(String) which is distinct from this implementation (which
- * dates back to Tapestry 5.0 and Selenium 1.0-beta-1).
+ * Note: Selenium 1.0-beta-2 has introduced a method start(String) which is distinct from this
+ * implementation (which dates back to Tapestry 5.0 and Selenium 1.0-beta-1).
*/
protected final void start(String... linkText)
{
@@ -1111,45 +1130,47 @@
}
/**
- * This does NOT invoke {@link com.thoughtworks.selenium.Selenium#start(String)}; it invokes {@link
- * #start(String[])}. This is necesasry due to the introduction of the start() method.
- *
- * @param linkText text of link to click
+ * This does NOT invoke {@link com.thoughtworks.selenium.Selenium#start(String)}; it invokes
+ * {@link #start(String[])}. This is necesasry due to the introduction of the start() method.
+ *
+ * @param linkText
+ * text of link to click
* @since 5.1.0.0
*/
public void start(String linkText)
{
- start(new String[] { linkText });
+ start(new String[]
+ { linkText });
}
/**
* @since 5.2.0.0
*/
- public void addCustomRequestHeader(String key, String value)
+ public void addCustomRequestHeader(String key, String value)
{
selenium.addCustomRequestHeader(key, value);
}
-
+
/**
* @since 5.2.0.0
*/
- public String captureNetworkTraffic(String type)
+ public String captureNetworkTraffic(String type)
{
return selenium.captureNetworkTraffic(type);
}
-
+
/**
* @since 5.2.0.0
*/
- public void deselectPopUp()
+ public void deselectPopUp()
{
selenium.deselectPopUp();
}
-
+
/**
* @since 5.2.0.0
*/
- public void selectPopUp(String windowID)
+ public void selectPopUp(String windowID)
{
selenium.selectPopUp(windowID);
}
Added: tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/Jetty7Runner.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/Jetty7Runner.java?rev=890879&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/Jetty7Runner.java (added)
+++ tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/Jetty7Runner.java Tue Dec 15 16:43:54 2009
@@ -0,0 +1,90 @@
+// Copyright 2009 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.test;
+
+import java.io.File;
+
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.webapp.WebAppContext;
+
+/**
+ * Launches an instance of Jetty7.
+ */
+public class Jetty7Runner
+{
+ private final Server jettyServer;
+
+ private final String description;
+
+ private final int port;
+
+ public Jetty7Runner(String webappFolder, String contextPath, int port) throws Exception
+ {
+ this.port = port;
+
+ String expandedPath = expand(webappFolder);
+
+ description = String.format("<Jetty7Runner: %s:%s (%s)", contextPath, port, expandedPath);
+
+ jettyServer = new Server(port);
+
+ WebAppContext webapp = new WebAppContext();
+ webapp.setContextPath(contextPath);
+ webapp.setWar(expandedPath);
+
+ // TODO: SSL support
+
+ jettyServer.setHandler(webapp);
+
+ jettyServer.start();
+ }
+
+ /** Immediately shuts down the server instance. */
+ public void stop()
+ {
+ System.out.printf("Stopping Jetty instance on port %d\n", port);
+
+ try
+ {
+ // Stop immediately and not gracefully.
+ jettyServer.stop();
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException("Error stopping Jetty instance: " + ex.toString(), ex);
+ }
+
+ System.out.println("Jetty instance has stopped.");
+ }
+
+ @Override
+ public String toString()
+ {
+ return description;
+ }
+
+ /**
+ * Needed inside Maven multi-projects to expand a path relative to the module to a complete
+ * path.
+ *
+ * @param moduleLocalPath
+ * @return expanded path
+ * @see TapestryTestConstants#MODULE_BASE_DIR
+ */
+ protected String expand(String moduleLocalPath)
+ {
+ return new File(TapestryTestConstants.MODULE_BASE_DIR, moduleLocalPath).getPath();
+ }
+}
Propchange: tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/Jetty7Runner.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/JettyRunner.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/JettyRunner.java?rev=890879&r1=890878&r2=890879&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/JettyRunner.java (original)
+++ tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/JettyRunner.java Tue Dec 15 16:43:54 2009
@@ -24,10 +24,12 @@
import static java.lang.String.format;
/**
- * Used to start up an instance of the Jetty servlet container in-process, as part of an integration test suite. The
+ * Used to start up an instance of the Jetty servlet container in-process, as part of an integration
+ * test suite. The
* started Jetty is reliant on the file <code>src/test/conf/webdefault.xml</code>.
- *
+ *
* @see AbstractIntegrationTestSuite
+ * @deprecated Use {@link Jetty7Runner} instead
*/
public class JettyRunner
{
@@ -46,20 +48,26 @@
private final String warPath;
private final Server jetty;
-
+
private final String[] virtualHosts;
/**
- * Creates and starts a new instance of Jetty. This should be done from a test case setup method.
- *
- * @param workingDir current directory (used for any relative files)
- * @param contextPath the context path for the deployed application
- * @param port the port number used to access the application
- * @param warPath the path to the exploded web application (typically, "src/main/webapp")
- * @param virtualHosts an array with virtual hosts
+ * Creates and starts a new instance of Jetty. This should be done from a test case setup
+ * method.
+ *
+ * @param workingDir
+ * current directory (used for any relative files)
+ * @param contextPath
+ * the context path for the deployed application
+ * @param port
+ * the port number used to access the application
+ * @param warPath
+ * the path to the exploded web application (typically, "src/main/webapp")
+ * @param virtualHosts
+ * an array with virtual hosts
*/
public JettyRunner(File workingDir, String contextPath, int port, String warPath,
- String ... virtualHosts)
+ String... virtualHosts)
{
this.workingDir = workingDir;
this.contextPath = contextPath;
@@ -101,27 +109,25 @@
return format("<JettyRunner %s:%d (%s)>", contextPath, port, warPath);
}
-
private Server createAndStart()
{
try
{
- File warPathFile = new File(warPath);
-
- String webappPath = warPathFile.isAbsolute()
- ? warPath
- : new File(workingDir, this.warPath).getPath();
+ File warPathFile = new File(warPath);
+
+ String webappPath = warPathFile.isAbsolute() ? warPath : new File(workingDir,
+ this.warPath).getPath();
String webDefaults = new File(workingDir, "src/test/conf/webdefault.xml").getPath();
File keystoreFile = new File(workingDir, "src/test/conf/keystore");
String keystore = keystoreFile.getPath();
- System.out.printf("Starting Jetty instance on port %d (%s mapped to %s)\n", port, contextPath, webappPath);
+ System.out.printf("Starting Jetty instance on port %d (%s mapped to %s)\n", port,
+ contextPath, webappPath);
Server server = new Server();
-
SocketListener socketListener = new SocketListener();
socketListener.setPort(port);
server.addListener(socketListener);
@@ -141,10 +147,11 @@
server.setRequestLog(log);
WebApplicationContext context = server.addWebApplication(contextPath, webappPath);
-
- for (String virtualHost : virtualHosts) {
- context.addVirtualHost(virtualHost);
- }
+
+ for (String virtualHost : virtualHosts)
+ {
+ context.addVirtualHost(virtualHost);
+ }
context.setDefaultsDescriptor(webDefaults);
Added: tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumLauncher.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumLauncher.java?rev=890879&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumLauncher.java (added)
+++ tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumLauncher.java Tue Dec 15 16:43:54 2009
@@ -0,0 +1,211 @@
+// Copyright 2009 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.test;
+
+import org.openqa.selenium.server.RemoteControlConfiguration;
+import org.openqa.selenium.server.SeleniumServer;
+import org.testng.ITestContext;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Optional;
+import org.testng.annotations.Parameters;
+
+import com.thoughtworks.selenium.CommandProcessor;
+import com.thoughtworks.selenium.DefaultSelenium;
+import com.thoughtworks.selenium.HttpCommandProcessor;
+import com.thoughtworks.selenium.Selenium;
+
+/**
+ * Base class for launching the Selenium test stack, which consists of an
+ * instance of {@link SeleniumServer}, and instance of {@link Selenium} RC (the
+ * client), and a web server (by default, an instance of Jetty 7).
+ * <p>
+ * This class contains configuration methods to launch the servers (before <em>test</em>) and shut
+ * them down (after <em>test</em>). In addition, the Selenium instance is stored as an attribute of
+ * the {@link ITestContext} where it can be pulled out by {@link SeleniumTestCase}.
+ * <p>
+ * To create selenium tests, include SeleniumLauncher as part of your TestNG configuration and
+ * (optionally) configure properties. Create a subclass of {@link SeleniumTestCase} to contain your
+ * tests.
+ * <p>
+ * It is rarely necessary to subclass SeleniumLauncher, except if the default Jetty server instance
+ * needs to be configured specially (or replaced with an alternate server such as Tomcat or Resin).
+ * <p>
+ * To use this as part of a set of tests, you must configure the class inside your testng.xml:
+ *
+ * <pre>
+ * <test name="My Integration Tests">
+ * <!-- parameters go here, if needed -->
+ * <classes>
+ * <class name="org.apache.tapestry5.test.SeleniumLauncher"/>
+ * </classes>
+ * <packages>
+ * <!-- list of packages containing test suites goes here -->
+ * </packages>
+ * </test>
+ * </pre>
+ *
+ * @since 5.2.0
+ */
+public class SeleniumLauncher
+{
+ private SeleniumServer seleniumServer;
+
+ private Selenium selenium;
+
+ private Runnable stopWebServer;
+
+ /**
+ * Starts up the servers. By placing <parameter> elements inside the appropriate
+ * <test> (of your testng.xml configuration
+ * file), you can change the configuration or behavior of the servers. It is common to have two
+ * or more identical tests that differ only in terms of the
+ * <code>tapestry.browser-start-command</code> parameter, to run tests
+ * against multiple browsers.
+ * <table>
+ * <tr>
+ * <th>Parameter</th>
+ * <th>Name</th>
+ * <th>Default</th>
+ * <th>Description</th>
+ * </tr>
+ * <tr>
+ * <td>webAppFolder</td>
+ * <td>tapestry.web-app-folder</td>
+ * <td>src/main/webapp</td>
+ * <td>Location of web application context</td>
+ * </tr>
+ * <tr>
+ * <td>contextPath</td>
+ * <td>tapestry.context-path</td>
+ * <td><em>empty string</em></td>
+ * <td>Context path (defaults to root)</td>
+ * </tr>
+ * <tr>
+ * <td>port</td>
+ * <td>tapestry.port</td>
+ * <td>9999</td>
+ * <td>Port number for web server to listen to</td>
+ * </tr>
+ * <tr>
+ * <td>browserStartCommand</td>
+ * <td>tapestry.browser-start-command</td>
+ * <td>*firefox</td>
+ * <td>Command string used to launch the browser, as defined by Selenium</td>
+ * </tr>
+ * </table>
+ *
+ * @param webAppFolder
+ * @param contextPath
+ * @param port
+ * @param browserStartCommand
+ * @param testContext
+ * TODO
+ * @throws Exception
+ */
+ // Note: Made this method synchronized since there's no guarantee the same thread that invokes
+ // setup() will invoke
+ // shutdown(). Best to be safe!
+ @Parameters(
+ { "tapestry.web-app-folder", "tapestry.context-path", "tapestry.port",
+ "tapestry.browser-start-command" })
+ @BeforeTest
+ public synchronized void startup(
+
+ @Optional("src/main/webapp")
+ String webAppFolder,
+
+ @Optional("")
+ String contextPath,
+
+ @Optional("9999")
+ int port,
+
+ @Optional("*firefox")
+ String browserStartCommand, ITestContext testContext) throws Exception
+ {
+ stopWebServer = launchWebServer(webAppFolder, contextPath, port);
+
+ seleniumServer = new SeleniumServer();
+
+ seleniumServer.start();
+
+ String baseURL = String.format("http://localhost:%d%s/", port, contextPath);
+
+ CommandProcessor cp = new HttpCommandProcessor("localhost",
+ RemoteControlConfiguration.DEFAULT_PORT, browserStartCommand, baseURL);
+
+ selenium = new DefaultSelenium(new ErrorReportingCommandProcessor(cp));
+
+ selenium.start();
+
+ testContext.setAttribute(TapestryTestConstants.BASE_URL_ATTRIBUTE, baseURL);
+ testContext.setAttribute(TapestryTestConstants.SELENIUM_ATTRIBUTE, selenium);
+ }
+
+ /** Shuts down the stack at the end of the test. */
+ @AfterTest
+ public synchronized void cleanup()
+ {
+ if (selenium != null)
+ {
+ selenium.stop();
+ selenium = null;
+ }
+
+ if (seleniumServer != null)
+ {
+ seleniumServer.stop();
+ seleniumServer = null;
+ }
+
+ if (stopWebServer != null)
+ {
+ stopWebServer.run();
+ stopWebServer = null;
+ }
+
+ }
+
+ /**
+ * Invoked from {@link #startup(String, String, int, String, ITestContext)} to launch the web
+ * server to be
+ * tested. The return value is a Runnable that will shut down the launched server at the end of
+ * the test (it is coded this way so that the default Jetty web server can be more easily
+ * replaced).
+ *
+ * @param webAppFolder
+ * path to the web application context
+ * @param contextPath
+ * the path the context is mapped to, usually the empty string
+ * @param port
+ * the port number the server should handle
+ * @return Runnable used to shut down the server
+ * @throws Exception
+ */
+ protected Runnable launchWebServer(String webAppFolder, String contextPath, int port)
+ throws Exception
+ {
+ final Jetty7Runner runner = new Jetty7Runner(webAppFolder, contextPath, port);
+
+ return new Runnable()
+ {
+ public void run()
+ {
+ runner.stop();
+ }
+ };
+ }
+}
Propchange: tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumLauncher.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java?rev=890879&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java (added)
+++ tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java Tue Dec 15 16:43:54 2009
@@ -0,0 +1,846 @@
+// Copyright 2009 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.test;
+
+import java.lang.reflect.Method;
+
+import org.testng.Assert;
+import org.testng.ITestContext;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+
+import com.thoughtworks.selenium.Selenium;
+
+/**
+ * Base class for creating Selenium-based integration test cases. This class implements all the
+ * methods of {@link Selenium} and delegates to an instance (setup once per test by
+ * {@link SeleniumLauncher}).
+ *
+ * @since 5.2.0
+ */
+public class SeleniumTestCase extends Assert implements Selenium
+{
+ /**
+ * Provided by {@link SeleniumLauncher}.
+ */
+ private Selenium delegate;
+
+ private String baseURL;
+
+ @BeforeClass
+ public void setup(ITestContext context)
+ {
+ delegate = (Selenium) context.getAttribute(TapestryTestConstants.SELENIUM_ATTRIBUTE);
+ baseURL = (String) context.getAttribute(TapestryTestConstants.BASE_URL_ATTRIBUTE);
+ }
+
+ @AfterClass
+ public void cleanup()
+ {
+ delegate = null;
+ baseURL = null;
+ }
+
+ /** Returns the base URL for the application. */
+ public String getBaseURL()
+ {
+ return baseURL;
+ }
+
+ @BeforeMethod
+ public void indicateTestMethodName(Method testMethod)
+ {
+ String className = testMethod.getDeclaringClass().getSimpleName();
+ String testName = testMethod.getName().replace("_", " ");
+
+ delegate.setContext(className + ": " + testName);
+ }
+
+ // ---------------------------------------------------------------------
+ // Start of delegate methods
+ //
+ // When upgrading to a new version of Selenium, it is probably easiest
+ // to delete all these methods and use the Generate Delegate Methods
+ // refactoring.
+ // ---------------------------------------------------------------------
+
+ public void addCustomRequestHeader(String key, String value)
+ {
+ delegate.addCustomRequestHeader(key, value);
+ }
+
+ public void addLocationStrategy(String strategyName, String functionDefinition)
+ {
+ delegate.addLocationStrategy(strategyName, functionDefinition);
+ }
+
+ public void addScript(String scriptContent, String scriptTagId)
+ {
+ delegate.addScript(scriptContent, scriptTagId);
+ }
+
+ public void addSelection(String locator, String optionLocator)
+ {
+ delegate.addSelection(locator, optionLocator);
+ }
+
+ public void allowNativeXpath(String allow)
+ {
+ delegate.allowNativeXpath(allow);
+ }
+
+ public void altKeyDown()
+ {
+ delegate.altKeyDown();
+ }
+
+ public void altKeyUp()
+ {
+ delegate.altKeyUp();
+ }
+
+ public void answerOnNextPrompt(String answer)
+ {
+ delegate.answerOnNextPrompt(answer);
+ }
+
+ public void assignId(String locator, String identifier)
+ {
+ delegate.assignId(locator, identifier);
+ }
+
+ public void attachFile(String fieldLocator, String fileLocator)
+ {
+ delegate.attachFile(fieldLocator, fileLocator);
+ }
+
+ public void captureEntirePageScreenshot(String filename, String kwargs)
+ {
+ delegate.captureEntirePageScreenshot(filename, kwargs);
+ }
+
+ public String captureEntirePageScreenshotToString(String kwargs)
+ {
+ return delegate.captureEntirePageScreenshotToString(kwargs);
+ }
+
+ public String captureNetworkTraffic(String type)
+ {
+ return delegate.captureNetworkTraffic(type);
+ }
+
+ public void captureScreenshot(String filename)
+ {
+ delegate.captureScreenshot(filename);
+ }
+
+ public String captureScreenshotToString()
+ {
+ return delegate.captureScreenshotToString();
+ }
+
+ public void check(String locator)
+ {
+ delegate.check(locator);
+ }
+
+ public void chooseCancelOnNextConfirmation()
+ {
+ delegate.chooseCancelOnNextConfirmation();
+ }
+
+ public void chooseOkOnNextConfirmation()
+ {
+ delegate.chooseOkOnNextConfirmation();
+ }
+
+ public void click(String locator)
+ {
+ delegate.click(locator);
+ }
+
+ public void clickAt(String locator, String coordString)
+ {
+ delegate.clickAt(locator, coordString);
+ }
+
+ public void close()
+ {
+ delegate.close();
+ }
+
+ public void contextMenu(String locator)
+ {
+ delegate.contextMenu(locator);
+ }
+
+ public void contextMenuAt(String locator, String coordString)
+ {
+ delegate.contextMenuAt(locator, coordString);
+ }
+
+ public void controlKeyDown()
+ {
+ delegate.controlKeyDown();
+ }
+
+ public void controlKeyUp()
+ {
+ delegate.controlKeyUp();
+ }
+
+ public void createCookie(String nameValuePair, String optionsString)
+ {
+ delegate.createCookie(nameValuePair, optionsString);
+ }
+
+ public void deleteAllVisibleCookies()
+ {
+ delegate.deleteAllVisibleCookies();
+ }
+
+ public void deleteCookie(String name, String optionsString)
+ {
+ delegate.deleteCookie(name, optionsString);
+ }
+
+ public void deselectPopUp()
+ {
+ delegate.deselectPopUp();
+ }
+
+ public void doubleClick(String locator)
+ {
+ delegate.doubleClick(locator);
+ }
+
+ public void doubleClickAt(String locator, String coordString)
+ {
+ delegate.doubleClickAt(locator, coordString);
+ }
+
+ public void dragAndDrop(String locator, String movementsString)
+ {
+ delegate.dragAndDrop(locator, movementsString);
+ }
+
+ public void dragAndDropToObject(String locatorOfObjectToBeDragged,
+ String locatorOfDragDestinationObject)
+ {
+ delegate.dragAndDropToObject(locatorOfObjectToBeDragged, locatorOfDragDestinationObject);
+ }
+
+ public void dragdrop(String locator, String movementsString)
+ {
+ delegate.dragdrop(locator, movementsString);
+ }
+
+ public void fireEvent(String locator, String eventName)
+ {
+ delegate.fireEvent(locator, eventName);
+ }
+
+ public void focus(String locator)
+ {
+ delegate.focus(locator);
+ }
+
+ public String getAlert()
+ {
+ return delegate.getAlert();
+ }
+
+ public String[] getAllButtons()
+ {
+ return delegate.getAllButtons();
+ }
+
+ public String[] getAllFields()
+ {
+ return delegate.getAllFields();
+ }
+
+ public String[] getAllLinks()
+ {
+ return delegate.getAllLinks();
+ }
+
+ public String[] getAllWindowIds()
+ {
+ return delegate.getAllWindowIds();
+ }
+
+ public String[] getAllWindowNames()
+ {
+ return delegate.getAllWindowNames();
+ }
+
+ public String[] getAllWindowTitles()
+ {
+ return delegate.getAllWindowTitles();
+ }
+
+ public String getAttribute(String attributeLocator)
+ {
+ return delegate.getAttribute(attributeLocator);
+ }
+
+ public String[] getAttributeFromAllWindows(String attributeName)
+ {
+ return delegate.getAttributeFromAllWindows(attributeName);
+ }
+
+ public String getBodyText()
+ {
+ return delegate.getBodyText();
+ }
+
+ public String getConfirmation()
+ {
+ return delegate.getConfirmation();
+ }
+
+ public String getCookie()
+ {
+ return delegate.getCookie();
+ }
+
+ public String getCookieByName(String name)
+ {
+ return delegate.getCookieByName(name);
+ }
+
+ public Number getCursorPosition(String locator)
+ {
+ return delegate.getCursorPosition(locator);
+ }
+
+ public Number getElementHeight(String locator)
+ {
+ return delegate.getElementHeight(locator);
+ }
+
+ public Number getElementIndex(String locator)
+ {
+ return delegate.getElementIndex(locator);
+ }
+
+ public Number getElementPositionLeft(String locator)
+ {
+ return delegate.getElementPositionLeft(locator);
+ }
+
+ public Number getElementPositionTop(String locator)
+ {
+ return delegate.getElementPositionTop(locator);
+ }
+
+ public Number getElementWidth(String locator)
+ {
+ return delegate.getElementWidth(locator);
+ }
+
+ public String getEval(String script)
+ {
+ return delegate.getEval(script);
+ }
+
+ public String getExpression(String expression)
+ {
+ return delegate.getExpression(expression);
+ }
+
+ public String getHtmlSource()
+ {
+ return delegate.getHtmlSource();
+ }
+
+ public String getLocation()
+ {
+ return delegate.getLocation();
+ }
+
+ public Number getMouseSpeed()
+ {
+ return delegate.getMouseSpeed();
+ }
+
+ public String getPrompt()
+ {
+ return delegate.getPrompt();
+ }
+
+ public String getSelectedId(String selectLocator)
+ {
+ return delegate.getSelectedId(selectLocator);
+ }
+
+ public String[] getSelectedIds(String selectLocator)
+ {
+ return delegate.getSelectedIds(selectLocator);
+ }
+
+ public String getSelectedIndex(String selectLocator)
+ {
+ return delegate.getSelectedIndex(selectLocator);
+ }
+
+ public String[] getSelectedIndexes(String selectLocator)
+ {
+ return delegate.getSelectedIndexes(selectLocator);
+ }
+
+ public String getSelectedLabel(String selectLocator)
+ {
+ return delegate.getSelectedLabel(selectLocator);
+ }
+
+ public String[] getSelectedLabels(String selectLocator)
+ {
+ return delegate.getSelectedLabels(selectLocator);
+ }
+
+ public String getSelectedValue(String selectLocator)
+ {
+ return delegate.getSelectedValue(selectLocator);
+ }
+
+ public String[] getSelectedValues(String selectLocator)
+ {
+ return delegate.getSelectedValues(selectLocator);
+ }
+
+ public String[] getSelectOptions(String selectLocator)
+ {
+ return delegate.getSelectOptions(selectLocator);
+ }
+
+ public String getSpeed()
+ {
+ return delegate.getSpeed();
+ }
+
+ public String getTable(String tableCellAddress)
+ {
+ return delegate.getTable(tableCellAddress);
+ }
+
+ public String getText(String locator)
+ {
+ return delegate.getText(locator);
+ }
+
+ public String getTitle()
+ {
+ return delegate.getTitle();
+ }
+
+ public String getValue(String locator)
+ {
+ return delegate.getValue(locator);
+ }
+
+ public boolean getWhetherThisFrameMatchFrameExpression(String currentFrameString, String target)
+ {
+ return delegate.getWhetherThisFrameMatchFrameExpression(currentFrameString, target);
+ }
+
+ public boolean getWhetherThisWindowMatchWindowExpression(String currentWindowString,
+ String target)
+ {
+ return delegate.getWhetherThisWindowMatchWindowExpression(currentWindowString, target);
+ }
+
+ public Number getXpathCount(String xpath)
+ {
+ return delegate.getXpathCount(xpath);
+ }
+
+ public void goBack()
+ {
+ delegate.goBack();
+ }
+
+ public void highlight(String locator)
+ {
+ delegate.highlight(locator);
+ }
+
+ public void ignoreAttributesWithoutValue(String ignore)
+ {
+ delegate.ignoreAttributesWithoutValue(ignore);
+ }
+
+ public boolean isAlertPresent()
+ {
+ return delegate.isAlertPresent();
+ }
+
+ public boolean isChecked(String locator)
+ {
+ return delegate.isChecked(locator);
+ }
+
+ public boolean isConfirmationPresent()
+ {
+ return delegate.isConfirmationPresent();
+ }
+
+ public boolean isCookiePresent(String name)
+ {
+ return delegate.isCookiePresent(name);
+ }
+
+ public boolean isEditable(String locator)
+ {
+ return delegate.isEditable(locator);
+ }
+
+ public boolean isElementPresent(String locator)
+ {
+ return delegate.isElementPresent(locator);
+ }
+
+ public boolean isOrdered(String locator1, String locator2)
+ {
+ return delegate.isOrdered(locator1, locator2);
+ }
+
+ public boolean isPromptPresent()
+ {
+ return delegate.isPromptPresent();
+ }
+
+ public boolean isSomethingSelected(String selectLocator)
+ {
+ return delegate.isSomethingSelected(selectLocator);
+ }
+
+ public boolean isTextPresent(String pattern)
+ {
+ return delegate.isTextPresent(pattern);
+ }
+
+ public boolean isVisible(String locator)
+ {
+ return delegate.isVisible(locator);
+ }
+
+ public void keyDown(String locator, String keySequence)
+ {
+ delegate.keyDown(locator, keySequence);
+ }
+
+ public void keyDownNative(String keycode)
+ {
+ delegate.keyDownNative(keycode);
+ }
+
+ public void keyPress(String locator, String keySequence)
+ {
+ delegate.keyPress(locator, keySequence);
+ }
+
+ public void keyPressNative(String keycode)
+ {
+ delegate.keyPressNative(keycode);
+ }
+
+ public void keyUp(String locator, String keySequence)
+ {
+ delegate.keyUp(locator, keySequence);
+ }
+
+ public void keyUpNative(String keycode)
+ {
+ delegate.keyUpNative(keycode);
+ }
+
+ public void metaKeyDown()
+ {
+ delegate.metaKeyDown();
+ }
+
+ public void metaKeyUp()
+ {
+ delegate.metaKeyUp();
+ }
+
+ public void mouseDown(String locator)
+ {
+ delegate.mouseDown(locator);
+ }
+
+ public void mouseDownAt(String locator, String coordString)
+ {
+ delegate.mouseDownAt(locator, coordString);
+ }
+
+ public void mouseDownRight(String locator)
+ {
+ delegate.mouseDownRight(locator);
+ }
+
+ public void mouseDownRightAt(String locator, String coordString)
+ {
+ delegate.mouseDownRightAt(locator, coordString);
+ }
+
+ public void mouseMove(String locator)
+ {
+ delegate.mouseMove(locator);
+ }
+
+ public void mouseMoveAt(String locator, String coordString)
+ {
+ delegate.mouseMoveAt(locator, coordString);
+ }
+
+ public void mouseOut(String locator)
+ {
+ delegate.mouseOut(locator);
+ }
+
+ public void mouseOver(String locator)
+ {
+ delegate.mouseOver(locator);
+ }
+
+ public void mouseUp(String locator)
+ {
+ delegate.mouseUp(locator);
+ }
+
+ public void mouseUpAt(String locator, String coordString)
+ {
+ delegate.mouseUpAt(locator, coordString);
+ }
+
+ public void mouseUpRight(String locator)
+ {
+ delegate.mouseUpRight(locator);
+ }
+
+ public void mouseUpRightAt(String locator, String coordString)
+ {
+ delegate.mouseUpRightAt(locator, coordString);
+ }
+
+ public void open(String url)
+ {
+ delegate.open(url);
+ }
+
+ public void openWindow(String url, String windowID)
+ {
+ delegate.openWindow(url, windowID);
+ }
+
+ public void refresh()
+ {
+ delegate.refresh();
+ }
+
+ public void removeAllSelections(String locator)
+ {
+ delegate.removeAllSelections(locator);
+ }
+
+ public void removeScript(String scriptTagId)
+ {
+ delegate.removeScript(scriptTagId);
+ }
+
+ public void removeSelection(String locator, String optionLocator)
+ {
+ delegate.removeSelection(locator, optionLocator);
+ }
+
+ public String retrieveLastRemoteControlLogs()
+ {
+ return delegate.retrieveLastRemoteControlLogs();
+ }
+
+ public void rollup(String rollupName, String kwargs)
+ {
+ delegate.rollup(rollupName, kwargs);
+ }
+
+ public void runScript(String script)
+ {
+ delegate.runScript(script);
+ }
+
+ public void select(String selectLocator, String optionLocator)
+ {
+ delegate.select(selectLocator, optionLocator);
+ }
+
+ public void selectFrame(String locator)
+ {
+ delegate.selectFrame(locator);
+ }
+
+ public void selectPopUp(String windowID)
+ {
+ delegate.selectPopUp(windowID);
+ }
+
+ public void selectWindow(String windowID)
+ {
+ delegate.selectWindow(windowID);
+ }
+
+ public void setBrowserLogLevel(String logLevel)
+ {
+ delegate.setBrowserLogLevel(logLevel);
+ }
+
+ public void setContext(String context)
+ {
+ delegate.setContext(context);
+ }
+
+ public void setCursorPosition(String locator, String position)
+ {
+ delegate.setCursorPosition(locator, position);
+ }
+
+ public void setExtensionJs(String extensionJs)
+ {
+ delegate.setExtensionJs(extensionJs);
+ }
+
+ public void setMouseSpeed(String pixels)
+ {
+ delegate.setMouseSpeed(pixels);
+ }
+
+ public void setSpeed(String value)
+ {
+ delegate.setSpeed(value);
+ }
+
+ public void setTimeout(String timeout)
+ {
+ delegate.setTimeout(timeout);
+ }
+
+ public void shiftKeyDown()
+ {
+ delegate.shiftKeyDown();
+ }
+
+ public void shiftKeyUp()
+ {
+ delegate.shiftKeyUp();
+ }
+
+ public void showContextualBanner()
+ {
+ delegate.showContextualBanner();
+ }
+
+ public void showContextualBanner(String className, String methodName)
+ {
+ delegate.showContextualBanner(className, methodName);
+ }
+
+ public void shutDownSeleniumServer()
+ {
+ delegate.shutDownSeleniumServer();
+ }
+
+ public void start()
+ {
+ delegate.start();
+ }
+
+ public void start(Object optionsObject)
+ {
+ delegate.start(optionsObject);
+ }
+
+ public void start(String optionsString)
+ {
+ delegate.start(optionsString);
+ }
+
+ public void stop()
+ {
+ delegate.stop();
+ }
+
+ public void submit(String formLocator)
+ {
+ delegate.submit(formLocator);
+ }
+
+ public void type(String locator, String value)
+ {
+ delegate.type(locator, value);
+ }
+
+ public void typeKeys(String locator, String value)
+ {
+ delegate.typeKeys(locator, value);
+ }
+
+ public void uncheck(String locator)
+ {
+ delegate.uncheck(locator);
+ }
+
+ public void useXpathLibrary(String libraryName)
+ {
+ delegate.useXpathLibrary(libraryName);
+ }
+
+ public void waitForCondition(String script, String timeout)
+ {
+ delegate.waitForCondition(script, timeout);
+ }
+
+ public void waitForFrameToLoad(String frameAddress, String timeout)
+ {
+ delegate.waitForFrameToLoad(frameAddress, timeout);
+ }
+
+ public void waitForPageToLoad(String timeout)
+ {
+ delegate.waitForPageToLoad(timeout);
+ }
+
+ public void waitForPopUp(String windowID, String timeout)
+ {
+ delegate.waitForPopUp(windowID, timeout);
+ }
+
+ public void windowFocus()
+ {
+ delegate.windowFocus();
+ }
+
+ public void windowMaximize()
+ {
+ delegate.windowMaximize();
+ }
+
+ // ---------------------------------------------------------------------
+ // End of delegate methods
+ // ---------------------------------------------------------------------
+
+}
Propchange: tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/TapestryTestConstants.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/TapestryTestConstants.java?rev=890879&r1=890878&r2=890879&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/TapestryTestConstants.java (original)
+++ tapestry/tapestry5/trunk/tapestry-test/src/main/java/org/apache/tapestry5/test/TapestryTestConstants.java Tue Dec 15 16:43:54 2009
@@ -16,6 +16,10 @@
import java.io.File;
+import org.testng.ITestContext;
+
+import com.thoughtworks.selenium.Selenium;
+
public class TapestryTestConstants
{
/**
@@ -23,15 +27,35 @@
*/
public static final String CURRENT_DIR_PATH = System.getProperty("user.dir");
/**
- * The Surefire plugin sets basedir but DOES NOT change the current working directory. When building across modules,
- * basedir changes for each module, but user.dir does not. This value should be used when referecing local files.
- * Outside of surefire, the "basedir" property will not be set, and the current working directory will be the
+ * The Surefire plugin sets basedir but DOES NOT change the current working directory. When
+ * building across modules,
+ * basedir changes for each module, but user.dir does not. This value should be used when
+ * referecing local files.
+ * Outside of surefire, the "basedir" property will not be set, and the current working
+ * directory will be the
* default.
*/
- public static final String MODULE_BASE_DIR_PATH = System.getProperty("basedir", CURRENT_DIR_PATH);
+ public static final String MODULE_BASE_DIR_PATH = System.getProperty("basedir",
+ CURRENT_DIR_PATH);
/**
* {@link #MODULE_BASE_DIR_PATH} as a file.
*/
public static final File MODULE_BASE_DIR = new File(MODULE_BASE_DIR_PATH);
+
+ /**
+ * {@link ITestContext} attribute holding an instance of {@link Selenium}.
+ *
+ * @see SeleniumLauncher#startup(String, String, int, String, ITestContext)
+ * @since 5.2.0
+ */
+ public static final String SELENIUM_ATTRIBUTE = "tapestry.selenium";
+
+ /**
+ * {@link ITestContext} attribute holding the application's base URL.
+ *
+ * @see SeleniumLauncher#startup(String, String, int, String, ITestContext)
+ * @since 5.2.0
+ */
+ public static final String BASE_URL_ATTRIBUTE = "tapestry.base-url";
}