Package org.apache.tapestry.services

Examples of org.apache.tapestry.services.ClassTransformation


    private static final String MARKUP_WRITER_CLASS_NAME = MarkupWriter.class.getName();

    @Test
    public void known_parameter_type()
    {
        ClassTransformation transformation = mockClassTransformation();

        replay();

        MethodSignature sig = new MethodSignature(Modifier.PUBLIC, "void", "myMethod", new String[]
        { MARKUP_WRITER_CLASS_NAME }, null);
View Full Code Here


    }

    @Test
    public void unknown_parameter_type()
    {
        ClassTransformation transformation = mockClassTransformation();

        replay();

        MethodSignature sig = new MethodSignature(Modifier.PUBLIC, "void", "myMethod", new String[]
        { MARKUP_WRITER_CLASS_NAME }, null);
View Full Code Here

    }

    @Test
    public void multiple_parameters_for_method()
    {
        ClassTransformation transformation = mockClassTransformation();

        replay();

        MethodSignature sig = new MethodSignature(Modifier.PUBLIC, "void", "myMethod", new String[]
        { MARKUP_WRITER_CLASS_NAME, LOCALE_CLASS_NAME }, null);
View Full Code Here

public class UnclaimedFieldWorkerTest extends InternalBaseTestCase
{
    @Test
    public void no_fields()
    {
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();

        train_findUnclaimedFields(ct);

        replay();
View Full Code Here

    }

    @Test
    public void normal()
    {
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();

        train_findUnclaimedFields(ct, "_fred");

        train_getFieldModifiers(ct, "_fred", Modifier.PRIVATE);

        train_getFieldType(ct, "_fred", "foo.Bar");

        expect(ct.addField(Modifier.PRIVATE, "foo.Bar", "_fred_default")).andReturn(
                "_$fred_default");

        ct.extendMethod(CONTAINING_PAGE_DID_LOAD_SIGNATURE, "_$fred_default = _fred;");
        ct.extendMethod(CONTAINING_PAGE_DID_DETACH_SIGNATURE, "_fred = _$fred_default;");

        replay();

        new UnclaimedFieldWorker().transform(ct, model);
View Full Code Here

    }

    @Test
    public void final_fields_are_skipped()
    {
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();

        train_findUnclaimedFields(ct, "_fred");

        train_getFieldModifiers(ct, "_fred", Modifier.PRIVATE | Modifier.FINAL);
View Full Code Here

    private static final String CLASS_NAME = Grid.class.getName();

    @Test
    public void default_id_from_field_name()
    {
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();
        InjectComponent annotation = newMock(InjectComponent.class);
        ComponentClassTransformWorker worker = new InjectComponentWorker();

        train_findFieldsWithAnnotation(ct, InjectComponent.class, "myfield");
        train_getFieldAnnotation(ct, "myfield", InjectComponent.class, annotation);
        train_getFieldType(ct, "myfield", CLASS_NAME);
        train_getResourcesFieldName(ct, "resources");
        expect(annotation.value()).andReturn("");
        ct.makeReadOnly("myfield");

        train_extendMethod(ct, TransformConstants.CONTAINING_PAGE_DID_LOAD_SIGNATURE,
                           "myfield = (" + CLASS_NAME + ") resources.getEmbeddedComponent(\"myfield\");");

View Full Code Here

    }

    @Test
    public void explicit_component_id_provided_as_annotation()
    {
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();
        InjectComponent annotation = newMock(InjectComponent.class);
        ComponentClassTransformWorker worker = new InjectComponentWorker();

        train_findFieldsWithAnnotation(ct, InjectComponent.class, "myfield");
        train_getFieldAnnotation(ct, "myfield", InjectComponent.class, annotation);
        train_getFieldType(ct, "myfield", CLASS_NAME);
        train_getResourcesFieldName(ct, "resources");
        expect(annotation.value()).andReturn("id_provided_as_annotation").atLeastOnce();
        ct.makeReadOnly("myfield");
        train_extendMethod(ct, TransformConstants.CONTAINING_PAGE_DID_LOAD_SIGNATURE,
                           "myfield = (" + CLASS_NAME + ") resources.getEmbeddedComponent(\"id_provided_as_annotation\");");

        replay();
View Full Code Here

/** Mostly just testing error conditions here. Functionality testing in integration tests. */
@Test
public class CachedWorkerTest extends TapestryTestCase
{
    public void must_have_return_type() throws Exception {
        ClassTransformation ct = mockClassTransformation();
        TransformMethodSignature sig = new TransformMethodSignature(Modifier.PUBLIC, "void", "getFoo", new String[0], new String[0]);
       
        expect(ct.findMethodsWithAnnotation(Cached.class)).andReturn(Arrays.asList(sig));
       
        replay();
        try {
            new CachedWorker(null).transform(ct, null);
            fail("did not throw");
View Full Code Here

        } catch (IllegalArgumentException e) {}
        verify();
    }
   
    public void must_not_have_parameters() throws Exception {
        ClassTransformation ct = mockClassTransformation();
        TransformMethodSignature sig = new TransformMethodSignature(Modifier.PUBLIC, "java.lang.Object", "getFoo", new String[] { "boolean" }, new String[0]);
       
        expect(ct.findMethodsWithAnnotation(Cached.class)).andReturn(Arrays.asList(sig));
       
        replay();
        try {
            new CachedWorker(null).transform(ct, null);
            fail("did not throw");
View Full Code Here

TOP

Related Classes of org.apache.tapestry.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.