use of com.sun.net.httpserver.HttpExchange 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);
}
}
Aggregations