Search in sources :

Example 6 with TesterService

use of io.servicetalk.grpc.netty.TesterProto.Tester.TesterService in project servicetalk by apple.

the class GrpcRouterConfigurationTest method testCanNotOverrideAlreadyRegisteredPath.

@Test
void testCanNotOverrideAlreadyRegisteredPath() {
    final TesterService asyncService = DEFAULT_STRATEGY_ASYNC_SERVICE;
    final TesterService alternativeAsyncService = CLASS_NO_OFFLOADS_STRATEGY_ASYNC_SERVICE;
    testCanNotOverrideAlreadyRegisteredPath(TestRpc.PATH, builder -> builder.test(asyncService).test(alternativeAsyncService));
    testCanNotOverrideAlreadyRegisteredPath(TestBiDiStreamRpc.PATH, builder -> builder.testBiDiStream(asyncService).testBiDiStream(alternativeAsyncService));
    testCanNotOverrideAlreadyRegisteredPath(TestResponseStreamRpc.PATH, builder -> builder.testResponseStream(asyncService).testResponseStream(alternativeAsyncService));
    testCanNotOverrideAlreadyRegisteredPath(TestRequestStreamRpc.PATH, builder -> builder.testRequestStream(asyncService).testRequestStream(alternativeAsyncService));
    final BlockingTesterService blockingService = DEFAULT_STRATEGY_BLOCKING_SERVICE;
    final BlockingTesterService alternativeBlockingService = CLASS_NO_OFFLOADS_STRATEGY_BLOCKING_SERVICE;
    testCanNotOverrideAlreadyRegisteredPath(BlockingTestRpc.PATH, builder -> builder.testBlocking(blockingService).testBlocking(alternativeBlockingService));
    testCanNotOverrideAlreadyRegisteredPath(BlockingTestBiDiStreamRpc.PATH, builder -> builder.testBiDiStreamBlocking(blockingService).testBiDiStreamBlocking(alternativeBlockingService));
    testCanNotOverrideAlreadyRegisteredPath(BlockingTestResponseStreamRpc.PATH, builder -> builder.testResponseStreamBlocking(blockingService).testResponseStreamBlocking(alternativeBlockingService));
    testCanNotOverrideAlreadyRegisteredPath(BlockingTestRequestStreamRpc.PATH, builder -> builder.testRequestStreamBlocking(blockingService).testRequestStreamBlocking(alternativeBlockingService));
}
Also used : BlockingTesterService(io.servicetalk.grpc.netty.TesterProto.Tester.BlockingTesterService) TesterService(io.servicetalk.grpc.netty.TesterProto.Tester.TesterService) BlockingTesterService(io.servicetalk.grpc.netty.TesterProto.Tester.BlockingTesterService) Test(org.junit.jupiter.api.Test)

Example 7 with TesterService

use of io.servicetalk.grpc.netty.TesterProto.Tester.TesterService in project servicetalk by apple.

the class GrpcRouterConfigurationTest method testCanNotOverrideAlreadyRegisteredPathWithAnotherApi.

@Test
void testCanNotOverrideAlreadyRegisteredPathWithAnotherApi() {
    final TesterService asyncService = DEFAULT_STRATEGY_ASYNC_SERVICE;
    final BlockingTesterService blockingService = DEFAULT_STRATEGY_BLOCKING_SERVICE;
    // Test registering of async RPC then blocking RPC for the same path:
    testCanNotOverrideAlreadyRegisteredPath(TestRpc.PATH, builder -> builder.test(asyncService).testBlocking(blockingService));
    testCanNotOverrideAlreadyRegisteredPath(TestBiDiStreamRpc.PATH, builder -> builder.testBiDiStream(asyncService).testBiDiStreamBlocking(blockingService));
    testCanNotOverrideAlreadyRegisteredPath(TestResponseStreamRpc.PATH, builder -> builder.testResponseStream(asyncService).testResponseStreamBlocking(blockingService));
    testCanNotOverrideAlreadyRegisteredPath(TestRequestStreamRpc.PATH, builder -> builder.testRequestStream(asyncService).testRequestStreamBlocking(blockingService));
    // Test registering of blocking RPC then async RPC for the same path:
    testCanNotOverrideAlreadyRegisteredPath(BlockingTestRpc.PATH, builder -> builder.testBlocking(blockingService).test(asyncService));
    testCanNotOverrideAlreadyRegisteredPath(BlockingTestBiDiStreamRpc.PATH, builder -> builder.testBiDiStreamBlocking(blockingService).testBiDiStream(asyncService));
    testCanNotOverrideAlreadyRegisteredPath(BlockingTestResponseStreamRpc.PATH, builder -> builder.testResponseStreamBlocking(blockingService).testResponseStream(asyncService));
    testCanNotOverrideAlreadyRegisteredPath(BlockingTestRequestStreamRpc.PATH, builder -> builder.testRequestStreamBlocking(blockingService).testRequestStream(asyncService));
}
Also used : BlockingTesterService(io.servicetalk.grpc.netty.TesterProto.Tester.BlockingTesterService) TesterService(io.servicetalk.grpc.netty.TesterProto.Tester.TesterService) BlockingTesterService(io.servicetalk.grpc.netty.TesterProto.Tester.BlockingTesterService) Test(org.junit.jupiter.api.Test)

Example 8 with TesterService

use of io.servicetalk.grpc.netty.TesterProto.Tester.TesterService in project servicetalk by apple.

the class TrailersOnlyErrorTest method testServiceThrows.

@Test
void testServiceThrows() throws Exception {
    final BlockingQueue<Throwable> asyncErrors = new LinkedBlockingDeque<>();
    final TesterService service = mockTesterService();
    setupServiceThrows(service);
    try (ServerContext serverContext = GrpcServers.forAddress(localAddress(0)).listenAndAwait(new Tester.ServiceFactory(service))) {
        final GrpcClientBuilder<HostAndPort, InetSocketAddress> clientBuilder = GrpcClients.forAddress(serverHostAndPort(serverContext)).initializeHttp(builder -> builder.appendClientFilter(__ -> true, setupResponseVerifierFilter(asyncErrors)));
        try (TesterClient client = clientBuilder.build(new Tester.ClientFactory())) {
            verifyException(client.test(TestRequest.newBuilder().build()).toFuture(), UNKNOWN);
            assertNoAsyncErrors(asyncErrors);
            verifyException(client.testRequestStream(Publisher.from(TestRequest.newBuilder().build())).toFuture(), UNKNOWN);
            assertNoAsyncErrors(asyncErrors);
            verifyException(client.testBiDiStream(from(TestRequest.newBuilder().build()).concat(never())).toFuture(), UNKNOWN);
            assertNoAsyncErrors(asyncErrors);
            verifyException(client.testBiDiStream(from(TestRequest.newBuilder().build())).toFuture(), UNKNOWN);
            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) TesterService(io.servicetalk.grpc.netty.TesterProto.Tester.TesterService) AddressUtils.serverHostAndPort(io.servicetalk.transport.netty.internal.AddressUtils.serverHostAndPort) HostAndPort(io.servicetalk.transport.api.HostAndPort) TesterClient(io.servicetalk.grpc.netty.TesterProto.Tester.TesterClient) ServerContext(io.servicetalk.transport.api.ServerContext) Test(org.junit.jupiter.api.Test)

Example 9 with TesterService

use of io.servicetalk.grpc.netty.TesterProto.Tester.TesterService in project servicetalk by apple.

the class ErrorHandlingTest method setupForServiceSecondOperatorThrows.

private ServiceFactory setupForServiceSecondOperatorThrows(final Throwable toThrow) {
    final TesterService service = mockTesterService();
    setupForServiceSecondOperatorThrows(service, toThrow);
    return new ServiceFactory(service);
}
Also used : ServiceFactory(io.servicetalk.grpc.netty.TesterProto.Tester.ServiceFactory) TesterService(io.servicetalk.grpc.netty.TesterProto.Tester.TesterService) BlockingTesterService(io.servicetalk.grpc.netty.TesterProto.Tester.BlockingTesterService)

Example 10 with TesterService

use of io.servicetalk.grpc.netty.TesterProto.Tester.TesterService in project servicetalk by apple.

the class ErrorHandlingTest method setupForServiceThrows.

private ServiceFactory setupForServiceThrows(final Throwable toThrow) {
    final TesterService service = mockTesterService();
    setupForServiceThrows(service, toThrow);
    return new ServiceFactory(service);
}
Also used : ServiceFactory(io.servicetalk.grpc.netty.TesterProto.Tester.ServiceFactory) TesterService(io.servicetalk.grpc.netty.TesterProto.Tester.TesterService) BlockingTesterService(io.servicetalk.grpc.netty.TesterProto.Tester.BlockingTesterService)

Aggregations

TesterService (io.servicetalk.grpc.netty.TesterProto.Tester.TesterService)14 BlockingTesterService (io.servicetalk.grpc.netty.TesterProto.Tester.BlockingTesterService)10 ServiceFactory (io.servicetalk.grpc.netty.TesterProto.Tester.ServiceFactory)6 Test (org.junit.jupiter.api.Test)4 Greeter (io.grpc.examples.helloworld.Greeter)3 GreeterClient (io.grpc.examples.helloworld.Greeter.GreeterClient)3 HelloRequest (io.grpc.examples.helloworld.HelloRequest)3 Completable.completed (io.servicetalk.concurrent.api.Completable.completed)3 Publisher (io.servicetalk.concurrent.api.Publisher)3 Publisher.from (io.servicetalk.concurrent.api.Publisher.from)3 Publisher.never (io.servicetalk.concurrent.api.Publisher.never)3 Single (io.servicetalk.concurrent.api.Single)3 DELIBERATE_EXCEPTION (io.servicetalk.concurrent.internal.DeliberateException.DELIBERATE_EXCEPTION)3 GrpcClientBuilder (io.servicetalk.grpc.api.GrpcClientBuilder)3 GRPC_STATUS (io.servicetalk.grpc.api.GrpcHeaderNames.GRPC_STATUS)3 GrpcServerBuilder (io.servicetalk.grpc.api.GrpcServerBuilder)3 GrpcStatusCode (io.servicetalk.grpc.api.GrpcStatusCode)3 UNIMPLEMENTED (io.servicetalk.grpc.api.GrpcStatusCode.UNIMPLEMENTED)3 UNKNOWN (io.servicetalk.grpc.api.GrpcStatusCode.UNKNOWN)3 GrpcStatusException (io.servicetalk.grpc.api.GrpcStatusException)3