1 26 27 package net.sourceforge.groboutils.autodoc.v1.log4j; 28 29 import net.sourceforge.groboutils.autodoc.v1.*; 30 31 import net.sourceforge.groboutils.junit.v1.iftc.*; 32 import junit.framework.Test; 33 import junit.framework.TestCase; 34 import junit.framework.TestSuite; 35 36 37 44 public class Log4jLogUTest extends TestCase 45 { 46 49 private static final Class THIS_CLASS = Log4jLogUTest.class; 50 51 public Log4jLogUTest( String name ) 52 { 53 super( name ); 54 } 55 56 57 60 64 protected void setUp() throws Exception 65 { 66 super.setUp(); 67 68 } 70 71 72 75 76 public void testConstructor1() 77 { 78 try 79 { 80 new Log4jLog( (Class )null ); 81 fail("did not throw IllegalArgumentException."); 82 } 83 catch (IllegalArgumentException e) 84 { 85 } 87 } 88 89 90 public void testConstructor2() 91 { 92 new Log4jLog( this.getClass() ); 93 } 94 95 96 public void testConstructor3() 97 { 98 try 99 { 100 new Log4jLog( (org.apache.log4j.Logger)null ); 101 fail("did not throw IllegalArgumentException."); 102 } 103 catch (IllegalArgumentException e) 104 { 105 } 107 } 108 109 110 public void testConstructor4() 111 { 112 new Log4jLog( org.apache.log4j.Logger.getLogger( this.getClass() ) ); 113 } 114 115 116 public void testConcatMessage1() 117 { 118 Log4jLog log = new Log4jLog( this.getClass() ); 119 Object sb = log.concatMessage( null ); 120 assertNotNull( 121 "concatMessage must not return null.", 122 sb ); 123 assertEquals( 124 "did not concat objects correctly.", 125 "null", 126 sb.toString() ); 127 } 128 129 130 public void testConcatMessage2() 131 { 132 Log4jLog log = new Log4jLog( this.getClass() ); 133 Object sb = log.concatMessage( new Object [0] ); 134 assertNotNull( 135 "concatMessage must not return null.", 136 sb ); 137 assertEquals( 138 "did not concat objects correctly.", 139 "", 140 sb.toString() ); 141 } 142 143 144 public void testConcatMessage3() 145 { 146 Log4jLog log = new Log4jLog( this.getClass() ); 147 Object sb = log.concatMessage( new Object [1] ); 148 assertNotNull( 149 "concatMessage must not return null.", 150 sb ); 151 assertEquals( 152 "did not concat objects correctly.", 153 "null", 154 sb.toString() ); 155 } 156 157 158 public void testConcatMessage4() 159 { 160 Log4jLog log = new Log4jLog( this.getClass() ); 161 Object sb = log.concatMessage( new Object [] 162 { "a", "b" } ); 163 assertNotNull( 164 "concatMessage must not return null.", 165 sb ); 166 assertEquals( 167 "did not concat objects correctly.", 168 "ab", 169 sb.toString() ); 170 } 171 172 173 public void testConcatMessage5() 174 { 175 Log4jLog log = new Log4jLog( this.getClass() ); 176 StringBuffer sb = (StringBuffer )log.concatMessage( new Object [] 177 { "a", null, "b" } ); 178 assertNotNull( 179 "concatMessage must not return null.", 180 sb ); 181 assertEquals( 182 "did not concat objects correctly.", 183 "anullb", 184 sb.toString() ); 185 } 186 187 188 191 192 195 196 public static Test suite() 197 { 198 InterfaceTestSuite suite = AutoDocLogUTestI.suite(); 199 suite.addTestSuite( THIS_CLASS ); 200 suite.addFactory( new CxFactory( "A" ) { 201 public Object createImplObject() { 202 return new Log4jLog( Test.class ); 203 } 204 } ); 205 206 return suite; 207 } 208 209 public static void main( String [] args ) 210 { 211 String [] name = { THIS_CLASS.getName() }; 212 213 216 junit.textui.TestRunner.main( name ); 217 } 218 219 220 224 protected void tearDown() throws Exception 225 { 226 228 super.tearDown(); 229 } 230 } 231 232 | Popular Tags |