@Test public void invalidInboundHeadersCancelStream() throws Exception { stream().transportState().setId(STREAM_ID); Http2Headers headers = grpcResponseHeaders(); headers.set("random", "4"); headers.remove(CONTENT_TYPE_HEADER); headers.status(new AsciiString("500")); stream().transportState().transportHeadersReceived(headers, false); verify(listener, never()).closed(any(Status.class), any(Metadata.class)); verify(channel, never()).writeAndFlush(any(CancelClientStreamCommand.class)); stream().transportState().transportDataReceived(Unpooled.buffer(100).writeZero(100), false); verify(channel, never()).writeAndFlush(any(CancelClientStreamCommand.class)); stream().transportState().transportDataReceived(Unpooled.buffer(1000).writeZero(1000), false); verify(writeQueue).enqueue(isA(CancelClientStreamCommand.class), eq(true)); ArgumentCaptor<Status> captor = ArgumentCaptor.forClass(Status.class); ArgumentCaptor<Metadata> metadataCaptor = ArgumentCaptor.forClass(Metadata.class); verify(listener).closed(captor.capture(), same(PROCESSED), metadataCaptor.capture()); assertEquals(Status.UNKNOWN.getCode(), captor.getValue().getCode()); assertEquals("4", metadataCaptor.getValue() .get(Metadata.Key.of("random", Metadata.ASCII_STRING_MARSHALLER))); }
@Override protected TransportState transportState() { return state; }
NettyClientStream extends AbstractClientStream { @Override protected TransportState transportState() { return state; } }
NettyClientStream extends AbstractClientStream { @Override protected TransportState transportState() { return state; } NettyClientStream(
      TransportState state,
      MethodDescriptor<?, ?> method,
      Metadata headers,
      Channel channel,
      AsciiString authority,
      AsciiString scheme,
      AsciiString userAgent,
      StatsTraceContext statsTraceCtx,
      TransportTracer transportTracer,
      CallOptions callOptions); }
NettyClientStream extends AbstractClientStream { @Override protected TransportState transportState() { return state; } NettyClientStream(
      TransportState state,
      MethodDescriptor<?, ?> method,
      Metadata headers,
      Channel channel,
      AsciiString authority,
      AsciiString scheme,
      AsciiString userAgent,
      StatsTraceContext statsTraceCtx,
      TransportTracer transportTracer,
      CallOptions callOptions); @Override void setAuthority(String authority); @Override Attributes getAttributes(); }
NettyClientStream extends AbstractClientStream { @Override protected TransportState transportState() { return state; } NettyClientStream(
      TransportState state,
      MethodDescriptor<?, ?> method,
      Metadata headers,
      Channel channel,
      AsciiString authority,
      AsciiString scheme,
      AsciiString userAgent,
      StatsTraceContext statsTraceCtx,
      TransportTracer transportTracer,
      CallOptions callOptions); @Override void setAuthority(String authority); @Override Attributes getAttributes();  }