|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| package org.jconfig.handler; |
|
9 |
| |
|
10 |
| import junit.framework.Test; |
|
11 |
| import junit.framework.TestCase; |
|
12 |
| import junit.framework.TestSuite; |
|
13 |
| |
|
14 |
| import org.jconfig.Configuration; |
|
15 |
| import org.jconfig.parser.DefaultConfigParser; |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| public class InputStreamHandlerTest extends TestCase { |
|
22 |
| |
|
23 |
1
| public InputStreamHandlerTest(java.lang.String testName) {
|
|
24 |
1
| super(testName);
|
|
25 |
| } |
|
26 |
| |
|
27 |
0
| public static void main(java.lang.String[] args) {
|
|
28 |
0
| System.setProperty("jconfig.parser", DefaultConfigParser.class.getName());
|
|
29 |
0
| junit.textui.TestRunner.run(suite());
|
|
30 |
| } |
|
31 |
| |
|
32 |
0
| public static Test suite() {
|
|
33 |
0
| TestSuite suite = new TestSuite(InputStreamHandlerTest.class);
|
|
34 |
0
| return suite;
|
|
35 |
| } |
|
36 |
| |
|
37 |
1
| public void testLoad() {
|
|
38 |
1
| InputStreamHandler cHandler = new InputStreamHandler();
|
|
39 |
1
| cHandler.setFileName("test.xml");
|
|
40 |
1
| try {
|
|
41 |
1
| Configuration config = cHandler.load("test");
|
|
42 |
1
| assertNotNull(config);
|
|
43 |
1
| String test = config.getProperty("USER",null,"JDBC");
|
|
44 |
1
| assertEquals("dice",test);
|
|
45 |
1
| cHandler.setEncoding("iso-8859-1");
|
|
46 |
1
| config.setProperty("PWD","for me","JDBC");
|
|
47 |
| |
|
48 |
1
| String val = config.getProperty("varprop1",null,"includeTest");
|
|
49 |
1
| assertNotNull(val);
|
|
50 |
1
| assertEquals("value1",val);
|
|
51 |
1
| cHandler.store(config);
|
|
52 |
| } |
|
53 |
| catch (Exception e) { |
|
54 |
0
| e.printStackTrace();
|
|
55 |
0
| fail("unexpected exception");
|
|
56 |
| } |
|
57 |
| } |
|
58 |
| |
|
59 |
| } |