Search in sources :

Example 1 with ResponseRenderer

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

the class ResponseRendererImplTest method content_type_from_component.

@Test
public void content_type_from_component() {
    RequestPageCache cache = mockRequestPageCache();
    PageContentTypeAnalyzer analyzer = mockPageContentTypeAnalyzer();
    Component component = mockComponent();
    String pageName = "foo/bar";
    Page page = mockPage();
    ContentType contentType = new ContentType("zig/zag");
    ComponentResources resources = mockComponentResources();
    train_getComponentResources(component, resources);
    train_getPageName(resources, pageName);
    train_get(cache, pageName, page);
    train_findContentType(analyzer, page, contentType);
    replay();
    ResponseRenderer renderer = new ResponseRendererImpl(cache, analyzer, null);
    assertSame(renderer.findContentType(component), contentType);
    verify();
}
Also used : ContentType(org.apache.tapestry5.http.ContentType) ResponseRenderer(org.apache.tapestry5.services.ResponseRenderer) Page(org.apache.tapestry5.internal.structure.Page) Component(org.apache.tapestry5.runtime.Component) ComponentResources(org.apache.tapestry5.ComponentResources) Test(org.testng.annotations.Test)

Example 2 with ResponseRenderer

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

the class ResponseRendererImplTest method render_page_markup.

@Test
public void render_page_markup() throws Exception {
    RequestPageCache cache = mockRequestPageCache();
    PageContentTypeAnalyzer analyzer = mockPageContentTypeAnalyzer();
    String pageName = "foo/bar";
    Page page = mockPage();
    PageResponseRenderer pageResponseRenderer = mockPageResponseRenderer();
    Response response = mockResponse();
    train_get(cache, pageName, page);
    pageResponseRenderer.renderPageResponse(page);
    replay();
    ResponseRenderer renderer = new ResponseRendererImpl(cache, analyzer, pageResponseRenderer);
    renderer.renderPageMarkupResponse(pageName);
    verify();
}
Also used : Response(org.apache.tapestry5.http.services.Response) ResponseRenderer(org.apache.tapestry5.services.ResponseRenderer) Page(org.apache.tapestry5.internal.structure.Page) Test(org.testng.annotations.Test)

Example 3 with ResponseRenderer

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

the class DeferredResponseRenderer method invokeQueuedRenderer.

private void invokeQueuedRenderer() throws IOException {
    while (true) {
        IOOperation responseRenderer = (IOOperation) request.getAttribute(TapestryConstants.RESPONSE_RENDERER);
        if (responseRenderer == null) {
            break;
        }
        // There's a particular case where an operation puts a different operation into the attribute;
        // we'll handle that on the next pass.
        request.setAttribute(TapestryConstants.RESPONSE_RENDERER, null);
        tracker.perform("Executing deferred response renderer.", responseRenderer);
    }
}
Also used : IOOperation(org.apache.tapestry5.ioc.IOOperation)

Aggregations

Page (org.apache.tapestry5.internal.structure.Page)2 ResponseRenderer (org.apache.tapestry5.services.ResponseRenderer)2 Test (org.testng.annotations.Test)2 ComponentResources (org.apache.tapestry5.ComponentResources)1 ContentType (org.apache.tapestry5.http.ContentType)1 Response (org.apache.tapestry5.http.services.Response)1 IOOperation (org.apache.tapestry5.ioc.IOOperation)1 Component (org.apache.tapestry5.runtime.Component)1