@Test(dependsOnMethods = "menuTest") public void aboutTest() throws JaxenException { when(llSvc.isLoggedIn()).thenReturn(true); doNothing().when(llSvc).checkRememberMe(); Document doc = tester().renderPage("about"); TapestryXPath xp2 = TapestryXPath.xpath("id('logout')"); assertNotNull( xp2.selectSingleNode(doc), "Assume user is logged in, the 'logout' node is not presented"); TapestryXPath xp3 = TapestryXPath.xpath("id('accountInfo')/a[@class='loginLink']"); assertNull( xp3.selectSingleNode(doc), "Assume user is logged in, The 'login' node is presented"); }
@Test public void menuTest() throws JaxenException { when(llSvc.isLoggedIn()).thenReturn(true); doNothing().when(llSvc).checkRememberMe(); Document doc = tester().renderPage("about"); TapestryXPath xp1 = TapestryXPath.xpath("id('menu')//ul/li//a"); List<String> list = xp1.selectElementsAttribute(doc, "href"); for (String string : list) { System.err.println(" -> " + string); } assertEquals( list.toArray(), new String[] {"/foo/", "/foo/extpersons", "/foo/admin", "/foo/about"}, "menu links does not match request"); }