use of org.apache.tapestry5.services.ComponentSource 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.ComponentSource 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();
}
use of org.apache.tapestry5.services.ComponentSource in project tapestry-5 by apache.
the class ComponentSourceImplTest method get_page_by_class.
@Test
public void get_page_by_class() {
RequestPageCache cache = mockRequestPageCache();
Page page = mockPage();
Component component = mockComponent();
ComponentClassResolver resolver = mockComponentClassResolver();
train_resolvePageClassNameToPageName(resolver, ComponentSourceImplTest.class.getName(), PAGE_NAME);
train_get(cache, PAGE_NAME, page);
train_getRootComponent(page, component);
replay();
ComponentSource source = new ComponentSourceImpl(cache, resolver, null);
assertSame(source.getPage(ComponentSourceImplTest.class), component);
verify();
}
use of org.apache.tapestry5.services.ComponentSource in project tapestry-5 by apache.
the class ComponentSourceImplTest method root_element_of_page.
@Test
public void root_element_of_page() {
RequestPageCache cache = mockRequestPageCache();
Page page = mockPage();
Component component = mockComponent();
ComponentClassResolver resolver = mockComponentClassResolver();
train_get(cache, PAGE_NAME, page);
train_getRootComponent(page, component);
replay();
ComponentSource source = new ComponentSourceImpl(cache, resolver, null);
assertSame(source.getComponent(PAGE_NAME), component);
verify();
}
use of org.apache.tapestry5.services.ComponentSource in project tapestry-5 by apache.
the class ComponentSourceImplTest method get_active_page_before_known.
@Test
public void get_active_page_before_known() {
RequestGlobals globals = mockRequestGlobals();
expect(globals.getActivePageName()).andReturn(null);
replay();
ComponentSource source = new ComponentSourceImpl(null, null, globals);
assertNull(source.getActivePage());
verify();
}
Aggregations