Search in sources :

Example 1 with BasicResponseRenderer

use of com.github.tomakehurst.wiremock.http.BasicResponseRenderer in project styx by ExpediaGroup.

the class WiremockResponseConverterTest method convertsResponseWithBody.

@Test
public void convertsResponseWithBody() {
    ResponseDefinition response = new ResponseDefinition(HTTP_OK, "{ \"count\" : 0, \"requestJournalDisabled\" : false}");
    response.setHeaders(new HttpHeaders(httpHeader("Transfer-Encoding", "chunked"), httpHeader("Content-Type", "application/json")));
    HttpResponse styxResponse = toStyxResponse(new BasicResponseRenderer().render(response));
    assertThat(styxResponse.status(), is(OK));
    Map<String, String> actual = headersAsMap(styxResponse);
    assertThat(actual, is(Map.of("Transfer-Encoding", "chunked", "Content-Type", "application/json")));
    assertThat(styxResponse.bodyAs(UTF_8), is("{ \"count\" : 0, \"requestJournalDisabled\" : false}"));
    assertThat(headerCount(styxResponse.headers()), is(2));
}
Also used : HttpHeaders(com.github.tomakehurst.wiremock.http.HttpHeaders) BasicResponseRenderer(com.github.tomakehurst.wiremock.http.BasicResponseRenderer) HttpResponse(com.hotels.styx.api.HttpResponse) ResponseDefinition(com.github.tomakehurst.wiremock.http.ResponseDefinition) Test(org.junit.jupiter.api.Test)

Example 2 with BasicResponseRenderer

use of com.github.tomakehurst.wiremock.http.BasicResponseRenderer in project styx by ExpediaGroup.

the class WiremockResponseConverterTest method convertsCreatedResponse.

@Test
public void convertsCreatedResponse() {
    ResponseDefinition created = ResponseDefinition.created();
    Response render = new BasicResponseRenderer().render(created);
    HttpResponse styxResponse = toStyxResponse(render);
    assertThat(styxResponse.status(), is(CREATED));
    assertThat(styxResponse.bodyAs(UTF_8), is(""));
    assertThat(headerCount(styxResponse.headers()), is(0));
}
Also used : HttpResponse(com.hotels.styx.api.HttpResponse) WiremockResponseConverter.toStyxResponse(com.hotels.styx.servers.WiremockResponseConverter.toStyxResponse) Response(com.github.tomakehurst.wiremock.http.Response) BasicResponseRenderer(com.github.tomakehurst.wiremock.http.BasicResponseRenderer) HttpResponse(com.hotels.styx.api.HttpResponse) ResponseDefinition(com.github.tomakehurst.wiremock.http.ResponseDefinition) Test(org.junit.jupiter.api.Test)

Example 3 with BasicResponseRenderer

use of com.github.tomakehurst.wiremock.http.BasicResponseRenderer in project wiremock by wiremock.

the class JettyHttpServerTest method init.

@BeforeEach
public void init() {
    Admin admin = Mockito.mock(Admin.class);
    adminRequestHandler = new AdminRequestHandler(AdminRoutes.defaults(), admin, new BasicResponseRenderer(), new NoAuthenticator(), false, Collections.<RequestFilter>emptyList());
    stubRequestHandler = new StubRequestHandler(Mockito.mock(StubServer.class), Mockito.mock(ResponseRenderer.class), admin, Collections.<String, PostServeAction>emptyMap(), Mockito.mock(RequestJournal.class), Collections.<RequestFilter>emptyList(), false);
}
Also used : NoAuthenticator(com.github.tomakehurst.wiremock.security.NoAuthenticator) StubRequestHandler(com.github.tomakehurst.wiremock.http.StubRequestHandler) PostServeAction(com.github.tomakehurst.wiremock.extension.PostServeAction) AdminRequestHandler(com.github.tomakehurst.wiremock.http.AdminRequestHandler) BasicResponseRenderer(com.github.tomakehurst.wiremock.http.BasicResponseRenderer) Admin(com.github.tomakehurst.wiremock.core.Admin) RequestFilter(com.github.tomakehurst.wiremock.extension.requestfilter.RequestFilter) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with BasicResponseRenderer

use of com.github.tomakehurst.wiremock.http.BasicResponseRenderer in project wiremock by wiremock.

the class AdminRequestHandlerTest method init.

@BeforeEach
public void init() {
    httpResponder = new MockHttpResponder();
    handler = new AdminRequestHandler(AdminRoutes.defaults(), admin, new BasicResponseRenderer(), new NoAuthenticator(), false, Collections.<RequestFilter>emptyList());
}
Also used : NoAuthenticator(com.github.tomakehurst.wiremock.security.NoAuthenticator) AdminRequestHandler(com.github.tomakehurst.wiremock.http.AdminRequestHandler) BasicResponseRenderer(com.github.tomakehurst.wiremock.http.BasicResponseRenderer) MockHttpResponder(com.github.tomakehurst.wiremock.testsupport.MockHttpResponder) RequestFilter(com.github.tomakehurst.wiremock.extension.requestfilter.RequestFilter) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

BasicResponseRenderer (com.github.tomakehurst.wiremock.http.BasicResponseRenderer)4 RequestFilter (com.github.tomakehurst.wiremock.extension.requestfilter.RequestFilter)2 AdminRequestHandler (com.github.tomakehurst.wiremock.http.AdminRequestHandler)2 ResponseDefinition (com.github.tomakehurst.wiremock.http.ResponseDefinition)2 NoAuthenticator (com.github.tomakehurst.wiremock.security.NoAuthenticator)2 HttpResponse (com.hotels.styx.api.HttpResponse)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Test (org.junit.jupiter.api.Test)2 Admin (com.github.tomakehurst.wiremock.core.Admin)1 PostServeAction (com.github.tomakehurst.wiremock.extension.PostServeAction)1 HttpHeaders (com.github.tomakehurst.wiremock.http.HttpHeaders)1 Response (com.github.tomakehurst.wiremock.http.Response)1 StubRequestHandler (com.github.tomakehurst.wiremock.http.StubRequestHandler)1 MockHttpResponder (com.github.tomakehurst.wiremock.testsupport.MockHttpResponder)1 WiremockResponseConverter.toStyxResponse (com.hotels.styx.servers.WiremockResponseConverter.toStyxResponse)1