public class DefaultMockServer extends Object implements MockServer
| Constructor and Description |
|---|
DefaultMockServer() |
DefaultMockServer(boolean useHttps) |
DefaultMockServer(Context context,
okhttp3.mockwebserver.MockWebServer server,
Map<ServerRequest,Queue<ServerResponse>> responses,
boolean useHttps) |
DefaultMockServer(Context context,
okhttp3.mockwebserver.MockWebServer server,
Map<ServerRequest,Queue<ServerResponse>> responses,
okhttp3.mockwebserver.Dispatcher dispatcher,
boolean useHttps) |
DefaultMockServer(okhttp3.mockwebserver.MockWebServer server,
Map<ServerRequest,Queue<ServerResponse>> responses,
boolean useHttps) |
| Modifier and Type | Method and Description |
|---|---|
MockServerExpectation |
expect()
Returns a
MockServerExpectation to set the expectations. |
String |
getHostName()
The host name for the
MockWebServer. |
okhttp3.mockwebserver.RecordedRequest |
getLastRequest()
Returns the last (most recent) HTTP request processed by the
MockWebServer. |
int |
getPort()
The port for the
MockWebServer. |
int |
getRequestCount()
Returns the number of HTTP requests received thus far by this server.
|
void |
shutdown() |
void |
start() |
void |
start(InetAddress inetAddress,
int port) |
void |
start(int port) |
okhttp3.mockwebserver.RecordedRequest |
takeRequest()
Awaits the next HTTP request, removes it, and returns it.
|
okhttp3.mockwebserver.RecordedRequest |
takeRequest(long timeout,
TimeUnit unit)
Awaits the next HTTP request (waiting up to the specified wait time if necessary), removes it,
and returns it.
|
Proxy |
toProxyAddress()
Returns a
Proxy for the MockWebServer with the current HostName and Port. |
String |
url(String path)
Returns a String URL for connecting to this server.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitonShutdown, onStartpublic DefaultMockServer()
public DefaultMockServer(boolean useHttps)
public DefaultMockServer(okhttp3.mockwebserver.MockWebServer server,
Map<ServerRequest,Queue<ServerResponse>> responses,
boolean useHttps)
public DefaultMockServer(Context context, okhttp3.mockwebserver.MockWebServer server, Map<ServerRequest,Queue<ServerResponse>> responses, boolean useHttps)
public DefaultMockServer(Context context, okhttp3.mockwebserver.MockWebServer server, Map<ServerRequest,Queue<ServerResponse>> responses, okhttp3.mockwebserver.Dispatcher dispatcher, boolean useHttps)
public final void start()
public final void start(int port)
public final void start(InetAddress inetAddress, int port)
public final void shutdown()
public String url(String path)
url in interface MockServerpath - the request path, such as "/".public int getPort()
MockWebServer.getPort in interface MockServerpublic String getHostName()
MockWebServer.getHostName in interface MockServerpublic Proxy toProxyAddress()
Proxy for the MockWebServer with the current HostName and Port.toProxyAddress in interface MockServerpublic MockServerExpectation expect()
MockServerExpectation to set the expectations.expect in interface MockServerpublic int getRequestCount()
getRequestCount in interface MockServerpublic okhttp3.mockwebserver.RecordedRequest takeRequest()
throws InterruptedException
takeRequest in interface MockServerInterruptedExceptionpublic okhttp3.mockwebserver.RecordedRequest takeRequest(long timeout,
TimeUnit unit)
throws InterruptedException
takeRequest in interface MockServertimeout - how long to wait before giving up, in units of unitunit - a TimeUnit determining how to interpret the timeout parameterInterruptedExceptionpublic okhttp3.mockwebserver.RecordedRequest getLastRequest()
throws InterruptedException
MockWebServer.
n.b. This method clears the request queue.getLastRequest in interface MockServerInterruptedExceptionCopyright © 2015–2024 Red Hat. All rights reserved.