@Test public void deleteSubscription() throws Exception { final String subscriptionId = "subscriptionId"; final String pushResourceId = "pushResourceId"; final ChannelHandlerContext ctx = mockChannelHandlerContext(subscriptionId); final Http2ConnectionEncoder encoder = mockEncoder(w -> w.thenReturn(pushPath(pushResourceId)) .thenReturn(pushPath(pushResourceId)), Resource.PUSH); final WebPushFrameListener frameListener = new WebPushFrameListener(MockWebPushServerBuilder .withSubscription(new DefaultSubscription(subscriptionId, pushResourceId)) .nonexistentPushResourceToken(pushResourceId) .build(), encoder); try { final Http2Headers subscribeHeaders = UserAgent.subscribe(frameListener, ctx, encoder); UserAgent.receivePushMessages(frameListener, ctx, subscribeHeaders); final Http2Headers deleteSubscriptionHeaders = UserAgent.deleteSubscription(frameListener, ctx, subscribeHeaders, encoder); assertThat(deleteSubscriptionHeaders.status(), equalTo(NO_CONTENT.codeAsText())); final Http2Headers goneHeaders = captureStreamHeaders(encoder); assertThat(goneHeaders.status(), equalTo(GONE.codeAsText())); final ByteBuf payload = copiedBuffer("payload", UTF_8); final Http2Headers headers = AppServer.sendPush(frameListener, ctx, encoder, subscribeHeaders, payload); assertThat(headers.status(), equalTo(NOT_FOUND.codeAsText())); } finally { frameListener.shutdown(); } }
void shutdown() { monitoredStreams.values().stream().forEach(client -> client.ctx.close()); monitoredStreams.clear(); acksStreams.values().stream().forEach(client -> client.ctx.close()); acksStreams.clear(); }
WebPushFrameListener extends Http2FrameAdapter { void shutdown() { monitoredStreams.values().stream().forEach(client -> client.ctx.close()); monitoredStreams.clear(); acksStreams.values().stream().forEach(client -> client.ctx.close()); acksStreams.clear(); } }
WebPushFrameListener extends Http2FrameAdapter { void shutdown() { monitoredStreams.values().stream().forEach(client -> client.ctx.close()); monitoredStreams.clear(); acksStreams.values().stream().forEach(client -> client.ctx.close()); acksStreams.clear(); } WebPushFrameListener(final WebPushServer webpushServer, final Http2ConnectionEncoder encoder); }
WebPushFrameListener extends Http2FrameAdapter { void shutdown() { monitoredStreams.values().stream().forEach(client -> client.ctx.close()); monitoredStreams.clear(); acksStreams.values().stream().forEach(client -> client.ctx.close()); acksStreams.clear(); } WebPushFrameListener(final WebPushServer webpushServer, final Http2ConnectionEncoder encoder); @Override void onHeadersRead(final ChannelHandlerContext ctx,
                              final int streamId,
                              final Http2Headers headers,
                              final int streamDependency,
                              final short weight,
                              final boolean exclusive,
                              final int padding,
                              final boolean endStream); @Override int onDataRead(final ChannelHandlerContext ctx,
                          final int streamId,
                          final ByteBuf data,
                          final int padding,
                          final boolean endOfStream); }
WebPushFrameListener extends Http2FrameAdapter { void shutdown() { monitoredStreams.values().stream().forEach(client -> client.ctx.close()); monitoredStreams.clear(); acksStreams.values().stream().forEach(client -> client.ctx.close()); acksStreams.clear(); } WebPushFrameListener(final WebPushServer webpushServer, final Http2ConnectionEncoder encoder); @Override void onHeadersRead(final ChannelHandlerContext ctx,
                              final int streamId,
                              final Http2Headers headers,
                              final int streamDependency,
                              final short weight,
                              final boolean exclusive,
                              final int padding,
                              final boolean endStream); @Override int onDataRead(final ChannelHandlerContext ctx,
                          final int streamId,
                          final ByteBuf data,
                          final int padding,
                          final boolean endOfStream);  }