1 package org.grlea.log.test; 2 3 6 18 19 import org.grlea.log.SimpleLog; 20 import org.grlea.log.SimpleLogger; 21 22 import junit.framework.TestSuite; 23 24 30 public class 31 TestOfInnerClassLogging 32 extends AbstractLoggingTest 33 { 34 35 public 36 TestOfInnerClassLogging(String name) 37 { 38 super(name); 40 } 41 42 public void 43 testNormalLogging() 44 throws Exception 45 { 46 new InnerClass(log).doSomeLogging(); 47 48 String [] expectedOutputLineParts = 49 { 50 " |main|TestOfInnerClassLogging$InnerClass|Test of Fatal", 51 " |main|TestOfInnerClassLogging$InnerClass|Test of Error", 52 " |main|TestOfInnerClassLogging$InnerClass|Test of Warn", 53 " |main|TestOfInnerClassLogging$InnerClass|Test of Info", 54 }; 55 56 checkOutput(expectedOutputLineParts); 57 } 58 59 public void 60 testLudicrousLogging() 61 throws Exception 62 { 63 properties.setProperty(InnerClass.class.getName(), "Ludicrous"); 64 log.reloadProperties(); 65 new InnerClass(log).doSomeLogging(); 66 67 String [] expectedOutputLineParts = 68 { 69 " |main|TestOfInnerClassLogging$InnerClass|Test of Fatal", 70 " |main|TestOfInnerClassLogging$InnerClass|Test of Error", 71 " |main|TestOfInnerClassLogging$InnerClass|Test of Warn", 72 " |main|TestOfInnerClassLogging$InnerClass|Test of Info", 73 " |main|TestOfInnerClassLogging$InnerClass|Test of Debug", 74 " |main|TestOfInnerClassLogging$InnerClass|Test of Verbose", 75 " |main|TestOfInnerClassLogging$InnerClass|Test of Ludicrous", 76 }; 77 78 checkOutput(expectedOutputLineParts); 79 } 80 81 public void 82 testTracing() 83 throws Exception 84 { 85 properties.setProperty(InnerClass.class.getName(), "Fatal"); 86 properties.setProperty(InnerClass.class.getName() + "#trace", "true"); 87 log.reloadProperties(); 88 new InnerClass(log).doSomeLogging(); 89 90 String [] expectedOutputLineParts = 91 { 92 " |main|TestOfInnerClassLogging$InnerClass|Test of Fatal", 93 ">>>|main|TestOfInnerClassLogging$InnerClass|doSomeLogging", 94 "<<<|main|TestOfInnerClassLogging$InnerClass|doSomeLogging", 95 }; 96 97 checkOutput(expectedOutputLineParts); 98 } 99 100 101 105 public static TestSuite 106 suite() 107 { 108 return new TestSuite(TestOfInnerClassLogging.class); 109 } 110 111 112 private static final class 113 InnerClass 114 { 115 private final SimpleLogger log; 116 117 public 118 InnerClass(SimpleLog logTarget) 119 { 120 log = new SimpleLogger(logTarget, InnerClass.class); 121 } 122 123 private void 124 doSomeLogging() 125 { 126 log.fatal("Test of Fatal"); 127 log.error("Test of Error"); 128 log.warn("Test of Warn"); 129 log.info("Test of Info"); 130 log.debug("Test of Debug"); 131 log.verbose("Test of Verbose"); 132 log.ludicrous("Test of Ludicrous"); 133 134 log.entry("doSomeLogging()"); 135 log.exit("doSomeLogging()"); 136 } 137 } 138 } | Popular Tags |