Package org.apache.tapestry.runtime

Examples of org.apache.tapestry.runtime.Component


    @Test
    public void root_element_of_page()
    {
        RequestPageCache cache = mockRequestPageCache();
        Page page = mockPage();
        Component component = mockComponent();

        train_get(cache, PAGE_NAME, page);

        train_getRootComponent(page, component);
View Full Code Here


    public void nested_element_within_page()
    {
        RequestPageCache cache = mockRequestPageCache();
        Page page = mockPage();
        ComponentPageElement element = mockComponentPageElement();
        Component component = mockComponent();

        train_get(cache, PAGE_NAME, page);

        train_getComponentElementByNestedId(page, NESTED_ELEMENT_ID, element);
View Full Code Here

    @Test
    public void get_page_by_logical_name()
    {
        RequestPageCache cache = mockRequestPageCache();
        Page page = mockPage();
        Component component = mockComponent();

        train_get(cache, PAGE_NAME, page);
        train_getRootComponent(page, component);

        replay();
View Full Code Here

    public void special_prop_binding_value_null()
    {
        Location l = mockLocation();
        String description = "my description";
        ComponentResources resources = mockComponentResources();
        Component component = mockComponent();

        train_getComponent(resources, component);

        replay();
View Full Code Here

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

        Component component = setupForIntegrationTest(resources);

        // On first invocation, the resources are queried.

        String value = "To be in Tapestry in the spring time ...";

        train_isLoaded(resources, true);
        train_isBound(resources, "invariantObject", true);
        train_readParameter(resources, "invariantObject", String.class, value);

        replay();

        assertSame(_access.get(component, "invariantObject"), value);

        verify();

        // No further training needed here.

        replay();

        // Still cached ...

        assertSame(_access.get(component, "invariantObject"), value);

        component.postRenderCleanup();

        // Still cached ...

        assertSame(_access.get(component, "invariantObject"), value);

        component.containingPageDidDetach();

        // Still cached ...

        assertSame(_access.get(component, "invariantObject"), value);
View Full Code Here

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

        Component component = setupForIntegrationTest(resources);

        // On first invocation, the resources are queried.

        long value = 123456;

        train_isLoaded(resources, true);
        train_isBound(resources, "invariantPrimitive", true);
        train_readParameter(resources, "invariantPrimitive", long.class, value);

        replay();

        assertEquals(_access.get(component, "invariantPrimitive"), value);

        verify();

        // No further training needed here.

        replay();

        // Still cached ...

        assertEquals(_access.get(component, "invariantPrimitive"), value);

        component.postRenderCleanup();

        // Still cached ...

        assertEquals(_access.get(component, "invariantPrimitive"), value);
View Full Code Here

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

        Component component = setupForIntegrationTest(resources);

        train_isLoaded(resources, false);

        replay();

        assertNull(_access.get(component, "object"));

        verify();

        train_isLoaded(resources, false);

        replay();

        _access.set(component, "object", "new-default");

        verify();

        train_isLoaded(resources, false);

        replay();

        assertEquals(_access.get(component, "object"), "new-default");

        verify();

        trainForPageDidLoad(resources);

        replay();

        component.containingPageDidLoad();

        verify();

        // For the set ...

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

        // For the first read ...

        train_isLoaded(resources, true);
        train_isBound(resources, "object", false);

        // For the second read (after postRenderCleanup) ...

        train_isLoaded(resources, true);
        train_isBound(resources, "object", false);

        replay();

        _access.set(component, "object", "new-value");
        assertEquals(_access.get(component, "object"), "new-value");

        component.postRenderCleanup();

        assertEquals(_access.get(component, "object"), "new-default");

        verify();
    }
View Full Code Here

    @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

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.