OSDN Git Service

7421ed334c5088c30a873b32b19d7cb2ce9602d5
[coroid/inqubus.git] / frontend / test / yukihane / inqubus / config / PropertiesTest.java
1 package yukihane.inqubus.config;
2
3 import java.io.File;
4 import static org.junit.Assert.*;
5
6 import java.nio.file.FileSystem;
7 import java.nio.file.FileSystems;
8 import org.apache.commons.configuration.ConfigurationException;
9 import org.junit.Test;
10
11 /**
12  *
13  * @author yuki
14  */
15 public class PropertiesTest {
16
17     @Test
18     public void testLoadFail() {
19         FileSystem fs = FileSystems.getDefault();
20         System.out.println(fs.getPath(".").toAbsolutePath());
21         Properties p = Properties.INSTANCE;
22         try {
23             p.load("test/testdata/error.xml");
24             fail("ファイルが存在しないので読み込みに失敗するはず");
25         } catch (ConfigurationException ex) {
26         }
27         try{
28             p.load("test/testdata/inqubus_test.xml");
29             fail("ファイルが空なので読み込みに失敗するはず");
30         } catch (ConfigurationException ex) {
31         }
32     }
33
34 //    @Test
35 //    public void test2() throws ConfigurationException, IllegalArgumentException, IllegalAccessException {
36 //        Properties p = Properties.INSTANCE;
37 //        p.load("test/testdata/inqubus_test.ok");
38 //        p.setDbLocation("d_loc");
39 //        p.save();
40 //        Field[] fields = p.getClass().getDeclaredFields();
41 //        for(Field f: fields){
42 //            f.setAccessible(true);
43 //            System.out.println(f.get(p));
44 //        }
45 //    }
46
47     @Test
48     public void testCreteConfig() throws ConfigurationException{
49         Properties p = Properties.INSTANCE;
50         p.setCommentUseLocal(false);
51         p.save(new File("test/testdata/save.xml"));
52     }
53 }