use of org.chromium.net.CronetException in project grpc-java by grpc.
the class CronetClientStreamTest method streamFailedAfterResponseHeaderReceived.
@Test
public void streamFailedAfterResponseHeaderReceived() {
ArgumentCaptor<BidirectionalStream.Callback> callbackCaptor = ArgumentCaptor.forClass(BidirectionalStream.Callback.class);
verify(factory).newBidirectionalStreamBuilder(isA(String.class), callbackCaptor.capture(), isA(Executor.class));
BidirectionalStream.Callback callback = callbackCaptor.getValue();
// Receive response header
UrlResponseInfo info = new UrlResponseInfoImpl(new ArrayList<>(), 200, "", responseHeader("200"), false, "", "", 0);
callback.onResponseHeadersReceived(cronetStream, info);
CronetException exception = mock(CronetException.class);
callback.onFailed(cronetStream, info, exception);
verify(transport).finishStream(eq(clientStream), isA(Status.class));
// finishStream calls transportReportStatus.
clientStream.transportState().transportReportStatus(Status.UNAVAILABLE, false, new Metadata());
ArgumentCaptor<Status> statusCaptor = ArgumentCaptor.forClass(Status.class);
verify(clientListener).closed(statusCaptor.capture(), isA(RpcProgress.class), isA(Metadata.class));
Status status = statusCaptor.getValue();
assertEquals(Status.UNAVAILABLE.getCode(), status.getCode());
}
use of org.chromium.net.CronetException in project grpc-java by grpc.
the class CronetClientStreamTest method streamFailedAfterTrailerAndEndOfStreamReceived.
@Test
public void streamFailedAfterTrailerAndEndOfStreamReceived() {
ArgumentCaptor<BidirectionalStream.Callback> callbackCaptor = ArgumentCaptor.forClass(BidirectionalStream.Callback.class);
verify(factory).newBidirectionalStreamBuilder(isA(String.class), callbackCaptor.capture(), isA(Executor.class));
BidirectionalStream.Callback callback = callbackCaptor.getValue();
// Receive response header
UrlResponseInfo info = new UrlResponseInfoImpl(new ArrayList<>(), 200, "", responseHeader("200"), false, "", "", 0);
callback.onResponseHeadersReceived(cronetStream, info);
// Report trailer and endOfStream
callback.onReadCompleted(cronetStream, null, ByteBuffer.allocate(0), true);
((CronetClientStream.BidirectionalStreamCallback) callback).processTrailers(trailers(0));
CronetException exception = mock(CronetException.class);
callback.onFailed(cronetStream, info, exception);
verify(transport).finishStream(eq(clientStream), isA(Status.class));
// finishStream calls transportReportStatus.
clientStream.transportState().transportReportStatus(Status.UNAVAILABLE, false, new Metadata());
ArgumentCaptor<Status> statusCaptor = ArgumentCaptor.forClass(Status.class);
verify(clientListener).closed(statusCaptor.capture(), isA(RpcProgress.class), isA(Metadata.class));
Status status = statusCaptor.getValue();
// Stream has already finished so OK status should be reported.
assertEquals(Status.OK.getCode(), status.getCode());
}
use of org.chromium.net.CronetException in project grpc-java by grpc.
the class CronetClientStreamTest method streamFailedAfterTrailerReceived.
@Test
public void streamFailedAfterTrailerReceived() {
ArgumentCaptor<BidirectionalStream.Callback> callbackCaptor = ArgumentCaptor.forClass(BidirectionalStream.Callback.class);
verify(factory).newBidirectionalStreamBuilder(isA(String.class), callbackCaptor.capture(), isA(Executor.class));
BidirectionalStream.Callback callback = callbackCaptor.getValue();
// Receive response header
UrlResponseInfo info = new UrlResponseInfoImpl(new ArrayList<>(), 200, "", responseHeader("200"), false, "", "", 0);
callback.onResponseHeadersReceived(cronetStream, info);
// Report trailer but not endOfStream.
((CronetClientStream.BidirectionalStreamCallback) callback).processTrailers(trailers(0));
CronetException exception = mock(CronetException.class);
callback.onFailed(cronetStream, info, exception);
verify(transport).finishStream(eq(clientStream), isA(Status.class));
// finishStream calls transportReportStatus.
clientStream.transportState().transportReportStatus(Status.UNAVAILABLE, false, new Metadata());
ArgumentCaptor<Status> statusCaptor = ArgumentCaptor.forClass(Status.class);
verify(clientListener).closed(statusCaptor.capture(), isA(RpcProgress.class), isA(Metadata.class));
Status status = statusCaptor.getValue();
// Stream has already finished so OK status should be reported.
assertEquals(Status.UNAVAILABLE.getCode(), status.getCode());
}
use of org.chromium.net.CronetException in project grpc-java by grpc.
the class CronetClientStreamTest method streamFailed.
@Test
public void streamFailed() {
ArgumentCaptor<BidirectionalStream.Callback> callbackCaptor = ArgumentCaptor.forClass(BidirectionalStream.Callback.class);
verify(factory).newBidirectionalStreamBuilder(isA(String.class), callbackCaptor.capture(), isA(Executor.class));
BidirectionalStream.Callback callback = callbackCaptor.getValue();
// Nothing happens and stream fails
CronetException exception = mock(CronetException.class);
callback.onFailed(cronetStream, null, exception);
verify(transport).finishStream(eq(clientStream), isA(Status.class));
// finishStream calls transportReportStatus.
clientStream.transportState().transportReportStatus(Status.UNAVAILABLE, false, new Metadata());
ArgumentCaptor<Status> statusCaptor = ArgumentCaptor.forClass(Status.class);
verify(clientListener).closed(statusCaptor.capture(), isA(RpcProgress.class), isA(Metadata.class));
Status status = statusCaptor.getValue();
assertEquals(Status.UNAVAILABLE.getCode(), status.getCode());
}
Aggregations