use of com.sun.net.httpserver.HttpServer in project cloudstack by apache.
the class ConsoleProxy method startupHttpCmdPort.
private static void startupHttpCmdPort() {
try {
s_logger.info("Listening for HTTP CMDs on port " + httpCmdListenPort);
HttpServer cmdServer = HttpServer.create(new InetSocketAddress(httpCmdListenPort), 2);
cmdServer.createContext("/cmd", new ConsoleProxyCmdHandler());
// creates a default executor
cmdServer.setExecutor(new ThreadExecutor());
cmdServer.start();
} catch (Exception e) {
s_logger.error(e.getMessage(), e);
System.exit(1);
}
}
use of com.sun.net.httpserver.HttpServer in project ceylon-compiler by ceylon.
the class CMRHTTPTests method testMdlHTTPRepos.
@Test
public void testMdlHTTPRepos() throws IOException {
RequestCounter rq = new RequestCounter();
String moduleA = "com.redhat.ceylon.compiler.java.test.cmr.modules.depend.a";
// Clean up any cached version
File carFileInCache = getModuleArchive(moduleA, "6.6.6", cacheDir);
if (carFileInCache.exists())
carFileInCache.delete();
// Compile the first module in its own repo
File repo = makeRepo();
Boolean result = getCompilerTask(Arrays.asList("-out", repo.getPath()), "modules/depend/a/module.ceylon", "modules/depend/a/package.ceylon", "modules/depend/a/A.ceylon").call();
Assert.assertEquals(Boolean.TRUE, result);
File carFile = getModuleArchive(moduleA, "6.6.6", repo.getPath());
assertTrue(carFile.exists());
final int port = allocPortForTest();
final String repoAURL = getRepoUrl(port);
// now serve the first repo over HTTP
HttpServer server = startServer(port, repo, false, rq);
try {
// then try to compile only one module (the other being loaded from its car)
result = getCompilerTask(Arrays.asList("-out", destDir, "-rep", repoAURL, "-verbose:cmr", "-cp", getClassPathAsPath()), "modules/depend/b/module.ceylon", "modules/depend/b/package.ceylon", "modules/depend/b/a.ceylon", "modules/depend/b/B.ceylon").call();
Assert.assertEquals(Boolean.TRUE, result);
} finally {
server.stop(1);
}
carFile = getModuleArchive("com.redhat.ceylon.compiler.java.test.cmr.modules.depend.b", "6.6.6");
assertTrue(carFile.exists());
// make sure it cached the module in the cache repo
assertTrue(carFileInCache.exists());
// make sure it didn't cache it in the output repo
carFile = getModuleArchive(moduleA, "6.6.6");
assertFalse(carFile.exists());
rq.check(37);
}
use of com.sun.net.httpserver.HttpServer 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