public abstract class ServerTestBase extends BasicServerTestBase
LocalTestServer
. Note that
the test server will be set up
before each individual tests
and teared down
afterwards. Use this base class
exclusively for tests that require the server. If you have some tests
that require the server and others that don't, split them in two different
classes.Modifier and Type | Field and Description |
---|---|
protected org.apache.http.params.HttpParams |
defaultParams
The default parameters for the client side.
|
protected org.apache.http.protocol.BasicHttpContext |
httpContext
The default context for the client side.
|
protected org.apache.http.protocol.HttpRequestExecutor |
httpExecutor
The request executor for the client side.
|
protected org.apache.http.protocol.BasicHttpProcessor |
httpProcessor
The HTTP processor for the client side.
|
protected org.apache.http.conn.scheme.SchemeRegistry |
supportedSchemes
The available schemes.
|
localServer
Constructor and Description |
---|
ServerTestBase() |
Modifier and Type | Method and Description |
---|---|
protected org.apache.http.impl.DefaultHttpClientConnection |
connectTo(org.apache.http.HttpHost target)
Opens a connection to the given target using
default
parameters . |
protected org.apache.http.impl.DefaultHttpClientConnection |
connectTo(org.apache.http.HttpHost target,
org.apache.http.params.HttpParams params)
Opens a connection to the given target using the given parameters.
|
void |
setUp()
Prepares the local server for testing.
|
getServerHttp, tearDown
protected org.apache.http.conn.scheme.SchemeRegistry supportedSchemes
protected org.apache.http.params.HttpParams defaultParams
protected org.apache.http.protocol.BasicHttpProcessor httpProcessor
protected org.apache.http.protocol.BasicHttpContext httpContext
protected org.apache.http.protocol.HttpRequestExecutor httpExecutor
public void setUp() throws Exception
httpContext
will always be
re-created. Tests that modify the other helper objects should afterwards
set the respective attributes to null
in a
finally{}
block to force re-creation for subsequent tests. Of
course that shouldn't be done with the test server, or only after shutting
that down.Exception
- in case of a problemprotected org.apache.http.impl.DefaultHttpClientConnection connectTo(org.apache.http.HttpHost target) throws Exception
default
parameters
. Maps to connectTo(target,defaultParams)
.target
- the target to connect toException
- in case of a problemprotected org.apache.http.impl.DefaultHttpClientConnection connectTo(org.apache.http.HttpHost target, org.apache.http.params.HttpParams params) throws Exception
target
- the target to connect toException
- in case of a problemCopyright © 2019. All Rights Reserved.