1 package yukihane.inqubus;
3 import yukihane.inqubus.Config;
5 import static org.junit.Assert.*;
7 import java.nio.file.FileSystem;
8 import java.nio.file.FileSystems;
9 import org.apache.commons.configuration.ConfigurationException;
10 import org.junit.After;
11 import org.junit.Before;
12 import org.junit.Test;
18 public class ConfigTest {
20 private final Config p = Config.INSTANCE;
24 Config.INSTANCE.clear();
28 public void tearDown() {
29 Config.INSTANCE.clear();
33 public void testLoadFail() {
34 FileSystem fs = FileSystems.getDefault();
35 System.out.println(fs.getPath(".").toAbsolutePath());
36 Config p = Config.INSTANCE;
38 p.load("test/testdata/error.xml");
39 fail("ファイルが存在しないので読み込みに失敗するはず");
40 } catch (ConfigurationException ex) {
43 p.load("test/testdata/inqubus_test.xml");
44 fail("ファイルが空なので読み込みに失敗するはず");
45 } catch (ConfigurationException ex) {
50 // public void test2() throws ConfigurationException, IllegalArgumentException, IllegalAccessException {
51 // Properties p = Properties.INSTANCE;
52 // p.load("test/testdata/inqubus_test.ok");
53 // p.setDbLocation("d_loc");
55 // Field[] fields = p.getClass().getDeclaredFields();
56 // for(Field f: fields){
57 // f.setAccessible(true);
58 // System.out.println(f.get(p));
62 public void testGetSetNetworkAccount() {
67 * デフォルト値の取得、設定とその設定値の取得のテストです.
70 public void testGetSetNetworkProxy() throws ConfigurationException {
75 assertEquals("", p.getId());
77 assertEquals("id", p.getId());
79 assertEquals("", p.getPassword());
80 p.setPassword("password");
81 assertEquals("password", p.getPassword());
87 assertEquals(false, p.getProxyUse());
89 assertEquals(true, p.getProxyUse());
91 assertEquals("localhost", p.getProxyHost());
92 p.setProxyHost("proxyhost");
93 assertEquals("proxyhost", p.getProxyHost());
95 assertEquals("8080", p.getProxyPort());
97 assertEquals("80", p.getProxyPort());
103 assertEquals("in/video", p.getVideoDir());
105 assertEquals("v", p.getVideoDir());
107 assertEquals("[{id}]{title}", p.getVideoFileNamePattern());
108 p.setVideoFileNamePattern("videotitle");
109 assertEquals("videotitle", p.getVideoFileNamePattern());
111 assertEquals(false, p.getVideoUseLocal());
112 p.setVideoUseLocal(true);
113 assertEquals(true, p.getVideoUseLocal());
118 assertEquals("in/comment", p.getCommentDir());
119 p.setCommentDir("c");
120 assertEquals("c", p.getCommentDir());
122 assertEquals("[{id}]{title}", p.getCommentFileNamePattern());
123 p.setVideoFileNamePattern("comtitle");
124 assertEquals("comtitle", p.getVideoFileNamePattern());
126 assertEquals(false, p.getCommentUseLocal());
127 p.setCommentUseLocal(true);
128 assertEquals(true, p.getCommentUseLocal());
134 assertEquals("out", p.getOutputDir());
135 p.setOutputDir("_out_");
136 assertEquals("_out_", p.getOutputDir());
138 // p.save(new File("test/testdata/save.xml"));