/** Sends an rpc to an unimplemented method on the server. */
 public void unimplementedMethod() {
   UnimplementedServiceGrpc.UnimplementedServiceBlockingStub stub =
       UnimplementedServiceGrpc.newBlockingStub(channel);
   try {
     stub.unimplementedCall(new EmptyProtos.Empty());
     fail();
   } catch (StatusRuntimeException e) {
     assertCodeEquals(io.grpc.Status.UNIMPLEMENTED, e.getStatus());
   }
 }
 @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);
   }
 }
  @Test
  @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
  public void create_invalid_argument_status_exception() {
    final IllegalArgumentException exception = new IllegalArgumentException("");

    final StatusRuntimeException statusRuntimeException =
        Statuses.invalidArgumentWithCause(exception);

    assertEquals(exception, statusRuntimeException.getCause());
    assertEquals(Status.INVALID_ARGUMENT.getCode(), statusRuntimeException.getStatus().getCode());
  }
 public void deadlineExceeded() {
   // warm up the channel and JVM
   blockingStub.emptyCall(new EmptyProtos.Empty());
   TestServiceGrpc.TestServiceBlockingStub stub =
       TestServiceGrpc.newBlockingStub(channel).withDeadlineAfter(10, TimeUnit.MILLISECONDS);
   StreamingOutputCallRequest request = new StreamingOutputCallRequest();
   request.responseParameters = new ResponseParameters[1];
   request.responseParameters[0] = new ResponseParameters();
   request.responseParameters[0].intervalUs = 20000;
   try {
     stub.streamingOutputCall(request).next();
     fail("Expected deadline to be exceeded");
   } catch (StatusRuntimeException ex) {
     assertCodeEquals(io.grpc.Status.DEADLINE_EXCEEDED, ex.getStatus());
   }
 }