Package org.apache.tapestry.runtime

Examples of org.apache.tapestry.runtime.Component


    @Test
    public void cached_object_read() throws Exception
    {
        InternalComponentResources resources = mockInternalComponentResources();

        Component component = setupForIntegrationTest(resources);

        train_isLoaded(resources, true);
        train_isBound(resources, "object", true);
        train_readParameter(resources, "object", String.class, "first");
        train_isRendering(resources, false);

        replay();

        assertEquals(_access.get(component, "object"), "first");

        verify();

        // Keeps re-reading the parameter when not rendering.

        train_isLoaded(resources, true);
        train_isBound(resources, "object", true);
        train_readParameter(resources, "object", String.class, "second");
        train_isRendering(resources, false);

        replay();

        assertEquals(_access.get(component, "object"), "second");

        verify();

        // Now, when rendering is active, the value is cached

        train_isLoaded(resources, true);
        train_isBound(resources, "object", true);
        train_readParameter(resources, "object", String.class, "third");
        train_isRendering(resources, true);

        replay();

        assertEquals(_access.get(component, "object"), "third");

        // Does not cause readParameter() to be invoked:

        assertEquals(_access.get(component, "object"), "third");

        verify();

        train_isLoaded(resources, true);
        train_isBound(resources, "object", true);
        train_readParameter(resources, "object", String.class, "fourth");
        train_isRendering(resources, false);

        replay();

        component.postRenderCleanup();

        assertEquals(_access.get(component, "object"), "fourth");

        verify();
    }
View Full Code Here


    @Test
    public void cached_object_write() throws Exception
    {
        InternalComponentResources resources = mockInternalComponentResources();

        Component component = setupForIntegrationTest(resources);

        train_isLoaded(resources, true);
        train_isBound(resources, "object", true);
        resources.writeParameter("object", "first");
        train_isRendering(resources, false);

        train_isLoaded(resources, true);
        train_isBound(resources, "object", true);
        train_readParameter(resources, "object", String.class, "second");
        train_isRendering(resources, false);

        replay();

        _access.set(component, "object", "first");
        assertEquals(_access.get(component, "object"), "second");

        verify();

        // Now try during rendering ...

        train_isLoaded(resources, true);
        train_isBound(resources, "object", true);
        resources.writeParameter("object", "third");
        train_isRendering(resources, true);

        replay();

        _access.set(component, "object", "third");
        assertEquals(_access.get(component, "object"), "third");

        verify();

        // And the cached value is lost after rendering is complete.

        train_isLoaded(resources, true);
        train_isBound(resources, "object", true);
        train_readParameter(resources, "object", String.class, "fourth");
        train_isRendering(resources, false);

        replay();

        component.postRenderCleanup();

        assertEquals(_access.get(component, "object"), "fourth");

        verify();
    }
View Full Code Here

    @Test
    public void cached_primitive_write() throws Exception
    {
        InternalComponentResources resources = mockInternalComponentResources();

        Component component = setupForIntegrationTest(resources);

        train_isLoaded(resources, true);
        train_isBound(resources, "primitive", true);
        resources.writeParameter("primitive", 321);

        train_isRendering(resources, false);

        train_isLoaded(resources, true);
        train_isBound(resources, "primitive", true);
        train_readParameter(resources, "primitive", int.class, 123);
        train_isRendering(resources, false);

        replay();

        _access.set(component, "primitive", 321);
        assertEquals(_access.get(component, "primitive"), 123);

        verify();

        // Now try during rendering ...

        train_isLoaded(resources, true);
        train_isBound(resources, "primitive", true);
        resources.writeParameter("primitive", 567);
        train_isRendering(resources, true);

        replay();

        _access.set(component, "primitive", 567);
        assertEquals(_access.get(component, "primitive"), 567);

        verify();

        // And the cached value is lost after rendering is complete.

        train_isLoaded(resources, true);
        train_isBound(resources, "primitive", true);
        train_readParameter(resources, "primitive", int.class, 890);
        train_isRendering(resources, false);

        replay();

        component.postRenderCleanup();

        assertEquals(_access.get(component, "primitive"), 890);

        verify();
    }
View Full Code Here

    @Test
    public void uncached_object_read() throws Exception
    {
        InternalComponentResources resources = mockInternalComponentResources();

        Component component = setupForIntegrationTest(resources);

        // Notice no check for isRendering() since that is irrelevant to uncached parameters.
        // Also note difference between field name and parameter name, due to Parameter.name() being
        // specified.
View Full Code Here

    @Test
    public void uncached_object_write() throws Exception
    {
        InternalComponentResources resources = mockInternalComponentResources();

        Component component = setupForIntegrationTest(resources);

        // Notice no check for isRendering() since that is irrelevant to uncached parameters.
        // Also note difference between field name and parameter name, due to Parameter.name() being
        // specified.
View Full Code Here

                train_isInvariant(resources, "value", true);

            };
        };

        Component component = setupForIntegrationTest(
                resources,
                mockLog(),
                DefaultParameterComponent.class.getName(),
                model,
                source,
View Full Code Here

                train_isInvariant(resources, "value", true);
            };
        };

        Component component = setupForIntegrationTest(
                resources,
                mockLog(),
                DefaultParameterBindingMethodComponent.class.getName(),
                model,
                source,
View Full Code Here

        phaseTwoTraining.run();

        replay();

        Component component = instantiator.newInstance(resources);

        component.containingPageDidLoad();

        verify();

        return component;
    }
View Full Code Here

    private static final String LINK_URI = "{LinkURI}";

    @Test
    public void result_is_root_component() throws Exception
    {
        Component result = mockComponent();
        Component source = mockComponent();
        ComponentResources resources = mockComponentResources();
        Log log = mockLog();
        RequestPageCache cache = mockRequestPageCache();
        Page page = mockPage();
        LinkFactory factory = mockLinkFactory();
View Full Code Here

    }

    @Test
    public void warning_for_component_is_not_root_component() throws Exception
    {
        Component child = mockComponent();
        Component source = mockComponent();
        Component root = mockComponent();
        Component container = mockComponent();
        ComponentResources rootResources = mockComponentResources();
        ComponentResources childResources = mockComponentResources();
        ComponentResources sourceResources = mockComponentResources();
        Log log = mockLog();
        RequestPageCache cache = mockRequestPageCache();
View Full Code Here

TOP

Related Classes of org.apache.tapestry.runtime.Component

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.