Introduce convenience test library APIs for creating test servers for tests in test/jdk/java/net/httpclient

XMLWordPrintable

    • b13

        In test/jdk/java/net/httpclient we have a number of tests which create HTTP servers. Many of those tests have repeated code of the form:


                InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0);
                httpTestServer = HttpTestServer.of(HttpServer.create(sa, 0));
        ...
                HttpsServer httpsServer = HttpsServer.create(sa, 0);
                httpsServer.setHttpsConfigurator(new HttpsConfigurator(sslContext));
                httpsTestServer = HttpTestServer.of(httpsServer);
        ...
                http2TestServer = HttpTestServer.of(new Http2TestServer("localhost", false, 0));
        ...
                https2TestServer = HttpTestServer.of(new Http2TestServer("localhost", true, sslContext));


        It would be good to have a convenience API to replace these calls with simpler calls and reduce the boilerplate code in these tests. The new APIs could be of the form:


                httpTestServer = HttpTestServer.create(HTTP_1_1);
        ...
                httpsTestServer = HttpTestServer.create(HTTP_1_1, sslContext);
        ...
                http2TestServer = HttpTestServer.create(HTTP_2);
        ...
                https2TestServer = HttpTestServer.create(HTTP_2, sslContext);


        The existing test server API will continue to exist. The proposed new APIs are for the default common cases that are used in most of these tests.

              Assignee:
              Jaikiran Pai
              Reporter:
              Jaikiran Pai
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: