OSDN Git Service

コンフィグ読み書きテストケース
[coroid/inqubus.git] / frontend / test / yukihane / inqubus / config / PropertiesTest.java
index 7421ed3..c06a010 100644 (file)
@@ -6,6 +6,8 @@ import static org.junit.Assert.*;
 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;
 
 /**
@@ -14,6 +16,18 @@ 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();
@@ -24,7 +38,7 @@ public class PropertiesTest {
             fail("ファイルが存在しないので読み込みに失敗するはず");
         } catch (ConfigurationException ex) {
         }
-        try{
+        try {
             p.load("test/testdata/inqubus_test.xml");
             fail("ファイルが空なので読み込みに失敗するはず");
         } catch (ConfigurationException ex) {
@@ -43,11 +57,83 @@ public class PropertiesTest {
 //            System.out.println(f.get(p));
 //        }
 //    }
+    @Test
+    public void testGetSetNetworkAccount() {
+    }
 
+    /**
+     * コンフィグ取得・設定テストケース.
+     * デフォルト値の取得、設定とその設定値の取得のテストです.
+     */
     @Test
-    public void testCreteConfig() throws ConfigurationException{
-        Properties p = Properties.INSTANCE;
-        p.setCommentUseLocal(false);
-        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"));
     }
 }