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;
}
}
}
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;
}
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();
}
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();
}
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();
}
Aggregations