Clarified test code.
This commit is contained in:
parent
73821e7ac6
commit
66df49bb4c
|
@ -42,7 +42,8 @@ public class HttpResponseConcurrentAbortTest extends AbstractHttpClientServerTes
|
||||||
private final CountDownLatch callbackLatch = new CountDownLatch(1);
|
private final CountDownLatch callbackLatch = new CountDownLatch(1);
|
||||||
private final CountDownLatch failureLatch = new CountDownLatch(1);
|
private final CountDownLatch failureLatch = new CountDownLatch(1);
|
||||||
private final CountDownLatch completeLatch = new CountDownLatch(1);
|
private final CountDownLatch completeLatch = new CountDownLatch(1);
|
||||||
private final AtomicBoolean success = new AtomicBoolean();
|
private final AtomicBoolean failureWasAsync = new AtomicBoolean();
|
||||||
|
private final AtomicBoolean completeWasSync = new AtomicBoolean();
|
||||||
|
|
||||||
public HttpResponseConcurrentAbortTest(SslContextFactory sslContextFactory)
|
public HttpResponseConcurrentAbortTest(SslContextFactory sslContextFactory)
|
||||||
{
|
{
|
||||||
|
@ -66,8 +67,9 @@ public class HttpResponseConcurrentAbortTest extends AbstractHttpClientServerTes
|
||||||
})
|
})
|
||||||
.send(new TestResponseListener());
|
.send(new TestResponseListener());
|
||||||
Assert.assertTrue(callbackLatch.await(5, TimeUnit.SECONDS));
|
Assert.assertTrue(callbackLatch.await(5, TimeUnit.SECONDS));
|
||||||
Assert.assertTrue(completeLatch.await(6, TimeUnit.SECONDS));
|
Assert.assertTrue(completeLatch.await(5, TimeUnit.SECONDS));
|
||||||
Assert.assertTrue(success.get());
|
Assert.assertTrue(failureWasAsync.get());
|
||||||
|
Assert.assertTrue(completeWasSync.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -89,7 +91,8 @@ public class HttpResponseConcurrentAbortTest extends AbstractHttpClientServerTes
|
||||||
.send(new TestResponseListener());
|
.send(new TestResponseListener());
|
||||||
Assert.assertTrue(callbackLatch.await(5, TimeUnit.SECONDS));
|
Assert.assertTrue(callbackLatch.await(5, TimeUnit.SECONDS));
|
||||||
Assert.assertTrue(completeLatch.await(5, TimeUnit.SECONDS));
|
Assert.assertTrue(completeLatch.await(5, TimeUnit.SECONDS));
|
||||||
Assert.assertTrue(success.get());
|
Assert.assertTrue(failureWasAsync.get());
|
||||||
|
Assert.assertTrue(completeWasSync.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -110,7 +113,8 @@ public class HttpResponseConcurrentAbortTest extends AbstractHttpClientServerTes
|
||||||
.send(new TestResponseListener());
|
.send(new TestResponseListener());
|
||||||
Assert.assertTrue(callbackLatch.await(5, TimeUnit.SECONDS));
|
Assert.assertTrue(callbackLatch.await(5, TimeUnit.SECONDS));
|
||||||
Assert.assertTrue(completeLatch.await(5, TimeUnit.SECONDS));
|
Assert.assertTrue(completeLatch.await(5, TimeUnit.SECONDS));
|
||||||
Assert.assertTrue(success.get());
|
Assert.assertTrue(failureWasAsync.get());
|
||||||
|
Assert.assertTrue(completeWasSync.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -141,7 +145,8 @@ public class HttpResponseConcurrentAbortTest extends AbstractHttpClientServerTes
|
||||||
.send(new TestResponseListener());
|
.send(new TestResponseListener());
|
||||||
Assert.assertTrue(callbackLatch.await(5, TimeUnit.SECONDS));
|
Assert.assertTrue(callbackLatch.await(5, TimeUnit.SECONDS));
|
||||||
Assert.assertTrue(completeLatch.await(5, TimeUnit.SECONDS));
|
Assert.assertTrue(completeLatch.await(5, TimeUnit.SECONDS));
|
||||||
Assert.assertTrue(success.get());
|
Assert.assertTrue(failureWasAsync.get());
|
||||||
|
Assert.assertTrue(completeWasSync.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void abort(final Response response)
|
private void abort(final Response response)
|
||||||
|
@ -157,14 +162,15 @@ public class HttpResponseConcurrentAbortTest extends AbstractHttpClientServerTes
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// The failure callback must be executed asynchronously.
|
// The failure callback is executed asynchronously, but
|
||||||
boolean latched = failureLatch.await(4, TimeUnit.SECONDS);
|
// here we are within the context of another response
|
||||||
success.set(latched);
|
// callback, which should detect that a failure happened
|
||||||
|
// and therefore this thread should complete the response.
|
||||||
|
failureWasAsync.set(failureLatch.await(2, TimeUnit.SECONDS));
|
||||||
|
|
||||||
// The complete callback must not be executed
|
// The complete callback must be executed by this thread,
|
||||||
// until we return from this callback.
|
// after we return from this response callback.
|
||||||
latched = completeLatch.await(1, TimeUnit.SECONDS);
|
completeWasSync.set(!completeLatch.await(1, TimeUnit.SECONDS));
|
||||||
success.set(!latched);
|
|
||||||
|
|
||||||
callbackLatch.countDown();
|
callbackLatch.countDown();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue