webidor/src/test/java/cz/xelfi/quoridor/webidor/GamesTest.java
changeset 117 c1057591a344
parent 114 ed560bfe37f0
child 149 a441b02a638a
     1.1 --- a/webidor/src/test/java/cz/xelfi/quoridor/webidor/GamesTest.java	Sat Sep 26 21:47:02 2009 +0200
     1.2 +++ b/webidor/src/test/java/cz/xelfi/quoridor/webidor/GamesTest.java	Thu Oct 01 06:06:55 2009 +0200
     1.3 @@ -31,6 +31,7 @@
     1.4  import java.io.File;
     1.5  import java.io.FileOutputStream;
     1.6  import java.io.IOException;
     1.7 +import java.util.ResourceBundle;
     1.8  import org.junit.After;
     1.9  import org.junit.Before;
    1.10  import org.junit.Test;
    1.11 @@ -112,4 +113,31 @@
    1.12          assertEquals("Last move is last touch of the file", middle, g.getId().getModified());
    1.13      }
    1.14  
    1.15 +    @Test public void testLoadGameWithInternationalComments() throws Exception {
    1.16 +        File f = new File(dir, "x");
    1.17 +        f.getParentFile().mkdirs();
    1.18 +        FileOutputStream os = new FileOutputStream(f);
    1.19 +        ResourceBundle b = ResourceBundle.getBundle("cz/xelfi/quoridor/webidor/TestBundle");
    1.20 +        String comment = b.getString("COMMENT");
    1.21 +        os.write(("# white: W\n# black: B\n# status: IN_PROGRESS\nN\n#" +
    1.22 +                comment + "\n... S # ok move\n\n").getBytes("UTF-8"));
    1.23 +        os.close();
    1.24 +
    1.25 +        Thread.sleep(1000);
    1.26 +
    1.27 +        long middle = f.lastModified();
    1.28 +
    1.29 +        Thread.sleep(1000);
    1.30 +
    1.31 +        Games games = new Games(dir, new Quoridor());
    1.32 +        Game g = games.getBoardInfo("x", -1);
    1.33 +        assertNotNull("Game found", g);
    1.34 +        assertNotNull("Board found", g.getBoard());
    1.35 +        assertEquals("List of moves has two", 2, g.getMoves().size());
    1.36 +        String commentRead = g.getMoves().get(0).getComments().get(0).getComment();
    1.37 +        assertEquals(comment, commentRead);
    1.38 +
    1.39 +        assertEquals("Last move is last touch of the file", middle, g.getId().getModified());
    1.40 +    }
    1.41 +
    1.42  }