use of org.apache.tapestry5.http.services.Response in project tapestry-5 by apache.
the class ComponentEventLinkEncoderImplTest method index_stripped_off.
@Test
public void index_stripped_off() {
RequestSecurityManager manager = mockRequestSecurityManager();
Response response = mockResponse();
ContextPathEncoder contextPathEncoder = getService(ContextPathEncoder.class);
expect(manager.checkPageSecurity("admin/Index")).andReturn(LinkSecurity.INSECURE);
train_encodeURL(response, "/admin/abc", "MAGIC");
replay();
ComponentEventLinkEncoder encoder = new ComponentEventLinkEncoderImpl(null, contextPathEncoder, null, response, manager, null, null, false, "", "", null, null);
PageRenderRequestParameters parameters = new PageRenderRequestParameters("admin/Index", new ArrayEventContext(typeCoercer, "abc"));
Link link = encoder.createPageRenderLink(parameters);
assertEquals(link.toURI(), "MAGIC");
verify();
}
use of org.apache.tapestry5.http.services.Response in project tapestry-5 by apache.
the class ComponentEventLinkEncoderImplTest method illegal_activation_context_leads_to_http_404.
@Test
public // TAP5-2436
void illegal_activation_context_leads_to_http_404() throws Exception {
ComponentClassResolver resolver = mockComponentClassResolver();
Request request = mockRequest();
Response response = mockResponse();
LocalizationSetter ls = mockLocalizationSetter();
MetaDataLocator metaDataLocator = neverWhitelistProtected();
train_getPath(request, "/foo/pageid=123");
train_setLocaleFromLocaleName(ls, "foo", false);
train_isPageName(resolver, "foo/pageid=123", false);
train_isPageName(resolver, "foo", false);
train_isPageName(resolver, "", true);
train_canonicalizePageName(resolver, "", "Index");
replay();
ComponentEventLinkEncoderImpl linkEncoder = new ComponentEventLinkEncoderImpl(resolver, contextPathEncoder, ls, response, null, null, null, true, null, "", metaDataLocator, null);
PageRenderRequestParameters parameters = linkEncoder.decodePageRenderRequest(request);
assertNull(parameters);
verify();
}
use of org.apache.tapestry5.http.services.Response in project tapestry-5 by apache.
the class ComponentEventLinkEncoderImplTest method not_a_page_request.
@Test
public void not_a_page_request() throws Exception {
ComponentClassResolver resolver = mockComponentClassResolver();
Request request = mockRequest();
Response response = mockResponse();
LocalizationSetter ls = mockLocalizationSetter();
stub_isPageName(resolver, false);
train_setLocaleFromLocaleName(ls, "foo", false);
train_getPath(request, "/foo/Bar.baz");
replay();
ComponentEventLinkEncoderImpl linkEncoder = new ComponentEventLinkEncoderImpl(resolver, contextPathEncoder, ls, response, null, null, null, true, null, "", null, null);
PageRenderRequestParameters parameters = linkEncoder.decodePageRenderRequest(request);
assertNull(parameters);
verify();
}
use of org.apache.tapestry5.http.services.Response in project tapestry-5 by apache.
the class ComponentEventLinkEncoderImplTest method empty_path.
@Test
public void empty_path() throws Exception {
ComponentClassResolver resolver = mockComponentClassResolver();
Request request = mockRequest();
Response response = mockResponse();
LocalizationSetter ls = mockLocalizationSetter();
train_getPath(request, "");
train_setLocaleFromLocaleName(ls, "", false);
train_isPageName(resolver, "", false);
replay();
ComponentEventLinkEncoderImpl linkEncoder = new ComponentEventLinkEncoderImpl(resolver, contextPathEncoder, ls, response, null, null, null, true, null, "", null, null);
PageRenderRequestParameters parameters = linkEncoder.decodePageRenderRequest(request);
assertNull(parameters);
verify();
}
use of org.apache.tapestry5.http.services.Response in project tapestry-5 by apache.
the class DefaultRequestExceptionHandlerTest method setup_tests.
@BeforeMethod
public void setup_tests() throws Exception {
mockConfiguration.clear();
pageCache = mockRequestPageCache();
renderer = mockPageResponseRenderer();
logger = mockLogger();
request = mockRequest();
response = mockResponse();
componentClassResolver = mockComponentClassResolver();
linkSource = mockLinkSource();
serviceResources = mockServiceResources();
mockConfiguration.put(AccessControlException.class, MyPage.class);
mockConfiguration.put(MyContextAwareException.class, new ExceptionHandlerAssistant() {
public Object handleRequestException(Throwable exception, List<Object> exceptionContext) throws IOException {
return null;
}
});
ExceptionReporter noopExceptionReporter = new ExceptionReporter() {
@Override
public void reportException(Throwable exception) {
}
};
exceptionHandler = new DefaultRequestExceptionHandler(pageCache, renderer, logger, "exceptionpage", request, response, componentClassResolver, linkSource, serviceResources, noopExceptionReporter, false, mockConfiguration);
}
Aggregations