01: /*
02: * LogManagerTest.java
03: * JUnit based test
04: *
05: * Created on 25. November 2002, 22:56
06: */
07:
08: package org.jzonic.jlo.reader;
09:
10: import junit.framework.Test;
11: import junit.framework.TestCase;
12: import junit.framework.TestSuite;
13: import org.jzonic.jlo.LogConfiguration;
14: import org.jzonic.jlo.Logger;
15:
16: /**
17: *
18: * @author Administrator
19: */
20: public class XMLFileReaderTest extends TestCase {
21:
22: public XMLFileReaderTest(java.lang.String testName) {
23: super (testName);
24: }
25:
26: public static void main(java.lang.String[] args) {
27: junit.textui.TestRunner.run(suite());
28: }
29:
30: public static Test suite() {
31: TestSuite suite = new TestSuite(XMLFileReaderTest.class);
32: return suite;
33: }
34:
35: public void testXMLFileReader() {
36: try {
37: XMLFileReader reader = new XMLFileReader();
38: reader.setFileName("jlo_logging.xml");
39: LogConfiguration lc = reader.parseConfiguration("test");
40: assertNotNull(lc);
41: assertEquals(4, lc.getLogGeneratorCount());
42: assertEquals(4, lc.getLoggerCount());
43: assertEquals(1, lc.getChannelCount());
44: Logger logger = lc.getLogger("org.jzonic");
45: assertNotNull(logger);
46: assertEquals(2, logger.getLogGenerators().size());
47: assertEquals(2, lc.getLogPipesCount());
48: assertEquals(2, lc.getFilterCount());
49: } catch (Exception e) {
50: e.printStackTrace();
51: fail("unexpected exception");
52: }
53: }
54:
55: public void testBrokenConfiguration() {
56: try {
57: XMLFileReader reader = new XMLFileReader();
58: reader.setFileName("broken_logging.xml");
59: LogConfiguration lc = reader
60: .parseConfiguration("broken_test");
61: assertNotNull(lc);
62: assertEquals(3, lc.getLogGeneratorCount());
63: assertEquals(2, lc.getLoggerCount());
64: assertEquals(1, lc.getChannelCount());
65: Logger logger = lc.getLogger("org.jzonic.jlo");
66: assertNotNull(logger);
67: assertEquals(0, logger.getLogGenerators().size());
68: assertEquals(0, lc.getLogPipesCount());
69: assertEquals(0, lc.getFilterCount());
70: } catch (Exception e) {
71: e.printStackTrace();
72: fail("unexpected exception");
73: }
74: }
75:
76: }
|