@Test(groups = "AllEnv") public void storeを呼び出されたら設定ファイルに保存するよ() throws IOException { ServerProperties.INSTANCE.setWindowLocation(new Point(3, 4)); ServerProperties.INSTANCE.setWindowSize(new Dimension(253, 254)); ServerProperties.INSTANCE.store(C保存可能な設定ファイル.toString()); final List<String> actual = Files.readAllLines(C保存可能な設定ファイル, Charset.forName("UTF-8")); final List<String> expected = Arrays.asList( "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>", "<!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.dtd\">", "<properties>", "<comment>Properties File for Boardgame Server</comment>", "<entry key=\"WINDOW_H\">254</entry>", "<entry key=\"WINDOW_Y\">4</entry>", "<entry key=\"WINDOW_X\">3</entry>", "<entry key=\"WINDOW_W\">253</entry>", "</properties>"); assertEquals(actual, expected); }
@Test(groups = "AllEnv", expectedExceptions = IllegalArgumentException.class) public void storeが呼び出されたけど設定ファイルが書き込み不能な時はIllegalArgumentExceptionをスローするよ() throws IOException { ServerProperties.INSTANCE.setWindowLocation(new Point(1, 1)); ServerProperties.INSTANCE.store(C設定ファイルが書き込み不能だった.toString()); }
@Test(groups = "AllEnv", expectedExceptions = IllegalArgumentException.class) public void storeが呼び出されたけど設定ファイルと同名のフォルダがあって書き込めない時はIllegalArgumentExceptionをスローするよ() throws IOException { ServerProperties.INSTANCE.setWindowLocation(new Point(1, 1)); ServerProperties.INSTANCE.store(C書き込める設定ファイルかと思ったらディレクトリだった.toString()); }
@Test(groups = "AllEnv", expectedExceptions = IllegalArgumentException.class) public void storeの引数に指定されたファイル名の拡張子がxmlじゃなかったらIllegalArgumentExceptionをスローするよ() throws IOException { ServerProperties.INSTANCE.store("test.txt"); }
@Test(groups = "AllEnv", expectedExceptions = IllegalArgumentException.class) public void storeの引数にnullを指定されたらIllegalArgumentExceptionをスローするよ() throws IOException { ServerProperties.INSTANCE.store(null); }