|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| package org.jconfig.handler; |
|
9 |
| |
|
10 |
| import java.io.File; |
|
11 |
| |
|
12 |
| import junit.framework.Test; |
|
13 |
| import junit.framework.TestCase; |
|
14 |
| import junit.framework.TestSuite; |
|
15 |
| |
|
16 |
| import org.jconfig.Configuration; |
|
17 |
| import org.jconfig.event.FileListener; |
|
18 |
| import org.jconfig.event.FileListenerEvent; |
|
19 |
| import org.jconfig.utils.ConfigurationUtils; |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| public class PropertiesHandlerTest extends TestCase { |
|
26 |
| |
|
27 |
2
| public PropertiesHandlerTest(java.lang.String testName) {
|
|
28 |
2
| super(testName);
|
|
29 |
| } |
|
30 |
| |
|
31 |
0
| public static void main(java.lang.String[] args) {
|
|
32 |
0
| junit.textui.TestRunner.run(suite());
|
|
33 |
| } |
|
34 |
| |
|
35 |
0
| public static Test suite() {
|
|
36 |
0
| TestSuite suite = new TestSuite(PropertiesHandlerTest.class);
|
|
37 |
0
| return suite;
|
|
38 |
| } |
|
39 |
| |
|
40 |
1
| public void testLoad() throws Exception {
|
|
41 |
1
| File file = ConfigurationUtils.getFileFromInputStream("test.properties");
|
|
42 |
1
| PropertiesFileHandler handler = new PropertiesFileHandler();
|
|
43 |
1
| handler.setFile(file);
|
|
44 |
1
| Configuration config = handler.load("test");
|
|
45 |
1
| assertNotNull(config);
|
|
46 |
1
| assertEquals(1,config.getNumberOfCategories());
|
|
47 |
1
| assertEquals("/usr/development/mystuff/etc/new_sitemap.xml",config.getProperty("sitemap_file"));
|
|
48 |
| } |
|
49 |
| |
|
50 |
1
| public void testFileChanged() throws Exception {
|
|
51 |
1
| File file = ConfigurationUtils.getFile("test.properties");
|
|
52 |
1
| assertNotNull(file);
|
|
53 |
1
| PropertiesFileHandler handler = new PropertiesFileHandler(file);
|
|
54 |
1
| handler.addFileListener( new TestFileListener() );
|
|
55 |
| } |
|
56 |
| } |
|
57 |
| class TestFileListener implements FileListener { |
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
0
| public void fileChanged(FileListenerEvent e) {
|
|
63 |
0
| System.out.println("huhu");
|
|
64 |
| } |
|
65 |
| |
|
66 |
| } |