Local HTTP server for tests that require one. Based on the
ElementalHttpServer
example in HttpCore.
Modifiers | Name | Description |
---|---|---|
static java.net.InetSocketAddress |
TEST_SERVER_ADDR |
The local address to bind to. |
Constructor and description |
---|
LocalTestServer
(BasicHttpProcessor proc, ConnectionReuseStrategy reuseStrat, HttpResponseFactory responseFactory, HttpExpectationVerifier expectationVerifier, HttpParams params, javax.net.ssl.SSLContext sslcontext) Creates a new test server. |
LocalTestServer
(javax.net.ssl.SSLContext sslcontext) Creates a new test server with SSL/TLS encryption. |
LocalTestServer
(BasicHttpProcessor proc, HttpParams params) Creates a new test server. |
Type Params | Return Type | Name and description |
---|---|---|
|
void |
awaitTermination(long timeMs) |
|
int |
getAcceptedConnectionCount() Returns the number of connections this test server has accepted. |
|
java.net.InetSocketAddress |
getServiceAddress() Obtains the local address the server is listening on |
|
void |
register(java.lang.String pattern, HttpRequestHandler handler) Registers a handler with the local registry. |
|
void |
registerDefaultHandlers() Registers a set of default request handlers. |
|
void |
start() Starts this test server. |
|
void |
stop() Stops this test server. |
|
java.lang.String |
toString() |
|
void |
unregister(java.lang.String pattern) Unregisters a handler from the local registry. |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
The local address to bind to. The host is an IP number rather than "localhost" to avoid surprises on hosts that map "localhost" to an IPv6 address or something else. The port is 0 to let the system pick one.
Creates a new test server.
proc
- the HTTP processors to be used by the server, or
null
to use a default
processorreuseStrat
- the connection reuse strategy to be used by the server, or
null
to use strategy.params
- the parameters to be used by the server, or null
to
use default parameterssslcontext
- optional SSL context if the server is to leverage SSL/TLS
transport securityCreates a new test server with SSL/TLS encryption.
sslcontext
- SSL contextCreates a new test server.
Returns the number of connections this test server has accepted.
Obtains the local address the server is listening on
Registers a handler with the local registry.
pattern
- the URL pattern to matchhandler
- the handler to applyRegisters a set of default request handlers.
URI pattern Handler ----------- ------- /echo/* EchoHandler /random/* RandomHandler
Starts this test server.
Stops this test server.
Unregisters a handler from the local registry.
pattern
- the URL pattern