use of com.github.tomakehurst.wiremock.core.Admin in project wiremock by wiremock.
the class NotMatchedPageAcceptanceTest method supportsCustomNoMatchRenderer.
@Test
public void supportsCustomNoMatchRenderer() {
configure(wireMockConfig().notMatchedRenderer(new NotMatchedRenderer() {
@Override
protected ResponseDefinition render(Admin admin, Request request) {
return ResponseDefinitionBuilder.responseDefinition().withStatus(403).withBody("No you don't!").build();
}
}));
WireMockResponse response = testClient.get("/should-not-match");
assertThat(response.statusCode(), is(403));
assertThat(response.content(), is("No you don't!"));
}
use of com.github.tomakehurst.wiremock.core.Admin 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);
}
use of com.github.tomakehurst.wiremock.core.Admin in project wiremock by wiremock.
the class StubRequestHandlerTest method init.
@BeforeEach
public void init() {
stubServer = mock(StubServer.class);
responseRenderer = mock(ResponseRenderer.class);
httpResponder = new MockHttpResponder();
admin = mock(Admin.class);
requestJournal = mock(RequestJournal.class);
requestHandler = new StubRequestHandler(stubServer, responseRenderer, admin, Collections.<String, PostServeAction>emptyMap(), requestJournal, Collections.<RequestFilter>emptyList(), false);
}
use of com.github.tomakehurst.wiremock.core.Admin in project wiremock by wiremock.
the class PostServeActionExtensionTest method providesServeEventWithResponseFieldPopulated.
@Test
public void providesServeEventWithResponseFieldPopulated() throws InterruptedException {
final AtomicInteger finalStatus = new AtomicInteger();
initWithOptions(options().dynamicPort().extensions(new PostServeAction() {
@Override
public String getName() {
return "response-field-test";
}
@Override
public void doGlobalAction(ServeEvent serveEvent, Admin admin) {
if (serveEvent.getResponse() != null) {
finalStatus.set(serveEvent.getResponse().getStatus());
}
}
}));
wm.stubFor(get(urlPathEqualTo("/response-status")).willReturn(aResponse().withStatus(418)));
client.get("/response-status");
await().atMost(5, SECONDS).until(getValue(finalStatus), is(418));
}
Aggregations