spring GRPC Java登录测试
因此,我正在使用grpc testin库进行一些集成测试。当我使用此代码时:
@Rule
public final GrpcCleanupRule grpcCleanup = new GrpcCleanupRule();
@Test
public void doTest() throws IOException {
String serverName = InProcessServerBuilder.generateName();
grpcCleanup.register(InProcessServerBuilder
.forName(serverName).directExecutor().addService(service).build().start());
SomeServerGrpc.SomeServerBlockingStub blockingStub = SomeServerGrpc.newBlockingStub(
grpcCleanup.register(InProcessChannelBuilder.forName(serverName).directExecutor().build()));
...
每当代码中出现异常时,我都会
io.grpc.StatusRuntimeException: UNKNOWN
at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:233)
at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:214)
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:139)
如何使grpc返回异常的真实原因而不仅仅是UNKNOWN
# 1 楼答案
好吧,我终于找到了一个方法:
及