37
37
import org .asynchttpclient .ListenableFuture ;
38
38
import org .asynchttpclient .RequestBuilder ;
39
39
import org .asynchttpclient .Response ;
40
+ import org .asynchttpclient .netty .channel .exception .TooManyConnectionsException ;
40
41
import org .asynchttpclient .test .EventCollectingHandler ;
41
42
import org .testng .annotations .Test ;
42
43
@@ -61,8 +62,8 @@ public void testMaxTotalConnections() throws Exception {
61
62
}
62
63
}
63
64
64
- @ Test (groups = "standalone" )
65
- public void testMaxTotalConnectionsException () throws IOException {
65
+ @ Test (groups = "standalone" , expectedExceptions = TooManyConnectionsException . class )
66
+ public void testMaxTotalConnectionsException () throws Throwable {
66
67
try (AsyncHttpClient client = asyncHttpClient (config ().setKeepAlive (true ).setMaxConnections (1 ))) {
67
68
String url = getTargetUrl ();
68
69
@@ -83,8 +84,7 @@ public void testMaxTotalConnectionsException() throws IOException {
83
84
}
84
85
85
86
assertNotNull (exception );
86
- assertNotNull (exception .getCause ());
87
- assertEquals (exception .getCause ().getMessage (), "Too many connections 1" );
87
+ throw exception .getCause ();
88
88
}
89
89
}
90
90
@@ -124,8 +124,8 @@ public Response onCompleted(Response response) throws Exception {
124
124
}
125
125
}
126
126
127
- @ Test (groups = "standalone" )
128
- public void multipleMaxConnectionOpenTest () throws Exception {
127
+ @ Test (groups = "standalone" , expectedExceptions = TooManyConnectionsException . class )
128
+ public void multipleMaxConnectionOpenTest () throws Throwable {
129
129
try (AsyncHttpClient c = asyncHttpClient (config ().setKeepAlive (true ).setConnectTimeout (5000 ).setMaxConnections (1 ))) {
130
130
String body = "hello there" ;
131
131
@@ -144,8 +144,7 @@ public void multipleMaxConnectionOpenTest() throws Exception {
144
144
exception = ex ;
145
145
}
146
146
assertNotNull (exception );
147
- assertNotNull (exception .getCause ());
148
- assertEquals (exception .getCause ().getMessage (), "Too many connections 1" );
147
+ throw exception .getCause ();
149
148
}
150
149
}
151
150
0 commit comments