Package org.apache.tapestry.services

Examples of org.apache.tapestry.services.ClassTransformation


    public void no_path_annotation()
    {
        SymbolSource symbolSource = mockSymbolSource();
        AssetSource assetSource = mockAssetSource();
        ObjectLocator locator = mockObjectLocator();
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();

        String fieldName = "myField";

        train_getFieldAnnotation(ct, fieldName, Path.class, null);
View Full Code Here


    public void path_annotation_present()
    {
        SymbolSource symbolSource = mockSymbolSource();
        AssetSource assetSource = mockAssetSource();
        ObjectLocator locator = mockObjectLocator();
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();
        Path annotation = mockPath();

        String fieldName = "myField";
        Class fieldType = Object.class;
        String value = "${foo}";
        String expanded = "foo.gif";

        train_getFieldAnnotation(ct, fieldName, Path.class, annotation);

        train_value(annotation, value);
        train_expandSymbols(symbolSource, value, expanded);

        train_addInjectedField(ct, AssetSource.class, "assetSource", assetSource, "as");
        train_getResourcesFieldName(ct, "rez");

        // This only tests that the code is generated as expected (which is a bit brittle), it
        // doesn't prove that the generated code actually works, but we have lots of integration
        // tests for that.

        ct
                .extendConstructor("myField = (java.lang.Object) as.findAsset(rez.getBaseResource(), \"foo.gif\", rez.getLocale());");

        ct.makeReadOnly(fieldName);

        replay();

        InjectionProvider provider = new AssetInjectionProvider(symbolSource, assetSource);
View Full Code Here

    public void anonymous_injection()
    {
        ObjectLocator locator = mockObjectLocator();
        InjectionProvider ip = newMock(InjectionProvider.class);
        Inject annotation = newMock(Inject.class);
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();

        train_findFieldsWithAnnotation(ct, Inject.class, "myfield");
        train_getFieldAnnotation(ct, "myfield", Inject.class, annotation);

        train_getFieldType(ct, "myfield", WEBREQUEST_CLASS_NAME);

        train_provideInjection(ip, "myfield", WEBREQUEST_CLASS_NAME, locator, ct, model, true);

        ct.claimField("myfield", annotation);

        replay();

        ComponentClassTransformWorker worker = new InjectResourcesWorker(locator, ip);
View Full Code Here

    public void anonymous_injection_not_provided()
    {
        ObjectLocator locator = mockObjectLocator();
        InjectionProvider ip = newMock(InjectionProvider.class);
        Inject annotation = newMock(Inject.class);
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();

        train_findFieldsWithAnnotation(ct, Inject.class, "myfield");
        train_getFieldAnnotation(ct, "myfield", Inject.class, annotation);
View Full Code Here

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

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

        replay();

        TransformMethodSignature sig = new TransformMethodSignature(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();

        TransformMethodSignature sig = new TransformMethodSignature(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();

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

public class InjectBlockWorkerTest extends TapestryTestCase
{
    @Test
    public void no_fields_of_type_block()
    {
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();

        train_findFieldsOfType(ct, InjectBlockWorker.BLOCK_TYPE_NAME);

        replay();
View Full Code Here

    }

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

        train_findFieldsOfType(ct, InjectBlockWorker.BLOCK_TYPE_NAME, "fred");

        train_getResourcesFieldName(ct, "rez");
View Full Code Here

     * generated code is valid and works.
     */
    @Test
    public void fields_with_annotations()
    {
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();
        Inject fredAnnotation = mockInject();
        Inject barneyAnnotation = mockInject();
        Id barneyId = newId();

        String barneyFieldName = "_barneyBlock";
        String fredFieldName = "fred";

        train_findFieldsOfType(
                ct,
                InjectBlockWorker.BLOCK_TYPE_NAME,
                fredFieldName,
                barneyFieldName);

        train_getResourcesFieldName(ct, "rez");

        train_getFieldAnnotation(ct, fredFieldName, Inject.class, fredAnnotation);

        train_getFieldAnnotation(ct, fredFieldName, Id.class, null);

        ct.makeReadOnly(fredFieldName);
        ct.claimField(fredFieldName, fredAnnotation);

        train_getFieldAnnotation(ct, barneyFieldName, Inject.class, barneyAnnotation);
        train_getFieldAnnotation(ct, barneyFieldName, Id.class, barneyId);

        train_value(barneyId, "barney");

        ct.makeReadOnly(barneyFieldName);
        ct.claimField(barneyFieldName, barneyAnnotation);

        train_extendMethod(
                ct,
                TransformConstants.CONTAINING_PAGE_DID_LOAD_SIGNATURE,
                "{",
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.