use of io.grpc.Metadata in project grpc-java by grpc.
the class AbstractClientStreamTest method deframeFailed_notifiesListener.
@Test
public void deframeFailed_notifiesListener() {
AbstractClientStream stream = new BaseAbstractClientStream(allocator) {
@Override
protected void sendCancel(Status errorStatus) {
transportReportStatus(errorStatus, true, /*stop delivery*/
new Metadata());
}
};
stream.start(mockListener);
stream.deframeFailed(new RuntimeException("something bad"));
verify(mockListener).closed(statusCaptor.capture(), isA(Metadata.class));
assertEquals(Code.INTERNAL, statusCaptor.getValue().getCode());
}
use of io.grpc.Metadata in project grpc-java by grpc.
the class AbstractClientStreamTest method inboundHeadersReceived_acceptsGzipEncoding.
@Test
public void inboundHeadersReceived_acceptsGzipEncoding() {
AbstractClientStream stream = new BaseAbstractClientStream(allocator);
stream.start(mockListener);
Metadata headers = new Metadata();
headers.put(GrpcUtil.MESSAGE_ENCODING_KEY, new Codec.Gzip().getMessageEncoding());
stream.inboundHeadersReceived(headers);
verify(mockListener).headersRead(headers);
}
use of io.grpc.Metadata in project grpc-java by grpc.
the class AbstractServerStreamTest method close_failsOnNullStatus.
@Test
public void close_failsOnNullStatus() {
thrown.expect(NullPointerException.class);
stream.close(null, new Metadata());
}
use of io.grpc.Metadata in project grpc-java by grpc.
the class AbstractServerStreamTest method close_sendsTrailers.
@Test
public void close_sendsTrailers() {
Metadata trailers = new Metadata();
stream.close(Status.INTERNAL, trailers);
verify(sink).writeTrailers(any(Metadata.class), eq(false));
}
use of io.grpc.Metadata in project grpc-java by grpc.
the class AbstractServerStreamTest method close_sendTrailersClearsReservedFields.
@Test
public void close_sendTrailersClearsReservedFields() {
// stream actually mutates trailers, so we can't check that the fields here are the same as
// the captured ones.
Metadata trailers = new Metadata();
trailers.put(Status.CODE_KEY, Status.OK);
trailers.put(Status.MESSAGE_KEY, "Everything's super.");
stream.close(Status.INTERNAL.withDescription("bad"), trailers);
verify(sink).writeTrailers(metadataCaptor.capture(), eq(false));
assertEquals(Status.Code.INTERNAL, metadataCaptor.getValue().get(Status.CODE_KEY).getCode());
assertEquals("bad", metadataCaptor.getValue().get(Status.MESSAGE_KEY));
}
Aggregations