1 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 ; 16 20 public class ErrorHandlerTest extends TestCase { 21 22 public ErrorHandlerTest(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(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 all = mer.getMessages(); 44 assertEquals(3,all.size()); 45 } 46 catch (Exception e) { 47 e.printStackTrace(); 48 fail("unexpected exception"); 49 } 50 } 51 52 53 54 } 55 | Popular Tags |