@Test
    @Disabled("Temporarily ignore until stabilized")
    void requireThatConnectionIsClosedAfterXRequests() throws Exception {
        final int MAX_REQUESTS = 10;
        Path privateKeyFile = File.createTempFile("junit", null, tmpFolder).toPath();
        Path certificateFile = File.createTempFile("junit", null, tmpFolder).toPath();
        generatePrivateKeyAndCertificate(privateKeyFile, certificateFile);
        ConnectorConfig.Builder connectorConfig = new ConnectorConfig.Builder()
                .maxRequestsPerConnection(MAX_REQUESTS)
                .ssl(new ConnectorConfig.Ssl.Builder()
                        .enabled(true)
                        .clientAuth(ConnectorConfig.Ssl.ClientAuth.Enum.NEED_AUTH)
                        .privateKeyFile(privateKeyFile.toString())
                        .certificateFile(certificateFile.toString())
                        .caCertificateFile(certificateFile.toString()));
        ServerConfig.Builder serverConfig = new ServerConfig.Builder()
                .connectionLog(new ServerConfig.ConnectionLog.Builder().enabled(true));
        InMemoryConnectionLog connectionLog = new InMemoryConnectionLog();
        Module overrideModule = binder -> binder.bind(ConnectionLog.class).toInstance(connectionLog);
        JettyTestDriver driver = JettyTestDriver.newConfiguredInstance(
                new EchoRequestHandler(), serverConfig, connectorConfig, overrideModule);

        // HTTP/1.1
        for (int i = 0; i < MAX_REQUESTS - 1; i++) {
            driver.client().get("/status.html")
                    .expectStatusCode(is(OK))
                    .expectNoHeader(CONNECTION);
        }
        driver.client().get("/status.html")
                .expectStatusCode(is(OK))
                .expectHeader(CONNECTION, is(CLOSE));

        // HTTP/2
        try (CloseableHttpAsyncClient client = createHttp2Client(driver)) {
            String uri = "https://localhost:" + driver.server().getListenPort() + "/status.html";
            for (int i = 0; i < 2 * MAX_REQUESTS; i++) {
                try {
                    client.execute(SimpleRequestBuilder.get(uri).build(), null).get();
                } catch (ExecutionException e) {
                    // Client sometimes throws ExecutionException with ConnectionClosedException as cause
                    // on the last request.
                    if (!(e.getCause() instanceof ConnectionClosedException)) throw e;
                }
            }
        }
        assertTrue(driver.close());
        long http2Connections = connectionLog.logEntries().stream()
                .filter(e -> e.httpProtocol().orElseThrow().equals("HTTP/2.0"))
                .count();
        assertEquals(2, http2Connections);
    }
@author Oyvind Bakksjo
@author Simon Thoresen Hult
@author bjorncs
container-core/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpServerTest.java