Start the client communicating to the proxy at the specified host and port
and contextPath for example:
ProxyClient mockServerClient = new ProxyClient("localhost", 1080, "/proxy");
Start the client communicating to a MockServer at the specified host and port
for example:
MockServerClient mockServerClient = new MockServerClient("localhost", 1080);
Start the client communicating to a MockServer at the specified host and port
and contextPath for example:
MockServerClient mockServerClient = new MockServerClient("localhost", 1080, "/mockserver");
Start the client communicating to a the proxy at the specified host and port
for example:
ProxyClient mockServerClient = new ProxyClient("localhost", 1080);
Start the client communicating to the proxy at the specified host and port
and contextPath for example:
ProxyClient mockServerClient = new ProxyClient("localhost", 1080, "/proxy");
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")
);
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
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")
);
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
Specify an unlimited expectation that will respond regardless of the number of matching http
for example:
mockServerClient
.when(
request()
.withPath("/some_path")
.withBody("some_request_body")
)
.respond(
response()
.withBody("some_response_body")
.withHeaders(
new Header("responseName", "responseValue")
)
);
Specify an limited expectation that will respond a specified number of times when the http is matched
for example:
mockServerClient
.when(
new HttpRequest()
.withPath("/some_path")
.withBody("some_request_body"),
Times.exactly(5)
)
.respond(
new HttpResponse()
.withBody("some_response_body")
.withHeaders(
new Header("responseName", "responseValue")
)
);
Specify an limited expectation that will respond a specified number of times when the http is matched
for example:
mockServerClient
.when(
new HttpRequest()
.withPath("/some_path")
.withBody("some_request_body"),
Times.exactly(5),
TimeToLive.exactly(TimeUnit.SECONDS, 120),
)
.respond(
new HttpResponse()
.withBody("some_response_body")
.withHeaders(
new Header("responseName", "responseValue")
)
);