1.1 --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Games.java Wed Jul 29 17:24:20 2009 +0200
1.2 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Games.java Wed Jul 29 18:48:04 2009 +0200
1.3 @@ -37,6 +37,7 @@
1.4 import java.io.IOException;
1.5 import java.io.PrintWriter;
1.6 import java.util.ArrayList;
1.7 +import java.util.Arrays;
1.8 import java.util.List;
1.9 import java.util.logging.Level;
1.10 import java.util.logging.Logger;
1.11 @@ -148,6 +149,10 @@
1.12 if (line == null) {
1.13 break;
1.14 }
1.15 + line = line.trim();
1.16 + if (line.length() == 0) {
1.17 + continue;
1.18 + }
1.19 if (line.startsWith("# white: ")) {
1.20 white = line.substring(9);
1.21 continue;
2.1 --- a/webidor/src/test/java/cz/xelfi/quoridor/webidor/QuoridorTest.java Wed Jul 29 17:24:20 2009 +0200
2.2 +++ b/webidor/src/test/java/cz/xelfi/quoridor/webidor/QuoridorTest.java Wed Jul 29 18:48:04 2009 +0200
2.3 @@ -30,10 +30,13 @@
2.4 import com.sun.jersey.api.client.UniformInterfaceException;
2.5 import com.sun.jersey.core.header.MediaTypes;
2.6 import com.sun.jersey.test.framework.JerseyTest;
2.7 +import cz.xelfi.quoridor.Board;
2.8 +import cz.xelfi.quoridor.Move;
2.9 +import cz.xelfi.quoridor.webidor.resources.Games;
2.10 +import cz.xelfi.quoridor.webidor.resources.Quoridor;
2.11 import java.io.File;
2.12 import java.io.FileReader;
2.13 import java.io.IOException;
2.14 -import java.util.Arrays;
2.15 import java.util.List;
2.16 import org.junit.Test;
2.17 import static org.junit.Assert.*;
2.18 @@ -133,6 +136,15 @@
2.19 if (!content.contains("N S")) {
2.20 fail(content);
2.21 }
2.22 +
2.23 + Games read = new Games(new File(dir, "games"));
2.24 + List<Game> readGames = read.getGames();
2.25 + assertEquals("One game read", 1, readGames.size());
2.26 + Board board = read.getGames().get(0).getBoard();
2.27 + assertEquals(1, board.getPlayers().get(0).getRow());
2.28 + assertEquals(7, board.getPlayers().get(1).getRow());
2.29 + assertEquals(Move.NORTH, read.getGames().get(0).getMoves().get(0));
2.30 + assertEquals(Move.SOUTH, read.getGames().get(0).getMoves().get(1));
2.31 }
2.32
2.33 }