01: /*
02: * LogManagerTest.java
03: * JUnit based test
04: *
05: * Created on 25. November 2002, 22:56
06: */
07:
08: package org.jzonic.jlo.error;
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.reader.*;
15: import java.util.List;
16:
17: /**
18: *
19: * @author Administrator
20: */
21: public class ErrorHandlerTest extends TestCase {
22:
23: public ErrorHandlerTest(java.lang.String testName) {
24: super (testName);
25: }
26:
27: public static void main(java.lang.String[] args) {
28: junit.textui.TestRunner.run(suite());
29: }
30:
31: public static Test suite() {
32: TestSuite suite = new TestSuite(ErrorHandlerTest.class);
33: return suite;
34: }
35:
36: public void testBrokenConfiguration() {
37: System.setProperty("jlo.errorhandler",
38: "org.jzonic.jlo.error.MockErrorReporter");
39: try {
40: XMLFileReader reader = new XMLFileReader();
41: reader.setFileName("broken_logging.xml");
42: LogConfiguration lc = reader
43: .parseConfiguration("broken_test");
44: assertNotNull(lc);
45: MockErrorReporter mer = (MockErrorReporter) ErrorHandlerFactory
46: .getErrorReporter();
47: List all = mer.getMessages();
48: assertEquals(3, all.size());
49: } catch (Exception e) {
50: e.printStackTrace();
51: fail("unexpected exception");
52: }
53: }
54:
55: }
|