use of org.apache.tapestry5.http.services.Response 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();
}
use of org.apache.tapestry5.http.services.Response 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();
}
use of org.apache.tapestry5.http.services.Response in project tapestry-5 by apache.
the class ComponentEventDispatcher method dispatch.
public boolean dispatch(Request request, Response response) throws IOException {
ComponentEventRequestParameters parameters = linkEncoder.decodeComponentEventRequest(request);
if (parameters == null)
return false;
// Inside this pipeline, may find that the component id does not exist (this check only occurs in production
// mode) ...
componentRequestHandler.handleComponentEvent(parameters);
// ... in which case, this attribute is set.
if (request.getAttribute(InternalConstants.REFERENCED_COMPONENT_NOT_FOUND) != null) {
return false;
}
return true;
}
use of org.apache.tapestry5.http.services.Response in project tapestry-5 by apache.
the class ComponentEventLinkEncoderImpl method createComponentEventLink.
public Link createComponentEventLink(ComponentEventRequestParameters parameters, boolean forForm) {
StringBuilder builder = new StringBuilder(BUFFER_SIZE);
// Build up the absolute URI.
String activePageName = parameters.getActivePageName();
String containingPageName = parameters.getContainingPageName();
String eventType = parameters.getEventType();
String nestedComponentId = parameters.getNestedComponentId();
boolean hasComponentId = InternalUtils.isNonBlank(nestedComponentId);
builder.append(contextPath);
encodeAppFolderAndLocale(builder);
builder.append(SLASH);
builder.append(activePageName.toLowerCase());
if (hasComponentId) {
builder.append('.');
builder.append(nestedComponentId);
}
if (!hasComponentId || !eventType.equals(EventConstants.ACTION)) {
builder.append(':');
builder.append(encodePageName(eventType));
}
appendContext(true, parameters.getEventContext(), builder);
Link result = new LinkImpl(builder.toString(), forForm, requestSecurityManager.checkPageSecurity(activePageName), response, contextPathEncoder, baseURLSource);
EventContext pageActivationContext = parameters.getPageActivationContext();
if (pageActivationContext.getCount() != 0) {
// Reuse the builder
builder.setLength(0);
appendContext(true, pageActivationContext, builder);
// Omit that first slash
result.addParameter(InternalConstants.PAGE_CONTEXT_NAME, builder.substring(1));
}
if (!containingPageName.equalsIgnoreCase(activePageName))
result.addParameter(InternalConstants.CONTAINER_PAGE_NAME, encodePageName(containingPageName));
return result;
}
use of org.apache.tapestry5.http.services.Response in project tapestry-5 by apache.
the class ResponseImplTest method addHeader.
@Test
public void addHeader() {
final String HEADER_NAME = "Header-Name";
final String[] HEADER_VALUES = { "asdfasdf", "FHDFGH", "####" };
final HttpServletResponse httpServletResponse = mockHttpServletResponse();
final HttpServletRequest httpServletRequest = mockHttpServletRequest();
Response response = new ResponseImpl(httpServletRequest, httpServletResponse);
for (String value : HEADER_VALUES) {
httpServletResponse.addHeader(HEADER_NAME, value);
}
replay();
for (String value : HEADER_VALUES) {
response.addHeader(HEADER_NAME, value);
}
verify();
}
Aggregations