use of com.github.tomakehurst.wiremock.testsupport.WireMockTestClient in project wiremock by wiremock.
the class AdminRequestHandlerTest method shouldLogInfoOnRequest.
@Test
public void shouldLogInfoOnRequest() throws UnsupportedEncodingException {
WireMockTestClient client = new WireMockTestClient(wm.getPort());
String postHeaderABCName = "ABC";
String postHeaderABCValue = "abc123";
String postBody = "{\n" + " \"request\": {\n" + " \"method\": \"GET\",\n" + " \"url\": \"/some/thing\"\n" + " },\n" + " \"response\": {\n" + " \"status\": 200,\n" + " \"body\": \"Hello world!\",\n" + " \"headers\": {\n" + " \"Content-Type\": \"text/plain\"\n" + " }\n" + " }\n" + "}";
client.post("/__admin/mappings", new StringEntity(postBody), withHeader(postHeaderABCName, postHeaderABCValue));
verify(notifier).info(contains("Admin request received:\n127.0.0.1 - POST /mappings\n"));
verify(notifier).info(contains(postHeaderABCName + ": [" + postHeaderABCValue + "]\n"));
verify(notifier).info(contains(postBody));
}
use of com.github.tomakehurst.wiremock.testsupport.WireMockTestClient in project wiremock by wiremock.
the class AcceptanceTestBase method setupServer.
public static void setupServer(WireMockConfiguration options) {
System.out.println("Configuring WireMockServer with root directory: " + options.filesRoot().getPath());
if (options.portNumber() == Options.DEFAULT_PORT) {
options.dynamicPort();
}
wireMockServer = new WireMockServer(options);
wireMockServer.start();
testClient = new WireMockTestClient(wireMockServer.port());
WireMock.configureFor(wireMockServer.port());
wm = wireMockServer;
}
use of com.github.tomakehurst.wiremock.testsupport.WireMockTestClient in project wiremock by wiremock.
the class ResponseTransformerAcceptanceTest method startWithExtensions.
@SuppressWarnings("unchecked")
private void startWithExtensions(Class<? extends Extension> extensionClasses) {
wm = new WireMockServer(wireMockConfig().dynamicPort().extensions(extensionClasses));
wm.start();
client = new WireMockTestClient(wm.port());
}
use of com.github.tomakehurst.wiremock.testsupport.WireMockTestClient in project wiremock by wiremock.
the class SnapshotDslAcceptanceTest method init.
@BeforeEach
public void init() {
proxyingService = new WireMockServer(wireMockConfig().dynamicPort().extensions(new TestParameterisedTransformer()).withRootDirectory(setupTempFileRoot().getAbsolutePath()));
proxyingService.start();
proxyingService.stubFor(proxyAllTo("http://localhost:" + wireMockServer.port()));
targetService = wireMockServer;
proxyStub = targetService.stubFor(any(anyUrl()).willReturn(ok()));
client = new WireMockTestClient(proxyingService.port());
WireMock.configureFor(proxyingService.port());
adminClient = WireMock.create().port(proxyingService.port()).build();
}
use of com.github.tomakehurst.wiremock.testsupport.WireMockTestClient in project wiremock by wiremock.
the class StandaloneAcceptanceTest method startRunner.
private void startRunner(String... args) {
runner = new WireMockServerRunner();
runner.run(argsWithPort(argsWithRecordingsPath(args)));
int port = runner.port();
testClient = new WireMockTestClient(port);
WireMock.configureFor(port);
}
Aggregations