Search in sources :

Example 16 with HttpHandler

use of com.sun.net.httpserver.HttpHandler in project ceylon-compiler by ceylon.

the class CeylonDocToolTests method externalLinksToRemoteRepoWithoutModuleNamePattern.

@Test
public void externalLinksToRemoteRepoWithoutModuleNamePattern() throws Exception {
    HttpServer stubServer = HttpServer.create(new InetSocketAddress(0), 1);
    stubServer.createContext("/repo", new HttpHandler() {

        @Override
        public void handle(HttpExchange httpExchange) throws IOException {
            if (httpExchange.getRequestMethod().equals("HEAD")) {
                httpExchange.sendResponseHeaders(HttpURLConnection.HTTP_OK, -1);
            } else {
                httpExchange.sendResponseHeaders(HttpURLConnection.HTTP_NOT_IMPLEMENTED, -1);
            }
            httpExchange.close();
        }
    });
    stubServer.start();
    try {
        String repoUrl = "http://localhost:" + stubServer.getAddress().getPort() + "/repo";
        externalLinks(repoUrl, "file://not-existing-dir", "https://not-existing-url", repoUrl);
    } finally {
        stubServer.stop(0);
    }
}
Also used : HttpHandler(com.sun.net.httpserver.HttpHandler) InetSocketAddress(java.net.InetSocketAddress) HttpServer(com.sun.net.httpserver.HttpServer) HttpExchange(com.sun.net.httpserver.HttpExchange) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

HttpHandler (com.sun.net.httpserver.HttpHandler)16 HttpExchange (com.sun.net.httpserver.HttpExchange)12 InetSocketAddress (java.net.InetSocketAddress)12 HttpServer (com.sun.net.httpserver.HttpServer)9 IOException (java.io.IOException)8 OutputStream (java.io.OutputStream)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 HttpContext (com.sun.net.httpserver.HttpContext)2 Set (java.util.Set)2 ExecutorService (java.util.concurrent.ExecutorService)2 Test (org.junit.Test)2 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 SegmentSizeInfo (com.linkedin.pinot.common.restlet.resources.SegmentSizeInfo)1 TableSizeInfo (com.linkedin.pinot.common.restlet.resources.TableSizeInfo)1 HttpFutureCallback (com.microsoft.azure.hdinsight.common.HttpFutureCallback)1 MultiHttpFutureCallback (com.microsoft.azure.hdinsight.common.MultiHttpFutureCallback)1 IClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail)1 BasicAuthenticator (com.sun.net.httpserver.BasicAuthenticator)1 Headers (com.sun.net.httpserver.Headers)1 HttpsConfigurator (com.sun.net.httpserver.HttpsConfigurator)1