use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException in project grpc-java by grpc.
the class ProtoUtilsTest method testJsonIoException.
@Test
public void testJsonIoException() throws Exception {
Marshaller<Type> marshaller = ProtoUtils.jsonMarshaller(Type.getDefaultInstance());
final IOException ioe = new IOException();
try {
marshaller.parse(new ByteArrayInputStream("{}".getBytes("UTF-8")) {
@Override
public void close() throws IOException {
throw ioe;
}
});
fail("Exception expected");
} catch (StatusRuntimeException ex) {
assertEquals(Status.Code.INTERNAL, ex.getStatus().getCode());
assertEquals(ioe, ex.getCause());
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException in project grpc-java by grpc.
the class ThriftUtilsTest method parseInvalid.
@Test
public void parseInvalid() throws Exception {
InputStream is = new ByteArrayInputStream(new byte[] { -127 });
try {
marshaller.parse(is);
fail("Expected exception");
} catch (StatusRuntimeException ex) {
assertEquals(Status.Code.INTERNAL, ex.getStatus().getCode());
assertTrue(ex.getCause() instanceof TException);
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException in project core-java by SpineEventEngine.
the class RequestValidator method feedToResponse.
private static void feedToResponse(InvalidRequestException cause, StreamObserver<?> responseObserver) {
final StatusRuntimeException validationException = invalidArgumentWithCause(cause);
responseObserver.onError(validationException);
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method getIamPolicyExceptionTest.
@Test
@SuppressWarnings("all")
public void getIamPolicyExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockIAMPolicy.addException(exception);
try {
String formattedResource = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]").toString();
client.getIamPolicy(formattedResource);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method pullExceptionTest.
@Test
@SuppressWarnings("all")
public void pullExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockSubscriber.addException(exception);
try {
SubscriptionName subscription = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
boolean returnImmediately = false;
int maxMessages = 496131527;
client.pull(subscription, returnImmediately, maxMessages);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
Aggregations