# HG changeset patch # User Martin Rexa # Date 1262901463 -3600 # Node ID c92831d4812c721d1a22066c4f001d885d0b7751 # Parent c5fbddc4c590216f2f3aafb6d1534f43cf26621e Starting statistics, adding parameter to UI.main so you have to specify where is statistics module running diff -r c5fbddc4c590 -r c92831d4812c freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java --- a/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Thu Jan 07 22:51:17 2010 +0100 +++ b/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Thu Jan 07 22:57:43 2010 +0100 @@ -447,12 +447,13 @@ port = Integer.parseInt(args[0]); } String remoteAPI = args.length >= 2 ? args[1] : null; + String remoteStatistics = args.length >= 3 ? args[2] : null; Locale.setDefault(Locale.ROOT); - Callable r = startServers(port, remoteAPI); + Callable r = startServers(port, remoteAPI, remoteStatistics); - if (args.length < 2 || !args[args.length - 1].equals("--kill")) { + if (args.length < 3 || !args[args.length - 1].equals("--kill")) { System.out.println("Hit enter to stop it..."); System.in.read(); } else { @@ -464,7 +465,7 @@ System.exit(0); } - static Callable startServers(int port, String remoteAPI) throws Exception { + static Callable startServers(int port, String remoteAPI, String remoteStatistics) throws Exception { Client client = new Client(); Client client1 = new Client(); @@ -473,8 +474,13 @@ throw new IllegalArgumentException("Provide URL to API server"); // NOI18N } else { base = client.resource(new URI(remoteAPI)); + apiServer = null; + } + + if (remoteStatistics == null) { + throw new IllegalArgumentException("Provide URL to API server"); // NOI18N + } else { stat = client1.resource(new URI("http://localhost:9444")); - apiServer = null; } ResourceConfig rc = new PackagesResourceConfig( diff -r c5fbddc4c590 -r c92831d4812c freemarkerdor/src/test/java/cz/xelfi/quoridor/freemarkerdor/UITest.java --- a/freemarkerdor/src/test/java/cz/xelfi/quoridor/freemarkerdor/UITest.java Thu Jan 07 22:51:17 2010 +0100 +++ b/freemarkerdor/src/test/java/cz/xelfi/quoridor/freemarkerdor/UITest.java Thu Jan 07 22:57:43 2010 +0100 @@ -33,6 +33,7 @@ import com.sun.jersey.core.util.MultivaluedMapImpl; import com.sun.net.httpserver.HttpServer; import cz.xelfi.quoridor.webidor.resources.Quoridor; +import cz.xelfi.quoridor.statistics.resources.Statistics; import java.awt.Image; import java.io.File; import java.io.FileOutputStream; @@ -59,9 +60,11 @@ public class UITest extends Object { private static File dir; private static HttpServer stopAPI; + private static HttpServer stopStatistics; private static Callable stop; private WebResource webResource; private WebResource apiResource; + private WebResource statResource; public UITest() throws Exception { } @@ -74,7 +77,8 @@ dir.mkdirs(); System.setProperty("quoridor.dir", dir.getPath()); stopAPI = Quoridor.start(9990); - stop = UI.startServers(9991, "http://localhost:9990"); + stopStatistics = Quoridor.start(9992); + stop = UI.startServers(9991, "http://localhost:9990", "http://localhost:9992"); File passwd = new File(dir, "passwd"); FileOutputStream os = new FileOutputStream(passwd); @@ -88,6 +92,7 @@ Client client = new Client(); webResource = client.resource(new URI("http://localhost:9991/")); apiResource = client.resource(new URI("http://localhost:9990/")); + statResource = client.resource(new URI("http://localhost:9992/")); } @AfterClass @@ -126,6 +131,12 @@ assertTrue(serviceWadl.length() > 0); } + @Test public void testStatWadl() { + String serviceWadl = statResource.path("application.wadl"). + accept(MediaTypes.WADL).get(String.class); + assertTrue(serviceWadl.length() > 0); + } + @Test public void testGetIndexPage() throws Exception { String logJarda = apiResource.path("login"). queryParam("name", "Jarda").