1 15 16 package net.sourceforge.groboutils.junit.v1.iftc; 17 18 import junit.framework.Test; 19 import junit.framework.TestCase; 20 import junit.framework.TestSuite; 21 22 23 32 public class Sample2IUTestI extends InterfaceTestCase { 33 private static final Class THIS_CLASS = Sample2IUTestI.class; 34 35 public static interface Sample2Factory { 36 public Sample2 create( String [] s ); 37 public Sample2 create( String s ); 38 } 39 40 public Sample2IUTestI( String name, ImplFactory f ) { 41 super( name, Sample2Factory.class, f ); 42 } 43 44 protected Sample2Factory createSample2Factory() { 45 return (Sample2Factory)createImplObject(); 46 } 47 48 49 protected Sample2 createSample2( String [] s ) { 50 Sample2 s2 = createSample2Factory().create( s ); 51 assertNotNull( "factory returned null.", s2 ); 52 return s2; 53 } 54 55 protected Sample2 createSample2( String s ) { 56 Sample2 s2 = createSample2Factory().create( s ); 57 assertNotNull( "factory returned null.", s2 ); 58 return s2; 59 } 60 61 64 public void testConstructor1() throws Exception { 65 Class c = createSample2( "a" ).getClass(); 66 java.lang.reflect.Constructor cntr = c.getConstructor( 67 new Class [] { String [].class } ); 68 assertNotNull( "Does not contain valid constructor.", cntr ); 69 } 70 71 72 public void testGetStrings1() throws Exception { 73 Sample2 s2 = createSample2( "a" ); 74 String s[] = s2.getStrings(); 75 assertNotNull( "Null string array.", s ); 76 assertEquals( "Incorrect array length.", 1, s.length ); 77 assertEquals( "Returned element incorrect.", "a", s[0] ); 78 } 79 80 81 public void testGetStrings2() throws Exception { 82 Sample2 s2 = createSample2( new String [] { "a", "b" } ); 83 String s[] = s2.getStrings(); 84 assertNotNull( "Null string array.", s ); 85 assertEquals( "Incorrect array length.", 2, s.length ); 86 assertEquals( "Returned element incorrect.", "a", s[0] ); 87 assertEquals( "Returned element incorrect.", "b", s[1] ); 88 } 89 90 public static InterfaceTestSuite suite() { 91 InterfaceTestSuite suite = 92 new InterfaceTestSuite( THIS_CLASS ); 93 return suite; 94 } 95 } 96 97 | Popular Tags |