|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mockserver.client.AbstractClient
org.mockserver.client.proxy.ProxyClient
public class ProxyClient
| Field Summary |
|---|
| Fields inherited from class org.mockserver.client.AbstractClient |
|---|
contextPath, expectationSerializer, host, httpRequestSerializer, logger, nettyHttpClient, port, verificationSequenceSerializer, verificationSerializer |
| Constructor Summary | |
|---|---|
ProxyClient(String host,
int port)
Start the client communicating to a the proxy at the specified host and port for example: ProxyClient mockServerClient = new ProxyClient("localhost", 1080); |
|
ProxyClient(String host,
int port,
String contextPath)
Start the client communicating to the proxy at the specified host and port and contextPath for example: ProxyClient mockServerClient = new ProxyClient("localhost", 1080, "/proxy"); |
|
| Method Summary | |
|---|---|
ProxyClient |
clear(HttpRequest httpRequest)
Clear all recorded requests that match the httpRequest parameter |
ProxyClient |
dumpToLogAsJava()
Output Java code for creating all requests / responses as Expectations to the log. |
ProxyClient |
dumpToLogAsJava(HttpRequest httpRequest)
Output Java code for creating matching requests and their responses as Expectations to the log. |
ProxyClient |
dumpToLogAsJSON()
Pretty-print the json for all requests / responses as Expectations to the log. |
ProxyClient |
dumpToLogAsJSON(HttpRequest httpRequest)
Pretty-print the json for matching requests and their responses as Expectations to the log. |
boolean |
isRunning()
Returns whether the proxy is running |
ProxyClient |
reset()
Reset the proxy by clearing recorded requests |
Expectation[] |
retrieveAsExpectations(HttpRequest httpRequest)
Retrieve the recorded requests that match the httpRequest parameter as expectations, use null for the parameter to retrieve all requests |
String |
retrieveAsJSON(HttpRequest httpRequest)
Retrieve the recorded requests that match the httpRequest parameter as a JSON array, use null for the parameter to retrieve all requests |
ProxyClient |
stop()
Stop the proxy gracefully (only support for Netty and Vert.X versions, not supported for WAR version) |
ProxyClient |
stop(boolean ignoreFailure)
|
ProxyClient |
verify(HttpRequest... httpRequests)
Verify a list of requests have been sent in the order specified for example: mockServerClient .verify( request() .withPath("/first_request") .withBody("some_request_body"), request() .withPath("/second_request") .withBody("some_request_body") ); |
ProxyClient |
verify(HttpRequest httpRequest,
VerificationTimes times)
Verify a request has been sent for example: mockServerClient .verify( request() .withPath("/some_path") .withBody("some_request_body"), VerificationTimes.exactly(3) ); VerificationTimes supports multiple static factory methods: once() - verify the request was only received once exactly(n) - verify the request was only received exactly n times atLeast(n) - verify the request was only received at least n times |
| Methods inherited from class org.mockserver.client.AbstractClient |
|---|
calculatePath, formatErrorMessage, sendRequest |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ProxyClient(String host,
int port)
host - the host for the MockServer to communicate withport - the port for the MockServer to communicate with
public ProxyClient(String host,
int port,
String contextPath)
host - the host for the proxy to communicate withport - the port for the proxy to communicate withcontextPath - the context path that the proxy war is deployed to| Method Detail |
|---|
public ProxyClient dumpToLogAsJSON()
public ProxyClient dumpToLogAsJSON(HttpRequest httpRequest)
httpRequest - the http request that is matched against when deciding what to log if null all requests are loggedpublic ProxyClient dumpToLogAsJava()
public ProxyClient dumpToLogAsJava(HttpRequest httpRequest)
httpRequest - the http request that is matched against when deciding what to log if null all requests are loggedpublic boolean isRunning()
public ProxyClient stop()
public ProxyClient stop(boolean ignoreFailure)
public ProxyClient reset()
public ProxyClient clear(HttpRequest httpRequest)
httpRequest - the http request that is matched against when deciding whether to clear recorded requests
public ProxyClient verify(HttpRequest... httpRequests)
throws AssertionError
httpRequests - the http requests that must be matched for this verification to pass
AssertionError - if the request has not been found
public ProxyClient verify(HttpRequest httpRequest,
VerificationTimes times)
throws AssertionError
httpRequest - the http request that must be matched for this verification to passtimes - the number of times this request must be matched
AssertionError - if the request has not been foundpublic Expectation[] retrieveAsExpectations(HttpRequest httpRequest)
httpRequest - the http request that is matched against when deciding whether to return each expectation, use null for the parameter to retrieve for all requests
public String retrieveAsJSON(HttpRequest httpRequest)
httpRequest - the http request that is matched against when deciding whether to return each expectation, use null for the parameter to retrieve for all requests
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||