1 26 27 package net.sourceforge.groboutils.junit.v1.iftc; 28 29 import org.easymock.EasyMock; 30 import org.easymock.MockControl; 31 import junit.framework.Test; 32 import junit.framework.TestCase; 33 import junit.framework.TestSuite; 34 35 36 43 public class CxFactoryUTest extends TestCase 44 { 45 48 private static final Class THIS_CLASS = CxFactoryUTest.class; 49 private static final String TC = "CxFactoryUTest"; 50 private static final org.apache.log4j.Logger LOG = 51 org.apache.log4j.Logger.getLogger( THIS_CLASS ); 52 53 public CxFactoryUTest( String name ) 54 { 55 super( name ); 56 } 57 58 59 public class MyCxFactory extends CxFactory 61 { 62 public MyCxFactory( String n ) 63 { 64 super( n ); 65 } 66 67 public MyCxFactory( String n, boolean a ) 68 { 69 super( n, a ); 70 } 71 72 public Object createImplObject() 73 { 74 return ""; 75 } 76 } 77 78 79 public static class MyStaticCxFactory extends CxFactory 81 { 82 public MyStaticCxFactory( String n ) 83 { 84 super( n ); 85 } 86 87 public MyStaticCxFactory( String n, boolean a ) 88 { 89 super( n, a ); 90 } 91 92 public Object createImplObject() 93 { 94 return ""; 95 } 96 } 97 98 99 102 103 104 105 public void testToString1() 106 { 107 CxFactory cf = new MyCxFactory( "1" ); 109 assertEquals( 110 "Returned unexpected factory name.", 111 "1", 112 cf.toString() ); 113 } 114 115 116 public void testToString1b() 117 { 118 CxFactory cf = new MyCxFactory( "1b", false ); 120 assertEquals( 121 "Returned unexpected factory name.", 122 "1b", 123 cf.toString() ); 124 } 125 126 127 public void testToString1a() 128 { 129 CxFactory cf = new MyCxFactory( "1a", true ); 131 assertEquals( 132 "Returned unexpected factory name.", 133 TC+"-1a", 134 cf.toString() ); 135 } 136 137 138 public void testToString2() 139 { 140 CxFactory cf = new MyCxFactory( "2" ) { }; 144 assertEquals( 145 "Returned unexpected factory name.", 146 "2", 147 cf.toString() ); 148 } 149 150 151 public void testToString2b() 152 { 153 CxFactory cf = new MyCxFactory( "2b", false ) { }; 157 assertEquals( 158 "Returned unexpected factory name.", 159 "2b", 160 cf.toString() ); 161 } 162 163 164 public void testToString2a() 165 { 166 CxFactory cf = new MyCxFactory( "2a", true ) { }; 170 assertEquals( 171 "Returned unexpected factory name.", 172 TC+"-2a", 173 cf.toString() ); 174 } 175 176 177 public void testToString3() 178 { 179 CxFactory cf = new MyStaticCxFactory( "3" ) { }; 183 assertEquals( 184 "Returned unexpected factory name.", 185 "3", 186 cf.toString() ); 187 } 188 189 190 public void testToString3b() 191 { 192 CxFactory cf = new MyStaticCxFactory( "3b", false ) { }; 196 assertEquals( 197 "Returned unexpected factory name.", 198 "3b", 199 cf.toString() ); 200 } 201 202 203 public void testToString3a() 204 { 205 CxFactory cf = new MyStaticCxFactory( "3a", true ) { }; 209 assertEquals( 210 "Returned unexpected factory name.", 211 TC+"-3a", 212 cf.toString() ); 213 } 214 215 216 public void testToString4() 217 { 218 LOG.debug( "Test4:" ); 220 CxFactory cf = new CxFactorySample( "4" ); 221 LOG.debug( "Returned Sample factory toString: ["+cf.toString()+"]" ); 222 assertEquals( 223 "Returned unexpected factory name.", 224 "4", 225 cf.toString() ); 226 } 227 228 229 public void testToString4b() 230 { 231 LOG.debug( "Test4:" ); 233 CxFactory cf = new CxFactorySample( "4b", false ); 234 LOG.debug( "Returned Sample factory toString: ["+cf.toString()+"]" ); 235 assertEquals( 236 "Returned unexpected factory name.", 237 "4b", 238 cf.toString() ); 239 } 240 241 242 public void testToString4a() 243 { 244 LOG.debug( "Test4:" ); 246 CxFactory cf = new CxFactorySample( "4a", true ); 247 LOG.debug( "Returned Sample factory toString: ["+cf.toString()+"]" ); 248 assertEquals( 249 "Returned unexpected factory name.", 250 "CxFactorySample-4a", 251 cf.toString() ); 252 } 253 254 255 258 259 public static InterfaceTestSuite suite() 260 { 261 InterfaceTestSuite suite = ImplFactoryUTestI.suite(); 262 263 suite.addFactory( new ImplFactory() { 266 public Object createImplObject() { 267 return new MyStaticCxFactory( "A-B" ); 268 } 269 270 public String toString() { 271 return "CxFactory-A"; 272 } 273 } ); 274 suite.addTestSuite( THIS_CLASS ); 275 276 return suite; 277 } 278 279 public static void main( String [] args ) 280 { 281 String [] name = { THIS_CLASS.getName() }; 282 283 286 junit.textui.TestRunner.main( name ); 287 } 288 289 290 294 protected void setUp() throws Exception 295 { 296 super.setUp(); 297 298 } 300 301 302 306 protected void tearDown() throws Exception 307 { 308 310 311 super.tearDown(); 312 } 313 } 314 315 | Popular Tags |