Search in sources :

Example 11 with Context

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

the class PageRenderRequestHandlerImplTest method loopback_request.

@Test
public void loopback_request() throws Exception {
    RequestPageCache cache = mockRequestPageCache();
    ComponentEventResultProcessor processor = mockComponentEventResultProcessor();
    PageResponseRenderer renderer = mockPageResponseRenderer();
    Page page = mockPage();
    EventContext context = mockEventContext();
    ComponentPageElement root = mockComponentPageElement();
    InternalComponentResources pageResources = mockInternalComponentResources();
    PageActivator activator = newMock(PageActivator.class);
    Request request = mockRequest();
    train_getAttribute(request, InternalConstants.BYPASS_ACTIVATION, null);
    train_get(cache, "foo/Bar", page);
    train_getRootElement(page, root);
    train_getComponentResources(root, pageResources);
    expect(activator.activatePage(pageResources, context, processor)).andReturn(false);
    // Skips the pageReset()
    renderer.renderPageResponse(page);
    replay();
    PageRenderRequestHandler handler = new PageRenderRequestHandlerImpl(cache, processor, renderer, activator, request);
    PageRenderRequestParameters parameters = new PageRenderRequestParameters("foo/Bar", context, true);
    handler.handle(parameters);
    verify();
}
Also used : EventContext(org.apache.tapestry5.EventContext) PageRenderRequestParameters(org.apache.tapestry5.services.PageRenderRequestParameters) ComponentPageElement(org.apache.tapestry5.internal.structure.ComponentPageElement) ComponentEventResultProcessor(org.apache.tapestry5.services.ComponentEventResultProcessor) InternalComponentResources(org.apache.tapestry5.internal.InternalComponentResources) Request(org.apache.tapestry5.http.services.Request) PageRenderRequestHandler(org.apache.tapestry5.services.PageRenderRequestHandler) Page(org.apache.tapestry5.internal.structure.Page) Test(org.testng.annotations.Test)

Example 12 with Context

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

the class StaticFilesFilterTest method existing_file.

@Test
public void existing_file() throws Exception {
    URL url = new URL("file://.");
    String path = "/cell.gif";
    Request request = newRequest(path);
    Response response = mockResponse();
    RequestHandler handler = mockRequestHandler();
    Context context = mockContext();
    train_getResource(context, path, url);
    replay();
    RequestFilter filter = new StaticFilesFilter(context);
    assertFalse(filter.service(request, response, handler));
    verify();
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(org.apache.tapestry5.http.services.Response) Context(org.apache.tapestry5.http.services.Context) RequestHandler(org.apache.tapestry5.http.services.RequestHandler) Request(org.apache.tapestry5.http.services.Request) URL(java.net.URL) RequestFilter(org.apache.tapestry5.http.services.RequestFilter) Test(org.testng.annotations.Test)

Example 13 with Context

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

the class StaticFilesFilterTest method colon_in_path_prevents_static_file_check.

/**
 * TAPESTRY-2606
 */
@Test
public void colon_in_path_prevents_static_file_check() throws Exception {
    String path = "/start.update:anevent";
    Request request = newRequest(path);
    Response response = mockResponse();
    RequestHandler handler = mockRequestHandler();
    Context context = mockContext();
    train_service(handler, request, response, true);
    replay();
    RequestFilter filter = new StaticFilesFilter(context);
    assertTrue(filter.service(request, response, handler));
    verify();
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(org.apache.tapestry5.http.services.Response) Context(org.apache.tapestry5.http.services.Context) RequestHandler(org.apache.tapestry5.http.services.RequestHandler) Request(org.apache.tapestry5.http.services.Request) RequestFilter(org.apache.tapestry5.http.services.RequestFilter) Test(org.testng.annotations.Test)

Example 14 with Context

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

the class StaticFilesFilterTest method existing_template_file_case_insenitive.

@Test
public void existing_template_file_case_insenitive() throws Exception {
    URL url = new URL("file://.");
    String path = "/cell.TML";
    Request request = newRequest(path);
    Response response = mockResponse();
    RequestHandler handler = mockRequestHandler();
    Context context = mockContext();
    train_getResource(context, path, url);
    response.sendError(HttpServletResponse.SC_FORBIDDEN, "URI /cell.TML may not be accessed remotely.");
    replay();
    RequestFilter filter = new StaticFilesFilter(context);
    assertTrue(filter.service(request, response, handler));
    verify();
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(org.apache.tapestry5.http.services.Response) Context(org.apache.tapestry5.http.services.Context) RequestHandler(org.apache.tapestry5.http.services.RequestHandler) Request(org.apache.tapestry5.http.services.Request) URL(java.net.URL) RequestFilter(org.apache.tapestry5.http.services.RequestFilter) Test(org.testng.annotations.Test)

Example 15 with Context

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

the class StaticFilesFilterTest method request_for_favicon.

@Test
public void request_for_favicon() throws IOException {
    Request request = newRequest("/favicon.ico");
    Response response = mockResponse();
    RequestHandler handler = mockRequestHandler();
    Context context = mockContext();
    replay();
    RequestFilter filter = new StaticFilesFilter(context);
    assertFalse(filter.service(request, response, handler));
    verify();
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(org.apache.tapestry5.http.services.Response) Context(org.apache.tapestry5.http.services.Context) RequestHandler(org.apache.tapestry5.http.services.RequestHandler) Request(org.apache.tapestry5.http.services.Request) RequestFilter(org.apache.tapestry5.http.services.RequestFilter) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)29 Context (org.apache.tapestry5.http.services.Context)18 Link (org.apache.tapestry5.http.Link)16 EventContext (org.apache.tapestry5.EventContext)12 ComponentEventCallback (org.apache.tapestry5.ComponentEventCallback)9 Request (org.apache.tapestry5.http.services.Request)9 Response (org.apache.tapestry5.http.services.Response)9 ComponentModel (org.apache.tapestry5.model.ComponentModel)9 Logger (org.slf4j.Logger)9 RequestFilter (org.apache.tapestry5.http.services.RequestFilter)8 RequestHandler (org.apache.tapestry5.http.services.RequestHandler)8 ComponentEvent (org.apache.tapestry5.runtime.ComponentEvent)8 ServletContext (javax.servlet.ServletContext)7 HttpServletResponse (javax.servlet.http.HttpServletResponse)7 PageRenderRequestParameters (org.apache.tapestry5.services.PageRenderRequestParameters)7 ComponentResources (org.apache.tapestry5.ComponentResources)6 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)6 InternalComponentResources (org.apache.tapestry5.internal.InternalComponentResources)6 JSONObject (org.apache.tapestry5.json.JSONObject)6 LinkCreationListener2 (org.apache.tapestry5.services.LinkCreationListener2)5