|
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 |
| public class URLHandlerTest extends TestCase { |
|
20 |
| |
|
21 |
| private SimpleWebServer server; |
|
22 |
| |
|
23 |
1
| public URLHandlerTest(java.lang.String testName) {
|
|
24 |
1
| super(testName);
|
|
25 |
| } |
|
26 |
| |
|
27 |
0
| public static void main(java.lang.String[] args) {
|
|
28 |
0
| junit.textui.TestRunner.run(suite());
|
|
29 |
| } |
|
30 |
| |
|
31 |
0
| public static Test suite() {
|
|
32 |
0
| TestSuite suite = new TestSuite(URLHandlerTest.class);
|
|
33 |
0
| return suite;
|
|
34 |
| } |
|
35 |
| |
|
36 |
1
| public void setUp() throws Exception {
|
|
37 |
1
| server = new SimpleWebServer();
|
|
38 |
| } |
|
39 |
| |
|
40 |
1
| public void tearDown() throws Exception {
|
|
41 |
1
| server.shutdown();
|
|
42 |
| } |
|
43 |
| |
|
44 |
1
| public void testLoad() {
|
|
45 |
1
| try {
|
|
46 |
1
| URLHandler handler = new URLHandler();
|
|
47 |
1
| handler.setURL("http://localhost:8181/test.xml");
|
|
48 |
1
| Configuration config = handler.load("test");
|
|
49 |
1
| assertNotNull(config);
|
|
50 |
1
| String test = config.getProperty("USER",null,"JDBC");
|
|
51 |
1
| assertEquals("dice",test);
|
|
52 |
1
| assertEquals("10000",config.getProperty("maxNumber",null,"VariableTest"));
|
|
53 |
1
| assertEquals(10000L,config.getLongProperty("maxNumber",-1,"VariableTest"));
|
|
54 |
| } |
|
55 |
| catch (Exception e) { |
|
56 |
0
| e.printStackTrace();
|
|
57 |
0
| fail("unexpected exception");
|
|
58 |
| } |
|
59 |
| } |
|
60 |
| } |