KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jzonic > jlo > error > ErrorHandlerTest


1 /*
2  * LogManagerTest.java
3  * JUnit based test
4  *
5  * Created on 25. November 2002, 22:56
6  */

7
8 package org.jzonic.jlo.error;
9
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 JavaDoc;
16 /**
17  *
18  * @author Administrator
19  */

20 public class ErrorHandlerTest extends TestCase {
21     
22     public ErrorHandlerTest(java.lang.String JavaDoc testName) {
23         super(testName);
24     }
25     
26     public static void main(java.lang.String JavaDoc[] args) {
27         junit.textui.TestRunner.run(suite());
28     }
29     
30     public static Test suite() {
31         TestSuite suite = new TestSuite(ErrorHandlerTest.class);
32         return suite;
33     }
34        
35     public void testBrokenConfiguration() {
36         System.setProperty("jlo.errorhandler","org.jzonic.jlo.error.MockErrorReporter");
37         try {
38             XMLFileReader reader = new XMLFileReader();
39             reader.setFileName("broken_logging.xml");
40             LogConfiguration lc = reader.parseConfiguration("broken_test");
41             assertNotNull( lc );
42             MockErrorReporter mer = (MockErrorReporter)ErrorHandlerFactory.getErrorReporter();
43             List JavaDoc all = mer.getMessages();
44             assertEquals(3,all.size());
45         }
46         catch (Exception JavaDoc e) {
47             e.printStackTrace();
48             fail("unexpected exception");
49         }
50     }
51     
52     
53     
54 }
55
Popular Tags