Package org.apache.tapestry.ioc.services

Examples of org.apache.tapestry.ioc.services.ClassFactory


    }

    @Test
    public void new_class_with_name_and_base_class() throws Exception
    {
        ClassFactory factory = new ClassFactoryImpl();
        String name = ClassFabUtils.generateClassName(Runnable.class);

        ClassFab cf = factory.newClass(name, Object.class);
        cf.addInterface(Runnable.class);

        addRunMethod(cf);

        Class newClass = cf.createClass();
View Full Code Here


    }

    @Test
    public void new_class_with_non_object_base_class() throws Exception
    {
        ClassFactory factory = new ClassFactoryImpl();
        String name = ClassFabUtils.generateClassName(Runnable.class);

        ClassFab cf = factory.newClass(name, BaseClass.class);
        cf.addInterface(Runnable.class);

        Class newClass = cf.createClass();

        Runnable instance = (Runnable) newClass.newInstance();
View Full Code Here

    }

    @Test
    public void new_class_with_interface() throws Exception
    {
        ClassFactory factory = new ClassFactoryImpl();

        ClassFab cf = factory.newClass(Runnable.class);

        addRunMethod(cf);

        Class newClass = cf.createClass();
View Full Code Here

    }

    @Test
    public void get_method_location() throws Exception
    {
        ClassFactory factory = new ClassFactoryImpl();

        Class target = LineNumberBean.class;

        Method m = target.getMethod("fred");

        // 21 is the line containing the close brace

        assertEquals(
                factory.getMethodLocation(m).toString(),
                "org.apache.tapestry.ioc.internal.services.LineNumberBean.fred() (at LineNumberBean.java:25)");

        m = target.getMethod("betty", String.class, int.class);

        // 25 is the line of the return statement

        assertEquals(
                factory.getMethodLocation(m).toString(),
                "org.apache.tapestry.ioc.internal.services.LineNumberBean.betty(String, int) (at LineNumberBean.java:29)");

        m = target.getDeclaredMethod("wilma", int[].class, Double[][][].class);

        assertEquals(
                factory.getMethodLocation(m).toString(),
                "org.apache.tapestry.ioc.internal.services.LineNumberBean.wilma(int[], Double[][][]) (at LineNumberBean.java:34)");
    }
View Full Code Here

    @Test
    public void get_constructor_location() throws Exception
    {
        Constructor cc = LineNumberBean.class.getConstructors()[0];

        ClassFactory factory = new ClassFactoryImpl();

        // Eclipse and Sun JDK don't agree on the line number, so we'll accept either.

        assertTrue(factory
                .getConstructorLocation(cc)
                .matches(
                        "org.apache.tapestry.ioc.internal.services.LineNumberBean\\(String, int\\) \\(at LineNumberBean.java:(19|20)\\)"));
    }
View Full Code Here

    @Test
    public void handle_beans_from_unexpected_classloader() throws Exception
    {
        // First, create something that looks like a Hibernate proxy.

        ClassFactory factory = new ClassFactoryImpl();

        Class clazz = SimpleBean.class;

        ClassFab cf = factory.newClass(clazz.getName() + "$$Proxy", clazz);

        cf.addInterface(Serializable.class);

        Class proxyClass = cf.createClass();
View Full Code Here

    @Test
    public void get_service_by_id_exists()
    {
        InternalRegistry registry = mockInternalRegistry();
        Log log = mockLog();
        ClassFactory factory = new ClassFactoryImpl();

        ModuleDef moduleDef = new DefaultModuleDefImpl(ModuleImplTestModule.class, log,
                getClassFactory());

        Module module = new ModuleImpl(registry, moduleDef, null, log);
View Full Code Here

    public void too_many_public_constructors_on_module_builder_class()
    {
        InternalRegistry registry = mockInternalRegistry();
        Log log = mockLog();
        ModuleDef def = new DefaultModuleDefImpl(ExtraPublicConstructorsModule.class, log, null);
        ClassFactory factory = newMock(ClassFactory.class);
        Module module = new ModuleImpl(registry, def, null, log);

        log.warn(contains("contains more than one public constructor"));

        train_expandSymbols(registry, "ClassFactory", "ClassFactory");
View Full Code Here

     * Import a class (or two) where the class is from a known and available class loader.
     */
    @Test
    public void import_ordinary_class()
    {
        ClassFactory factory = new ClassFactoryImpl();

        assertSame(factory.importClass(Object.class), Object.class);
        assertSame(factory.importClass(LocationImpl.class), LocationImpl.class);
    }
View Full Code Here

     * available class loader) is returned.
     */
    @Test
    public void import_proxy_class() throws Exception
    {
        ClassFactory alienFactory = new ClassFactoryImpl();

        Class<TargetBean> clazz = TargetBean.class;

        ClassFab cf = alienFactory.newClass(clazz.getName() + "$$Proxy", clazz);

        Class alienClass = cf.createClass();

        ClassFactory factory = new ClassFactoryImpl();

        assertSame(factory.importClass(alienClass), clazz);
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.ioc.services.ClassFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.