Maybe you can add a RestAssuredConfigFactory to make the usage a bit simpler. · Issue #4 · dzieciou/curl-logger · GitHub
More Web Proxy on the site http://driver.im/
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/**
* To provide cUrl log configuration for RestAssured
*/
public class RestAssuredConfigFactory {
public static RestAssuredConfig singleLineCurl() {
return config()
.httpClient(httpClientConfig()
.reuseHttpClientInstance()
.httpClientFactory(new SingleCurlLoggingHttpClientFactory()));
}
private static class SingleCurlLoggingHttpClientFactory implements HttpClientConfig.HttpClientFactory {
@Override
public HttpClient createHttpClient() {
AbstractHttpClient client = new DefaultHttpClient();
client.addRequestInterceptor(CurlLoggingInterceptor.defaultBuilder().printSingleliner().build());// singleLine cUrl
return client;
}
}
public static RestAssuredConfig multiLineCurl() {
return config()
.httpClient(httpClientConfig()
.reuseHttpClientInstance()
.httpClientFactory(new MultiCurlLoggingHttpClientFactory()));
}
private static class MultiCurlLoggingHttpClientFactory implements HttpClientConfig.HttpClientFactory {
@Override
public HttpClient createHttpClient() {
AbstractHttpClient client = new DefaultHttpClient();
client.addRequestInterceptor(CurlLoggingInterceptor.defaultBuilder().printMultiliner().build());// multiLine cUrl
return client;
}
}
}
And to use it:
RestAssured.given()
.config(RestAssuredConfigFactory.singleLineCurl())// this will log the cUrl to the log print out
.contentType(ContentType.JSON)
.body(new LandLord("Tao", "Zhang"))
.when()
.post("/landlords")
.then()
.statusCode(201);
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Something like this:
And to use it:
The text was updated successfully, but these errors were encountered: