NettyServerStream extends AbstractServerStream<Integer> { void inboundDataReceived(ByteBuf frame, boolean endOfStream) { super.inboundDataReceived(new NettyReadableBuffer(frame.retain()), endOfStream); } NettyServerStream(Channel channel, Http2Stream http2Stream, NettyServerHandler handler,
                    int maxMessageSize); @Override Integer id(); @Override void request(final int numMessages); @Override void cancel(Status status); @Override Attributes attributes();  }
@Test public void closeAfterClientHalfCloseShouldSucceed() throws Exception { stream().inboundDataReceived(new EmptyByteBuf(UnpooledByteBufAllocator.DEFAULT), true); assertTrue(stream().canSend()); verify(serverListener).halfClosed(); stream().close(Status.OK, trailers); assertTrue(stream().isClosed()); verifyNoMoreInteractions(serverListener); verify(writeQueue).enqueue( new SendResponseHeadersCommand(STREAM_ID, new DefaultHttp2Headers() .status(new AsciiString("200")) .set(new AsciiString("content-type"), new AsciiString("application/grpc")) .set(new AsciiString("grpc-status"), new AsciiString("0")), true), true); stream().complete(); verify(serverListener).closed(Status.OK); verifyNoMoreInteractions(serverListener); }
@Test public void abortStreamAfterClientHalfCloseShouldCallClose() { Status status = Status.INTERNAL.withCause(new Throwable()); stream().inboundDataReceived(new EmptyByteBuf(UnpooledByteBufAllocator.DEFAULT), true); assertTrue(stream().canSend()); verify(serverListener).halfClosed(); stream().abortStream(status, true); verify(serverListener).closed(same(status)); verifyNoMoreInteractions(serverListener); assertTrue(stream().isClosed()); }