55import static org .junit .Assert .fail ;
66
77import java .io .IOException ;
8- import java .io .InputStream ;
98import java .net .URL ;
109import java .nio .ByteBuffer ;
1110import java .util .HashMap ;
2524import org .threadly .litesockets .SocketExecuter ;
2625import org .threadly .litesockets .TCPServer ;
2726import org .threadly .litesockets .ThreadedSocketExecuter ;
28- import org .threadly .litesockets .buffers .MergedByteBuffers ;
29- import org .threadly .litesockets .buffers .ReuseableMergedByteBuffers ;
3027import org .threadly .litesockets .client .http .HTTPClient .HTTPResponseData ;
3128import org .threadly .litesockets .protocols .http .request .HTTPRequest ;
3229import org .threadly .litesockets .protocols .http .request .HTTPRequestBuilder ;
3734import org .threadly .litesockets .protocols .http .shared .HTTPHeaders ;
3835import org .threadly .litesockets .protocols .http .shared .HTTPParsingException ;
3936import org .threadly .litesockets .utils .IOUtils ;
37+ import org .threadly .litesockets .utils .PortUtils ;
4038import org .threadly .test .concurrent .TestCondition ;
4139import org .threadly .util .Clock ;
42- import org .w3c .dom .Element ;
43- import org .xml .sax .SAXException ;
4440
4541public class HTTPClientTests {
4642 static String CONTENT = "TEST123" ;
@@ -86,7 +82,7 @@ public void stop() {
8682 @ Test
8783 public void manyRequestsConcurrent () throws IOException {
8884 final int number = 500 ;
89- final int port = TestUtils .findTCPPort ();
85+ final int port = PortUtils .findTCPPort ();
9086 fakeServer = new TestHTTPServer (port , RESPONSE_CL , CONTENT , false , false );
9187 final HTTPRequestBuilder hrb = new HTTPRequestBuilder ().setPort (port );
9288 final HTTPClient httpClient = new HTTPClient ();
@@ -140,7 +136,7 @@ public boolean get() {
140136 @ Test
141137 public void manyRequestsConcurrentJavaExecutor () throws IOException , InterruptedException {
142138 final int number = 500 ;
143- final int port = TestUtils .findTCPPort ();
139+ final int port = PortUtils .findTCPPort ();
144140 final ThreadedSocketExecuter TSE = new ThreadedSocketExecuter (PS );
145141 TSE .start ();
146142 fakeServer = new TestHTTPServer (port , RESPONSE_CL , CONTENT , false , false );
@@ -200,7 +196,7 @@ public boolean get() {
200196 @ Test
201197 public void manyRequestsConcurrentOnPool () throws IOException {
202198 final int number = 500 ;
203- final int port = TestUtils .findTCPPort ();
199+ final int port = PortUtils .findTCPPort ();
204200 fakeServer = new TestHTTPServer (port , RESPONSE_CL , CONTENT , false , false );
205201 final HTTPRequestBuilder hrb = new HTTPRequestBuilder (new URL ("http://localhost:" +port ));
206202 final ThreadedSocketExecuter TSE = new ThreadedSocketExecuter (PS );
@@ -257,7 +253,7 @@ public boolean get() {
257253
258254 @ Test
259255 public void blockingRequest () throws IOException , HTTPParsingException {
260- int port = TestUtils .findTCPPort ();
256+ int port = PortUtils .findTCPPort ();
261257 fakeServer = new TestHTTPServer (port , RESPONSE_CL , CONTENT , false , true );
262258 final HTTPRequestBuilder hrb = new HTTPRequestBuilder (new URL ("http://localhost:" +port ));
263259 final HTTPClient httpClient = new HTTPClient ();
@@ -267,7 +263,7 @@ public void blockingRequest() throws IOException, HTTPParsingException {
267263
268264 @ Test
269265 public void noContentLengthNoBody () throws IOException , HTTPParsingException {
270- int port = TestUtils .findTCPPort ();
266+ int port = PortUtils .findTCPPort ();
271267 fakeServer = new TestHTTPServer (port , RESPONSE_NO_CL , "" , false , true );
272268 final HTTPRequestBuilder hrb = new HTTPRequestBuilder (new URL ("http://localhost:" +port ));
273269 final HTTPClient httpClient = new HTTPClient ();
@@ -278,7 +274,7 @@ public void noContentLengthNoBody() throws IOException, HTTPParsingException {
278274
279275 @ Test
280276 public void noContentLengthWithBody () throws IOException , HTTPParsingException {
281- int port = TestUtils .findTCPPort ();
277+ int port = PortUtils .findTCPPort ();
282278 fakeServer = new TestHTTPServer (port , RESPONSE_NO_CL , CONTENT , false , true );
283279 final HTTPRequestBuilder hrb = new HTTPRequestBuilder (new URL ("http://localhost:" +port ));
284280 final HTTPClient httpClient = new HTTPClient ();
@@ -290,7 +286,7 @@ public void noContentLengthWithBody() throws IOException, HTTPParsingException {
290286
291287 @ Test
292288 public void closeBeforeLength () throws IOException , HTTPParsingException {
293- int port = TestUtils .findTCPPort ();
289+ int port = PortUtils .findTCPPort ();
294290 fakeServer = new TestHTTPServer (port , RESPONSE_HUGE , CONTENT , false , true );
295291 final HTTPRequestBuilder hrb = new HTTPRequestBuilder (new URL ("http://localhost:" +port ));
296292 final HTTPClient httpClient = new HTTPClient ();
@@ -306,7 +302,7 @@ public void closeBeforeLength() throws IOException, HTTPParsingException {
306302
307303 @ Test
308304 public void timeoutRequest () throws IOException , HTTPParsingException {
309- int port = TestUtils .findTCPPort ();
305+ int port = PortUtils .findTCPPort ();
310306 TCPServer server = SEI .createTCPServer ("localhost" , port );
311307 server .start ();
312308 final HTTPRequestBuilder hrb = new HTTPRequestBuilder (new URL ("http://localhost:" +port ));
@@ -322,7 +318,7 @@ public void timeoutRequest() throws IOException, HTTPParsingException {
322318
323319 @ Test
324320 public void expireRequest () throws IOException , HTTPParsingException {
325- int port = TestUtils .findTCPPort ();
321+ int port = PortUtils .findTCPPort ();
326322 fakeServer = new TestHTTPServer (port , RESPONSE_CL , "" , false , false );
327323 final HTTPRequestBuilder hrb = new HTTPRequestBuilder (new URL ("http://localhost:" +port ));
328324 final HTTPClient httpClient = new HTTPClient ();
@@ -339,7 +335,7 @@ public void expireRequest() throws IOException, HTTPParsingException {
339335
340336 @ Test
341337 public void sslRequest () throws IOException , HTTPParsingException {
342- int port = TestUtils .findTCPPort ();
338+ int port = PortUtils .findTCPPort ();
343339 fakeServer = new TestHTTPServer (port , RESPONSE_CL , CONTENT , true , false );
344340 final HTTPRequestBuilder hrb = new HTTPRequestBuilder (new URL ("https://localhost:" +port ));
345341 final HTTPClient httpClient = new HTTPClient ();
@@ -349,7 +345,7 @@ public void sslRequest() throws IOException, HTTPParsingException {
349345
350346 @ Test
351347 public void toLargeRequest () throws IOException , HTTPParsingException {
352- int port = TestUtils .findTCPPort ();
348+ int port = PortUtils .findTCPPort ();
353349 fakeServer = new TestHTTPServer (port , RESPONSE_HUGE , LARGE_CONTENT , false , false );
354350 final HTTPRequestBuilder hrb = new HTTPRequestBuilder (new URL ("http://localhost:" +port ));
355351 final HTTPClient httpClient = new HTTPClient ();
@@ -364,7 +360,7 @@ public void toLargeRequest() throws IOException, HTTPParsingException {
364360
365361 @ Test
366362 public void toLargeRequestNoContentLength () throws IOException , HTTPParsingException {
367- int port = TestUtils .findTCPPort ();
363+ int port = PortUtils .findTCPPort ();
368364 fakeServer = new TestHTTPServer (port , RESPONSE_NO_CL , LARGE_CONTENT , false , true );
369365 final HTTPRequestBuilder hrb = new HTTPRequestBuilder (new URL ("http://localhost:" +port ));
370366 final HTTPClient httpClient = new HTTPClient ();
@@ -409,7 +405,7 @@ public void toLargeRequestNoContentLength() throws IOException, HTTPParsingExcep
409405
410406 @ Test
411407 public void timeOut () throws IOException , InterruptedException , ExecutionException , TimeoutException {
412- int port = TestUtils .findTCPPort ();
408+ int port = PortUtils .findTCPPort ();
413409 TCPServer server = SEI .createTCPServer ("localhost" , port );
414410 server .setClientAcceptor (new ClientAcceptor () {
415411 @ Override
@@ -437,7 +433,7 @@ public void accept(Client c) {
437433
438434 @ Test
439435 public void urlRequest () throws HTTPParsingException , IOException {
440- int port = TestUtils .findTCPPort ();
436+ int port = PortUtils .findTCPPort ();
441437 fakeServer = new TestHTTPServer (port , RESPONSE_CL , CONTENT , false , false );
442438 final HTTPClient httpClient = new HTTPClient ();
443439 httpClient .start ();
0 commit comments