@Test
public void shouldVerifyRequests() throws Exception {
// given
HttpClient httpClient = createHttpClient();
ProxyClient proxyClient = new ProxyClient("127.0.0.1", getProxyPort()).reset();
// when
httpClient.execute(
new HttpGet(
new URIBuilder()
.setScheme("http")
.setHost("localhost")
.setPort(getServerPort())
.setPath("/test_headers_and_body")
.build()
)
);
httpClient.execute(
new HttpGet(
new URIBuilder()
.setScheme("http")
.setHost("localhost")
.setPort(getServerPort())
.setPath("/test_headers_only")
.build()
)
);
// then
proxyClient
.verify(
request()
.withMethod("GET")
.withPath("/test_headers_and_body")
);
proxyClient
.verify(
request()
.withMethod("GET")
.withPath("/test_headers_and_body"),
exactly(1)
);
proxyClient
.verify(
request()
.withPath("/test_headers_.*"),
atLeast(1)
);
proxyClient
.verify(
request()
.withPath("/test_headers_.*"),
exactly(2)
);
proxyClient
.verify(
request()
.withPath("/other_path"),
exactly(0)
);