# HG changeset patch # User Jaroslav Tulach # Date 1252389252 -7200 # Node ID 5f081edc85026153cc871c02b34b1995c10386aa # Parent 2bb77e95034760f1fe0b353436af14bcac39cfad Running the API server and the HTML generator in the same container diff -r 2bb77e950347 -r 5f081edc8502 freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java --- a/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Tue Sep 08 07:45:59 2009 +0200 +++ b/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Tue Sep 08 07:54:12 2009 +0200 @@ -215,30 +215,32 @@ } static Callable startServers(int port) throws Exception { - final HttpServer api = Quoridor.start(port + 1); + File home = new File(System.getProperty("user.home")); + File quoridor = new File(home, ".quoridor"); + + System.setProperty("quoridor.dir", quoridor.getPath()); + + ResourceConfig rc = new PackagesResourceConfig( + "cz.xelfi.quoridor.webidor", + "cz.xelfi.quoridor.freemarkerdor" + ); + Client client = new Client(); - base = client.resource(new URI("http://localhost:" + (port + 1) + "/api/")); + base = client.resource(new URI("http://localhost:" + port + "/api/")); - final HttpServer s = start(port); + final String baseUri = "http://localhost:" + port + "/"; + final HttpServer server = HttpServerFactory.create(baseUri, rc); + server.start(); System.out.println("Quoridor started at port " + port); return new Callable() { public Void call() throws Exception { - s.stop(0); - api.stop(0); + server.stop(0); return null; } }; } - static HttpServer start(int port) throws IOException { - final String baseUri = "http://localhost:" + port + "/"; - ResourceConfig rc = new PackagesResourceConfig("cz.xelfi.quoridor.freemarkerdor"); - HttpServer server = HttpServerFactory.create(baseUri, rc); - server.start(); - return server; - } - private Viewable viewable(String page, Document doc, Object... more) { String bundle = page.split("\\.")[0]; diff -r 2bb77e950347 -r 5f081edc8502 freemarkerdor/src/test/java/cz/xelfi/quoridor/freemarkerdor/UITest.java --- a/freemarkerdor/src/test/java/cz/xelfi/quoridor/freemarkerdor/UITest.java Tue Sep 08 07:45:59 2009 +0200 +++ b/freemarkerdor/src/test/java/cz/xelfi/quoridor/freemarkerdor/UITest.java Tue Sep 08 07:54:12 2009 +0200 @@ -108,7 +108,7 @@ if (res.indexOf("Login") == -1) { fail("Wrong index.html:\n" + res); } - if (res.indexOf("action=\"login\"") == -1) { + if (res.indexOf("action=\"/login\"") == -1) { fail("Wrong index.html:\n" + res); } if (res.toLowerCase().indexOf("error") != -1) {