Made test more robust.

The check for the connection being closed may fail spuriously because
the notification of CompleteListener happens before the connection is
closed.
This commit is contained in:
Simone Bordet 2014-02-06 11:56:25 +01:00
parent 5edf2799e9
commit 9356ab46da

View File

@ -1137,6 +1137,10 @@ public class HttpClientTest extends AbstractHttpClientServerTest
ContentResponse response = listener.get(2 * timeout, TimeUnit.MILLISECONDS); ContentResponse response = listener.get(2 * timeout, TimeUnit.MILLISECONDS);
Assert.assertEquals(200, response.getStatus()); Assert.assertEquals(200, response.getStatus());
// The parser notifies end-of-content and therefore the CompleteListener
// before closing the connection, so we need to wait before checking
// that the connection is closed to avoid races.
Thread.sleep(1000);
Assert.assertTrue(((HttpConnectionOverHTTP)connection).isClosed()); Assert.assertTrue(((HttpConnectionOverHTTP)connection).isClosed());
} }
} }