@Test
    void testProxy_serverImmediateClose_throwsException() throws Exception {
        channelHandlerFactory = SimpleChannelHandlerFactory.onChannelRead((ctx, msg) -> {
            ReferenceCountUtil.release(msg);
            ctx.close();
        });
        final TestProxyConfigSelector selector = new TestProxyConfigSelector(new ProxyConfigSelector() {
            @Override
            public ProxyConfig select(SessionProtocol protocol, Endpoint endpoint) {
                return ProxyConfig.socks4(socksProxyServer.address());
            }

            @Override
            public void connectFailed(SessionProtocol protocol, Endpoint endpoint,
                                      SocketAddress sa, Throwable throwable) {
                assertThat(protocol).isEqualTo(SessionProtocol.H1C);
                assertThat(endpoint).isEqualTo(backendServer.httpEndpoint());
                assertThat(sa).isEqualTo(socksProxyServer.address());
                assertThat(throwable).isInstanceOf(UnprocessedRequestException.class)
                                     .hasCauseInstanceOf(ProxyConnectException.class);
                throw new RuntimeException("connectFailed exception");
            }
        });

        try (ClientFactory clientFactory =
                     ClientFactory.builder()
                                  .proxyConfig(selector)
                                  .useHttp2Preface(true)
                                  .build()) {

            final WebClient webClient = WebClient.builder(SessionProtocol.H1C, backendServer.httpEndpoint())
                                                 .factory(clientFactory)
                                                 .decorator(LoggingClient.newDecorator())
                                                 .build();
            final CompletableFuture<AggregatedHttpResponse> responseFuture =
                    webClient.get(PROXY_PATH).aggregate();
            assertThatThrownBy(responseFuture::join).isInstanceOf(CompletionException.class)
                                                    .hasCauseInstanceOf(UnprocessedRequestException.class)
                                                    .hasRootCauseInstanceOf(ProxyConnectException.class);
            assertThat(selector.result()).isTrue();
        }
    }
Tests if a request is failed with {@link SessionProtocolNegotiationException} if a session negotiation
with the backend server takes longer than a connection timeout.

<p>Cleartext protocol are not used because the session could immediately complete when a connection is
established with the proxy server.
core/src/test/java/com/linecorp/armeria/client/proxy/ProxyClientIntegrationTest.java