use of io.grpc.Metadata in project grpc-java by grpc.
the class AbstractClientStreamTest method rstStreamClosesStream.
@Test
public void rstStreamClosesStream() {
AbstractClientStream stream = new BaseAbstractClientStream(allocator);
stream.start(mockListener);
// The application will call request when waiting for a message, which will in turn call this
// on the transport thread.
stream.requestMessagesFromDeframer(1);
// Send first byte of 2 byte message
stream.deframe(ReadableBuffers.wrap(new byte[] { 0, 0, 0, 0, 2, 1 }), false);
Status status = Status.INTERNAL;
// Simulate getting a reset
stream.transportReportStatus(status, false, /*stop delivery*/
new Metadata());
assertTrue(stream.isClosed());
}
use of io.grpc.Metadata in project grpc-java by grpc.
the class AbstractClientStreamTest method inboundHeadersReceived_acceptsIdentityEncoding.
@Test
public void inboundHeadersReceived_acceptsIdentityEncoding() {
AbstractClientStream stream = new BaseAbstractClientStream(allocator);
stream.start(mockListener);
Metadata headers = new Metadata();
headers.put(GrpcUtil.MESSAGE_ENCODING_KEY, Codec.Identity.NONE.getMessageEncoding());
stream.inboundHeadersReceived(headers);
verify(mockListener).headersRead(headers);
}
use of io.grpc.Metadata in project grpc-java by grpc.
the class AbstractClientStreamTest method inboundHeadersReceived_notifiesListener.
@Test
public void inboundHeadersReceived_notifiesListener() {
AbstractClientStream stream = new BaseAbstractClientStream(allocator);
stream.start(mockListener);
Metadata headers = new Metadata();
stream.inboundHeadersReceived(headers);
verify(mockListener).headersRead(headers);
}
use of io.grpc.Metadata in project grpc-java by grpc.
the class AbstractClientStreamTest method inboundHeadersReceived_failsOnPhaseStatus.
@Test
public void inboundHeadersReceived_failsOnPhaseStatus() {
AbstractClientStream stream = new BaseAbstractClientStream(allocator);
stream.start(mockListener);
Metadata headers = new Metadata();
stream.inboundPhase(Phase.STATUS);
thrown.expect(IllegalStateException.class);
stream.inboundHeadersReceived(headers);
}
use of io.grpc.Metadata in project grpc-java by grpc.
the class AbstractClientStreamTest method cancel_notifiesOnlyOnce.
@Test
public void cancel_notifiesOnlyOnce() {
AbstractClientStream stream = new BaseAbstractClientStream(allocator) {
@Override
protected void sendCancel(Status errorStatus) {
transportReportStatus(errorStatus, true, /*stop delivery*/
new Metadata());
}
};
stream.start(mockListener);
stream.cancel(Status.DEADLINE_EXCEEDED);
verify(mockListener).closed(isA(Status.class), isA(Metadata.class));
}
Aggregations