Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8303457

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

    XMLWordPrintable

Details

    • b13

    Backports

      Description

        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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                  Created:
                  Updated:
                  Resolved: