use of io.grpc.StatusException in project google-cloud-java by GoogleCloudPlatform.
the class SubscriberTest method testFailedChannel_recoverableError_channelReopened.
@Test
public void testFailedChannel_recoverableError_channelReopened() throws Exception {
if (!isStreamingTest) {
// This test is not applicable to polling.
return;
}
final int expectedChannelCount = Runtime.getRuntime().availableProcessors() * Subscriber.CHANNELS_PER_CORE;
Subscriber subscriber = startSubscriber(getTestSubscriberBuilder(testReceiver).setExecutorProvider(InstantiatingExecutorProvider.newBuilder().setExecutorThreadCount(1).build()));
// Recoverable error
fakeSubscriberServiceImpl.sendError(new StatusException(Status.INTERNAL));
assertEquals(1, fakeSubscriberServiceImpl.waitForClosedStreams(1));
assertEquals(expectedChannelCount, fakeSubscriberServiceImpl.waitForOpenedStreams(expectedChannelCount));
subscriber.stopAsync().awaitTerminated();
}
use of io.grpc.StatusException in project core-java by SpineEventEngine.
the class ErrorsShould method return_absent_if_passed_Throwable_is_not_status_exception.
@Test
public void return_absent_if_passed_Throwable_is_not_status_exception() {
final String msg = "Neither a StatusException nor a StatusRuntimeException.";
final Exception exception = new Exception(msg);
assertFalse(Errors.fromStreamError(exception).isPresent());
}
use of io.grpc.StatusException in project core-java by SpineEventEngine.
the class ErrorsShould method return_Error_extracted_form_StatusException_metadata.
@Test
public void return_Error_extracted_form_StatusException_metadata() {
final Error expectedError = Error.getDefaultInstance();
final Metadata metadata = MetadataConverter.toMetadata(expectedError);
final StatusException statusException = INVALID_ARGUMENT.asException(metadata);
assertEquals(expectedError, Errors.fromStreamError(statusException).get());
}
Aggregations