Package org.apache.tapestry5.services

Examples of org.apache.tapestry5.services.ClassTransformation


    {
        Logger logger = mockLogger();

        replay();

        ClassTransformation ct = createClassTransformation(ClaimedFields.class, logger);

        ct.addField(Modifier.PRIVATE, "int", "newField");

        List<String> unclaimed = ct.findUnclaimedFields();

        assertEquals(unclaimed, asList("_field1", "_field4", "_zzfield"));

        verify();
    }
View Full Code Here


    {
        Logger logger = mockLogger();

        replay();

        ClassTransformation ct = createClassTransformation(ParentClass.class, logger);

        Meta meta = ct.getAnnotation(Meta.class);

        assertNotNull(meta);

        // Try again (the annotation will be cached). Use an annotation
        // that will not be present.

        Target t = ct.getAnnotation(Target.class);

        assertNull(t);

        verify();
    }
View Full Code Here

        Logger logger = mockLogger();

        replay();

        ClassTransformation ct = createClassTransformation(ChildClassInheritsAnnotation.class, logger);

        InheritedAnnotation ia = ct.getAnnotation(InheritedAnnotation.class);

        // Javassist does not, but ClassTransformation patches around that.

        assertNotNull(ia);
View Full Code Here

    {
        Logger logger = mockLogger();

        replay();

        ClassTransformation ct = createClassTransformation(ChildClassInheritsAnnotation.class, logger);

        Meta meta = ct.getAnnotation(Meta.class);

        assertNull(meta);

        verify();
    }
View Full Code Here

    {
        Logger logger = mockLogger();

        replay();

        ClassTransformation ct = createClassTransformation(AnnotatedPage.class, logger);

        List<TransformMethodSignature> l = ct.findMethodsWithAnnotation(SetupRender.class);

        // Check order

        assertEquals(l.size(), 2);
        assertEquals(l.get(0).toString(), "void beforeRender()");
        assertEquals(l.get(1).toString(), "boolean earlyRender(org.apache.tapestry5.MarkupWriter)");

        // Check up on cacheing

        assertEquals(ct.findMethodsWithAnnotation(SetupRender.class), l);

        // Check up on no match.

        assertTrue(ct.findFieldsWithAnnotation(Deprecated.class).isEmpty());

        verify();
    }
View Full Code Here

    {
        Logger logger = mockLogger();

        replay();

        final ClassTransformation ct = createClassTransformation(AnnotatedPage.class, logger);

        // Duplicates, somewhat less efficiently, the logic in find_methods_with_annotation().

        MethodFilter filter = new MethodFilter()
        {
            public boolean accept(TransformMethodSignature signature)
            {
                return ct.getMethodAnnotation(signature, SetupRender.class) != null;
            }
        };

        List<TransformMethodSignature> l = ct.findMethods(filter);

        // Check order

        assertEquals(l.size(), 2);
        assertEquals(l.get(0).toString(), "void beforeRender()");
        assertEquals(l.get(1).toString(), "boolean earlyRender(org.apache.tapestry5.MarkupWriter)");

        // Check up on cacheing

        assertEquals(ct.findMethodsWithAnnotation(SetupRender.class), l);

        // Check up on no match.

        assertTrue(ct.findFieldsWithAnnotation(Deprecated.class).isEmpty());

        verify();
    }
View Full Code Here

    {
        Logger logger = mockLogger();

        replay();

        ClassTransformation ct = createClassTransformation(AnnotatedPage.class, logger);

        assertSame(ct.toClass("float"), Float.class);

        verify();
    }
View Full Code Here

    {
        Logger logger = mockLogger();

        replay();

        ClassTransformation ct = createClassTransformation(AnnotatedPage.class, logger);

        assertSame(ct.toClass("java.util.Map"), Map.class);

        verify();
    }
View Full Code Here

    {
        Logger logger = mockLogger();

        replay();

        ClassTransformation ct = createClassTransformation(EventHandlerTarget.class, logger);

        OnEvent annotation = ct.getMethodAnnotation(new TransformMethodSignature("handler"), OnEvent.class);

        // Check that the attributes of the annotation match the expectation.

        assertEquals(annotation.value(), "fred");
        assertEquals(annotation.component(), "alpha");
View Full Code Here

    {
        Logger logger = mockLogger();

        replay();

        ClassTransformation ct = createClassTransformation(MethodIdentifier.class, logger);

        List<TransformMethodSignature> sigs = ct.findMethodsWithAnnotation(OnEvent.class);

        assertEquals(sigs.size(), 1);

        TransformMethodSignature sig = sigs.get(0);

        assertEquals(
                ct.getMethodIdentifier(sig),
                "org.apache.tapestry5.internal.transform.pages.MethodIdentifier.makeWaves(java.lang.String, int[]) (at MethodIdentifier.java:24)");

        verify();
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.services.ClassTransformation

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.