use of com.github.dreamhead.moco.HttpRequest in project moco by dreamhead.
the class HttpRequestMatcherTest method should_not_be_match_if_request_is_different.
@Test
public void should_not_be_match_if_request_is_different() {
HttpRequest request = DefaultHttpRequest.builder().withUri("/uri").withVersion(HttpProtocolVersion.VERSION_1_1).withMethod(HttpMethod.POST).withTextContent("proxy").withHeaders(of("Cookie", "loggedIn=true", "Host", "localhost:12306")).build();
HttpRequest another = DefaultHttpRequest.builder().withUri("/uri").withVersion(HttpProtocolVersion.VERSION_1_1).withMethod(HttpMethod.POST).withTextContent("different").withHeaders(of("Cookie", "loggedIn=true", "Host", "localhost:12306")).build();
assertThat(new HttpRequestFailoverMatcher(request).match(another), is(false));
}
use of com.github.dreamhead.moco.HttpRequest in project moco by dreamhead.
the class MocoHandler method handleRequest.
private FullHttpResponse handleRequest(final FullHttpRequest message) {
HttpRequest request = DefaultHttpRequest.newRequest(message);
DefaultMutableHttpResponse httpResponse = getHttpResponse(request);
FullHttpResponse response = httpResponse.toFullResponse();
prepareForKeepAlive(message, response);
monitor.onMessageLeave(httpResponse);
return response;
}
use of com.github.dreamhead.moco.HttpRequest in project moco by dreamhead.
the class XmlRequestMatcherTest method should_return_false_for_empty_content.
@Test
public void should_return_false_for_empty_content() {
XmlRequestMatcher unitUnderTest = new XmlRequestMatcher(new ContentRequestExtractor(), text("<request><parameters><id>1</id></parameters></request>"));
HttpRequest request = DefaultHttpRequest.builder().withContent(MessageContent.content("")).build();
assertThat(unitUnderTest.match(request), is(false));
}
Aggregations