Skip to content

Commit

Permalink
Issue #4331 Async Write Complete
Browse files Browse the repository at this point in the history
test both PENDING and UNREADY

Signed-off-by: Greg Wilkins <[email protected]>
  • Loading branch information
gregw committed Dec 2, 2019
1 parent 4592441 commit be28e87
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,10 @@ public static Stream<Arguments> tests()
tests.add(new Object[]{new HelloWorldHandler(), 200, "Hello world"});
tests.add(new Object[]{new SendErrorHandler(499, "Test async sendError"), 499, "Test async sendError"});
tests.add(new Object[]{new AsyncReadyCompleteHandler(), 200, AsyncReadyCompleteHandler.data});
tests.add(new Object[]{new AsyncWriteCompleteHandler(false), 200, AsyncWriteCompleteHandler.data});
tests.add(new Object[]{new AsyncWriteCompleteHandler(true), 200, AsyncWriteCompleteHandler.data});
tests.add(new Object[]{new AsyncWriteCompleteHandler(false, false), 200, AsyncWriteCompleteHandler.data});
tests.add(new Object[]{new AsyncWriteCompleteHandler(false, true), 200, AsyncWriteCompleteHandler.data});
tests.add(new Object[]{new AsyncWriteCompleteHandler(true, false), 200, AsyncWriteCompleteHandler.data});
tests.add(new Object[]{new AsyncWriteCompleteHandler(true, true), 200, AsyncWriteCompleteHandler.data});
return tests.stream().map(Arguments::of);
}

Expand Down Expand Up @@ -275,9 +277,11 @@ private static class AsyncWriteCompleteHandler extends AbstractHandler
static String data = "Now is the time for all good men to come to the aid of the party";

final boolean close;
final boolean unReady;

AsyncWriteCompleteHandler(boolean close)
AsyncWriteCompleteHandler(boolean unReady, boolean close)
{
this.unReady = unReady;
this.close = close;
}

Expand All @@ -296,6 +300,8 @@ public void onWritePossible() throws IOException
response.setContentType("text/plain");
response.setContentLength(bytes.length);
out.write(bytes);
if (unReady)
assertThat(out.isReady(),Matchers.is(false));
if (close)
out.close();
context.complete();
Expand Down

0 comments on commit be28e87

Please sign in to comment.