1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.configuration;
19
20 import static org.junit.Assert.assertNotNull;
21 import static org.junit.Assert.assertTrue;
22
23 import org.apache.commons.configuration.resolver.CatalogResolver;
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26 import org.junit.After;
27 import org.junit.Before;
28 import org.junit.Test;
29
30
31
32
33
34
35 public class TestCatalogResolver
36 {
37 private static final String CATALOG_FILES = "catalog.xml";
38 private static final String PUBLIC_FILE = "testResolver.xml";
39 private static final String REWRITE_SYSTEM_FILE = "test.properties.xml";
40 private static final String REWRITE_SCHEMA_FILE = "sample.xml";
41
42 private CatalogResolver resolver;
43 private XMLConfiguration config;
44
45 @Before
46 public void setUp() throws Exception
47 {
48 resolver = new CatalogResolver();
49 resolver.setCatalogFiles(CATALOG_FILES);
50
51 config = new XMLConfiguration();
52 config.setEntityResolver(resolver);
53 }
54
55 @After
56 public void tearDown() throws Exception
57 {
58 resolver = null;
59 config = null;
60 }
61
62 @Test
63 public void testPublic() throws Exception
64 {
65 config.setFileName(PUBLIC_FILE);
66 config.load();
67 }
68
69 @Test
70 public void testRewriteSystem() throws Exception
71 {
72 config.setFileName(REWRITE_SYSTEM_FILE);
73 config.load();
74 }
75
76
77
78
79
80
81 @Test
82 public void testSchemaResolver() throws Exception
83 {
84 config.setFileName(REWRITE_SCHEMA_FILE);
85 config.setSchemaValidation(true);
86 config.load();
87 }
88
89 @Test
90 public void testDebug() throws Exception
91 {
92 resolver.setDebug(true);
93
94
95 }
96
97 @Test
98 public void testLogger() throws Exception
99 {
100 Log log = LogFactory.getLog(this.getClass());
101 resolver.setLogger(log);
102 assertNotNull("No Logger returned", resolver.getLogger());
103 assertTrue("Incorrect Logger", log == resolver.getLogger());
104 }
105
106 }