use of org.apache.beam.vendor.grpc.v1p43p2.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 org.apache.beam.vendor.grpc.v1p43p2.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 org.apache.beam.vendor.grpc.v1p43p2.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());
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException in project core-java by SpineEventEngine.
the class StreamObserversShould 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(StreamObservers.fromStreamError(exception).isPresent());
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusException in project curiostack by curioswitch.
the class ListenableFutureAssert method getFailureGrpcStatus.
private Status getFailureGrpcStatus() {
Throwable t = catchThrowable(() -> getUnchecked(actual));
Throwable cause = t.getCause();
if (cause instanceof StatusRuntimeException) {
return ((StatusRuntimeException) cause).getStatus();
} else if (cause instanceof StatusException) {
return ((StatusException) cause).getStatus();
} else {
// Could throw AssertionError, but use assertj for consistent error messages. The following
// is guaranteed to throw.
assertThat(cause).isInstanceOfAny(StatusException.class, StatusRuntimeException.class);
throw new IllegalStateException("Can't reach here.");
}
}
Aggregations