Search in sources :

Example 6 with MetaDataLocator

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();
}
Also used : Response(org.apache.tapestry5.http.services.Response) ComponentEventLinkEncoder(org.apache.tapestry5.services.ComponentEventLinkEncoder) Request(org.apache.tapestry5.http.services.Request) MetaDataLocator(org.apache.tapestry5.services.MetaDataLocator) Test(org.testng.annotations.Test)

Example 7 with MetaDataLocator

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();
}
Also used : Response(org.apache.tapestry5.http.services.Response) PageRenderRequestParameters(org.apache.tapestry5.services.PageRenderRequestParameters) ComponentEventLinkEncoder(org.apache.tapestry5.services.ComponentEventLinkEncoder) EmptyEventContext(org.apache.tapestry5.internal.EmptyEventContext) Request(org.apache.tapestry5.http.services.Request) MetaDataLocator(org.apache.tapestry5.services.MetaDataLocator) Test(org.testng.annotations.Test)

Example 8 with MetaDataLocator

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();
}
Also used : PageLifecycleListener(org.apache.tapestry5.runtime.PageLifecycleListener) MetaDataLocator(org.apache.tapestry5.services.MetaDataLocator) Test(org.testng.annotations.Test)

Example 9 with MetaDataLocator

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();
}
Also used : PageLifecycleListener(org.apache.tapestry5.runtime.PageLifecycleListener) MetaDataLocator(org.apache.tapestry5.services.MetaDataLocator) Test(org.testng.annotations.Test)

Example 10 with MetaDataLocator

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();
}
Also used : PageLifecycleListener(org.apache.tapestry5.runtime.PageLifecycleListener) Logger(org.slf4j.Logger) MetaDataLocator(org.apache.tapestry5.services.MetaDataLocator) Test(org.testng.annotations.Test)

Aggregations

MetaDataLocator (org.apache.tapestry5.services.MetaDataLocator)37 Test (org.testng.annotations.Test)32 Request (org.apache.tapestry5.http.services.Request)18 ComponentClassResolver (org.apache.tapestry5.services.ComponentClassResolver)13 LocalizationSetter (org.apache.tapestry5.services.LocalizationSetter)13 Response (org.apache.tapestry5.http.services.Response)12 ComponentModel (org.apache.tapestry5.model.ComponentModel)11 ComponentResources (org.apache.tapestry5.ComponentResources)9 SymbolSource (org.apache.tapestry5.ioc.services.SymbolSource)9 PageRenderRequestParameters (org.apache.tapestry5.services.PageRenderRequestParameters)8 EmptyEventContext (org.apache.tapestry5.internal.EmptyEventContext)7 ComponentEventRequestParameters (org.apache.tapestry5.services.ComponentEventRequestParameters)6 Dispatcher (org.apache.tapestry5.http.services.Dispatcher)5 ComponentRequestHandler (org.apache.tapestry5.services.ComponentRequestHandler)5 PageLifecycleListener (org.apache.tapestry5.runtime.PageLifecycleListener)4 ComponentEventLinkEncoder (org.apache.tapestry5.services.ComponentEventLinkEncoder)4 ClientWhitelist (org.apache.tapestry5.services.security.ClientWhitelist)4 URLEventContext (org.apache.tapestry5.internal.URLEventContext)2 PersistentFieldStrategy (org.apache.tapestry5.services.PersistentFieldStrategy)2 Link (org.apache.tapestry5.http.Link)1