@Test public void receipt() throws Exception { final String subscriptionId = "subscriptionId"; final String pushResourceId = "pushResourceId"; final String receiptsToken = "receiptsToken"; final String receiptToken = "receiptToken"; final ChannelHandlerContext ctx = mockChannelHandlerContext(subscriptionId); final Http2ConnectionEncoder encoder = mockEncoder(w -> w.thenReturn(recieptsPath(receiptToken)), Resource.RECEIPT); final WebPushFrameListener frameListener = new WebPushFrameListener(MockWebPushServerBuilder .withSubscription(new DefaultSubscription(subscriptionId, pushResourceId)) .subscriptionMaxAge(10000L) .receiptsToken(receiptsToken) .receiptToken(receiptToken) .pushResourceToken(pushResourceId) .build(), encoder); try { final Http2Headers subscribeHeaders = UserAgent.subscribe(frameListener, ctx, encoder); final CharSequence receiptsUri = getLinkUri(WebLink.RECEIPTS, subscribeHeaders.getAll(LINK_HEADER)); final Http2Headers headers = AppServer.receiptsSubcsribe(receiptsUri, frameListener, ctx, encoder); assertThat(headers.status(), equalTo(CREATED.codeAsText())); assertThat(headers.get(LOCATION), equalTo(asciiString(recieptsPath(receiptToken)))); } 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);  }