use of org.apache.tapestry5.services.ComponentClassResolver in project tapestry-5 by apache.
the class ComponentEventLinkEncoderImplTest method no_extra_context.
private void no_extra_context(boolean finalSlash) throws Exception {
ComponentClassResolver resolver = mockComponentClassResolver();
Request request = mockRequest(false);
LocalizationSetter ls = mockLocalizationSetter();
MetaDataLocator metaDataLocator = neverWhitelistProtected();
String path = "/foo/Bar" + (finalSlash ? "/" : "");
train_getPath(request, path);
train_setLocaleFromLocaleName(ls, "foo", false);
train_isPageName(resolver, "foo/Bar", true);
train_canonicalizePageName(resolver, "foo/Bar", "foo/bar");
replay();
ComponentEventLinkEncoderImpl linkEncoder = new ComponentEventLinkEncoderImpl(resolver, contextPathEncoder, ls, null, null, null, null, true, null, "", metaDataLocator, null);
PageRenderRequestParameters parameters = linkEncoder.decodePageRenderRequest(request);
assertEquals(parameters.getLogicalPageName(), "foo/bar");
assertEquals(parameters.getActivationContext().getCount(), 0);
assertFalse(parameters.isLoopback());
verify();
}
use of org.apache.tapestry5.services.ComponentClassResolver in project tapestry-5 by apache.
the class DefaultRequestExceptionHandlerTest method handleRequestExceptionWithConfiguredPage.
@Test
public void handleRequestExceptionWithConfiguredPage() throws IOException {
train_resolvePageClassNameToPageName(componentClassResolver, MyPage.class.getName(), "mypage");
Link link = mockLink();
expect(linkSource.createPageRenderLink("mypage", false, new Object[] { "accesscontrol" })).andReturn(link);
expect(request.isXHR()).andReturn(false);
response.sendRedirect(link);
EasyMock.expectLastCall();
replay();
// also test unwrapping TapestryExceptions
exceptionHandler.handleRequestException(new OperationException(new RenderQueueException("renderqueue", new Object[0], new TapestryException("tapestryexception", new AccessControlException("No permission"))), new String[0]));
}
use of org.apache.tapestry5.services.ComponentClassResolver 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);
}
use of org.apache.tapestry5.services.ComponentClassResolver in project tapestry-5 by apache.
the class ComponentSourceImplTest method get_active_page.
@Test
public void get_active_page() {
RequestPageCache cache = mockRequestPageCache();
Page page = mockPage();
Component component = mockComponent();
ComponentClassResolver resolver = mockComponentClassResolver();
RequestGlobals globals = mockRequestGlobals();
String pageName = "Active";
expect(globals.getActivePageName()).andReturn(pageName);
train_get(cache, pageName, page);
train_getRootComponent(page, component);
replay();
ComponentSource source = new ComponentSourceImpl(cache, resolver, globals);
assertSame(source.getActivePage(), component);
verify();
}
use of org.apache.tapestry5.services.ComponentClassResolver in project tapestry-5 by apache.
the class ComponentSourceImplTest method nested_element_within_page.
@Test
public void nested_element_within_page() {
RequestPageCache cache = mockRequestPageCache();
Page page = mockPage();
ComponentPageElement element = mockComponentPageElement();
Component component = mockComponent();
ComponentClassResolver resolver = mockComponentClassResolver();
train_get(cache, PAGE_NAME, page);
train_getComponentElementByNestedId(page, NESTED_ELEMENT_ID, element);
train_getComponent(element, component);
replay();
ComponentSource source = new ComponentSourceImpl(cache, resolver, null);
assertSame(source.getComponent(PAGE_NAME + ":" + NESTED_ELEMENT_ID), component);
verify();
}
Aggregations