public class LocalTestServer extends Object
ElementalHttpServer example in HttpCore.| Modifier and Type | Field and Description | 
|---|---|
| static InetSocketAddress | TEST_SERVER_ADDRThe local address to bind to. | 
| Constructor and Description | 
|---|
| LocalTestServer(org.apache.http.protocol.BasicHttpProcessor proc,
               org.apache.http.ConnectionReuseStrategy reuseStrat,
               org.apache.http.HttpResponseFactory responseFactory,
               org.apache.http.protocol.HttpExpectationVerifier expectationVerifier,
               org.apache.http.params.HttpParams params,
               SSLContext sslcontext)Creates a new test server. | 
| LocalTestServer(org.apache.http.protocol.BasicHttpProcessor proc,
               org.apache.http.params.HttpParams params)Creates a new test server. | 
| LocalTestServer(SSLContext sslcontext)Creates a new test server with SSL/TLS encryption. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | awaitTermination(long timeMs) | 
| int | getAcceptedConnectionCount()Returns the number of connections this test server has accepted. | 
| InetSocketAddress | getServiceAddress()Obtains the local address the server is listening on | 
| protected org.apache.http.ConnectionReuseStrategy | newConnectionReuseStrategy() | 
| protected org.apache.http.params.HttpParams | newDefaultParams()Obtains a set of reasonable default parameters for a server. | 
| protected org.apache.http.HttpResponseFactory | newHttpResponseFactory() | 
| protected org.apache.http.protocol.HttpProcessor | newProcessor()Obtains an HTTP protocol processor with default interceptors. | 
| void | register(String pattern,
        org.apache.http.protocol.HttpRequestHandler handler)Registers a handler with the local registry. | 
| void | registerDefaultHandlers()Registersa set of default request handlers. | 
| void | start()Starts this test server. | 
| void | stop()Stops this test server. | 
| String | toString() | 
| void | unregister(String pattern)Unregisters a handler from the local registry. | 
public static final InetSocketAddress TEST_SERVER_ADDR
public LocalTestServer(org.apache.http.protocol.BasicHttpProcessor proc,
                       org.apache.http.ConnectionReuseStrategy reuseStrat,
                       org.apache.http.HttpResponseFactory responseFactory,
                       org.apache.http.protocol.HttpExpectationVerifier expectationVerifier,
                       org.apache.http.params.HttpParams params,
                       SSLContext sslcontext)
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 default 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 securitypublic LocalTestServer(SSLContext sslcontext)
sslcontext - SSL contextpublic LocalTestServer(org.apache.http.protocol.BasicHttpProcessor proc,
                       org.apache.http.params.HttpParams params)
protected org.apache.http.protocol.HttpProcessor newProcessor()
protected org.apache.http.params.HttpParams newDefaultParams()
protected org.apache.http.ConnectionReuseStrategy newConnectionReuseStrategy()
protected org.apache.http.HttpResponseFactory newHttpResponseFactory()
public int getAcceptedConnectionCount()
public void registerDefaultHandlers()
Registers a set of default request handlers.
 
 URI pattern Handler ----------- ------- /echo/*EchoHandler/random/*RandomHandler
public void register(String pattern, org.apache.http.protocol.HttpRequestHandler handler)
pattern - the URL pattern to matchhandler - the handler to applypublic void unregister(String pattern)
pattern - the URL patternpublic void awaitTermination(long timeMs)
                      throws InterruptedException
InterruptedExceptionpublic InetSocketAddress getServiceAddress()
Copyright © 2019. All Rights Reserved.