1 25 26 package org.objectweb.jonas.jonasadmin.test.jonasserver; 27 28 import java.io.File ; 29 30 import junit.framework.TestSuite; 31 32 import org.objectweb.jonas.jonasadmin.test.catalina.ConnectorUtils; 33 import org.objectweb.jonas.jonasadmin.test.logging.LoggerUtils; 34 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminAuth; 35 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminFiles; 36 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminTestCase; 37 38 import com.meterware.httpunit.HttpUnitOptions; 39 import com.meterware.httpunit.WebConversation; 40 import com.meterware.httpunit.WebLink; 41 import com.meterware.httpunit.WebResponse; 42 import com.meterware.httpunit.WebTable; 43 44 45 50 public class F_JonasAdminSaveAll extends JonasAdminTestCase { 51 52 55 private static final String URL_JONASADMIN_SERVER = "EditJonasServer.do"; 56 57 60 private static final String URL_JONASADMIN_SERVLET_SERVER = "EditServletServer.do"; 61 62 65 private static final String URL_JONASADMIN_SAVE_ALL = "SaveCatalina.do"; 66 67 70 private static final String URL_WELCOME = "/jonasAdmin/Welcome.do"; 71 72 75 private static WebConversation wc2 = new WebConversation(); 76 77 80 private String beginTime; 81 82 85 private String endTime; 86 87 91 public F_JonasAdminSaveAll(String s) { 92 super(s, URL_JONASADMIN); 93 } 94 95 100 public F_JonasAdminSaveAll(WebConversation wc, String s) { 101 super(wc, s, URL_JONASADMIN); 102 } 103 104 108 public static void main(String [] args) { 109 110 String testtorun = null; 111 for (int argn = 0; argn < args.length; argn++) { 113 String sArg = args[argn]; 114 if (sArg.equals("-n")) { 115 testtorun = args[++argn]; 116 } 117 } 118 if (testtorun == null) { 119 junit.textui.TestRunner.run(suite()); 120 } else { 121 junit.textui.TestRunner.run(new F_JonasAdminSaveAll(testtorun)); 122 } 123 } 124 125 129 public static TestSuite suite() { 130 return new TestSuite(F_JonasAdminSaveAll.class); 131 } 132 133 138 public static TestSuite suite(WebConversation wc) { 139 TestSuite suite = new TestSuite(); 140 suite.addTest(new F_JonasAdminSaveAll(wc, "testSaveAll")); 141 return suite; 142 } 143 144 149 protected void setUp() throws Exception { 150 super.setUp(); 151 152 beginTime = getTime(); 154 155 if (wc.getCurrentPage().getURL() == null) { 156 useWar("jonasAdmin"); 157 try { 159 JonasAdminAuth.doValidAuth(wc, url); 160 } catch (Exception e) { 161 fail("authentification failed : " + e); 162 } 163 } else { 164 try { 166 wc.getFrameContents(FRAME_TREE); 167 } catch (Exception e) { 168 wc.getResponse(urlLogOut); 169 try { 171 JonasAdminAuth.doValidAuth(wc, url); 172 } catch (Exception auth) { 173 fail("authentification failed : " + auth); 174 } 175 } 176 } 177 } 178 179 184 public void testSaveAll() throws Exception { 185 186 WebResponse wr; 187 WebLink link; 188 WebTable table; 189 190 HttpUnitOptions.setExceptionsThrownOnScriptError(false); 192 HttpUnitOptions.setExceptionsThrownOnErrorStatus(false); 194 195 try { 198 JonasAdminAuth.doValidAuth(wc2, url); 199 } catch (Exception e) { 200 fail("authentification failed : " + e); 201 } 202 203 if (jProp.isCatalina()) { 204 wr = wc.getFrameContents(FRAME_TREE); 206 link = wr.getFirstMatchingLink( WebLink.MATCH_URL_STRING, URL_JONASADMIN_SERVER); 207 link.click(); 208 wr = wc.getFrameContents(FRAME_CONTENT); 209 link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, URL_JONASADMIN_SERVLET_SERVER); 211 link.click(); 212 wr = wc.getFrameContents(FRAME_CONTENT); 213 214 String port = ConnectorUtils.createNewConnector(wc2, "http"); 216 LoggerUtils.createNewEngineLogger(wc2); 218 219 link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, URL_JONASADMIN_SAVE_ALL); 221 link.click(); 222 wr = wc.getFrameContents(FRAME_CONTENT); 223 224 ConnectorUtils.deleteConnector(wc2, port); 226 LoggerUtils.deleteLogger(wc2, null); 228 229 XMLTest xmlTest = new XMLTest(""); 231 File serverXml = JonasAdminFiles.getServerXmlFile(); 232 xmlTest.testServerXml(serverXml, port); 233 234 } 235 } 236 237 241 public void tearDown() throws Exception { 242 endTime = getTime(); 244 245 JonasAdminFiles.recoverServerConf(beginTime, endTime); 247 } 248 } 249 | Popular Tags |