# HG changeset patch # User Jaroslav Tulach # Date 1253478825 -7200 # Node ID 7d090f2c5b91820985e6b3524d1bf75b9b964575 # Parent 6e55d5c85d3cac7eb0349a2404ef86f60cf7b90e Fixing the history of images. Testing that images are present and readable in the game page. diff -r 6e55d5c85d3c -r 7d090f2c5b91 freemarkerdor/pom.xml --- a/freemarkerdor/pom.xml Sun Sep 20 20:04:41 2009 +0200 +++ b/freemarkerdor/pom.xml Sun Sep 20 22:33:45 2009 +0200 @@ -10,13 +10,13 @@ org.apidesign freemarkerdor freemarkerdor - 1.18 + 1.19 http://maven.apache.org ${project.groupId} webidor - 1.2 + 1.3 org.netbeans.modules diff -r 6e55d5c85d3c -r 7d090f2c5b91 freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java --- a/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Sun Sep 20 20:04:41 2009 +0200 +++ b/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java Sun Sep 20 22:33:45 2009 +0200 @@ -154,7 +154,7 @@ ) throws IllegalPositionException { WebResource wr = base.path("games").path(id); if (move != -1) { - wr.queryParam("move", "" + move); + wr = wr.queryParam("move", "" + move); } String txt = wr.accept(MediaType.TEXT_PLAIN).get(String.class); Board b = Board.valueOf(txt); diff -r 6e55d5c85d3c -r 7d090f2c5b91 freemarkerdor/src/test/java/cz/xelfi/quoridor/freemarkerdor/UITest.java --- a/freemarkerdor/src/test/java/cz/xelfi/quoridor/freemarkerdor/UITest.java Sun Sep 20 20:04:41 2009 +0200 +++ b/freemarkerdor/src/test/java/cz/xelfi/quoridor/freemarkerdor/UITest.java Sun Sep 20 22:33:45 2009 +0200 @@ -31,12 +31,16 @@ import com.sun.jersey.api.client.WebResource; import com.sun.jersey.core.header.MediaTypes; import com.sun.jersey.core.util.MultivaluedMapImpl; +import java.awt.Image; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.net.URI; import java.util.Locale; import java.util.concurrent.Callable; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.ws.rs.core.Cookie; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; @@ -178,8 +182,13 @@ queryParam("password", "pes"). accept(MediaType.TEXT_PLAIN). put(String.class); + String logJarda = webResource.path("api/login"). + queryParam("name", "Jarda"). + queryParam("password", "darda"). + accept(MediaType.TEXT_PLAIN). + put(String.class); ClientResponse res = webResource.path("games/create"). - queryParam("white", "unknown1"). + queryParam("white", "Jarda"). queryParam("black", "test"). cookie(Cookie.valueOf("login=" + logTest)). accept("text/html"). @@ -194,6 +203,57 @@ if (txt.indexOf(games[0]) == -1) { fail(games[0] + " expected inside of:\n" + txt); } + + ClientResponse page = webResource.path("games/" + games[0]). + cookie(Cookie.valueOf("login=" + logJarda)). + get(ClientResponse.class); + String ptxt = page.getEntity(String.class); + assertEquals("OK:\n" + ptxt, ClientResponse.Status.OK, page.getClientResponseStatus()); + + Pattern p = Pattern.compile(".*org.apidesign webidor jar - 1.2 + 1.3 webidor server http://maven.apache.org diff -r 6e55d5c85d3c -r 7d090f2c5b91 webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Games.java --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Games.java Sun Sep 20 20:04:41 2009 +0200 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Games.java Sun Sep 20 22:33:45 2009 +0200 @@ -110,8 +110,11 @@ @GET @Path("{id}") @Produces(MediaType.TEXT_PLAIN) - public String getBoard(@PathParam("id") String id) { - Game g = findGame(id); + public String getBoard( + @PathParam("id") String id, + @QueryParam("move") @DefaultValue("-1") int move + ) { + Game g = findGame(id, move); if (g == null) { throw new IllegalArgumentException("Unknown game " + id); }