Package org.apache.tapestry5.services

Examples of org.apache.tapestry5.services.ComponentClassTransformWorker


        train_getClassName(ct, "foo.bar.Baz");

        replay();

        ComponentClassTransformWorker worker = new InjectWorker(locator, ip);

        try
        {
            worker.transform(ct, model);
            unreachable();
        }
        catch (RuntimeException ex)
        {
            assertEquals(
View Full Code Here


    public void activate_dafault_passivate_false()
    {
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();
        PageActivationContext annotation = newMock(PageActivationContext.class);
        ComponentClassTransformWorker worker = new PageActivationContextWorker();

        train_findFieldsWithAnnotation(ct, PageActivationContext.class,
                                       "myfield");
        train_getFieldAnnotation(ct, "myfield", PageActivationContext.class,
                                 annotation);
        train_getFieldType(ct, "myfield", CLASS_NAME);
        expect(annotation.activate()).andReturn(true);

        TransformMethodSignature sig = new TransformMethodSignature(
                Modifier.PROTECTED | Modifier.FINAL, "void", "onActivate",
                new String[]{CLASS_NAME}, null);

        ct.addTransformedMethod(sig, "myfield = $1;");

        expect(annotation.passivate()).andReturn(false);

        replay();

        worker.transform(ct, model);

        verify();
    }
View Full Code Here

    public void activate_false_passivate_default()
    {
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();
        PageActivationContext annotation = newMock(PageActivationContext.class);
        ComponentClassTransformWorker worker = new PageActivationContextWorker();

        train_findFieldsWithAnnotation(ct, PageActivationContext.class,
                                       "myfield");
        train_getFieldAnnotation(ct, "myfield", PageActivationContext.class,
                                 annotation);
        train_getFieldType(ct, "myfield", CLASS_NAME);
        expect(annotation.activate()).andReturn(false);

        expect(annotation.passivate()).andReturn(true);

        TransformMethodSignature sig = new TransformMethodSignature(
                Modifier.PROTECTED | Modifier.FINAL, "java.lang.Object",
                "onPassivate", null, null);

        ct.addTransformedMethod(sig, "return ($w) myfield;");

        replay();

        worker.transform(ct, model);

        verify();
    }
View Full Code Here

    public void activate_false_passivate_false()
    {
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();
        PageActivationContext annotation = newMock(PageActivationContext.class);
        ComponentClassTransformWorker worker = new PageActivationContextWorker();

        train_findFieldsWithAnnotation(ct, PageActivationContext.class,
                                       "myfield");
        train_getFieldAnnotation(ct, "myfield", PageActivationContext.class,
                                 annotation);
        train_getFieldType(ct, "myfield", CLASS_NAME);
        expect(annotation.activate()).andReturn(false);

        expect(annotation.passivate()).andReturn(false);

        replay();

        worker.transform(ct, model);

        verify();
    }
View Full Code Here

    @Test
    public void illegal_number_of_page_activation_context_handlers()
    {
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();
        ComponentClassTransformWorker worker = new PageActivationContextWorker();

        train_findFieldsWithAnnotation(ct, PageActivationContext.class,
                                       "myfield", "myfield2");

        replay();

        try
        {
            worker.transform(ct, model);
            fail("did not throw");
        }
        catch (RuntimeException e)
        {
            e.printStackTrace();
View Full Code Here

        train_isRootTransformation(ct, false);

        replay();

        ComponentClassTransformWorker worker = new InvokePostRenderCleanupOnResourcesWorker();

        worker.transform(ct, model);

        verify();
    }
View Full Code Here

        train_extendMethod(ct, TransformConstants.POST_RENDER_CLEANUP_SIGNATURE, "rez.postRenderCleanup();");

        replay();

        ComponentClassTransformWorker worker = new InvokePostRenderCleanupOnResourcesWorker();

        worker.transform(ct, model);

        verify();
    }
View Full Code Here

        map.put("alpha", validator);
        map.put("beta", validator);

        replay();

        FieldValidatorSource source = new FieldValidatorSourceImpl(messagesSource, coercer, null, map, null);

        try
        {
            source.createValidator(field, "foo", null);
            unreachable();
        }
        catch (IllegalArgumentException ex)
        {
            assertEquals(ex.getMessage(), "Unknown validator type 'foo'.  Configured validators are alpha, beta.");
View Full Code Here

        train_getValueType(validator, Object.class);
        validator.validate(field, null, formatter, inputValue);

        replay();

        FieldValidatorSource source = new FieldValidatorSourceImpl(messagesSource, coercer, fs, map, null);

        FieldValidator fieldValidator = source.createValidator(field, "required", null);

        fieldValidator.validate(inputValue);

        verify();
    }
View Full Code Here

        train_getValueType(validator, Object.class);
        validator.validate(field, null, formatter, inputValue);

        replay();

        FieldValidatorSource source = new FieldValidatorSourceImpl(messagesSource, coercer, fs, map, null);

        FieldValidator fieldValidator = source.createValidator(field, "required", null);

        fieldValidator.validate(inputValue);

        verify();
    }
View Full Code Here

TOP

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

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.