1 26 27 package net.sourceforge.groboutils.junit.v1; 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 import junit.framework.AssertionFailedError; 35 36 37 44 public class AssertConstructorUTest extends TestCase 45 { 46 49 private static final Class THIS_CLASS = AssertConstructorUTest.class; 50 51 public AssertConstructorUTest( String name ) 52 { 53 super( name ); 54 } 55 56 57 58 59 62 public void testAssertHasDefaultConstructor1() 63 { 64 AssertConstructor.assertHasDefaultConstructor( Object .class ); 65 } 66 67 68 public void testAssertHasDefaultConstructor2() 69 { 70 boolean failed = true; 71 try 72 { 73 AssertConstructor.assertHasDefaultConstructor( Integer .class ); 74 } 75 catch (AssertionFailedError e) 76 { 77 failed = false; 78 } 79 if (failed) 80 { 81 fail( "Did not cause an assertion failure." ); 82 } 83 } 84 85 86 public void testAssertHasDefaultConstructor3() 87 { 88 AssertConstructor.assertHasDefaultConstructor( new Object () ); 89 } 90 91 92 public void testAssertHasDefaultConstructor4() 93 { 94 boolean failed = true; 95 try 96 { 97 AssertConstructor.assertHasDefaultConstructor( new Integer ( 1 ) ); 98 } 99 catch (AssertionFailedError e) 100 { 101 failed = false; 102 } 103 if (failed) 104 { 105 fail( "Did not cause an assertion failure." ); 106 } 107 } 108 109 public void testAssertHasDefaultConstructor1a() 110 { 111 AssertConstructor.assertHasDefaultConstructor( "A", Object .class ); 112 } 113 114 115 public void testAssertHasDefaultConstructor2a() 116 { 117 boolean failed = true; 118 try 119 { 120 AssertConstructor.assertHasDefaultConstructor( ":A:", 121 Integer .class ); 122 } 123 catch (AssertionFailedError e) 124 { 125 assertTrue( 126 "Did not throw an error with the message text.", 127 e.getMessage().indexOf( ":A:" ) >= 0 ); 128 failed = false; 129 } 130 if (failed) 131 { 132 fail( "Did not cause an assertion failure." ); 133 } 134 } 135 136 137 public void testAssertHasDefaultConstructor3a() 138 { 139 AssertConstructor.assertHasDefaultConstructor( "A", new Object () ); 140 } 141 142 143 public void testAssertHasDefaultConstructor4a() 144 { 145 boolean failed = true; 146 try 147 { 148 AssertConstructor.assertHasDefaultConstructor( ":A:", 149 new Integer ( 1 ) ); 150 } 151 catch (AssertionFailedError e) 152 { 153 assertTrue( 154 "Did not throw an error with the message text.", 155 e.getMessage().indexOf( ":A:" ) >= 0 ); 156 failed = false; 157 } 158 if (failed) 159 { 160 fail( "Did not cause an assertion failure." ); 161 } 162 } 163 164 165 166 public void testAssertHasConstructor1() 167 { 168 AssertConstructor.assertHasConstructor( Object .class, new Class [0], 169 AssertConstructor.ANY_PROTECTION ); 170 } 171 172 173 public void testAssertHasConstructor2() 174 { 175 boolean failed = true; 176 try 177 { 178 AssertConstructor.assertHasConstructor( Object .class, 179 new Class [0], AssertConstructor.PRIVATE ); 180 } 181 catch (AssertionFailedError e) 182 { 183 failed = false; 184 } 185 if (failed) 186 { 187 fail( "Did not cause an assertion failure." ); 188 } 189 } 190 191 192 public void testAssertHasConstructor3() 193 { 194 AssertConstructor.assertHasConstructor( Integer .class, 195 new Class [] { Integer.TYPE }, 196 AssertConstructor.PUBLIC ); 197 } 198 199 200 201 202 205 206 public static Test suite() 207 { 208 TestSuite suite = new TestSuite( THIS_CLASS ); 209 210 return suite; 211 } 212 213 public static void main( String [] args ) 214 { 215 String [] name = { THIS_CLASS.getName() }; 216 217 220 junit.textui.TestRunner.main( name ); 221 } 222 223 224 228 protected void setUp() throws Exception 229 { 230 super.setUp(); 231 232 } 234 235 236 240 protected void tearDown() throws Exception 241 { 242 244 245 super.tearDown(); 246 } 247 } 248 249 | Popular Tags |