import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import org.apache.commons.configuration.ConfigurationException;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
/**
*/
public class PropertiesTest {
+ private final Properties p = Properties.INSTANCE;
+
+ @Before
+ public void setUp() {
+ Properties.INSTANCE.clear();
+ }
+
+ @After
+ public void tearDown() {
+ Properties.INSTANCE.clear();
+ }
+
@Test
public void testLoadFail() {
FileSystem fs = FileSystems.getDefault();
fail("ファイルが存在しないので読み込みに失敗するはず");
} catch (ConfigurationException ex) {
}
- try{
+ try {
p.load("test/testdata/inqubus_test.xml");
fail("ファイルが空なので読み込みに失敗するはず");
} catch (ConfigurationException ex) {
// System.out.println(f.get(p));
// }
// }
+ @Test
+ public void testGetSetNetworkAccount() {
+ }
+ /**
+ * コンフィグ取得・設定テストケース.
+ * デフォルト値の取得、設定とその設定値の取得のテストです.
+ */
@Test
- public void testCreteConfig() throws ConfigurationException{
- Properties p = Properties.INSTANCE;
- p.setCommentDownload(true);
- p.save(new File("test/testdata/save.xml"));
+ public void testGetSetNetworkProxy() throws ConfigurationException {
+
+ /*
+ * ネットワーク - アカウント
+ */
+ assertEquals("", p.getId());
+ p.setId("id");
+ assertEquals("id", p.getId());
+
+ assertEquals("", p.getPassword());
+ p.setPassword("password");
+ assertEquals("password", p.getPassword());
+
+
+ /*
+ * ネットワーク - プロキシ
+ */
+ assertEquals(false, p.getUseProxy());
+ p.setUseProxy(true);
+ assertEquals(true, p.getUseProxy());
+
+ assertEquals("localhost", p.getProxyHost());
+ p.setProxyHost("proxyhost");
+ assertEquals("proxyhost", p.getProxyHost());
+
+ assertEquals("8080", p.getProxyPort());
+ p.setProxyPort("80");
+ assertEquals("80", p.getProxyPort());
+
+
+ /*
+ * ファイル - 動画
+ */
+ assertEquals("in/video", p.getVideoDir());
+ p.setVideoDir("v");
+ assertEquals("v", p.getVideoDir());
+
+ assertEquals("[{id}]{title}", p.getVideoFileNamePattern());
+ p.setVideoFileNamePattern("videotitle");
+ assertEquals("videotitle", p.getVideoFileNamePattern());
+
+ assertEquals(false, p.getVideoUseLocal());
+ p.setVideoUseLocal(true);
+ assertEquals(true, p.getVideoUseLocal());
+
+ /*
+ * ファイル - コメント
+ */
+ assertEquals("in/comment", p.getCommentDir());
+ p.setCommentDir("c");
+ assertEquals("c", p.getCommentDir());
+
+ assertEquals("[{id}]{title}", p.getCommentFileNamePattern());
+ p.setVideoFileNamePattern("comtitle");
+ assertEquals("comtitle", p.getVideoFileNamePattern());
+
+ assertEquals(false, p.getCommentUseLocal());
+ p.setCommentUseLocal(true);
+ assertEquals(true, p.getCommentUseLocal());
+
+
+ /*
+ * ファイル - 変換動画
+ */
+ assertEquals("out", p.getOutputDir());
+ p.setOutputDir("_out_");
+ assertEquals("_out_", p.getOutputDir());
+
+// p.save(new File("test/testdata/save.xml"));
}
}