Search in sources :

Example 6 with RequestFilter

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

the class StaticFilesFilterTest method not_a_static_file_request.

@Test
public void not_a_static_file_request() throws Exception {
    String path = "/start.update";
    Request request = newRequest(path);
    Response response = mockResponse();
    RequestHandler handler = mockRequestHandler();
    Context context = mockContext();
    train_getResource(context, path, null);
    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 7 with RequestFilter

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

the class StaticFilesFilterTest method path_does_not_contain_a_period.

@Test
public void path_does_not_contain_a_period() throws Exception {
    Request request = newRequest("/start");
    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 8 with RequestFilter

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

the class StaticFilesFilterTest method existing_template_file.

@Test
public void existing_template_file() 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)

Aggregations

Request (org.apache.tapestry5.http.services.Request)8 RequestFilter (org.apache.tapestry5.http.services.RequestFilter)8 RequestHandler (org.apache.tapestry5.http.services.RequestHandler)8 Response (org.apache.tapestry5.http.services.Response)8 HttpServletResponse (javax.servlet.http.HttpServletResponse)7 Context (org.apache.tapestry5.http.services.Context)7 Test (org.testng.annotations.Test)7 URL (java.net.URL)3 StreamResponse (org.apache.tapestry5.StreamResponse)1 HttpServletRequestFilter (org.apache.tapestry5.http.services.HttpServletRequestFilter)1 ComponentEventRequestFilter (org.apache.tapestry5.services.ComponentEventRequestFilter)1 ComponentEventRequestHandler (org.apache.tapestry5.services.ComponentEventRequestHandler)1 ComponentRequestFilter (org.apache.tapestry5.services.ComponentRequestFilter)1 ComponentRequestHandler (org.apache.tapestry5.services.ComponentRequestHandler)1 PageRenderRequestFilter (org.apache.tapestry5.services.PageRenderRequestFilter)1 PageRenderRequestHandler (org.apache.tapestry5.services.PageRenderRequestHandler)1