Skip to content

Commit

Permalink
Do not reuse HTTP client instance (bug fix for #37)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzieciou committed Nov 2, 2020
1 parent e66f6b2 commit c184aa4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static RestAssuredConfig updateConfig(RestAssuredConfig config, Options o
handlers);
return config
.httpClient(config.getHttpClientConfig()
.reuseHttpClientInstance()
.dontReuseHttpClientInstance()
.httpClientFactory(new MyHttpClientFactory(originalFactory, interceptor)));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.dzieciou.testing.curl;


import io.restassured.specification.RequestSpecification;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
Expand All @@ -21,6 +22,7 @@
import io.restassured.config.HttpClientConfig;
import io.restassured.config.RestAssuredConfig;

import static io.restassured.RestAssured.config;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.not;
Expand Down Expand Up @@ -101,6 +103,24 @@ public void shouldSentRequestWhenUsingConfigurationFactory() {
.statusCode(200);
}

@Test
public void shouldSentSameRequestTwice() {
// Verifying fix for https://github.com/dzieciou/curl-logger/issues/37

//@formatter:off
RequestSpecification request = RestAssured.given()
.baseUri(MOCK_BASE_URI)
.port(MOCK_PORT)
.config(CurlRestAssuredConfigFactory.createConfig())
.body("anything")
.when();

request.post("/");

request.post("/");
//@formatter:on
}

@AfterClass
public void closeMock() {
mockServer.stop();
Expand Down

0 comments on commit c184aa4

Please sign in to comment.