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

package org.jfox.framework;

import junit.framework.TestCase;

/**
 * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
 */

public class ConstructorComponentFactoryTest extends TestCase {
    ConstrComponentFactory constrComponentFactory;

    ComponentName name = null;
    Registry registry = null;

    public void setUp() throws Exception {
        super.setUp();
        constrComponentFactory = new ConstrComponentFactory(TestComponentA.class, new Parameter[0]);
        registry = Registry.getInstance();
    }

    public void tearDown() throws Exception {
        super.setUp();
    }

    public void testMakeComponent() throws Exception {
        Component comp = constrComponentFactory.makeComponent();
        System.out.println("Component: " + comp);
    }

    public void testComponentName() {
        System.out.println("ComponentName: " + constrComponentFactory.getComponentName());
    }

    public void testRegister() {
        try {
            ComponentMeta meta = registry.registerComponent(TestComponentA.class, new Parameter[0], null);
            System.out.println("Registered ComponentMeta: " + meta);
            System.out.println("Registered ComponentName: " + meta.getComponentName());

            Component comp = registry.getComponentInstance(meta.getComponentName());
            System.out.println("Component: " + comp);
        }
        catch(Exception e) {
            e.printStackTrace();
        }
    }

}
