Search in sources :

Example 1 with UNIMPLEMENTED

use of io.servicetalk.grpc.api.GrpcStatusCode.UNIMPLEMENTED in project servicetalk by apple.

the class TrailersOnlyErrorTest method testRouteThrows.

@Test
void testRouteThrows() throws Exception {
    final BlockingQueue<Throwable> asyncErrors = new LinkedBlockingDeque<>();
    try (ServerContext serverContext = GrpcServers.forAddress(localAddress(0)).listenAndAwait(new Tester.ServiceFactory(mockTesterService()))) {
        final GrpcClientBuilder<HostAndPort, InetSocketAddress> clientBuilder = GrpcClients.forAddress(serverHostAndPort(serverContext)).initializeHttp(builder -> builder.appendClientFilter(__ -> true, setupResponseVerifierFilter(asyncErrors)));
        // thus no route is found and it should result in UNIMPLEMENTED.
        try (GreeterClient client = clientBuilder.build(new Greeter.ClientFactory())) {
            verifyException(client.sayHello(HelloRequest.newBuilder().build()).toFuture(), UNIMPLEMENTED);
            assertNoAsyncErrors(asyncErrors);
        }
    }
}
Also used : TestUtils.assertNoAsyncErrors(io.servicetalk.test.resources.TestUtils.assertNoAsyncErrors) FilterableStreamingHttpClient(io.servicetalk.http.api.FilterableStreamingHttpClient) UNKNOWN(io.servicetalk.grpc.api.GrpcStatusCode.UNKNOWN) GrpcStatusCode(io.servicetalk.grpc.api.GrpcStatusCode) HelloRequest(io.grpc.examples.helloworld.HelloRequest) HttpResponseMetaData(io.servicetalk.http.api.HttpResponseMetaData) GreeterClient(io.grpc.examples.helloworld.Greeter.GreeterClient) GrpcStatusException(io.servicetalk.grpc.api.GrpcStatusException) Future(java.util.concurrent.Future) UNIMPLEMENTED(io.servicetalk.grpc.api.GrpcStatusCode.UNIMPLEMENTED) TesterClient(io.servicetalk.grpc.netty.TesterProto.Tester.TesterClient) Greeter(io.grpc.examples.helloworld.Greeter) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) BlockingQueue(java.util.concurrent.BlockingQueue) StreamingHttpClientFilter(io.servicetalk.http.api.StreamingHttpClientFilter) InetSocketAddress(java.net.InetSocketAddress) Test(org.junit.jupiter.api.Test) Matchers.equalTo(org.hamcrest.Matchers.equalTo) GrpcClientBuilder(io.servicetalk.grpc.api.GrpcClientBuilder) Mockito.mock(org.mockito.Mockito.mock) Publisher.never(io.servicetalk.concurrent.api.Publisher.never) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) StreamingHttpResponse(io.servicetalk.http.api.StreamingHttpResponse) Publisher(io.servicetalk.concurrent.api.Publisher) StreamingHttpRequester(io.servicetalk.http.api.StreamingHttpRequester) StreamingHttpServiceFilter(io.servicetalk.http.api.StreamingHttpServiceFilter) HttpServiceContext(io.servicetalk.http.api.HttpServiceContext) GrpcServerBuilder(io.servicetalk.grpc.api.GrpcServerBuilder) StreamingHttpRequest(io.servicetalk.http.api.StreamingHttpRequest) AddressUtils.serverHostAndPort(io.servicetalk.transport.netty.internal.AddressUtils.serverHostAndPort) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Publisher.from(io.servicetalk.concurrent.api.Publisher.from) DELIBERATE_EXCEPTION(io.servicetalk.concurrent.internal.DeliberateException.DELIBERATE_EXCEPTION) AddressUtils.localAddress(io.servicetalk.transport.netty.internal.AddressUtils.localAddress) ServerContext(io.servicetalk.transport.api.ServerContext) Single(io.servicetalk.concurrent.api.Single) TesterService(io.servicetalk.grpc.netty.TesterProto.Tester.TesterService) TestRequest(io.servicetalk.grpc.netty.TesterProto.TestRequest) Mockito.when(org.mockito.Mockito.when) ExecutionException(java.util.concurrent.ExecutionException) GRPC_STATUS(io.servicetalk.grpc.api.GrpcHeaderNames.GRPC_STATUS) Completable.completed(io.servicetalk.concurrent.api.Completable.completed) StreamingHttpResponseFactory(io.servicetalk.http.api.StreamingHttpResponseFactory) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) StreamingHttpClientFilterFactory(io.servicetalk.http.api.StreamingHttpClientFilterFactory) Tester(io.servicetalk.grpc.netty.TesterProto.Tester) HostAndPort(io.servicetalk.transport.api.HostAndPort) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) Tester(io.servicetalk.grpc.netty.TesterProto.Tester) InetSocketAddress(java.net.InetSocketAddress) AddressUtils.serverHostAndPort(io.servicetalk.transport.netty.internal.AddressUtils.serverHostAndPort) HostAndPort(io.servicetalk.transport.api.HostAndPort) ServerContext(io.servicetalk.transport.api.ServerContext) Greeter(io.grpc.examples.helloworld.Greeter) GreeterClient(io.grpc.examples.helloworld.Greeter.GreeterClient) Test(org.junit.jupiter.api.Test)

Aggregations

Greeter (io.grpc.examples.helloworld.Greeter)1 GreeterClient (io.grpc.examples.helloworld.Greeter.GreeterClient)1 HelloRequest (io.grpc.examples.helloworld.HelloRequest)1 Completable.completed (io.servicetalk.concurrent.api.Completable.completed)1 Publisher (io.servicetalk.concurrent.api.Publisher)1 Publisher.from (io.servicetalk.concurrent.api.Publisher.from)1 Publisher.never (io.servicetalk.concurrent.api.Publisher.never)1 Single (io.servicetalk.concurrent.api.Single)1 DELIBERATE_EXCEPTION (io.servicetalk.concurrent.internal.DeliberateException.DELIBERATE_EXCEPTION)1 GrpcClientBuilder (io.servicetalk.grpc.api.GrpcClientBuilder)1 GRPC_STATUS (io.servicetalk.grpc.api.GrpcHeaderNames.GRPC_STATUS)1 GrpcServerBuilder (io.servicetalk.grpc.api.GrpcServerBuilder)1 GrpcStatusCode (io.servicetalk.grpc.api.GrpcStatusCode)1 UNIMPLEMENTED (io.servicetalk.grpc.api.GrpcStatusCode.UNIMPLEMENTED)1 UNKNOWN (io.servicetalk.grpc.api.GrpcStatusCode.UNKNOWN)1 GrpcStatusException (io.servicetalk.grpc.api.GrpcStatusException)1 TestRequest (io.servicetalk.grpc.netty.TesterProto.TestRequest)1 Tester (io.servicetalk.grpc.netty.TesterProto.Tester)1 TesterClient (io.servicetalk.grpc.netty.TesterProto.Tester.TesterClient)1 TesterService (io.servicetalk.grpc.netty.TesterProto.Tester.TesterService)1