Search in sources :

Example 6 with Path

use of org.apache.tapestry5.annotations.Path in project tapestry-5 by apache.

the class TemplateParserImplTest method resource_that_throws_exception.

@Test
public // TAP5-2516
void resource_that_throws_exception() throws Exception {
    Resource resource = new AbstractResource("throwfoo") {

        @Override
        public URL toURL() {
            return null;
        }

        @Override
        public boolean exists() {
            return true;
        }

        @Override
        protected Resource newResource(String path) {
            return null;
        }

        @Override
        public InputStream openStream() throws IOException {
            throw new IOException("foo");
        }
    };
    try {
        getParser().parseTemplate(resource);
        unreachable();
    } catch (RuntimeException ex) {
        if (ex.getCause() instanceof TapestryException && ex.getCause().getCause() instanceof IOException) {
            assertMessageContains(ex, "foo");
        } else {
            throw ex;
        }
    }
}
Also used : Resource(org.apache.tapestry5.commons.Resource) ClasspathResource(org.apache.tapestry5.ioc.internal.util.ClasspathResource) AbstractResource(org.apache.tapestry5.ioc.internal.util.AbstractResource) AbstractResource(org.apache.tapestry5.ioc.internal.util.AbstractResource) IOException(java.io.IOException) TapestryException(org.apache.tapestry5.commons.internal.util.TapestryException) Test(org.testng.annotations.Test)

Example 7 with Path

use of org.apache.tapestry5.annotations.Path in project tapestry-5 by apache.

the class StaticFilesFilterTest method newRequest.

protected final Request newRequest(String path) {
    Request request = mockRequest();
    train_getPath(request, path);
    return request;
}
Also used : Request(org.apache.tapestry5.http.services.Request)

Example 8 with Path

use of org.apache.tapestry5.annotations.Path 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 9 with Path

use of org.apache.tapestry5.annotations.Path 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 10 with Path

use of org.apache.tapestry5.annotations.Path 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)

Aggregations

Test (org.testng.annotations.Test)22 Request (org.apache.tapestry5.http.services.Request)14 Context (org.apache.tapestry5.http.services.Context)9 Resource (org.apache.tapestry5.commons.Resource)8 Path (io.fabric8.annotations.Path)6 IOException (java.io.IOException)6 URL (java.net.URL)6 HttpServletResponse (javax.servlet.http.HttpServletResponse)6 RequestFilter (org.apache.tapestry5.http.services.RequestFilter)5 RequestHandler (org.apache.tapestry5.http.services.RequestHandler)5 Response (org.apache.tapestry5.http.services.Response)5 ComponentClassResolver (org.apache.tapestry5.services.ComponentClassResolver)5 LocalizationSetter (org.apache.tapestry5.services.LocalizationSetter)5 MetaDataLocator (org.apache.tapestry5.services.MetaDataLocator)5 PageRenderRequestParameters (org.apache.tapestry5.services.PageRenderRequestParameters)5 Configuration (io.fabric8.annotations.Configuration)4 Endpoint (io.fabric8.annotations.Endpoint)4 External (io.fabric8.annotations.External)4 PortName (io.fabric8.annotations.PortName)4 Protocol (io.fabric8.annotations.Protocol)4