1 7 8 package org.jzonic.jlo.reader; 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.Logger; 15 16 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 } 50 catch (Exception e) { 51 e.printStackTrace(); 52 fail("unexpected exception"); 53 } 54 } 55 56 public void testBrokenConfiguration() { 57 try { 58 XMLFileReader reader = new XMLFileReader(); 59 reader.setFileName("broken_logging.xml"); 60 LogConfiguration lc = reader.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 } 71 catch (Exception e) { 72 e.printStackTrace(); 73 fail("unexpected exception"); 74 } 75 } 76 77 78 79 } 80 | Popular Tags |