1 25 26 package org.objectweb.jonas.jonasadmin.test.navigation; 27 28 import junit.framework.TestSuite; 29 30 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminAuth; 31 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminTestCase; 32 33 import com.meterware.httpunit.HttpUnitOptions; 34 import com.meterware.httpunit.WebConversation; 35 import com.meterware.httpunit.WebLink; 36 import com.meterware.httpunit.WebResponse; 37 38 43 public class F_JonasAdminLogout extends JonasAdminTestCase { 44 45 48 private static final String URL_JONASADMIN_LOGOUT = "logOut.do"; 49 50 54 public F_JonasAdminLogout(String s) { 55 super(s, URL_JONASADMIN); 56 } 57 58 63 public F_JonasAdminLogout(WebConversation wc, String s) { 64 super(wc, s, URL_JONASADMIN); 65 } 66 67 71 public static void main(String [] args) { 72 73 String testtorun = null; 74 for (int argn = 0; argn < args.length; argn++) { 76 String sArg = args[argn]; 77 if (sArg.equals("-n")) { 78 testtorun = args[++argn]; 79 } 80 } 81 if (testtorun == null) { 82 junit.textui.TestRunner.run(suite()); 83 } else { 84 junit.textui.TestRunner.run(new F_JonasAdminLogout(testtorun)); 85 } 86 } 87 88 92 public static TestSuite suite() { 93 return new TestSuite(F_JonasAdminLogout.class); 94 } 95 96 101 public static TestSuite suite(WebConversation wc) { 102 TestSuite suite = new TestSuite(); 103 suite.addTest(new F_JonasAdminLogout(wc, "testLogout")); 104 return suite; 105 } 106 107 112 protected void setUp() throws Exception { 113 super.setUp(); 114 115 if (wc.getCurrentPage().getURL() == null) { 116 useWar("jonasAdmin"); 117 try { 119 JonasAdminAuth.doValidAuth(wc, url); 120 } catch (Exception e) { 121 fail("authentification failed : " + e); 122 } 123 } else { 124 try { 126 wc.getFrameContents(FRAME_TREE); 127 } catch (Exception e) { 128 wc.getResponse(urlLogOut); 129 try { 131 JonasAdminAuth.doValidAuth(wc, url); 132 } catch (Exception auth) { 133 fail("authentification failed : " + auth); 134 } 135 } 136 } 137 } 138 139 144 public void testLogout() throws Exception { 145 146 WebResponse wr; 147 WebResponse topFrame; 148 WebLink link; 149 150 HttpUnitOptions.setExceptionsThrownOnScriptError(false); 152 HttpUnitOptions.setExceptionsThrownOnErrorStatus(false); 154 155 topFrame = wc.getFrameContents(FRAME_TOP); 157 158 link = topFrame.getFirstMatchingLink(WebLink.MATCH_URL_STRING, URL_JONASADMIN_LOGOUT); 159 wr = link.click(); 160 161 assertTrue("It is not the login page. ", wr.getText().indexOf("login.jsp") != -1); 162 try { 163 wc.getFrameContents(FRAME_TREE); 164 fail("There is tree frame. "); 165 } catch (Exception e){ 166 } 168 169 170 wc.getResponse(getAbsoluteUrl(URL_JONASADMIN + "/Welcome.do")); 172 173 try { 175 JonasAdminAuth.doValidAuth(wc, url); 176 } catch (Exception e) { 177 fail("authentification failed : " + e); 178 } 179 180 try { 181 assertNotNull("There is not tree frame. ", wc.getFrameContents(FRAME_TREE)); 182 } catch (Exception e) { 183 fail("There is not tree frame. "); 184 } 185 } 186 } | Popular Tags |