use of org.apache.tapestry5.runtime.PageLifecycleListener in project tapestry-5 by apache.
the class InternalComponentResourcesImplTest method add_page_lifecycle_listener.
@Test
public void add_page_lifecycle_listener() {
Component component = mockComponent();
Instantiator ins = mockInstantiator(component);
ComponentModel model = mockComponentModel();
ComponentPageElement element = mockComponentPageElement();
Page page = mockPage();
PageLifecycleListener listener = newMock(PageLifecycleListener.class);
train_getModel(ins, model);
page.addLifecycleListener(listener);
replay();
InternalComponentResources resources = new InternalComponentResourcesImpl(page, element, null, null, null, null, ins, false);
resources.addPageLifecycleListener(listener);
verify();
}
use of org.apache.tapestry5.runtime.PageLifecycleListener 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.runtime.PageLifecycleListener 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.runtime.PageLifecycleListener 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();
}
use of org.apache.tapestry5.runtime.PageLifecycleListener in project tapestry-5 by apache.
the class PageImplTest method load_notification.
@Test
public void load_notification() {
MetaDataLocator locator = newMetaDataLocator(LOGICAL_PAGE_NAME, true);
PageLifecycleListener listener1 = newPageLifecycle();
PageLifecycleListener listener2 = newPageLifecycle();
listener1.containingPageDidLoad();
listener2.containingPageDidLoad();
replay();
Page page = new PageImpl(LOGICAL_PAGE_NAME, selector, null, perThreadManager, locator);
page.addLifecycleListener(listener1);
page.addLifecycleListener(listener2);
page.loaded();
verify();
}
Aggregations