1 26 27 package net.sourceforge.groboutils.codecoverage.v2.util; 28 29 import junit.framework.Test; 30 import junit.framework.TestCase; 31 import junit.framework.TestSuite; 32 import net.sourceforge.groboutils.autodoc.v1.AutoDoc; 33 34 35 42 public class ClassSignatureUtilUTest extends TestCase 43 { 44 47 private static final Class THIS_CLASS = ClassSignatureUtilUTest.class; 48 private static final AutoDoc DOC = new AutoDoc( THIS_CLASS ); 49 50 public ClassSignatureUtilUTest( String name ) 51 { 52 super( name ); 53 } 54 55 56 57 60 61 public void testGetInstance1() 62 { 63 assertNotNull( 64 "Returned a null instance.", 65 ClassSignatureUtil.getInstance() ); 66 } 67 68 69 public void testCreateClassSignature1() 70 { 71 try 72 { 73 ClassSignatureUtil.getInstance().createClassSignature( null, -1 ); 74 fail( "Did not throw IllegalArgumentException." ); 75 } 76 catch (IllegalArgumentException e) 77 { 78 } 80 } 81 82 83 public void testCreateClassSignature2() 84 { 85 String sig = ClassSignatureUtil.getInstance(). 86 createClassSignature( "a.b.C", 1L ); 87 assertEquals( 88 "Did not create correct signature.", 89 "a.b.C-1", 90 sig ); 91 } 92 93 94 public void testCreateClassSignature3() 95 { 96 String sig = ClassSignatureUtil.getInstance(). 97 createClassSignature( "", 100L ); 98 assertEquals( 99 "Did not create correct signature.", 100 "-100", 101 sig ); 102 } 103 104 105 public void testGetClassName1() 106 { 107 try 108 { 109 ClassSignatureUtil.getInstance().getClassName( null ); 110 fail( "Did not throw IllegalArgumentException." ); 111 } 112 catch (IllegalArgumentException e) 113 { 114 } 116 } 117 118 119 public void testGetClassName2() 120 { 121 String name = ClassSignatureUtil.getInstance(). 122 getClassName( "" ); 123 assertEquals( 124 "Did not return correct class name.", 125 "", 126 name ); 127 } 128 129 130 public void testGetClassName3() 131 { 132 String name = ClassSignatureUtil.getInstance(). 133 getClassName( "a.b.C" ); 134 assertEquals( 135 "Did not return correct class name.", 136 "a.b.C", 137 name ); 138 } 139 140 141 public void testGetClassName4() 142 { 143 String name = ClassSignatureUtil.getInstance(). 144 getClassName( "a.b.C--100" ); 145 assertEquals( 146 "Did not return correct class name.", 147 "a.b.C", 148 name ); 149 } 150 151 152 public void testGetClassName5() 153 { 154 String name = ClassSignatureUtil.getInstance(). 155 getClassName( "a.b.C D-100" ); 156 assertEquals( 157 "Did not return correct class name.", 158 "a.b.C D", 159 name ); 160 } 161 162 163 164 167 168 public static Test suite() 169 { 170 TestSuite suite = new TestSuite( THIS_CLASS ); 171 172 return suite; 173 } 174 175 public static void main( String [] args ) 176 { 177 String [] name = { THIS_CLASS.getName() }; 178 179 182 junit.textui.TestRunner.main( name ); 183 } 184 185 186 190 protected void setUp() throws Exception 191 { 192 super.setUp(); 193 194 } 196 197 198 202 protected void tearDown() throws Exception 203 { 204 206 207 super.tearDown(); 208 } 209 } 210 211 | Popular Tags |