public class JettyTestSetup
extends junit.extensions.TestSetup
public static Test suite()
{
TestSuite suite = new TestSuite(Myclass.class);
return new JettyTestSetup(suite);
}
Constructor and Description |
---|
JettyTestSetup(junit.framework.Test theTest) |
JettyTestSetup(junit.framework.Test theTest,
Configuration theBaseConfiguration,
ServletConfiguration theServletConfiguration,
FilterConfiguration theFilterConfiguration) |
Modifier and Type | Method and Description |
---|---|
protected java.io.File |
getConfigFile() |
protected java.io.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(java.net.HttpURLConnection theConnection)
Fully reads the input stream from the passed HTTP URL connection to
prevent (harmless) server-side exception.
|
void |
run(junit.framework.TestResult theResult)
Make sure that
tearDown() is called if setUp() fails
to start the container properly. |
void |
setConfigFile(java.io.File theConfigFile)
Sets the configuration file to use for initializing Jetty.
|
void |
setForceShutdown(boolean isForcedShutdown) |
void |
setResourceDir(java.io.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(java.net.URL theUrl)
Tests whether we are able to connect to the HTTP server identified by the
specified URL.
|
basicRun, countTestCases, getTest, toString
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame
public JettyTestSetup(junit.framework.Test theTest)
theTest
- the test we are decorating (usually a test suite)public JettyTestSetup(junit.framework.Test theTest, Configuration theBaseConfiguration, ServletConfiguration theServletConfiguration, FilterConfiguration theFilterConfiguration)
theTest
- the test we are decorating (usually a test suite)theBaseConfiguration
- the base configuration object used to
configure JettytheServletConfiguration
- the servlet configuration object used
to configure JettytheFilterConfiguration
- the filter configuration object used
to configure Jettypublic void run(junit.framework.TestResult theResult)
tearDown()
is called if setUp()
fails
to start the container properly. The default
TestSetup.run(TestResult)
method does not provide this feature
unfortunately.run
in interface junit.framework.Test
run
in class junit.extensions.TestSetup
TestSetup.run(TestResult)
protected void setUp() throws java.lang.Exception
cactus.jetty.config
) to further
configure Jetty. Example:
-Dcactus.jetty.config=./jetty.xml
.setUp
in class junit.extensions.TestSetup
java.lang.Exception
- if an error happens during initializationprotected void tearDown() throws java.lang.Exception
tearDown
in class junit.extensions.TestSetup
java.lang.Exception
- if an error happens during the shutdownpublic final void setConfigFile(java.io.File theConfigFile)
theConfigFile
- The configuration file to setpublic final void setResourceDir(java.io.File theResourceDir)
theResourceDir
- The resource directory to setpublic final void setForceShutdown(boolean isForcedShutdown)
isForcedShutdown
- if true the container will be stopped even
if it has not been started by usprotected final java.io.File getConfigFile()
null
if it has not been
setprotected final java.io.File getResourceDir()
null
if it has not been
setprotected int testConnectivity(java.net.URL theUrl)
theUrl
- The URL to checkprotected boolean isAvailable(int theCode)
theCode
- the HTTP response code to verifytrue
if the test URL could be called without error,
false
otherwiseprotected void readFully(java.net.HttpURLConnection theConnection) throws java.io.IOException
theConnection
- the HTTP URL connection to read fromjava.io.IOException
- if an error happens during the readprotected boolean isRunning()
Copyright © 2000-2004 Apache Software Foundation. All Rights Reserved.