1 9 package org.ditchnet.jsp.taglib.tabs.test; 10 11 import java.util.List ; 12 import org.w3c.dom.*; 13 import junit.framework.Test; 14 import junit.framework.TestCase; 15 import junit.framework.TestSuite; 16 import com.meterware.httpunit.WebLink; 17 import com.meterware.httpunit.HTMLPage; 18 import com.meterware.httpunit.WebRequest; 19 import com.meterware.httpunit.WebResponse; 20 import com.meterware.httpunit.HTMLElement; 21 import com.meterware.httpunit.WebConversation; 22 import com.meterware.httpunit.GetMethodWebRequest; 23 import com.meterware.httpunit.scripting.ScriptableDelegate; 24 import com.meterware.httpunit.scripting.ScriptableDelegate; 25 import org.ditchnet.test.DitchBaseTestCase; 26 import org.ditchnet.xml.Xhtml; 27 import org.ditchnet.xml.dom.DomUtils; 28 29 30 public class TabsTaglibHomepageTest extends DitchBaseTestCase { 31 32 static final String URI = "http://localhost:8080/taglibs/index.jsp"; 33 34 static final String TAB_CONTAINER_CLASS_NAME = "org-ditchnet-tab-container"; 35 static final String TAB_WRAP_CLASS_NAME = "ditch-tab-wrap"; 36 static final String TAB_CLASS_NAME = "ditch-tab"; 37 static final String TAB_BG_LEFT_CLASS_NAME = "ditch-tab-bg-left"; 38 static final String TAB_PANE_WRAP_CLASS_NAME = "ditch-tab-pane-wrap"; 39 static final String TAB_PANE_CLASS_NAME = "ditch-tab-pane"; 40 41 public static void main(String [] args) { 42 junit.textui.TestRunner.run( suite() ); 43 } 44 45 public static Test suite() { 46 TestSuite suite = new TestSuite( 47 "Test the Tabs Taglib homepage (It uses the tabs)"); 48 suite.addTestSuite( TabsTaglibHomepageTest.class ); 49 return suite; 50 } 51 52 public TabsTaglibHomepageTest(String name) { 53 super(name); 54 } 55 56 WebConversation wc; 57 WebRequest req; 58 WebResponse res; 59 Document doc; 60 Element docEl; 61 62 public void setUp() throws Exception { 63 wc = new WebConversation(); 64 req = new GetMethodWebRequest( URI ); 65 res = wc.getResponse( req ); 66 doc = res.getDOM(); 67 docEl = doc.getDocumentElement(); 68 } 69 70 public void testPageTitle() throws Exception { 71 String title = res.getTitle(); 72 assertEquals(title,"The Ultimate JSP Tabs!"); 73 } 74 75 public void testSkinContainerExistence() throws Exception { 76 List defaultSkinContainers = DomUtils.getDescendantsByClassName( 77 docEl, 78 "ditch-tab-skin-default"); 79 assertEquals(3,defaultSkinContainers.size()); 80 List invisibleSkinContainers = DomUtils.getDescendantsByClassName( 81 docEl, 82 "ditch-tab-skin-invisible"); 83 assertEquals(1,invisibleSkinContainers.size()); 84 } 85 86 public void testTabsDefaultFocusStatus() throws Exception { 87 List unfocusedTabs = DomUtils.getDescendantsByClassName( 88 docEl, 89 "ditch-tab ditch-unfocused"); 90 List focusedTabs = DomUtils.getDescendantsByClassName( 91 docEl, 92 "ditch-tab ditch-focused"); 93 assertEquals(12,unfocusedTabs.size()); 94 assertEquals(4,focusedTabs.size()); 95 } 96 97 public void testMainContainerExistence() throws Exception { 98 Element mainContainer = doc.getElementById("tabs-main-container"); 99 Element overviewTab = doc.getElementById("overview-tab"); 100 } 104 105 public void testScript() throws Exception { 106 HTMLPage.Scriptable jsDoc = res.getScriptableObject().getDocument(); 107 ScriptableDelegate div = jsDoc.getElementWithID( "author" ); 108 } 114 115 public void testServerSideTabSwitching() throws Exception { 116 WebLink overviewLink = res.getLinkWith("Overview"); 117 assertNotNull(overviewLink); 118 res = overviewLink.click(); 119 doc = res.getDOM(); 120 Element overviewTab = doc.getElementById( "overview-tab" ); 121 } 124 125 } 126 | Popular Tags |