Search in sources :

Example 11 with ServerContext

use of io.servicetalk.transport.api.ServerContext in project servicetalk by apple.

the class TcpServerBinder method bind.

/**
 * Create a {@link ServerContext} that represents a socket which is bound and listening on the
 * {@code listenAddress}.
 *
 * @param listenAddress The address to bind to.
 * @param config The {@link ReadOnlyTcpServerConfig} to use for the bind socket and newly accepted sockets.
 * @param autoRead if {@code true} auto read will be enabled for new {@link Channel}s.
 * @param executionContext The {@link ExecutionContext} to use for the bind socket.
 * @param connectionAcceptor The {@link ConnectionAcceptor} used to filter newly accepted sockets.
 * @param connectionFunction Used to create a new {@link NettyConnection} from a {@link Channel}.
 * @param connectionConsumer Used to consume the result of {@code connectionFunction} after initialization and
 * filtering is done. This can be used for protocol specific initialization and to start data flow.
 * @param <CC> The type of {@link ConnectionContext} that is created for each accepted socket.
 * @return a {@link Single} that completes with a {@link ServerContext} that represents a socket which is bound and
 * listening on the {@code listenAddress}.
 */
public static <CC extends ConnectionContext> Single<ServerContext> bind(SocketAddress listenAddress, final ReadOnlyTcpServerConfig config, final boolean autoRead, final ExecutionContext<?> executionContext, @Nullable final InfluencerConnectionAcceptor connectionAcceptor, final BiFunction<Channel, ConnectionObserver, Single<CC>> connectionFunction, final Consumer<CC> connectionConsumer) {
    requireNonNull(connectionFunction);
    requireNonNull(connectionConsumer);
    listenAddress = toNettyAddress(listenAddress);
    EventLoopAwareNettyIoExecutor nettyIoExecutor = toEventLoopAwareNettyIoExecutor(executionContext.ioExecutor());
    ServerBootstrap bs = new ServerBootstrap();
    configure(config, autoRead, bs, nettyIoExecutor.eventLoopGroup(), listenAddress.getClass());
    ChannelSet channelSet = new ChannelSet(executionContext.executionStrategy().isCloseOffloaded() ? executionContext.executor() : immediate());
    bs.handler(new ChannelInboundHandlerAdapter() {

        @Override
        public void channelRead(final ChannelHandlerContext ctx, final Object msg) {
            // Verify that we do not leak pooled memory in the "accept" pipeline
            if (msg instanceof ReferenceCounted) {
                try {
                    throw new IllegalArgumentException("Unexpected ReferenceCounted msg in 'accept' pipeline: " + msg);
                } finally {
                    ((ReferenceCounted) msg).release();
                }
            }
            if (msg instanceof Channel) {
                final Channel channel = (Channel) msg;
                if (!channel.isActive()) {
                    channel.close();
                    LOGGER.debug("Channel ({}) is accepted, but was already inactive", msg);
                    return;
                } else if (!channelSet.addIfAbsent(channel)) {
                    LOGGER.warn("Channel ({}) not added to ChannelSet", msg);
                    return;
                }
            }
            ctx.fireChannelRead(msg);
        }
    });
    bs.childHandler(new io.netty.channel.ChannelInitializer<Channel>() {

        @Override
        protected void initChannel(Channel channel) {
            Single<CC> connectionSingle = connectionFunction.apply(channel, config.transportObserver().onNewConnection(channel.localAddress(), channel.remoteAddress()));
            if (connectionAcceptor != null) {
                connectionSingle = connectionSingle.flatMap(conn -> defer(() -> connectionAcceptor.accept(conn).concat(succeeded(conn))).subscribeOn(connectionAcceptor.requiredOffloads().isConnectOffloaded() ? executionContext.executor() : immediate()));
            }
            connectionSingle.beforeOnError(cause -> {
                // Getting the remote-address may involve volatile reads and potentially a syscall, so guard it.
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("Failed to create a connection for remote address {}", channel.remoteAddress(), cause);
                }
                close(channel, cause);
            }).subscribe(connectionConsumer);
        }
    });
    ChannelFuture future = bs.bind(listenAddress);
    return new SubscribableSingle<ServerContext>() {

        @Override
        protected void handleSubscribe(Subscriber<? super ServerContext> subscriber) {
            subscriber.onSubscribe(() -> future.cancel(true));
            future.addListener((ChannelFuture f) -> {
                Channel channel = f.channel();
                Throwable cause = f.cause();
                if (cause == null) {
                    subscriber.onSuccess(NettyServerContext.wrap(channel, channelSet, connectionAcceptor, executionContext));
                } else {
                    close(channel, f.cause());
                    subscriber.onError(f.cause());
                }
            });
        }
    };
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) ChannelSet(io.servicetalk.transport.netty.internal.ChannelSet) Channel(io.netty.channel.Channel) EventLoopAwareNettyIoExecutor(io.servicetalk.transport.netty.internal.EventLoopAwareNettyIoExecutor) EventLoopAwareNettyIoExecutors.toEventLoopAwareNettyIoExecutor(io.servicetalk.transport.netty.internal.EventLoopAwareNettyIoExecutors.toEventLoopAwareNettyIoExecutor) SubscribableSingle(io.servicetalk.concurrent.api.internal.SubscribableSingle) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) ServerBootstrap(io.netty.bootstrap.ServerBootstrap) ServerContext(io.servicetalk.transport.api.ServerContext) NettyServerContext(io.servicetalk.transport.netty.internal.NettyServerContext) SubscribableSingle(io.servicetalk.concurrent.api.internal.SubscribableSingle) Single(io.servicetalk.concurrent.api.Single) ChannelInboundHandlerAdapter(io.netty.channel.ChannelInboundHandlerAdapter) ReferenceCounted(io.netty.util.ReferenceCounted)

Example 12 with ServerContext

use of io.servicetalk.transport.api.ServerContext in project servicetalk by apple.

the class HttpProvidersTest method testSingleAddressHttpClientBuilderProviderForResolvedAddress.

@Test
void testSingleAddressHttpClientBuilderProviderForResolvedAddress() throws Exception {
    try (ServerContext serverContext = HttpServers.forAddress(localAddress(0)).listenStreamingAndAwait(new TestServiceStreaming())) {
        SocketAddress serverAddress = serverContext.listenAddress();
        TestSingleAddressHttpClientBuilderProvider.MODIFY_FOR_ADDRESS.set(serverAddress);
        try (BlockingHttpClient client = HttpClients.forResolvedAddress(serverAddress).buildBlocking()) {
            assertThat(TestSingleAddressHttpClientBuilderProvider.BUILD_COUNTER.get(), is(1));
            HttpResponse response = client.request(client.get(SVC_ECHO));
            assertThat(response.status(), is(OK));
            assertThat(TestSingleAddressHttpClientBuilderProvider.CONNECTION_COUNTER.get(), is(1));
        }
    }
}
Also used : HttpServerContext(io.servicetalk.http.api.HttpServerContext) ServerContext(io.servicetalk.transport.api.ServerContext) BlockingHttpClient(io.servicetalk.http.api.BlockingHttpClient) HttpResponse(io.servicetalk.http.api.HttpResponse) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) Test(org.junit.jupiter.api.Test)

Example 13 with ServerContext

use of io.servicetalk.transport.api.ServerContext in project servicetalk by apple.

the class HttpProvidersTest method testSingleAddressHttpClientBuilderProviderWithHostAndPort.

@Test
void testSingleAddressHttpClientBuilderProviderWithHostAndPort() throws Exception {
    try (ServerContext serverContext = HttpServers.forAddress(localAddress(0)).listenStreamingAndAwait(new TestServiceStreaming())) {
        HostAndPort serverAddress = serverHostAndPort(serverContext);
        TestSingleAddressHttpClientBuilderProvider.MODIFY_FOR_ADDRESS.set(serverAddress);
        try (BlockingHttpClient client = HttpClients.forSingleAddress(serverAddress).buildBlocking()) {
            assertThat(TestSingleAddressHttpClientBuilderProvider.BUILD_COUNTER.get(), is(1));
            HttpResponse response = client.request(client.get(SVC_ECHO));
            assertThat(response.status(), is(OK));
            assertThat(TestSingleAddressHttpClientBuilderProvider.CONNECTION_COUNTER.get(), is(1));
        }
    }
}
Also used : AddressUtils.serverHostAndPort(io.servicetalk.transport.netty.internal.AddressUtils.serverHostAndPort) HostAndPort(io.servicetalk.transport.api.HostAndPort) HttpServerContext(io.servicetalk.http.api.HttpServerContext) ServerContext(io.servicetalk.transport.api.ServerContext) BlockingHttpClient(io.servicetalk.http.api.BlockingHttpClient) HttpResponse(io.servicetalk.http.api.HttpResponse) Test(org.junit.jupiter.api.Test)

Example 14 with ServerContext

use of io.servicetalk.transport.api.ServerContext in project servicetalk by apple.

the class HttpRequestEncoderTest method protocolPayloadEndOutboundShouldNotTriggerOnFailedFlush.

@Test
void protocolPayloadEndOutboundShouldNotTriggerOnFailedFlush() throws Exception {
    AtomicReference<CloseHandler> closeHandlerRef = new AtomicReference<>();
    try (CompositeCloseable resources = newCompositeCloseable()) {
        Processor serverCloseTrigger = newCompletableProcessor();
        CountDownLatch serverChannelLatch = new CountDownLatch(1);
        AtomicReference<Channel> serverChannelRef = new AtomicReference<>();
        ReadOnlyTcpServerConfig sConfig = new TcpServerConfig().asReadOnly();
        ServerContext serverContext = resources.prepend(TcpServerBinder.bind(localAddress(0), sConfig, false, SEC, null, (channel, observer) -> DefaultNettyConnection.initChannel(channel, SEC.bufferAllocator(), SEC.executor(), SEC.ioExecutor(), forPipelinedRequestResponse(false, channel.config()), defaultFlushStrategy(), 0L, null, new TcpServerChannelInitializer(sConfig, observer).andThen(channel2 -> {
            serverChannelRef.compareAndSet(null, channel2);
            serverChannelLatch.countDown();
        }), defaultStrategy(), mock(Protocol.class), observer, false, __ -> false), connection -> {
        }).toFuture().get());
        ReadOnlyHttpClientConfig cConfig = new HttpClientConfig().asReadOnly();
        assert cConfig.h1Config() != null;
        NettyConnection<Object, Object> conn = resources.prepend(TcpConnector.connect(null, serverHostAndPort(serverContext), cConfig.tcpConfig(), false, CEC, (channel, connectionObserver) -> {
            CloseHandler closeHandler = spy(forPipelinedRequestResponse(true, channel.config()));
            closeHandlerRef.compareAndSet(null, closeHandler);
            return DefaultNettyConnection.initChannel(channel, CEC.bufferAllocator(), CEC.executor(), CEC.ioExecutor(), closeHandler, defaultFlushStrategy(), 0L, cConfig.tcpConfig().sslConfig(), new TcpClientChannelInitializer(cConfig.tcpConfig(), connectionObserver).andThen(new HttpClientChannelInitializer(getByteBufAllocator(CEC.bufferAllocator()), cConfig.h1Config(), closeHandler)).andThen(channel2 -> channel2.pipeline().addLast(new ChannelInboundHandlerAdapter() {

                @Override
                public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
                    // Propagate the user event in the pipeline before
                    // triggering the test condition.
                    ctx.fireUserEventTriggered(evt);
                    if (evt instanceof ChannelInputShutdownReadComplete) {
                        serverCloseTrigger.onComplete();
                    }
                }
            })), defaultStrategy(), HTTP_1_1, connectionObserver, true, __ -> false);
        }, NoopTransportObserver.INSTANCE).toFuture().get());
        // The server needs to wait to close the conneciton until after the client has established the connection.
        serverChannelLatch.await();
        Channel serverChannel = serverChannelRef.get();
        assertNotNull(serverChannel);
        assumeFalse(serverChannel instanceof NioSocketChannel, "Windows doesn't emit ChannelInputShutdownReadComplete. Investigation Required.");
        ((SocketChannel) serverChannel).config().setSoLinger(0);
        // Close and send RST concurrently with client write
        serverChannel.close();
        StreamingHttpRequest request = reqRespFactory.post("/closeme");
        fromSource(serverCloseTrigger).toFuture().get();
        Completable write = conn.write(from(request, allocator.fromAscii("Bye"), EmptyHttpHeaders.INSTANCE));
        assertThrows(ExecutionException.class, () -> write.toFuture().get());
        CloseHandler closeHandler = closeHandlerRef.get();
        assertNotNull(closeHandler);
        verify(closeHandler, never()).protocolPayloadEndOutbound(any(), any());
    }
}
Also used : UNSUPPORTED_PROTOCOL_CLOSE_HANDLER(io.servicetalk.transport.netty.internal.CloseHandler.UNSUPPORTED_PROTOCOL_CLOSE_HANDLER) ChannelInputShutdownReadComplete(io.netty.channel.socket.ChannelInputShutdownReadComplete) Protocol(io.servicetalk.transport.api.ConnectionInfo.Protocol) HttpRequestMethod(io.servicetalk.http.api.HttpRequestMethod) ChannelInboundHandlerAdapter(io.netty.channel.ChannelInboundHandlerAdapter) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) Integer.toHexString(java.lang.Integer.toHexString) TcpServerChannelInitializer(io.servicetalk.tcp.netty.internal.TcpServerChannelInitializer) TcpServerConfig(io.servicetalk.tcp.netty.internal.TcpServerConfig) ReadOnlyTcpServerConfig(io.servicetalk.tcp.netty.internal.ReadOnlyTcpServerConfig) SourceAdapters.fromSource(io.servicetalk.concurrent.api.SourceAdapters.fromSource) HttpRequestMetaDataFactory.newRequestMetaData(io.servicetalk.http.api.HttpRequestMetaDataFactory.newRequestMetaData) HttpExecutionStrategies.defaultStrategy(io.servicetalk.http.api.HttpExecutionStrategies.defaultStrategy) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Assumptions.assumeFalse(org.junit.jupiter.api.Assumptions.assumeFalse) CONNECTION(io.servicetalk.http.api.HttpHeaderNames.CONNECTION) USER_AGENT(io.servicetalk.http.api.HttpHeaderNames.USER_AGENT) SocketChannel(io.netty.channel.socket.SocketChannel) TcpConnector(io.servicetalk.tcp.netty.internal.TcpConnector) CompositeCloseable(io.servicetalk.concurrent.api.CompositeCloseable) TRANSFER_ENCODING(io.servicetalk.http.api.HttpHeaderNames.TRANSFER_ENCODING) POST(io.servicetalk.http.api.HttpRequestMethod.POST) AsyncCloseables.newCompositeCloseable(io.servicetalk.concurrent.api.AsyncCloseables.newCompositeCloseable) DefaultNettyConnection(io.servicetalk.transport.netty.internal.DefaultNettyConnection) CONTENT_LENGTH(io.servicetalk.http.api.HttpHeaderNames.CONTENT_LENGTH) DefaultHttpHeadersFactory(io.servicetalk.http.api.DefaultHttpHeadersFactory) HttpRequestMetaData(io.servicetalk.http.api.HttpRequestMetaData) Test(org.junit.jupiter.api.Test) CountDownLatch(java.util.concurrent.CountDownLatch) TcpClientChannelInitializer(io.servicetalk.tcp.netty.internal.TcpClientChannelInitializer) Buffer(io.servicetalk.buffer.api.Buffer) Processor(io.servicetalk.concurrent.CompletableSource.Processor) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) FlushStrategies.defaultFlushStrategy(io.servicetalk.transport.netty.internal.FlushStrategies.defaultFlushStrategy) CloseHandler(io.servicetalk.transport.netty.internal.CloseHandler) Mockito.mock(org.mockito.Mockito.mock) NioSocketChannel(io.netty.channel.socket.nio.NioSocketChannel) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) CsvSource(org.junit.jupiter.params.provider.CsvSource) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) DEFAULT_ALLOCATOR(io.servicetalk.buffer.netty.BufferAllocators.DEFAULT_ALLOCATOR) CloseHandler.forPipelinedRequestResponse(io.servicetalk.transport.netty.internal.CloseHandler.forPipelinedRequestResponse) HttpHeaders(io.servicetalk.http.api.HttpHeaders) Mockito.spy(org.mockito.Mockito.spy) AtomicReference(java.util.concurrent.atomic.AtomicReference) EMPTY_BUFFER(io.servicetalk.buffer.api.EmptyBuffer.EMPTY_BUFFER) EmptyHttpHeaders(io.servicetalk.http.api.EmptyHttpHeaders) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) ByteBuf(io.netty.buffer.ByteBuf) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) NettyIoExecutors.createIoExecutor(io.servicetalk.transport.netty.NettyIoExecutors.createIoExecutor) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) StreamingHttpRequest(io.servicetalk.http.api.StreamingHttpRequest) AddressUtils.serverHostAndPort(io.servicetalk.transport.netty.internal.AddressUtils.serverHostAndPort) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Publisher.from(io.servicetalk.concurrent.api.Publisher.from) Processors.newCompletableProcessor(io.servicetalk.concurrent.api.Processors.newCompletableProcessor) CHUNKED(io.servicetalk.http.api.HttpHeaderValues.CHUNKED) KEEP_ALIVE(io.servicetalk.http.api.HttpHeaderValues.KEEP_ALIVE) ValueSource(org.junit.jupiter.params.provider.ValueSource) AddressUtils.localAddress(io.servicetalk.transport.netty.internal.AddressUtils.localAddress) ServerContext(io.servicetalk.transport.api.ServerContext) StreamingHttpRequestResponseFactory(io.servicetalk.http.api.StreamingHttpRequestResponseFactory) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) Completable(io.servicetalk.concurrent.api.Completable) ExecutionContextExtension(io.servicetalk.transport.netty.internal.ExecutionContextExtension) IOException(java.io.IOException) GET(io.servicetalk.http.api.HttpRequestMethod.GET) TcpServerBinder(io.servicetalk.tcp.netty.internal.TcpServerBinder) Mockito.verify(org.mockito.Mockito.verify) Channel(io.netty.channel.Channel) ExecutionException(java.util.concurrent.ExecutionException) US_ASCII(java.nio.charset.StandardCharsets.US_ASCII) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Mockito.never(org.mockito.Mockito.never) BufferUtils.getByteBufAllocator(io.servicetalk.buffer.netty.BufferUtils.getByteBufAllocator) String.valueOf(java.lang.String.valueOf) BufferAllocator(io.servicetalk.buffer.api.BufferAllocator) Executors(io.servicetalk.concurrent.api.Executors) NettyConnection(io.servicetalk.transport.netty.internal.NettyConnection) ArrayDeque(java.util.ArrayDeque) NoopTransportObserver(io.servicetalk.transport.netty.internal.NoopTransportObserver) INSTANCE(io.servicetalk.http.api.DefaultHttpHeadersFactory.INSTANCE) HTTP_1_1(io.servicetalk.http.api.HttpProtocolVersion.HTTP_1_1) DefaultStreamingHttpRequestResponseFactory(io.servicetalk.http.api.DefaultStreamingHttpRequestResponseFactory) Completable(io.servicetalk.concurrent.api.Completable) Processor(io.servicetalk.concurrent.CompletableSource.Processor) Processors.newCompletableProcessor(io.servicetalk.concurrent.api.Processors.newCompletableProcessor) ChannelInputShutdownReadComplete(io.netty.channel.socket.ChannelInputShutdownReadComplete) CompositeCloseable(io.servicetalk.concurrent.api.CompositeCloseable) AsyncCloseables.newCompositeCloseable(io.servicetalk.concurrent.api.AsyncCloseables.newCompositeCloseable) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) ReadOnlyTcpServerConfig(io.servicetalk.tcp.netty.internal.ReadOnlyTcpServerConfig) TcpClientChannelInitializer(io.servicetalk.tcp.netty.internal.TcpClientChannelInitializer) Protocol(io.servicetalk.transport.api.ConnectionInfo.Protocol) SocketChannel(io.netty.channel.socket.SocketChannel) NioSocketChannel(io.netty.channel.socket.nio.NioSocketChannel) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) Channel(io.netty.channel.Channel) TcpServerChannelInitializer(io.servicetalk.tcp.netty.internal.TcpServerChannelInitializer) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) TcpServerConfig(io.servicetalk.tcp.netty.internal.TcpServerConfig) ReadOnlyTcpServerConfig(io.servicetalk.tcp.netty.internal.ReadOnlyTcpServerConfig) NioSocketChannel(io.netty.channel.socket.nio.NioSocketChannel) ServerContext(io.servicetalk.transport.api.ServerContext) CloseHandler(io.servicetalk.transport.netty.internal.CloseHandler) StreamingHttpRequest(io.servicetalk.http.api.StreamingHttpRequest) ChannelInboundHandlerAdapter(io.netty.channel.ChannelInboundHandlerAdapter) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 15 with ServerContext

use of io.servicetalk.transport.api.ServerContext in project servicetalk by apple.

the class HttpSerializationErrorTest method serializationMapThrowsPropagatesToClient.

@ParameterizedTest
@MethodSource("executors")
void serializationMapThrowsPropagatesToClient(HttpTestExecutionStrategy serverStrategy) throws Exception {
    serverExecutionStrategy = serverStrategy.executorSupplier.get();
    TypeReference<Map<String, Object>> mapType = new TypeReference<Map<String, Object>>() {
    };
    HttpSerializerDeserializer<Map<String, Object>> httpSerializer = jsonSerializer(JACKSON.serializerDeserializer(mapType));
    HttpStreamingSerializerDeserializer<Map<String, Object>> httpStreamingSerializer = jsonStreamingSerializer(JACKSON.streamingSerializerDeserializer(mapType));
    try (ServerContext srv = HttpServers.forAddress(localAddress(0)).executionStrategy(serverExecutionStrategy).listenAndAwait((ctx, request, responseFactory) -> responseFactory.ok().toStreamingResponse().payloadBody(request.toStreamingRequest().payloadBody(httpStreamingSerializer).map(result -> {
        throw DELIBERATE_EXCEPTION;
    }), httpStreamingSerializer).toResponse());
        BlockingHttpClient clt = HttpClients.forSingleAddress(serverHostAndPort(srv)).buildBlocking()) {
        HttpResponse resp = clt.request(clt.post("/foo").payloadBody(emptyMap(), httpSerializer));
        assertEquals(INTERNAL_SERVER_ERROR, resp.status());
    }
}
Also used : BlockingHttpClient(io.servicetalk.http.api.BlockingHttpClient) INTERNAL_SERVER_ERROR(io.servicetalk.http.api.HttpResponseStatus.INTERNAL_SERVER_ERROR) Collections.emptyMap(java.util.Collections.emptyMap) HttpSerializers.jsonStreamingSerializer(io.servicetalk.http.api.HttpSerializers.jsonStreamingSerializer) AddressUtils.localAddress(io.servicetalk.transport.netty.internal.AddressUtils.localAddress) ServerContext(io.servicetalk.transport.api.ServerContext) JACKSON(io.servicetalk.data.jackson.JacksonSerializerFactory.JACKSON) DEFAULT(io.servicetalk.http.netty.HttpTestExecutionStrategy.DEFAULT) Collection(java.util.Collection) HttpResponse(io.servicetalk.http.api.HttpResponse) AfterEach(org.junit.jupiter.api.AfterEach) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) HttpExecutionStrategy(io.servicetalk.http.api.HttpExecutionStrategy) HttpStreamingSerializerDeserializer(io.servicetalk.http.api.HttpStreamingSerializerDeserializer) NO_OFFLOAD(io.servicetalk.http.netty.HttpTestExecutionStrategy.NO_OFFLOAD) HttpSerializers.jsonSerializer(io.servicetalk.http.api.HttpSerializers.jsonSerializer) AddressUtils.serverHostAndPort(io.servicetalk.transport.netty.internal.AddressUtils.serverHostAndPort) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) HttpSerializerDeserializer(io.servicetalk.http.api.HttpSerializerDeserializer) TypeReference(com.fasterxml.jackson.core.type.TypeReference) DELIBERATE_EXCEPTION(io.servicetalk.concurrent.internal.DeliberateException.DELIBERATE_EXCEPTION) MethodSource(org.junit.jupiter.params.provider.MethodSource) ServerContext(io.servicetalk.transport.api.ServerContext) BlockingHttpClient(io.servicetalk.http.api.BlockingHttpClient) HttpResponse(io.servicetalk.http.api.HttpResponse) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Collections.emptyMap(java.util.Collections.emptyMap) Map(java.util.Map) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

ServerContext (io.servicetalk.transport.api.ServerContext)106 Test (org.junit.jupiter.api.Test)57 BlockingHttpClient (io.servicetalk.http.api.BlockingHttpClient)42 HttpResponse (io.servicetalk.http.api.HttpResponse)39 AddressUtils.serverHostAndPort (io.servicetalk.transport.netty.internal.AddressUtils.serverHostAndPort)34 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)34 AddressUtils.localAddress (io.servicetalk.transport.netty.internal.AddressUtils.localAddress)33 StreamingHttpResponse (io.servicetalk.http.api.StreamingHttpResponse)28 InetSocketAddress (java.net.InetSocketAddress)27 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)26 StreamingHttpRequest (io.servicetalk.http.api.StreamingHttpRequest)24 MethodSource (org.junit.jupiter.params.provider.MethodSource)22 HostAndPort (io.servicetalk.transport.api.HostAndPort)20 Single (io.servicetalk.concurrent.api.Single)19 Single.succeeded (io.servicetalk.concurrent.api.Single.succeeded)19 StreamingHttpClient (io.servicetalk.http.api.StreamingHttpClient)16 ClientSslConfigBuilder (io.servicetalk.transport.api.ClientSslConfigBuilder)15 OK (io.servicetalk.http.api.HttpResponseStatus.OK)14 DefaultTestCerts (io.servicetalk.test.resources.DefaultTestCerts)14 AtomicReference (java.util.concurrent.atomic.AtomicReference)14