Package org.apache.tapestry.services

Examples of org.apache.tapestry.services.ClassTransformation


    @Test
    public void no_fields_with_annotation()
    {
        ApplicationStateManager manager = newApplicationStateManager();
        ClassTransformation ct = mockClassTransformation();
        MutableComponentModel model = mockMutableComponentModel();

        train_findFieldsWithAnnotation(ct, ApplicationState.class);

        replay();
View Full Code Here


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

        String fieldName = "myField";
        String fieldType = "java.lang.String";
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";
        String fieldType = "java.lang.Object";
        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

    {
        Log log = mockLog();

        replay();

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

        assertEquals(ct.newMemberName("fred"), "_$fred");
        assertEquals(ct.newMemberName("fred"), "_$fred_0");

        // Here we're exposing a bit of the internal algorithm, which strips
        // off '$' and '_' before tacking "_$" in front.

        assertEquals(ct.newMemberName("_fred"), "_$fred_1");
        assertEquals(ct.newMemberName("_$fred"), "_$fred_2");
        assertEquals(ct.newMemberName("__$___$____$_fred"), "_$fred_3");

        // Here we're trying to force conflicts with existing declared
        // fields and methods of the class.

        assertEquals(ct.newMemberName("_parentField"), "_$parentField");
        assertEquals(ct.newMemberName("conflictField"), "_$conflictField_0");
        assertEquals(ct.newMemberName("conflictMethod"), "_$conflictMethod_0");

        verify();
    }
View Full Code Here

    {
        Log log = mockLog();

        replay();

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

        assertEquals(ct.newMemberName("prefix", "fred"), "_$prefix_fred");
        assertEquals(ct.newMemberName("prefix", "fred"), "_$prefix_fred_0");

        // Here we're exposing a bit of the internal algorithm, which strips
        // off '$' and '_' before tacking "_$" in front.

        assertEquals(ct.newMemberName("prefix", "_fred"), "_$prefix_fred_1");
        assertEquals(ct.newMemberName("prefix", "_$fred"), "_$prefix_fred_2");
        assertEquals(ct.newMemberName("prefix", "__$___$____$_fred"), "_$prefix_fred_3");

        verify();
    }
View Full Code Here

    {
        Log log = mockLog();

        replay();

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

        try
        {
            ct.getFieldAnnotation("unknownField", Retain.class);
            unreachable();
        }
        catch (RuntimeException ex)
        {
            assertEquals(
View Full Code Here

    {
        Log log = mockLog();

        replay();

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

        Retain retain = ct.getFieldAnnotation("_annotatedField", Retain.class);

        assertNotNull(retain);

        verify();
    }
View Full Code Here

    {
        Log log = mockLog();

        replay();

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

        // Field with annotations, but not that annotation
        assertNull(ct.getFieldAnnotation("_annotatedField", Override.class));

        // Field with no annotations
        assertNull(ct.getFieldAnnotation("_parentField", Override.class));

        verify();
    }
View Full Code Here

    {
        Log log = mockLog();

        replay();

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

        List<String> fields = ct.findFieldsWithAnnotation(Retain.class);

        assertEquals(fields.size(), 1);
        assertEquals(fields.get(0), "_annotatedField");

        verify();
View Full Code Here

    {
        Log log = mockLog();

        replay();

        ClassTransformation ct = createClassTransformation(FindFieldClass.class, log);

        checkFindFields(ct, "boolean", "_booleanValue");
        checkFindFields(ct, "int[]", "_intArrayValue");
        checkFindFields(ct, "java.lang.String", "_stringValue");
        checkFindFields(ct, "java.util.Date[]", "_dateArrayValue");
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.