public interface MockServer
| 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.
|
default void |
onShutdown()
This method is called right after shutdown.
|
default void |
onStart()
This method is called right before start.
|
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.
|
default void onStart()
default void onShutdown()
int getPort()
MockWebServer.String getHostName()
MockWebServer.Proxy toProxyAddress()
Proxy for the MockWebServer with the current HostName and Port.String url(String path)
path - the request path, such as "/".MockServerExpectation expect()
MockServerExpectation to set the expectations.int getRequestCount()
okhttp3.mockwebserver.RecordedRequest takeRequest()
throws InterruptedException
InterruptedExceptionokhttp3.mockwebserver.RecordedRequest takeRequest(long timeout,
TimeUnit unit)
throws InterruptedException
timeout - how long to wait before giving up, in units of unitunit - a TimeUnit determining how to interpret the timeout parameterInterruptedExceptionokhttp3.mockwebserver.RecordedRequest getLastRequest()
throws InterruptedException
MockWebServer.
n.b. This method clears the request queue.InterruptedExceptionCopyright © 2015–2024 Red Hat. All rights reserved.