Search in sources :

Example 1 with PageRenderQueue

use of org.apache.tapestry5.internal.services.PageRenderQueue in project tapestry-5 by apache.

the class LinkSourceImplTest method testEventLinkCreation2.

private void testEventLinkCreation2(String pageName, String nestedId, String eventType, boolean forForm, Object... context) {
    Page primaryPage = mockPage();
    PageRenderQueue queue = mockPageRenderQueue();
    PageActivationContextCollector collector = mockPageActivationContextCollector();
    LinkCreationListener2 listener = mockLinkCreationListener2();
    ComponentEventLinkEncoder linkEncoder = mockComponentEventLinkEncoder();
    Link link = mockLink();
    ArrayEventContext eventContext = new ArrayEventContext(typeCoercer, context);
    ArrayEventContext pageEventContext = new ArrayEventContext(typeCoercer, "a", "b");
    train_getRenderingPage(queue, null);
    train_getName(primaryPage, pageName);
    train_collectPageActivationContext(collector, pageName, "a", "b");
    ComponentEventRequestParameters parameters = new ComponentEventRequestParameters(pageName, pageName, nestedId, eventType, pageEventContext, eventContext);
    expect(linkEncoder.createComponentEventLink(parameters, forForm)).andReturn(link);
    listener.createdComponentEventLink(link, parameters);
    List<LinkCreationListener2> configuration = CollectionFactory.newList(listener);
    replay();
    LinkSource source = new LinkSourceImpl(queue, collector, typeCoercer, null, linkEncoder, null, null, configuration);
    Link returnedLink = source.createComponentEventLink(primaryPage, nestedId, eventType, forForm, context);
    // Make sure the same link is returned.
    assertSame(returnedLink, link);
    verify();
}
Also used : ComponentEventLinkEncoder(org.apache.tapestry5.services.ComponentEventLinkEncoder) ComponentEventRequestParameters(org.apache.tapestry5.services.ComponentEventRequestParameters) Page(org.apache.tapestry5.internal.structure.Page) LinkCreationListener2(org.apache.tapestry5.services.LinkCreationListener2) Link(org.apache.tapestry5.http.Link)

Example 2 with PageRenderQueue

use of org.apache.tapestry5.internal.services.PageRenderQueue in project tapestry-5 by apache.

the class LinkSourceImplTest method testEventLinkCreation.

private void testEventLinkCreation(String pageName, String nestedId, String eventType, boolean forForm, Object... context) {
    Page primaryPage = mockPage();
    PageRenderQueue queue = mockPageRenderQueue();
    PageActivationContextCollector collector = mockPageActivationContextCollector();
    LinkCreationListener2 listener = mockLinkCreationListener2();
    ComponentEventLinkEncoder linkEncoder = mockComponentEventLinkEncoder();
    Link link = mockLink();
    ArrayEventContext eventContext = new ArrayEventContext(typeCoercer, context);
    ArrayEventContext pageEventContext = new ArrayEventContext(typeCoercer, "a", "b");
    train_getRenderingPage(queue, null);
    train_getName(primaryPage, pageName);
    train_collectPageActivationContext(collector, pageName, "a", "b");
    ComponentEventRequestParameters parameters = new ComponentEventRequestParameters(pageName, pageName, nestedId, eventType, pageEventContext, eventContext);
    expect(linkEncoder.createComponentEventLink(parameters, forForm)).andReturn(link);
    listener.createdComponentEventLink(link, parameters);
    replay();
    LinkSource source = new LinkSourceImpl(queue, collector, typeCoercer, null, linkEncoder, null, null, emptyConfiguration);
    source.getLinkCreationHub().addListener(listener);
    Link returnedLink = source.createComponentEventLink(primaryPage, nestedId, eventType, forForm, context);
    // Make sure the same link is returned.
    assertSame(returnedLink, link);
    verify();
}
Also used : ComponentEventLinkEncoder(org.apache.tapestry5.services.ComponentEventLinkEncoder) ComponentEventRequestParameters(org.apache.tapestry5.services.ComponentEventRequestParameters) Page(org.apache.tapestry5.internal.structure.Page) LinkCreationListener2(org.apache.tapestry5.services.LinkCreationListener2) Link(org.apache.tapestry5.http.Link)

Example 3 with PageRenderQueue

use of org.apache.tapestry5.internal.services.PageRenderQueue in project tapestry-5 by apache.

the class LinkSourceImplTest method component_event_from_other_page.

@Test
public void component_event_from_other_page() {
    String primaryPageName = "blocks/AppDisplay";
    Page primaryPage = mockPage();
    Page activePage = mockPage();
    PageRenderQueue queue = mockPageRenderQueue();
    PageActivationContextCollector collector = mockPageActivationContextCollector();
    ComponentEventLinkEncoder linkEncoder = mockComponentEventLinkEncoder();
    Link link = mockLink();
    train_getRenderingPage(queue, activePage);
    train_getName(activePage, "order/View");
    train_getName(primaryPage, primaryPageName);
    train_collectPageActivationContext(collector, "order/View", "x", "y");
    EventContext pageActivationContext = new ArrayEventContext(typeCoercer, "x", "y");
    EventContext eventContext = new ArrayEventContext(typeCoercer, 3, 5, 9);
    ComponentEventRequestParameters parameters = new ComponentEventRequestParameters("order/View", primaryPageName, "gnip.gnop", "myevent", pageActivationContext, eventContext);
    expect(linkEncoder.createComponentEventLink(parameters, true)).andReturn(link);
    replay();
    LinkSource source = new LinkSourceImpl(queue, collector, typeCoercer, null, linkEncoder, null, null, emptyConfiguration);
    assertSame(source.createComponentEventLink(primaryPage, "gnip.gnop", "myevent", true, 3, 5, 9), link);
    verify();
}
Also used : EventContext(org.apache.tapestry5.EventContext) ComponentEventLinkEncoder(org.apache.tapestry5.services.ComponentEventLinkEncoder) ComponentEventRequestParameters(org.apache.tapestry5.services.ComponentEventRequestParameters) Page(org.apache.tapestry5.internal.structure.Page) Link(org.apache.tapestry5.http.Link) Test(org.testng.annotations.Test)

Example 4 with PageRenderQueue

use of org.apache.tapestry5.internal.services.PageRenderQueue in project tapestry-5 by apache.

the class AjaxComponentInstanceEventResultProcessorTest method render_complete_page_as_partial.

@Test
public void render_complete_page_as_partial() throws IOException {
    String pageName = "Biff";
    RequestPageCache cache = mockRequestPageCache();
    ComponentResources resources = mockComponentResources();
    Component component = mockComponent();
    PageRenderQueue queue = mockPageRenderQueue();
    ComponentEventResultProcessor master = mockComponentEventResultProcessor();
    train_getComponentResources(component, resources);
    train_getPage(resources, component);
    train_getPageName(resources, pageName);
    master.processResultValue(pageName);
    replay();
    ComponentEventResultProcessor<Component> processor = new AjaxComponentInstanceEventResultProcessor(cache, master);
    processor.processResultValue(component);
    verify();
}
Also used : ComponentEventResultProcessor(org.apache.tapestry5.services.ComponentEventResultProcessor) Component(org.apache.tapestry5.runtime.Component) ComponentResources(org.apache.tapestry5.ComponentResources) Test(org.testng.annotations.Test)

Aggregations

Link (org.apache.tapestry5.http.Link)3 Page (org.apache.tapestry5.internal.structure.Page)3 ComponentEventLinkEncoder (org.apache.tapestry5.services.ComponentEventLinkEncoder)3 ComponentEventRequestParameters (org.apache.tapestry5.services.ComponentEventRequestParameters)3 LinkCreationListener2 (org.apache.tapestry5.services.LinkCreationListener2)2 Test (org.testng.annotations.Test)2 ComponentResources (org.apache.tapestry5.ComponentResources)1 EventContext (org.apache.tapestry5.EventContext)1 Component (org.apache.tapestry5.runtime.Component)1 ComponentEventResultProcessor (org.apache.tapestry5.services.ComponentEventResultProcessor)1