Skip to content

Commit

Permalink
Improve Http2ServerTest#testConnectionDecodeError
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Sep 25, 2017
1 parent 12221be commit a07c777
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/test/java/io/vertx/test/core/Http2ServerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1603,30 +1603,37 @@ public void onPushPromiseRead(ChannelHandlerContext ctx, int streamId, int promi
@Test
public void testConnectionDecodeError() throws Exception {
Context ctx = vertx.getOrCreateContext();
waitFor(6);
waitFor(3);
Future<Void> when = Future.future();
server.requestHandler(req -> {
AtomicInteger reqFailures = new AtomicInteger();
AtomicInteger respFailures = new AtomicInteger();
req.exceptionHandler(err -> {
// Called twice : reset + close
assertSame(ctx, Vertx.currentContext());
complete();
reqFailures.incrementAndGet();
});
req.response().exceptionHandler(err -> {
// Called once : reset
assertSame(ctx, Vertx.currentContext());
complete();
respFailures.incrementAndGet();
});
req.response().closeHandler(v -> {
// Called once : close
assertSame(ctx, Vertx.currentContext());
complete();
});
req.response().endHandler(v -> {
// Called once : close
assertTrue(reqFailures.get() > 0);
assertTrue(respFailures.get() > 0);
assertSame(ctx, Vertx.currentContext());
complete();
});
req.connection().exceptionHandler(err -> {
HttpConnection conn = req.connection();
AtomicInteger connFailures = new AtomicInteger();
conn.exceptionHandler(err -> {
assertSame(ctx, Vertx.currentContext());
connFailures.incrementAndGet();
});
conn.closeHandler(v -> {
assertTrue(connFailures.get() > 0);
assertSame(ctx, Vertx.currentContext());
complete();
});
Expand All @@ -1638,6 +1645,7 @@ public void testConnectionDecodeError() throws Exception {
int id = request.nextStreamId();
Http2ConnectionEncoder encoder = request.encoder;
when.setHandler(ar -> {
// Send a stream ID that does not exists
encoder.frameWriter().writeRstStream(request.context, 10, 0, request.context.newPromise());
request.context.flush();
});
Expand Down

0 comments on commit a07c777

Please sign in to comment.