aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Becker2012-08-03 13:56:00 (EDT)
committerThomas Becker2012-08-03 13:56:00 (EDT)
commitd4d41fb87748d17308937a08b464bc8be9423b47 (patch)
tree758c1c4d5a2e4b118185794dc1ef85512b88037d
parent3187fe00fe4bd5387fd9b7a276cb0906d50a02d4 (diff)
downloadorg.eclipse.jetty.project-d4d41fb87748d17308937a08b464bc8be9423b47.zip
org.eclipse.jetty.project-d4d41fb87748d17308937a08b464bc8be9423b47.tar.gz
org.eclipse.jetty.project-d4d41fb87748d17308937a08b464bc8be9423b47.tar.bz2
jetty9 - fix WriteFlusherTest.testConcurrentAccessToIncompleteWriteAndOnFail()
-rw-r--r--jetty-io/src/test/java/org/eclipse/jetty/io/WriteFlusherTest.java24
1 files changed, 17 insertions, 7 deletions
diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/WriteFlusherTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/WriteFlusherTest.java
index b24022b..da46c07 100644
--- a/jetty-io/src/test/java/org/eclipse/jetty/io/WriteFlusherTest.java
+++ b/jetty-io/src/test/java/org/eclipse/jetty/io/WriteFlusherTest.java
@@ -330,7 +330,7 @@ public class WriteFlusherTest
}
@Test
- public void testConcurrentAccessToWriteAndFailed() throws IOException, InterruptedException, ExecutionException
+ public void testConcurrentAccessToWriteAndOnFail() throws IOException, InterruptedException, ExecutionException
{
final CountDownLatch failedCalledLatch = new CountDownLatch(1);
final CountDownLatch writeCalledLatch = new CountDownLatch(1);
@@ -458,7 +458,8 @@ public class WriteFlusherTest
}
@Test
- public void testConcurrentAccessToIncompleteWriteAndFailed() throws IOException, InterruptedException, ExecutionException, TimeoutException
+ public void testConcurrentAccessToIncompleteWriteAndOnFail() throws IOException, InterruptedException,
+ ExecutionException, TimeoutException
{
final CountDownLatch failedCalledLatch = new CountDownLatch(1);
final CountDownLatch onIncompleteFlushedCalledLatch = new CountDownLatch(1);
@@ -470,6 +471,14 @@ public class WriteFlusherTest
protected void onIncompleteFlushed()
{
onIncompleteFlushedCalledLatch.countDown();
+ try
+ {
+ failedCalledLatch.await(5, TimeUnit.SECONDS);
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
completeWrite();
completeWrite.countDown();
}
@@ -478,13 +487,15 @@ public class WriteFlusherTest
ExposingStateCallback callback = new ExposingStateCallback();
executor.submit(new Writer(writeFlusher, callback));
assertThat("Write has been called.", writeCalledLatch.await(5, TimeUnit.SECONDS), is(true));
+ // make sure we're in pending state when calling onFail
+ assertThat("onIncompleteFlushed has been called.", onIncompleteFlushedCalledLatch.await(5,
+ TimeUnit.SECONDS), is(true));
executor.submit(new FailedCaller(writeFlusher, failedCalledLatch));
assertThat("Failed has been called.", failedCalledLatch.await(5, TimeUnit.SECONDS), is(true));
- writeFlusher.write(_context, new FutureCallback<String>(), BufferUtil.toBuffer("foobar"));
assertThat("completeWrite done", completeWrite.await(5, TimeUnit.SECONDS), is(true));
- callback.get(5, TimeUnit.SECONDS);
- assertThat("callback failed has not been called", callback.isFailed(), is(false));
- assertThat("callback complete has been called", callback.isCompleted(), is(true));
+ // when we fail in PENDING state, we should have called callback.failed()
+ assertThat("callback failed has been called", callback.isFailed(), is(true));
+ assertThat("callback complete has not been called", callback.isCompleted(), is(false));
}
private static class EndPointMock extends ByteArrayEndPoint
@@ -530,7 +541,6 @@ public class WriteFlusherTest
}
}
-
private static class FailedCaller implements Callable
{
private final WriteFlusher writeFlusher;