Search in sources :

Example 11 with StatusException

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();
}
Also used : StatusException(io.grpc.StatusException) Test(org.junit.Test)

Example 12 with StatusException

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());
}
Also used : StatusRuntimeException(io.grpc.StatusRuntimeException) StatusException(io.grpc.StatusException) Test(org.junit.Test)

Example 13 with StatusException

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());
}
Also used : StatusException(io.grpc.StatusException) Metadata(io.grpc.Metadata) Test(org.junit.Test)

Aggregations

StatusException (io.grpc.StatusException)13 Test (org.junit.Test)9 Metadata (io.grpc.Metadata)3 HealthCheckResponse (io.grpc.health.v1.HealthCheckResponse)3 IOException (java.io.IOException)3 HealthCheckRequest (io.grpc.health.v1.HealthCheckRequest)2 ByteString (com.google.protobuf.ByteString)1 Status (io.grpc.Status)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1 ServingStatus (io.grpc.health.v1.HealthCheckResponse.ServingStatus)1 KeepAliveManager (io.grpc.internal.KeepAliveManager)1 FrameWriter (io.grpc.okhttp.internal.framed.FrameWriter)1 Http2 (io.grpc.okhttp.internal.framed.Http2)1 Settings (io.grpc.okhttp.internal.framed.Settings)1 Variant (io.grpc.okhttp.internal.framed.Variant)1 ChannelFuture (io.netty.channel.ChannelFuture)1 ChannelFutureListener (io.netty.channel.ChannelFutureListener)1 ChannelPromise (io.netty.channel.ChannelPromise)1 Http2Exception (io.netty.handler.codec.http2.Http2Exception)1 Http2Headers (io.netty.handler.codec.http2.Http2Headers)1