# HG changeset patch # User Jaroslav Tulach # Date 1252338223 -7200 # Node ID 33cf89760fabf7fa2fb828a995830cd6933fac1a # Parent f5741fe21fe6d722d4f587be8ef6f5a7f6e06e02 Pluggable argument with reference to port diff -r f5741fe21fe6 -r 33cf89760fab freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java --- a/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Mon Sep 07 17:03:46 2009 +0200 +++ b/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Mon Sep 07 17:43:43 2009 +0200 @@ -193,22 +193,33 @@ // public static void main(String[] args) throws Exception { - Callable r = startServers(); + int port = 9998; + if (args.length > 1) { + port = Integer.parseInt(args[0]); + } - System.in.read(); + + Callable r = startServers(port); + + if (args.length > 2 && args[1].equals("--kill")) { + System.out.println("Hit enter to stop it..."); + System.in.read(); + } else { + synchronized (UI.class) { + UI.class.wait(); + } + } r.call(); System.exit(0); } - static Callable startServers() throws Exception { - final HttpServer api = Quoridor.start(9998); + static Callable startServers(int port) throws Exception { + final HttpServer api = Quoridor.start(port + 1); Client client = new Client(); - base = client.resource(new URI("http://localhost:9998/api/")); + base = client.resource(new URI("http://localhost:" + (port + 1) + "/api/")); - final HttpServer s = start(9997); - System.out.println( - "Quoridor started at port 9997\n" + "Hit enter to stop it..." - ); + final HttpServer s = start(port); + System.out.println("Quoridor started at port " + port); return new Callable() { public Void call() throws Exception { diff -r f5741fe21fe6 -r 33cf89760fab freemarkerdor/src/test/java/cz/xelfi/quoridor/freemarkerdor/UITest.java --- a/freemarkerdor/src/test/java/cz/xelfi/quoridor/freemarkerdor/UITest.java Mon Sep 07 17:03:46 2009 +0200 +++ b/freemarkerdor/src/test/java/cz/xelfi/quoridor/freemarkerdor/UITest.java Mon Sep 07 17:43:43 2009 +0200 @@ -63,10 +63,10 @@ dir = File.createTempFile("quoridor", ".dir"); dir.delete(); System.setProperty("quoridor.dir", dir.getPath()); - stop = UI.startServers(); + stop = UI.startServers(9991); Client client = new Client(); - webResource = client.resource(new URI("http://localhost:9997/")); + webResource = client.resource(new URI("http://localhost:9991/")); } @After