Skip to content

Commit d05402d

Browse files
committed
Add test for AsyncHttpClient#820
1 parent cfc9e28 commit d05402d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/test/java/com/ning/http/client/async/ConnectionPoolTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
import com.ning.http.client.AsyncHttpClient;
4141
import com.ning.http.client.AsyncHttpClientConfig;
4242
import com.ning.http.client.ListenableFuture;
43+
import com.ning.http.client.Request;
44+
import com.ning.http.client.RequestBuilder;
4345
import com.ning.http.client.Response;
4446

4547
public abstract class ConnectionPoolTest extends AbstractBasicTest {
@@ -246,4 +248,25 @@ public Response onCompleted(Response response) throws Exception {
246248
assertEquals(count.get(), 0);
247249
}
248250
}
251+
252+
@Test(groups = { "standalone", "default_provider" })
253+
public void nonPoolableConnectionReleaseSemaphoresTest() throws Throwable {
254+
255+
AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder()
256+
.setMaxConnections(6)
257+
.setMaxConnectionsPerHost(3)
258+
.build();
259+
260+
Request request = new RequestBuilder().setUrl(getTargetUrl()).setHeader("Connection", "close").build();
261+
262+
try (AsyncHttpClient client = getAsyncHttpClient(config)) {
263+
client.executeRequest(request).get();
264+
Thread.sleep(1000);
265+
client.executeRequest(request).get();
266+
Thread.sleep(1000);
267+
client.executeRequest(request).get();
268+
Thread.sleep(1000);
269+
client.executeRequest(request).get();
270+
}
271+
}
249272
}

0 commit comments

Comments
 (0)