org.apache.tapestry5.test
Class SeleniumLauncher

java.lang.Object
  extended by org.apache.tapestry5.test.SeleniumLauncher

public class SeleniumLauncher
extends java.lang.Object

Base class for launching the Selenium test stack, which consists of an instance of SeleniumServer, and instance of Selenium RC (the client), and a web server (by default, an instance of Jetty 7).

This class contains configuration methods to launch the servers (before test) and shut them down (after test). In addition, the Selenium instance is stored as an attribute of the ITestContext where it can be pulled out by SeleniumTestCase.

To create selenium tests, include SeleniumLauncher as part of your TestNG configuration and (optionally) configure properties. Create a subclass of SeleniumTestCase to contain your tests.

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).

To use this as part of a set of tests, you must configure the class inside your testng.xml:

 <test name="My Integration Tests">
   <!-- parameters go here, if needed -->
   <packages>
     <!-- list of packages containing test suites goes here -->
   </packages>
   <classes>
     <class name="org.apache.tapestry5.test.SeleniumLauncher"/>
   </classes>
 </test>
 

Since:
5.2.0

Constructor Summary
SeleniumLauncher()
           
 
Method Summary
 void cleanup()
          Shuts down the stack at the end of the test.
protected  java.lang.Runnable launchWebServer(java.lang.String webAppFolder, java.lang.String contextPath, int port, int sslPort)
          Invoked from #startup(String, String, int, String, ITestContext) to launch the web server to be tested.
 void startup(java.lang.String webAppFolder, java.lang.String contextPath, int port, int sslPort, java.lang.String browserStartCommand, org.testng.ITestContext testContext, org.testng.xml.XmlTest xmlTest)
          Starts up the servers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SeleniumLauncher

public SeleniumLauncher()
Method Detail

startup

public void startup(java.lang.String webAppFolder,
                    java.lang.String contextPath,
                    int port,
                    int sslPort,
                    java.lang.String browserStartCommand,
                    org.testng.ITestContext testContext,
                    org.testng.xml.XmlTest xmlTest)
             throws java.lang.Exception
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 tapestry.browser-start-command parameter, to run tests against multiple browsers.
Parameter Name Default Description
webAppFolder tapestry.web-app-folder src/main/webapp Location of web application context
contextPath tapestry.context-path empty string Context path (defaults to root). As elsewhere, the context path should be blank, or start with a slash (but not end with one).
port tapestry.port 9090 Port number for web server to listen to
sslPort tapestry.ssl-port 8443 Port number for web server to listen to for secure requests
browserStartCommand tapestry.browser-start-command *firefox Command string used to launch the browser, as defined by Selenium
Tests in the beforeStartup group will be run before the start of Selenium. This can be used to programmatically override the above parameter values. For an example see org.apache.tapestry5.integration.reload.ReloadTests#beforeStartup.

Parameters:
webAppFolder -
contextPath -
port -
browserStartCommand -
testContext - Used to share objects between the launcher and the test suites
Throws:
java.lang.Exception

cleanup

public void cleanup()
Shuts down the stack at the end of the test.


launchWebServer

protected java.lang.Runnable launchWebServer(java.lang.String webAppFolder,
                                             java.lang.String contextPath,
                                             int port,
                                             int sslPort)
                                      throws java.lang.Exception
Invoked from #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).

Parameters:
webAppFolder - path to the web application context
contextPath - the path the context is mapped to, usually the empty string
port - the port number the server should handle
sslPort - the port number on which the server should handle secure requests
Returns:
Runnable used to shut down the server
Throws:
java.lang.Exception


Copyright © 2007-2010 Apache Software Foundation. All Rights Reserved.