1.1 --- a/webidor/src/test/java/cz/xelfi/quoridor/webidor/FinishedGameTest.java Sun Nov 08 10:21:46 2009 +0100
1.2 +++ b/webidor/src/test/java/cz/xelfi/quoridor/webidor/FinishedGameTest.java Tue Dec 08 15:34:50 2009 +0100
1.3 @@ -27,6 +27,7 @@
1.4 package cz.xelfi.quoridor.webidor;
1.5
1.6 import com.sun.jersey.api.client.GenericType;
1.7 +import com.sun.jersey.api.client.UniformInterfaceException;
1.8 import com.sun.jersey.test.framework.JerseyTest;
1.9 import java.io.File;
1.10 import java.io.FileOutputStream;
1.11 @@ -135,7 +136,13 @@
1.12 }
1.13
1.14
1.15 - Game end = webResource.path("games/" + s.getId()).accept(MediaType.TEXT_XML).get(Game.class);
1.16 + try {
1.17 + Game end = webResource.path("games/" + s.getId()).accept(MediaType.TEXT_XML).get(Game.class);
1.18 + fail("If the game is finished, one cannot get its status without login");
1.19 + } catch (UniformInterfaceException ex) {
1.20 + // OK
1.21 + }
1.22 + Game end = webResource.path("games/" + s.getId()).queryParam("loginID", logJirka).accept(MediaType.TEXT_XML).get(Game.class);
1.23 assertEquals("BlackWins", GameStatus.blackWon, end.getId().getStatus());
1.24
1.25 assertEquals("Jirka wins", "Jirka", end.getCurrentPlayer());
1.26 @@ -156,13 +163,23 @@
1.27 .queryParam("loginID", logJarda)
1.28 .queryParam("black", "Jirka").post(GameId.class);
1.29
1.30 + assertTrue("In progress", s.getStatus().isInProgress());
1.31 +
1.32 webResource.path("games/" + s.getId()).
1.33 queryParam("loginID", logJarda).
1.34 queryParam("player", "Jarda").
1.35 queryParam("move", "RESIGN").put(GameId.class);
1.36 - Game end = webResource.path("games/" + s.getId()).accept(MediaType.TEXT_XML).get(Game.class);
1.37 + try {
1.38 + Game end = webResource.path("games/" + s.getId()).accept(MediaType.TEXT_XML).get(Game.class);
1.39 + fail("Should not be able to get game when finished");
1.40 + } catch (UniformInterfaceException ex) {
1.41 + // OK
1.42 + }
1.43 + Game end = webResource.path("games/" + s.getId()).queryParam("loginID", logJarda).accept(MediaType.TEXT_XML).get(Game.class);
1.44 assertEquals("BlackWins", GameStatus.blackWon, end.getId().getStatus());
1.45 assertEquals("Jirka wins", "Jirka", end.getCurrentPlayer());
1.46 +
1.47 + assertFalse("is finished", end.getId().getStatus().isInProgress());
1.48 }
1.49
1.50 }