Skip to content

Commit 2b704f9

Browse files
author
eugenp
committed
further connection management work
1 parent 5991755 commit 2b704f9

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

httpclient/src/test/java/org/baeldung/httpclient/HttpClientConnectionManagementTest.java renamed to httpclient/src/test/java/org/baeldung/httpclient/conn/HttpClientConnectionManagementTest.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.baeldung.httpclient;
1+
package org.baeldung.httpclient.conn;
22

33
import static org.junit.Assert.assertTrue;
44

@@ -109,18 +109,12 @@ public final void whenOpeningLowLevelConnectionWithSocketTimeout_thenNoException
109109
// 3
110110

111111
@Test
112-
// @Ignore
113-
public final void whenPollingConnectionManagerIsConfiguredOnHttpClient_thenNoExceptions() throws InterruptedException {
112+
public final void whenPollingConnectionManagerIsConfiguredOnHttpClient_thenNoExceptions() throws InterruptedException, ClientProtocolException, IOException {
114113
poolingConnManager = new PoolingHttpClientConnectionManager();
115-
final CloseableHttpClient client1 = HttpClients.custom().setConnectionManager(poolingConnManager).build();
116-
final CloseableHttpClient client2 = HttpClients.custom().setConnectionManager(poolingConnManager).build();
117-
final TesterVersion_MultiHttpClientConnThread thread1 = new TesterVersion_MultiHttpClientConnThread(client1, get1, poolingConnManager);
118-
final TesterVersion_MultiHttpClientConnThread thread2 = new TesterVersion_MultiHttpClientConnThread(client2, get2, poolingConnManager);
119-
thread1.start();
120-
thread1.join();
121-
thread2.start();
122-
thread2.join(1000);
123-
assertTrue(poolingConnManager.getTotalStats().getLeased() == 2);
114+
client = HttpClients.custom().setConnectionManager(poolingConnManager).build();
115+
client.execute(get1);
116+
117+
assertTrue(poolingConnManager.getTotalStats().getLeased() == 1);
124118
}
125119

126120
@Test
@@ -149,8 +143,8 @@ public final void whenTwoConnectionsForTwoRequests_thenNoExceptions() throws Int
149143
final MultiHttpClientConnThread thread1 = new MultiHttpClientConnThread(client1, get1);
150144
final MultiHttpClientConnThread thread2 = new MultiHttpClientConnThread(client2, get2);
151145
thread1.start();
152-
thread1.join();
153146
thread2.start();
147+
thread1.join();
154148
thread2.join();
155149
}
156150

httpclient/src/test/java/org/baeldung/httpclient/IdleConnectionMonitorThread.java renamed to httpclient/src/test/java/org/baeldung/httpclient/conn/IdleConnectionMonitorThread.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.baeldung.httpclient;
1+
package org.baeldung.httpclient.conn;
22

33
import java.util.concurrent.TimeUnit;
44

httpclient/src/test/java/org/baeldung/httpclient/MultiHttpClientConnThread.java renamed to httpclient/src/test/java/org/baeldung/httpclient/conn/MultiHttpClientConnThread.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.baeldung.httpclient;
1+
package org.baeldung.httpclient.conn;
22

33
import java.io.IOException;
44
import java.util.logging.Level;

httpclient/src/test/java/org/baeldung/httpclient/TesterVersion_MultiHttpClientConnThread.java renamed to httpclient/src/test/java/org/baeldung/httpclient/conn/TesterVersion_MultiHttpClientConnThread.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.baeldung.httpclient;
1+
package org.baeldung.httpclient.conn;
22

33
import java.io.IOException;
44
import java.util.logging.Level;

0 commit comments

Comments
 (0)