private static void verifyOneWayInvocation(Class<?> expectedServiceType, String expectedParam) { await().untilAsserted(() -> { final RequestLog log = requestLogs.poll(); assertThat(log).isNotNull(); final RpcRequest req = (RpcRequest) log.requestContent(); final RpcResponse res = (RpcResponse) log.responseContent(); assertThat(req).isNotNull(); assertThat(req.serviceType()).isSameAs(expectedServiceType); assertThat(req.method()).isEqualTo("hello"); assertThat(req.params()).containsExactly(expectedParam); assertThat((Object) res).isNotNull(); assertThat(res.get()).isNull(); }); }
private void checkRequestLogError(RequestLogErrorChecker checker) throws Exception { final RequestLog log = requestLogQueue.take(); assertThat(log.availabilities()).contains(RequestLogAvailability.COMPLETE); final RpcRequest rpcReq = (RpcRequest) log.requestContent(); if (rpcReq != null) { assertThat(rpcReq.serviceType()).isEqualTo(GrpcLogUtil.class); } checker.check(log.responseHeaders(), rpcReq, log.responseCause()); }
private void checkRequestLog(RequestLogChecker checker) throws Exception { final RequestLog log = requestLogQueue.take(); assertThat(log.availabilities()).contains(RequestLogAvailability.COMPLETE); final RpcRequest rpcReq = (RpcRequest) log.requestContent(); final RpcResponse rpcRes = (RpcResponse) log.responseContent(); assertThat(rpcReq).isNotNull(); assertThat((Object) rpcRes).isNotNull(); assertThat(rpcReq.serviceType()).isEqualTo(GrpcLogUtil.class); final Status grpcStatus; if (rpcRes.cause() != null) { grpcStatus = ((StatusException) rpcRes.cause()).getStatus(); } else { grpcStatus = null; } checker.check(rpcReq, rpcRes, grpcStatus); }
private static void checkRequestLog(RequestLogChecker checker) throws Exception { final RequestLog log = requestLogQueue.take(); assertThat(log.availabilities()).contains(RequestLogAvailability.COMPLETE); final RpcRequest rpcReq = (RpcRequest) log.requestContent(); final RpcResponse rpcRes = (RpcResponse) log.responseContent(); assertThat(rpcReq).isNotNull(); assertThat((Object) rpcRes).isNotNull(); assertThat(rpcReq.serviceType()).isEqualTo(GrpcLogUtil.class); final Status grpcStatus; if (rpcRes.cause() != null) { grpcStatus = ((StatusException) rpcRes.cause()).getStatus(); } else { grpcStatus = null; } checker.check(rpcReq, rpcRes, grpcStatus); }
@Test(timeout = 10000) public void testMessageLogsForOneWay() throws Exception { final OnewayHelloService.Iface client = Clients.newClient(clientFactory(), getURI(Handlers.HELLO), Handlers.ONEWAYHELLO.iface(), clientOptions); recordMessageLogs = true; client.hello("trustin"); final RequestLog log = requestLogs.take(); assertThat(log.requestHeaders()).isInstanceOf(HttpHeaders.class); assertThat(log.requestContent()).isInstanceOf(RpcRequest.class); assertThat(log.rawRequestContent()).isInstanceOf(ThriftCall.class); final RpcRequest request = (RpcRequest) log.requestContent(); assertThat(request.serviceType()).isEqualTo(OnewayHelloService.Iface.class); assertThat(request.method()).isEqualTo("hello"); assertThat(request.params()).containsExactly("trustin"); final ThriftCall rawRequest = (ThriftCall) log.rawRequestContent(); assertThat(rawRequest.header().type).isEqualTo(TMessageType.ONEWAY); assertThat(rawRequest.header().name).isEqualTo("hello"); assertThat(rawRequest.args()).isInstanceOf(OnewayHelloService.hello_args.class); assertThat(((OnewayHelloService.hello_args) rawRequest.args()).getName()).isEqualTo("trustin"); assertThat(log.responseHeaders()).isInstanceOf(HttpHeaders.class); assertThat(log.responseContent()).isInstanceOf(RpcResponse.class); assertThat(log.rawResponseContent()).isNull(); final RpcResponse response = (RpcResponse) log.responseContent(); assertThat(response.get()).isNull(); }
@Test(timeout = 10000) public void testMessageLogsForException() throws Exception { final HelloService.Iface client = Clients.newClient(clientFactory(), getURI(Handlers.EXCEPTION), Handlers.EXCEPTION.iface(), clientOptions); recordMessageLogs = true; assertThatThrownBy(() -> client.hello("trustin")).isInstanceOf(TApplicationException.class); final RequestLog log = requestLogs.take(); assertThat(log.requestHeaders()).isInstanceOf(HttpHeaders.class); assertThat(log.requestContent()).isInstanceOf(RpcRequest.class); assertThat(log.rawRequestContent()).isInstanceOf(ThriftCall.class); final RpcRequest request = (RpcRequest) log.requestContent(); assertThat(request.serviceType()).isEqualTo(HelloService.Iface.class); assertThat(request.method()).isEqualTo("hello"); assertThat(request.params()).containsExactly("trustin"); final ThriftCall rawRequest = (ThriftCall) log.rawRequestContent(); assertThat(rawRequest.header().type).isEqualTo(TMessageType.CALL); assertThat(rawRequest.header().name).isEqualTo("hello"); assertThat(rawRequest.args()).isInstanceOf(HelloService.hello_args.class); assertThat(((HelloService.hello_args) rawRequest.args()).getName()).isEqualTo("trustin"); assertThat(log.responseHeaders()).isInstanceOf(HttpHeaders.class); assertThat(log.responseContent()).isInstanceOf(RpcResponse.class); assertThat(log.rawResponseContent()).isInstanceOf(ThriftReply.class); final RpcResponse response = (RpcResponse) log.responseContent(); assertThat(response.cause()).isNotNull(); final ThriftReply rawResponse = (ThriftReply) log.rawResponseContent(); assertThat(rawResponse.header().type).isEqualTo(TMessageType.EXCEPTION); assertThat(rawResponse.header().name).isEqualTo("hello"); assertThat(rawResponse.exception()).isNotNull(); }
assertThat(request.serviceType()).isEqualTo(HelloService.Iface.class); assertThat(request.method()).isEqualTo("hello"); assertThat(request.params()).containsExactly("trustin");
assertThat(request.serviceType()).isEqualTo(HelloService.AsyncIface.class); assertThat(request.method()).isEqualTo("hello"); assertThat(request.params()).containsExactly("Trustin");
assertThat(request.serviceType()).isEqualTo(HelloService.AsyncIface.class); assertThat(request.method()).isEqualTo("hello"); assertThat(request.params()).containsExactly("Trustin");
func = metadata(call.serviceType()).function(method); if (func == null) { throw new IllegalArgumentException("Thrift method not found: " + method);
func = metadata(call.serviceType()).function(method); if (func == null) { throw new IllegalArgumentException("Thrift method not found: " + method);
func = metadata(call.serviceType()).function(method); if (func == null) { throw new IllegalArgumentException("Thrift method not found: " + method);
func = metadata(call.serviceType()).function(method); if (func == null) { throw new IllegalArgumentException("Thrift method not found: " + method);