1 5 package org.easymock.classextension.tests; 6 7 import org.easymock.classextension.internal.SunClassInstantiator; 8 9 import junit.framework.TestCase; 10 11 public class SunClassInstantiatorTest extends TestCase { 12 13 public static class DefaultConstructorClass { 14 15 } 16 17 public static class NoDefaultConstructorClass { 18 19 public NoDefaultConstructorClass(int i) { 20 } 21 } 22 23 public static class PrivateEmptyConstructorClass { 24 25 private PrivateEmptyConstructorClass() { 26 } 27 } 28 29 private SunClassInstantiator instantiator = null; 30 31 public void setUp() throws Exception { 32 super.setUp(); 33 instantiator = new SunClassInstantiator(); 34 } 35 36 public void tearDown() throws Exception { 37 instantiator = null; 38 super.tearDown(); 39 } 40 41 public void testNewInstance_DefaultConstructor() throws Exception { 42 Object o = instantiator.newInstance(DefaultConstructorClass.class); 43 assertTrue(o instanceof DefaultConstructorClass); 44 } 45 46 public void testNewInstance_NoDefaultConstructor() throws Exception { 47 Object o = instantiator.newInstance(NoDefaultConstructorClass.class); 48 assertTrue(o instanceof NoDefaultConstructorClass); 49 } 50 51 public void testNewInstance_PrivateEmptyConstructor() throws Exception { 52 Object o = instantiator.newInstance(PrivateEmptyConstructorClass.class); 53 assertTrue(o instanceof PrivateEmptyConstructorClass); 54 } 55 } 56 | Popular Tags |