| |
|
| org.apache.cactus.extension.jetty.JettyTestSetup
JettyTestSetup | public class JettyTestSetup extends TestSetup (Code) | | Custom JUnit test setup to use to automatically start Jetty. Example:
public static Test suite()
{
TestSuite suite = new TestSuite(Myclass.class);
return new JettyTestSetup(suite);
}
version: $Id: JettyTestSetup.java 239036 2004-08-17 10:35:57Z vmassol $ |
Method Summary | |
final protected File | getConfigFile() | final protected File | getResourceDir() | protected boolean | isAvailable(int theCode) Tests whether an HTTP return code corresponds to a valid connection
to the test URL or not. | protected boolean | isRunning() | protected void | readFully(HttpURLConnection theConnection) Fully reads the input stream from the passed HTTP URL connection to
prevent (harmless) server-side exception. | public void | run(TestResult theResult) Make sure that
JettyTestSetup.tearDown is called if
JettyTestSetup.setUp fails
to start the container properly. | final public void | setConfigFile(File theConfigFile) Sets the configuration file to use for initializing Jetty. | final public void | setForceShutdown(boolean isForcedShutdown) | final public void | setResourceDir(File theResourceDir) Sets the directory in which Jetty will look for the web-application
resources. | protected void | setUp() Start an embedded Jetty server. | protected void | tearDown() Stop the running Jetty server. | protected int | testConnectivity(URL theUrl) Tests whether we are able to connect to the HTTP server identified by the
specified URL. |
JettyTestSetup | public JettyTestSetup(Test theTest)(Code) | | Parameters: theTest - the test we are decorating (usually a test suite) |
JettyTestSetup | public JettyTestSetup(Test theTest, Configuration theBaseConfiguration, ServletConfiguration theServletConfiguration, FilterConfiguration theFilterConfiguration)(Code) | | Parameters: theTest - the test we are decorating (usually a test suite) Parameters: theBaseConfiguration - the base configuration object used toconfigure Jetty Parameters: theServletConfiguration - the servlet configuration object usedto configure Jetty Parameters: theFilterConfiguration - the filter configuration object usedto configure Jetty |
getConfigFile | final protected File getConfigFile()(Code) | | The resource directory, or null if it has not beenset |
getResourceDir | final protected File getResourceDir()(Code) | | The resource directory, or null if it has not beenset |
isAvailable | protected boolean isAvailable(int theCode)(Code) | | Tests whether an HTTP return code corresponds to a valid connection
to the test URL or not. Success is 200 up to but excluding 300.
Parameters: theCode - the HTTP response code to verify true if the test URL could be called without error,false otherwise |
isRunning | protected boolean isRunning()(Code) | | true if the server is running or false otherwise |
readFully | protected void readFully(HttpURLConnection theConnection) throws IOException(Code) | | Fully reads the input stream from the passed HTTP URL connection to
prevent (harmless) server-side exception.
Parameters: theConnection - the HTTP URL connection to read from exception: IOException - if an error happens during the read |
run | public void run(TestResult theResult)(Code) | | Make sure that
JettyTestSetup.tearDown is called if
JettyTestSetup.setUp fails
to start the container properly. The default
TestSetup.run(TestResult) method does not provide this feature
unfortunately.
See Also: TestSetup.run(TestResult) |
setConfigFile | final public void setConfigFile(File theConfigFile)(Code) | | Sets the configuration file to use for initializing Jetty.
Parameters: theConfigFile - The configuration file to set |
setForceShutdown | final public void setForceShutdown(boolean isForcedShutdown)(Code) | | Parameters: isForcedShutdown - if true the container will be stopped evenif it has not been started by us |
setResourceDir | final public void setResourceDir(File theResourceDir)(Code) | | Sets the directory in which Jetty will look for the web-application
resources.
Parameters: theResourceDir - The resource directory to set |
setUp | protected void setUp() throws Exception(Code) | | Start an embedded Jetty server. It is allowed to pass a Jetty XML as
a system property (cactus.jetty.config ) to further
configure Jetty. Example:
-Dcactus.jetty.config=./jetty.xml .
exception: Exception - if an error happens during initialization |
tearDown | protected void tearDown() throws Exception(Code) | | Stop the running Jetty server.
exception: Exception - if an error happens during the shutdown |
testConnectivity | protected int testConnectivity(URL theUrl)(Code) | | Tests whether we are able to connect to the HTTP server identified by the
specified URL.
Parameters: theUrl - The URL to check the HTTP response code or -1 if no connection could be established |
|
|
|