1 package yukihane.inqubus.config;
4 import static org.junit.Assert.*;
6 import java.nio.file.FileSystem;
7 import java.nio.file.FileSystems;
8 import org.apache.commons.configuration.ConfigurationException;
9 import org.junit.After;
10 import org.junit.Before;
11 import org.junit.Test;
17 public class PropertiesTest {
19 private final Properties p = Properties.INSTANCE;
23 Properties.INSTANCE.clear();
27 public void tearDown() {
28 Properties.INSTANCE.clear();
32 public void testLoadFail() {
33 FileSystem fs = FileSystems.getDefault();
34 System.out.println(fs.getPath(".").toAbsolutePath());
35 Properties p = Properties.INSTANCE;
37 p.load("test/testdata/error.xml");
38 fail("ファイルが存在しないので読み込みに失敗するはず");
39 } catch (ConfigurationException ex) {
42 p.load("test/testdata/inqubus_test.xml");
43 fail("ファイルが空なので読み込みに失敗するはず");
44 } catch (ConfigurationException ex) {
49 // public void test2() throws ConfigurationException, IllegalArgumentException, IllegalAccessException {
50 // Properties p = Properties.INSTANCE;
51 // p.load("test/testdata/inqubus_test.ok");
52 // p.setDbLocation("d_loc");
54 // Field[] fields = p.getClass().getDeclaredFields();
55 // for(Field f: fields){
56 // f.setAccessible(true);
57 // System.out.println(f.get(p));
61 public void testGetSetNetworkAccount() {
66 * デフォルト値の取得、設定とその設定値の取得のテストです.
69 public void testGetSetNetworkProxy() throws ConfigurationException {
74 assertEquals("", p.getId());
76 assertEquals("id", p.getId());
78 assertEquals("", p.getPassword());
79 p.setPassword("password");
80 assertEquals("password", p.getPassword());
86 assertEquals(false, p.getUseProxy());
88 assertEquals(true, p.getUseProxy());
90 assertEquals("localhost", p.getProxyHost());
91 p.setProxyHost("proxyhost");
92 assertEquals("proxyhost", p.getProxyHost());
94 assertEquals("8080", p.getProxyPort());
96 assertEquals("80", p.getProxyPort());
102 assertEquals("in/video", p.getVideoDir());
104 assertEquals("v", p.getVideoDir());
106 assertEquals("[{id}]{title}", p.getVideoFileNamePattern());
107 p.setVideoFileNamePattern("videotitle");
108 assertEquals("videotitle", p.getVideoFileNamePattern());
110 assertEquals(false, p.getVideoUseLocal());
111 p.setVideoUseLocal(true);
112 assertEquals(true, p.getVideoUseLocal());
117 assertEquals("in/comment", p.getCommentDir());
118 p.setCommentDir("c");
119 assertEquals("c", p.getCommentDir());
121 assertEquals("[{id}]{title}", p.getCommentFileNamePattern());
122 p.setVideoFileNamePattern("comtitle");
123 assertEquals("comtitle", p.getVideoFileNamePattern());
125 assertEquals(false, p.getCommentUseLocal());
126 p.setCommentUseLocal(true);
127 assertEquals(true, p.getCommentUseLocal());
133 assertEquals("out", p.getOutputDir());
134 p.setOutputDir("_out_");
135 assertEquals("_out_", p.getOutputDir());
137 // p.save(new File("test/testdata/save.xml"));