use of org.apache.tapestry5.services.MetaDataLocator in project tapestry-5 by apache.
the class RequestSecurityManagerImplTest method check_page_security.
@Test(dataProvider = "check_page_security_data")
public void check_page_security(boolean secureRequest, boolean securePage, LinkSecurity expectedLinkSecurity) {
Request request = mockRequest();
Response response = mockResponse();
MetaDataLocator locator = mockMetaDataLocator();
ComponentEventLinkEncoder encoder = newMock(ComponentEventLinkEncoder.class);
train_isSecure(request, secureRequest);
train_isSecure(locator, PAGE_NAME, securePage);
replay();
RequestSecurityManager manager = new RequestSecurityManagerImpl(request, response, encoder, locator, true);
assertEquals(manager.checkPageSecurity(PAGE_NAME), expectedLinkSecurity);
verify();
}
use of org.apache.tapestry5.services.MetaDataLocator in project tapestry-5 by apache.
the class RequestSecurityManagerImplTest method check_page_not_secure.
@Test
public void check_page_not_secure() throws Exception {
Request request = mockRequest();
Response response = mockResponse();
MetaDataLocator locator = mockMetaDataLocator();
ComponentEventLinkEncoder encoder = newMock(ComponentEventLinkEncoder.class);
train_isSecure(request, false);
train_isSecure(locator, PAGE_NAME, false);
replay();
PageRenderRequestParameters parameters = new PageRenderRequestParameters(PAGE_NAME, new EmptyEventContext(), false);
RequestSecurityManager manager = new RequestSecurityManagerImpl(request, response, encoder, locator, true);
assertFalse(manager.checkForInsecurePageRenderRequest(parameters));
verify();
}
use of org.apache.tapestry5.services.MetaDataLocator in project tapestry-5 by apache.
the class PageImplTest method detach_notification.
@Test
public void detach_notification() {
PageLifecycleListener listener1 = newPageLifecycle();
PageLifecycleListener listener2 = newPageLifecycle();
listener1.containingPageDidDetach();
listener2.containingPageDidDetach();
MetaDataLocator locator = newMetaDataLocator(LOGICAL_PAGE_NAME, true);
replay();
Page page = new PageImpl(LOGICAL_PAGE_NAME, selector, null, perThreadManager, locator);
page.addLifecycleListener(listener1);
page.addLifecycleListener(listener2);
assertFalse(page.detached());
verify();
}
use of org.apache.tapestry5.services.MetaDataLocator in project tapestry-5 by apache.
the class PageImplTest method attach_notification.
@Test
public void attach_notification() {
MetaDataLocator locator = newMetaDataLocator(LOGICAL_PAGE_NAME, true);
PageLifecycleListener listener1 = newPageLifecycle();
PageLifecycleListener listener2 = newPageLifecycle();
listener1.containingPageDidAttach();
listener2.containingPageDidAttach();
replay();
Page page = new PageImpl(LOGICAL_PAGE_NAME, selector, null, perThreadManager, locator);
page.addLifecycleListener(listener1);
page.addLifecycleListener(listener2);
page.attached();
verify();
}
use of org.apache.tapestry5.services.MetaDataLocator in project tapestry-5 by apache.
the class PageImplTest method detach_dirty_if_listener_throws_exception.
/**
* Also checks that all listeners are invoked, even if one of them throws an exception.
*/
@Test
public void detach_dirty_if_listener_throws_exception() {
ComponentPageElement element = mockComponentPageElement();
Logger logger = mockLogger();
PageLifecycleListener listener1 = newPageLifecycle();
PageLifecycleListener listener2 = newPageLifecycle();
RuntimeException t = new RuntimeException("Listener detach exception.");
MetaDataLocator locator = newMetaDataLocator(LOGICAL_PAGE_NAME, true);
train_getLogger(element, logger);
listener1.containingPageDidDetach();
setThrowable(t);
logger.error(contains("failed during page detach"), same(t));
listener2.containingPageDidDetach();
replay();
Page page = new PageImpl(LOGICAL_PAGE_NAME, selector, null, perThreadManager, locator);
page.setRootElement(element);
page.addLifecycleListener(listener1);
page.addLifecycleListener(listener2);
assertTrue(page.detached());
verify();
}
Aggregations