Starting statistics, adding parameter to UI.main so you have to specify where is statistics module running statistics-and-elo
authorMartin Rexa <martin.rexa@centrum.cz>
Thu, 07 Jan 2010 22:57:43 +0100
branchstatistics-and-elo
changeset 180c92831d4812c
parent 179 c5fbddc4c590
child 181 e3fb438103e0
Starting statistics, adding parameter to UI.main so you have to specify where is statistics module running
freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java
freemarkerdor/src/test/java/cz/xelfi/quoridor/freemarkerdor/UITest.java
     1.1 --- a/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java	Thu Jan 07 22:51:17 2010 +0100
     1.2 +++ b/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java	Thu Jan 07 22:57:43 2010 +0100
     1.3 @@ -447,12 +447,13 @@
     1.4              port = Integer.parseInt(args[0]);
     1.5          }
     1.6          String remoteAPI = args.length >= 2 ? args[1] : null;
     1.7 +        String remoteStatistics = args.length >= 3 ? args[2] : null;
     1.8  
     1.9          Locale.setDefault(Locale.ROOT);
    1.10  
    1.11 -        Callable<Void> r = startServers(port, remoteAPI);
    1.12 +        Callable<Void> r = startServers(port, remoteAPI, remoteStatistics);
    1.13  
    1.14 -        if (args.length < 2 || !args[args.length - 1].equals("--kill")) {
    1.15 +        if (args.length < 3 || !args[args.length - 1].equals("--kill")) {
    1.16              System.out.println("Hit enter to stop it...");
    1.17              System.in.read();
    1.18          } else {
    1.19 @@ -464,7 +465,7 @@
    1.20          System.exit(0);
    1.21      }
    1.22  
    1.23 -    static Callable<Void> startServers(int port, String remoteAPI) throws Exception {
    1.24 +    static Callable<Void> startServers(int port, String remoteAPI, String remoteStatistics) throws Exception {
    1.25          Client client = new Client();
    1.26          Client client1 = new Client();
    1.27  
    1.28 @@ -473,8 +474,13 @@
    1.29              throw new IllegalArgumentException("Provide URL to API server"); // NOI18N
    1.30          } else {
    1.31              base = client.resource(new URI(remoteAPI));
    1.32 +            apiServer = null;
    1.33 +        }
    1.34 +
    1.35 +        if (remoteStatistics == null) {
    1.36 +            throw new IllegalArgumentException("Provide URL to API server"); // NOI18N
    1.37 +        } else {
    1.38              stat = client1.resource(new URI("http://localhost:9444"));
    1.39 -            apiServer = null;
    1.40          }
    1.41  
    1.42          ResourceConfig rc = new PackagesResourceConfig(
     2.1 --- a/freemarkerdor/src/test/java/cz/xelfi/quoridor/freemarkerdor/UITest.java	Thu Jan 07 22:51:17 2010 +0100
     2.2 +++ b/freemarkerdor/src/test/java/cz/xelfi/quoridor/freemarkerdor/UITest.java	Thu Jan 07 22:57:43 2010 +0100
     2.3 @@ -33,6 +33,7 @@
     2.4  import com.sun.jersey.core.util.MultivaluedMapImpl;
     2.5  import com.sun.net.httpserver.HttpServer;
     2.6  import cz.xelfi.quoridor.webidor.resources.Quoridor;
     2.7 +import cz.xelfi.quoridor.statistics.resources.Statistics;
     2.8  import java.awt.Image;
     2.9  import java.io.File;
    2.10  import java.io.FileOutputStream;
    2.11 @@ -59,9 +60,11 @@
    2.12  public class UITest extends Object {
    2.13      private static File dir;
    2.14      private static HttpServer stopAPI;
    2.15 +    private static HttpServer stopStatistics;
    2.16      private static Callable<Void> stop;
    2.17      private WebResource webResource;
    2.18      private WebResource apiResource;
    2.19 +    private WebResource statResource;
    2.20  
    2.21      public UITest() throws Exception {
    2.22      }
    2.23 @@ -74,7 +77,8 @@
    2.24          dir.mkdirs();
    2.25          System.setProperty("quoridor.dir", dir.getPath());
    2.26          stopAPI = Quoridor.start(9990);
    2.27 -        stop = UI.startServers(9991, "http://localhost:9990");
    2.28 +        stopStatistics = Quoridor.start(9992);
    2.29 +        stop = UI.startServers(9991, "http://localhost:9990", "http://localhost:9992");
    2.30  
    2.31          File passwd = new File(dir, "passwd");
    2.32          FileOutputStream os = new FileOutputStream(passwd);
    2.33 @@ -88,6 +92,7 @@
    2.34          Client client = new Client();
    2.35          webResource = client.resource(new URI("http://localhost:9991/"));
    2.36          apiResource = client.resource(new URI("http://localhost:9990/"));
    2.37 +        statResource = client.resource(new URI("http://localhost:9992/"));
    2.38      }
    2.39  
    2.40      @AfterClass
    2.41 @@ -126,6 +131,12 @@
    2.42          assertTrue(serviceWadl.length() > 0);
    2.43      }
    2.44  
    2.45 +    @Test public void testStatWadl() {
    2.46 +        String serviceWadl = statResource.path("application.wadl").
    2.47 +                accept(MediaTypes.WADL).get(String.class);
    2.48 +        assertTrue(serviceWadl.length() > 0);
    2.49 +    }
    2.50 +
    2.51      @Test public void testGetIndexPage() throws Exception {
    2.52          String logJarda = apiResource.path("login").
    2.53              queryParam("name", "Jarda").