KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > easymock > classextension > tests > SunClassInstantiatorTest


1 /*
2  * Copyright (c) 2003-2004 OFFIS. This program is made available under the terms of
3  * the MIT License.
4  */

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 JavaDoc {
32         super.setUp();
33         instantiator = new SunClassInstantiator();
34     }
35
36     public void tearDown() throws Exception JavaDoc {
37         instantiator = null;
38         super.tearDown();
39     }
40
41     public void testNewInstance_DefaultConstructor() throws Exception JavaDoc {
42         Object JavaDoc o = instantiator.newInstance(DefaultConstructorClass.class);
43         assertTrue(o instanceof DefaultConstructorClass);
44     }
45
46     public void testNewInstance_NoDefaultConstructor() throws Exception JavaDoc {
47         Object JavaDoc o = instantiator.newInstance(NoDefaultConstructorClass.class);
48         assertTrue(o instanceof NoDefaultConstructorClass);
49     }
50
51     public void testNewInstance_PrivateEmptyConstructor() throws Exception JavaDoc {
52         Object JavaDoc o = instantiator.newInstance(PrivateEmptyConstructorClass.class);
53         assertTrue(o instanceof PrivateEmptyConstructorClass);
54     }
55 }
56
Popular Tags