KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > ioc > ConstructorComponentFactoryTest


1 /* JFox, the OpenSource J2EE Application Server
2  *
3  * Distributable under GNU LGPL license by gun.org
4  * more details please visit http://www.huihoo.org/jfox
5  */

6
7 package org.jfox.ioc;
8
9 import junit.framework.TestCase;
10 import org.jfox.ioc.component.TestComponentB;
11 import org.jfox.ioc.depend.Dependency;
12 import org.jfox.ioc.factory.ConstrComponentFactory;
13
14 /**
15  * @author <a HREF="mailto:young_yy@hotmail.com">Young Yang</a>
16  */

17
18 public class ConstructorComponentFactoryTest extends TestCase {
19     ConstrComponentFactory constrComponentFactory;
20
21     ComponentName name = null;
22     Registry registry = null;
23
24     public void setUp() throws Exception JavaDoc {
25         super.setUp();
26         constrComponentFactory = new ConstrComponentFactory(ComponentName.newInstance(TestComponentB.class),TestComponentB.class,Dependency.EMPTY_PARAMETERS);
27         registry = Registry.getInstance();
28     }
29
30     public void tearDown() throws Exception JavaDoc {
31         super.setUp();
32     }
33
34     public void testMakeComponent() throws Exception JavaDoc {
35         Component comp = constrComponentFactory.makeComponent();
36         System.out.println("Component: " + comp);
37     }
38
39     public void testComponentName() {
40         System.out.println("ComponentName: " + constrComponentFactory.getComponentName());
41     }
42
43     public void testRegister() {
44         try {
45             ComponentMeta meta = registry.registerComponent(TestComponentB.class, Dependency.EMPTY_PARAMETERS);
46             System.out.println("Registered ComponentMeta: " + meta);
47             System.out.println("Registered ComponentName: " + meta.getComponentName());
48
49             Component comp = registry.getComponentInstance(meta.getComponentName());
50             System.out.println("Component: " + comp);
51         }
52         catch(Exception JavaDoc e) {
53             e.printStackTrace();
54         }
55     }
56
57 }
58
Popular Tags