1 package org.grlea.log.test; 2 3 6 18 19 import junit.framework.TestSuite; 20 21 27 public class 28 TestOfConfiguration 29 extends AbstractLoggingTest 30 { 31 public 32 TestOfConfiguration(String name) 33 { 34 super(name); 36 } 37 38 public void 39 testFatal() 40 throws Exception 41 { 42 properties.setProperty(SimpleLoggingClass.class.getName(), "Fatal"); 43 new SimpleLoggingClass(log).doSomeLogging(); 44 45 String [] expectedOutputLineParts = 46 { 47 " |main|SimpleLoggingClass|Test of Fatal", 48 }; 49 50 checkOutput(expectedOutputLineParts); 51 } 52 53 public void 54 testError() 55 throws Exception 56 { 57 properties.setProperty(SimpleLoggingClass.class.getName(), "Error"); 58 new SimpleLoggingClass(log).doSomeLogging(); 59 60 String [] expectedOutputLineParts = 61 { 62 " |main|SimpleLoggingClass|Test of Fatal", 63 " |main|SimpleLoggingClass|Test of Error", 64 }; 65 66 checkOutput(expectedOutputLineParts); 67 } 68 69 public void 70 testWarn() 71 throws Exception 72 { 73 properties.setProperty(SimpleLoggingClass.class.getName(), "Warn"); 74 new SimpleLoggingClass(log).doSomeLogging(); 75 76 String [] expectedOutputLineParts = 77 { 78 " |main|SimpleLoggingClass|Test of Fatal", 79 " |main|SimpleLoggingClass|Test of Error", 80 " |main|SimpleLoggingClass|Test of Warn", 81 }; 82 83 checkOutput(expectedOutputLineParts); 84 } 85 86 public void 87 testInfo() 88 throws Exception 89 { 90 properties.setProperty(SimpleLoggingClass.class.getName(), "Info"); 91 new SimpleLoggingClass(log).doSomeLogging(); 92 93 String [] expectedOutputLineParts = 94 { 95 " |main|SimpleLoggingClass|Test of Fatal", 96 " |main|SimpleLoggingClass|Test of Error", 97 " |main|SimpleLoggingClass|Test of Warn", 98 " |main|SimpleLoggingClass|Test of Info", 99 }; 100 101 checkOutput(expectedOutputLineParts); 102 } 103 104 public void 105 testDebug() 106 throws Exception 107 { 108 properties.setProperty(SimpleLoggingClass.class.getName(), "Debug"); 109 new SimpleLoggingClass(log).doSomeLogging(); 110 111 String [] expectedOutputLineParts = 112 { 113 " |main|SimpleLoggingClass|Test of Fatal", 114 " |main|SimpleLoggingClass|Test of Error", 115 " |main|SimpleLoggingClass|Test of Warn", 116 " |main|SimpleLoggingClass|Test of Info", 117 " |main|SimpleLoggingClass|Test of Debug", 118 }; 119 120 checkOutput(expectedOutputLineParts); 121 } 122 123 public void 124 testVerbose() 125 throws Exception 126 { 127 properties.setProperty(SimpleLoggingClass.class.getName(), "Verbose"); 128 new SimpleLoggingClass(log).doSomeLogging(); 129 130 String [] expectedOutputLineParts = 131 { 132 " |main|SimpleLoggingClass|Test of Fatal", 133 " |main|SimpleLoggingClass|Test of Error", 134 " |main|SimpleLoggingClass|Test of Warn", 135 " |main|SimpleLoggingClass|Test of Info", 136 " |main|SimpleLoggingClass|Test of Debug", 137 " |main|SimpleLoggingClass|Test of Verbose", 138 }; 139 140 checkOutput(expectedOutputLineParts); 141 } 142 143 public void 144 testLudicrous() 145 throws Exception 146 { 147 properties.setProperty(SimpleLoggingClass.class.getName(), "Ludicrous"); 148 new SimpleLoggingClass(log).doSomeLogging(); 149 150 String [] expectedOutputLineParts = 151 { 152 " |main|SimpleLoggingClass|Test of Fatal", 153 " |main|SimpleLoggingClass|Test of Error", 154 " |main|SimpleLoggingClass|Test of Warn", 155 " |main|SimpleLoggingClass|Test of Info", 156 " |main|SimpleLoggingClass|Test of Debug", 157 " |main|SimpleLoggingClass|Test of Verbose", 158 " |main|SimpleLoggingClass|Test of Ludicrous", 159 }; 160 161 checkOutput(expectedOutputLineParts); 162 } 163 164 public void 165 testTracing() 166 throws Exception 167 { 168 properties.setProperty(SimpleLoggingClass.class.getName(), "Fatal"); 169 properties.setProperty(SimpleLoggingClass.class.getName() + "#trace", "true"); 170 new SimpleLoggingClass(log).doSomeLogging(); 171 172 String [] expectedOutputLineParts = 173 { 174 " |main|SimpleLoggingClass|Test of Fatal", 175 ">>>|main|SimpleLoggingClass|doSomeLogging()", 176 "<<<|main|SimpleLoggingClass|doSomeLogging()", 177 }; 178 179 checkOutput(expectedOutputLineParts); 180 } 181 182 186 public static TestSuite 187 suite() 188 { 189 return new TestSuite(TestOfConfiguration.class); 190 } 191 } | Popular Tags |