ComponentSourceImpl implements ComponentSource { public Component getActivePage() { String pageName = globals.getActivePageName(); return pageName == null ? null : getPage(pageName); } ComponentSourceImpl(RequestPageCache pageCache, ComponentClassResolver resolver, RequestGlobals globals); Component getComponent(String completeId); Component getPage(String pageName); Component getPage(Class pageClass); Component getActivePage();  }
@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(); }
@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(); }