use of io.servicetalk.grpc.netty.TesterProto.TestResponse in project servicetalk by apple.
the class ErrorHandlingTest method verifyStreamingResponse.
private void verifyStreamingResponse(final Publisher<TestResponse> resp) throws Exception {
TestPublisherSubscriber<TestResponse> subscriber = new TestPublisherSubscriber<>();
CountDownLatch terminationLatch = new CountDownLatch(1);
toSource(resp.afterFinally(terminationLatch::countDown)).subscribe(subscriber);
subscriber.awaitSubscription().request(Long.MAX_VALUE);
terminationLatch.await();
Throwable cause;
switch(testMode) {
case ServiceEmitsDataThenError:
case ServiceEmitsDataThenGrpcException:
case BlockingServiceWritesThenThrows:
case BlockingServiceWritesThenThrowsGrpcException:
case ServiceSecondOperatorThrowsGrpcException:
List<TestResponse> items = subscriber.takeOnNext(1);
assertThat("Unexpected response.", items, hasSize(1));
assertThat("Unexpected response.", items, contains(cannedResponse));
cause = subscriber.awaitOnError();
assertThat("Unexpected termination.", cause, is(notNullValue()));
verifyException(cause);
break;
case HttpClientFilterThrows:
case HttpClientFilterThrowsGrpcException:
case HttpClientFilterEmitsError:
case HttpClientFilterEmitsGrpcException:
case HttpFilterThrows:
case HttpFilterThrowsGrpcException:
case HttpFilterEmitsError:
case HttpFilterEmitsGrpcException:
case ServiceThrows:
case ServiceThrowsGrpcException:
case ServiceOperatorThrows:
case ServiceOperatorThrowsGrpcException:
case ServiceEmitsError:
case ServiceEmitsGrpcException:
case BlockingServiceThrows:
case BlockingServiceThrowsGrpcException:
cause = subscriber.awaitOnError();
assertThat("Unexpected termination.", cause, is(notNullValue()));
verifyException(cause);
break;
default:
throw new IllegalArgumentException("Unknown mode: " + testMode);
}
}
Aggregations