|
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 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| public class ScriptHandlerTest extends TestCase { |
|
21 |
| |
|
22 |
2
| public ScriptHandlerTest(java.lang.String testName) {
|
|
23 |
2
| super(testName);
|
|
24 |
| } |
|
25 |
| |
|
26 |
0
| public static void main(java.lang.String[] args) {
|
|
27 |
0
| junit.textui.TestRunner.run(suite());
|
|
28 |
| } |
|
29 |
| |
|
30 |
0
| public static Test suite() {
|
|
31 |
0
| TestSuite suite = new TestSuite(ScriptHandlerTest.class);
|
|
32 |
0
| return suite;
|
|
33 |
| } |
|
34 |
| |
|
35 |
1
| public void testLoad() {
|
|
36 |
1
| ScriptHandler scriptHandler = new ScriptHandler();
|
|
37 |
1
| try {
|
|
38 |
1
| Configuration cfg = scriptHandler.load("test");
|
|
39 |
1
| assertNotNull(cfg);
|
|
40 |
1
| String val = cfg.getProperty("hello");
|
|
41 |
1
| assertEquals("world",val);
|
|
42 |
1
| val = cfg.getProperty("more",null,"special");
|
|
43 |
1
| assertEquals("override",val);
|
|
44 |
1
| val = cfg.getProperty("more",null,"stuff");
|
|
45 |
1
| assertEquals("override",val);
|
|
46 |
1
| val = cfg.getProperty("my crap",null,"stuff");
|
|
47 |
1
| assertEquals("is real crap",val);
|
|
48 |
| |
|
49 |
| } |
|
50 |
| catch (Exception e) { |
|
51 |
0
| e.printStackTrace();
|
|
52 |
0
| fail("unexpected exception");
|
|
53 |
| } |
|
54 |
| } |
|
55 |
| |
|
56 |
1
| public void testBrokenFile() {
|
|
57 |
1
| ScriptHandler scriptHandler = new ScriptHandler();
|
|
58 |
1
| try {
|
|
59 |
1
| scriptHandler.load("broken");
|
|
60 |
0
| fail("expected exception");
|
|
61 |
| } |
|
62 |
| catch (Exception e) { |
|
63 |
| } |
|
64 |
| } |
|
65 |
| |
|
66 |
| } |