1 25 26 package org.objectweb.jonas.jonasadmin.test.service.container; 27 28 import java.io.File ; 29 30 import junit.framework.TestSuite; 31 32 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminAuth; 33 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminFiles; 34 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminTestCase; 35 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminUtils; 36 37 import com.meterware.httpunit.Button; 38 import com.meterware.httpunit.HttpUnitOptions; 39 import com.meterware.httpunit.TableCell; 40 import com.meterware.httpunit.WebConversation; 41 import com.meterware.httpunit.WebForm; 42 import com.meterware.httpunit.WebLink; 43 import com.meterware.httpunit.WebResponse; 44 import com.meterware.httpunit.WebTable; 45 46 51 public class F_JonasAdminWebContainer extends JonasAdminTestCase { 52 53 56 private static final String URL_JONASADMIN_WEB_CONTAINERS = "ListWebContainers.do"; 57 58 61 private static final String URL_JONASADMIN_WEBAPP = "EditWebApp.do"; 62 63 66 private static final String URL_JONASADMIN_EDIT_WAR = "EditWar.do"; 67 68 71 private static final String URL_JONASADMIN_SERVLETS = "warServlets.jsp"; 72 73 76 private static final String URL_JONASADMIN_WEB_XML = "warWebXml.jsp"; 77 78 81 private static final String URL_JONASADMIN_JONAS_XML = "warJonasXml.jsp"; 82 83 86 private static final String URL_JONASADMIN_WEBAPP_ALARM = "EditWebApp.do?on=jonas%3Aj2eeType%3DWebModule%2Cname%3D%2F%2Flocalhost%2Falarm%2CJ2EEApplication%3Dalarm%2CJ2EEServer%3Djonas"; 87 88 91 private static final String BUTTON_SERVLET_CANCEL = "EditWebAppCatalina.do"; 92 93 96 private static final String BUTTON_SERVLET_SAVE_ALL = "SaveCatalina.do"; 97 98 101 private static final String BUTTON_WEBAPP_STOP = "javascript:submitHidden('webAppCatalinaForm','action','stop')"; 102 103 106 private static final String BUTTON_WEBAPP_START = "javascript:submitHidden('webAppCatalinaForm','action','start')"; 107 108 111 private static final String BUTTON_WEBAPP_RELOAD = "javascript:submitHidden('webAppCatalinaForm','action','reload')"; 112 113 116 private static final int NUMBER_OF_TABS_FOR_WEB_CONTAINERS = 1; 117 118 121 private static final int NUMBER_OF_TABS_FOR_ROOT = 6; 122 123 126 private static final int NUMBER_OF_TABS_FOR_STOPPED_ROOT = 4; 127 128 132 public F_JonasAdminWebContainer(String s) { 133 super(s, URL_JONASADMIN); 134 } 135 136 141 public F_JonasAdminWebContainer(WebConversation wc, String s) { 142 super(wc, s, URL_JONASADMIN); 143 } 144 145 149 public static void main(String [] args) { 150 151 String testtorun = null; 152 for (int argn = 0; argn < args.length; argn++) { 154 String sArg = args[argn]; 155 if (sArg.equals("-n")) { 156 testtorun = args[++argn]; 157 } 158 } 159 if (testtorun == null) { 160 junit.textui.TestRunner.run(suite()); 161 } else { 162 junit.textui.TestRunner.run(new F_JonasAdminWebContainer(testtorun)); 163 } 164 } 165 166 170 public static TestSuite suite() { 171 return new TestSuite(F_JonasAdminWebContainer.class); 172 } 173 174 179 public static TestSuite suite(WebConversation wc) { 180 TestSuite suite = new TestSuite(); 181 suite.addTest(new F_JonasAdminWebContainer(wc, "testWebContainerNoInEar")); 182 suite.addTest(new F_JonasAdminWebContainer(wc, "testWebContainerInEar")); 183 return suite; 184 } 185 186 191 protected void setUp() throws Exception { 192 super.setUp(); 193 194 if (wc.getCurrentPage().getURL() == null) { 195 useWar("jonasAdmin"); 196 try { 198 JonasAdminAuth.doValidAuth(wc, url); 199 } catch (Exception e) { 200 fail("authentification failed : " + e); 201 } 202 } else { 203 try { 205 wc.getFrameContents(FRAME_TREE); 206 } catch (Exception e) { 207 wc.getResponse(urlLogOut); 208 try { 210 JonasAdminAuth.doValidAuth(wc, url); 211 } catch (Exception auth) { 212 fail("authentification failed : " + auth); 213 } 214 } 215 } 216 } 217 218 223 public void testWebContainerNoInEar() throws Exception { 224 225 WebResponse wr; 226 WebLink link; 227 WebTable table; 228 WebTable tabTable; 229 TableCell cell; 230 int selectedTab; 231 JonasAdminUtils utils = new JonasAdminUtils(); 232 233 HttpUnitOptions.setExceptionsThrownOnScriptError(false); 235 HttpUnitOptions.setExceptionsThrownOnErrorStatus(false); 237 238 wr = wc.getFrameContents(FRAME_TREE); 240 link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, URL_JONASADMIN_WEB_CONTAINERS); 241 link.click(); 242 wr = wc.getFrameContents(FRAME_CONTENT); 243 selectedTab = 1; 244 245 table = utils.getTable(wr, 0); 247 for (int i = 1; i < table.getRowCount(); i++) { 248 cell = table.getTableCell(i, 0); 249 assertEquals("There is no one link for the context : " + cell.getText(), 1, cell.getLinks().length); 250 } 251 252 tabTable = utils.getTabTable(wr); 254 testTabs(tabTable, NUMBER_OF_TABS_FOR_WEB_CONTAINERS, selectedTab); 255 256 int rowRoot = utils.getFirstRow("ROOT", table, 0).intValue(); 258 link = table.getTableCell(rowRoot, 0).getLinks()[0]; 259 link.click(); 260 wr = wc.getFrameContents(FRAME_CONTENT); 261 selectedTab = 2; 262 263 if (jProp.isCatalina()) { 265 table = utils.getTable(wr, 4); 266 testContextTableCatalina(table, "/", "localhost"); 267 } else { 268 table = utils.getTable(wr, 1); 269 testContextTableJetty(table, "/", "JOnAS Package index", "true"); 270 } 271 272 tabTable = utils.getTabTable(wr); 274 testTabs(tabTable, NUMBER_OF_TABS_FOR_ROOT, selectedTab); 275 assertTrue("The link " + URL_JONASADMIN_WEB_CONTAINERS + " is not found in the first tab. ", tabTable 277 .getTableCell(0, 0).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_WEB_CONTAINERS)); 278 assertTrue("The link " + URL_JONASADMIN_EDIT_WAR + " is not found in the third tab. ", tabTable.getTableCell(0, 279 4).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_EDIT_WAR)); 280 assertTrue("The link " + URL_JONASADMIN_SERVLETS + " is not found in the fourth tab. ", tabTable.getTableCell( 281 0, 6).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_SERVLETS)); 282 assertTrue("The link " + URL_JONASADMIN_WEB_XML + " is not found in the fifth tab. ", tabTable.getTableCell(0, 283 8).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_WEB_XML)); 284 assertTrue("The link " + URL_JONASADMIN_JONAS_XML + " is not found in the sixth tab. ", tabTable.getTableCell( 285 0, 10).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_JONAS_XML)); 286 287 if (jProp.isCatalina()) { 288 wr = testSaveButton(wr); 290 291 wr = testModifySettings(wr); 293 294 wr = testActions(wr, utils); 296 } 297 298 link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, URL_JONASADMIN_EDIT_WAR); 300 link.click(); 301 wr = wc.getFrameContents(FRAME_CONTENT); 302 selectedTab = 3; 303 304 table = utils.getTable(wr, 1); 306 testWebContainerTable(table, "", "localhost", "ctxroot.war", "true"); 307 308 try { 310 table = utils.getTable(wr, 3); 311 fail("There is the 'In application container' table. "); 312 } catch (Exception e) { 313 } 315 316 tabTable = utils.getTabTable(wr); 318 testTabs(tabTable, NUMBER_OF_TABS_FOR_ROOT, selectedTab); 319 assertTrue("The link " + URL_JONASADMIN_WEB_CONTAINERS + " is not found in the first tab. ", tabTable 321 .getTableCell(0, 0).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_WEB_CONTAINERS)); 322 assertTrue("The link " + URL_JONASADMIN_WEBAPP + " is not found in the second tab. ", tabTable.getTableCell(0, 323 2).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_WEBAPP)); 324 assertTrue("The link " + URL_JONASADMIN_SERVLETS + " is not found in the fourth tab. ", tabTable.getTableCell( 325 0, 6).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_SERVLETS)); 326 assertTrue("The link " + URL_JONASADMIN_WEB_XML + " is not found in the fifth tab. ", tabTable.getTableCell(0, 327 8).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_WEB_XML)); 328 assertTrue("The link " + URL_JONASADMIN_JONAS_XML + " is not found in the sixth tab. ", tabTable.getTableCell( 329 0, 10).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_JONAS_XML)); 330 331 link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, URL_JONASADMIN_SERVLETS); 333 link.click(); 334 wr = wc.getFrameContents(FRAME_CONTENT); 335 selectedTab = 4; 336 337 wr = testServlet(wr, utils); 339 340 tabTable = utils.getTabTable(wr); 342 testTabs(tabTable, NUMBER_OF_TABS_FOR_ROOT, selectedTab); 343 assertTrue("The link " + URL_JONASADMIN_WEB_CONTAINERS + " is not found in the first tab. ", tabTable 345 .getTableCell(0, 0).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_WEB_CONTAINERS)); 346 assertTrue("The link " + URL_JONASADMIN_WEBAPP + " is not found in the second tab. ", tabTable.getTableCell(0, 347 2).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_WEBAPP)); 348 assertTrue("The link " + URL_JONASADMIN_EDIT_WAR + " is not found in the third tab. ", tabTable.getTableCell(0, 349 4).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_EDIT_WAR)); 350 assertTrue("The link " + URL_JONASADMIN_WEB_XML + " is not found in the fifth tab. ", tabTable.getTableCell(0, 351 8).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_WEB_XML)); 352 assertTrue("The link " + URL_JONASADMIN_JONAS_XML + " is not found in the sixth tab. ", tabTable.getTableCell( 353 0, 10).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_JONAS_XML)); 354 355 link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, URL_JONASADMIN_WEB_XML); 357 link.click(); 358 wr = wc.getFrameContents(FRAME_CONTENT); 359 selectedTab = 5; 360 361 364 tabTable = utils.getTabTable(wr); 366 testTabs(tabTable, NUMBER_OF_TABS_FOR_ROOT, selectedTab); 367 assertTrue("The link " + URL_JONASADMIN_WEB_CONTAINERS + " is not found in the first tab. ", tabTable 369 .getTableCell(0, 0).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_WEB_CONTAINERS)); 370 assertTrue("The link " + URL_JONASADMIN_WEBAPP + " is not found in the second tab. ", tabTable.getTableCell(0, 371 2).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_WEBAPP)); 372 assertTrue("The link " + URL_JONASADMIN_EDIT_WAR + " is not found in the third tab. ", tabTable.getTableCell(0, 373 4).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_EDIT_WAR)); 374 assertTrue("The link " + URL_JONASADMIN_SERVLETS + " is not found in the fourth tab. ", tabTable.getTableCell( 375 0, 6).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_SERVLETS)); 376 assertTrue("The link " + URL_JONASADMIN_JONAS_XML + " is not found in the sixth tab. ", tabTable.getTableCell( 377 0, 10).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_JONAS_XML)); 378 379 link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, URL_JONASADMIN_JONAS_XML); 381 link.click(); 382 wr = wc.getFrameContents(FRAME_CONTENT); 383 selectedTab = 6; 384 385 388 tabTable = utils.getTabTable(wr); 390 testTabs(tabTable, NUMBER_OF_TABS_FOR_ROOT, selectedTab); 391 assertTrue("The link " + URL_JONASADMIN_WEB_CONTAINERS + " is not found in the first tab. ", tabTable 393 .getTableCell(0, 0).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_WEB_CONTAINERS)); 394 assertTrue("The link " + URL_JONASADMIN_WEBAPP + " is not found in the second tab. ", tabTable.getTableCell(0, 395 2).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_WEBAPP)); 396 assertTrue("The link " + URL_JONASADMIN_EDIT_WAR + " is not found in the third tab. ", tabTable.getTableCell(0, 397 4).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_EDIT_WAR)); 398 assertTrue("The link " + URL_JONASADMIN_SERVLETS + " is not found in the fourth tab. ", tabTable.getTableCell( 399 0, 6).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_SERVLETS)); 400 assertTrue("The link " + URL_JONASADMIN_WEB_XML + " is not found in the fifth tab. ", tabTable.getTableCell(0, 401 8).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_WEB_XML)); 402 403 } 404 405 410 public void testWebContainerInEar() throws Exception { 411 412 WebResponse wr; 413 WebLink link; 414 WebTable table; 415 TableCell cell; 416 JonasAdminUtils utils = new JonasAdminUtils(); 417 418 HttpUnitOptions.setExceptionsThrownOnScriptError(false); 420 HttpUnitOptions.setExceptionsThrownOnErrorStatus(false); 422 423 useEar("alarm"); 425 426 wr = wc.getFrameContents(FRAME_TREE); 428 link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, URL_JONASADMIN_WEB_CONTAINERS); 429 link.click(); 430 wr = wc.getFrameContents(FRAME_CONTENT); 431 432 link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, URL_JONASADMIN_WEBAPP_ALARM); 434 link.click(); 435 wr = wc.getFrameContents(FRAME_CONTENT); 436 437 link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, URL_JONASADMIN_EDIT_WAR); 439 link.click(); 440 wr = wc.getFrameContents(FRAME_CONTENT); 441 442 table = utils.getTable(wr, 1); 444 try { 445 table = utils.getTable(wr, 4); 446 } catch (Exception e) { 447 fail("There is not the 'In application container' table. "); 448 } 449 testInApplicationContainer(table); 450 451 } 452 453 459 private void testTabs(WebTable tabTable, int nbTabs, int selectedTab) { 460 TableCell selectedCell; 461 assertEquals("There are not " + nbTabs + " tabs. ", nbTabs, (tabTable.getColumnCount() + 1) / 2); 463 selectedCell = tabTable.getTableCell(1, (selectedTab * 2) - 2); 465 assertEquals("It is not the selected tab. ", 1, selectedCell.getElementsWithAttribute("src", 466 "/jonasAdmin/images/dot.gif").length); 467 } 468 469 476 private void testContextTableCatalina(WebTable table, String path, String host) throws Exception { 477 WebConversation wc2 = new WebConversation(); 478 assertEquals("It is not the expected path. ", path, table.getTableCell(0, 2).getText()); 480 String urlRoot = prefixUrl + path; 481 int code = wc2.getResponse(urlRoot).getResponseCode(); 482 assertEquals("The page " + urlRoot + " is not found. ", 200, code); 483 assertEquals("It is not the expected host. ", host, table.getTableCell(1, 2).getText()); 485 } 486 487 495 private void testContextTableJetty(WebTable table, String path, String name, String started) throws Exception { 496 WebConversation wc2 = new WebConversation(); 497 assertEquals("It is not the expected path. ", path, table.getTableCell(0, 2).getText()); 499 String urlRoot = prefixUrl + path; 500 int code = wc2.getResponse(urlRoot).getResponseCode(); 501 assertEquals("The page " + urlRoot + " is not found. ", 200, code); 502 assertEquals("It is not the expected name of the context. ", name, table.getTableCell(1, 2).getText()); 504 assertEquals("It is not the expected value of 'Started'. ", name, table.getTableCell(2, 2).getText()); 506 } 507 508 516 private void testWebContainerTable(WebTable table, String contextRoot, String hostName, String path, String model) { 517 assertEquals("It is not the context root. ", contextRoot, table.getTableCell(0, 2).getText()); 519 assertEquals("It is not the host name. ", hostName, table.getTableCell(1, 2).getText()); 521 assertTrue("It is not the end of the path. ", table.getTableCell(2, 2).getText().endsWith(path)); 523 assertEquals("It is not the Java 2 delegation model value. ", model, table.getTableCell(3, 2).getText()); 525 } 526 527 533 private WebResponse testSaveButton(WebResponse wr) throws Exception { 534 String beginTime; 535 String endTime; 536 WebLink link; 537 WebForm form = wr.getForms()[0]; 538 String previousPage = wr.getElementsWithAttribute("class", "contentTitle")[0].getText(); 539 Button button = form.getButtons()[2]; 541 button.click(); 542 wr = wc.getFrameContents(FRAME_CONTENT); 543 assertTrue("The save button doesn't go to 'jonasserver/servletServer.jsp'. ", wr.getText().indexOf( 544 "jonasserver/servletServer.jsp") != -1); 545 beginTime = getTime(); 547 link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, BUTTON_SERVLET_SAVE_ALL); 548 WebResponse wrSaveAll = wc.sendRequest(link.getRequest()); 549 endTime = getTime(); 551 JonasAdminFiles.recoverServerConf(beginTime, endTime); 553 assertEquals("The cancel button of the servlet server page doesn't go back to '" + previousPage + "' page. !", 554 previousPage, wrSaveAll.getElementsWithAttribute("class", "contentTitle")[0].getText()); 555 556 link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, BUTTON_SERVLET_CANCEL); 557 link.click(); 558 wr = wc.getFrameContents(FRAME_CONTENT); 559 assertEquals("The cancel button of the servlet server page doesn't go back to '" + previousPage + "' page. !", 560 previousPage, wr.getElementsWithAttribute("class", "contentTitle")[0].getText()); 561 562 return wr; 563 } 564 565 571 private WebResponse testModifySettings(WebResponse wr) throws Exception { 572 WebForm form = wr.getForms()[0]; 573 form.setParameter("cookies", "false"); 574 form.setParameter("reloadable", "true"); 575 form.setParameter("swallowOutput", "true"); 576 Button button = form.getSubmitButton("btn_apply"); 577 button.click(); 578 wr = wc.getFrameContents(FRAME_CONTENT); 579 form = wr.getForms()[0]; 580 String cookies = form.getParameterValue("cookies"); 581 String reloadable = form.getParameterValue("reloadable"); 582 String swallowOutput = form.getParameterValue("swallowOutput"); 583 584 assertEquals("The value of the cookie parameter is not 'false'. ", "false", cookies); 585 assertEquals("The value of the reloadable parameter is not 'true'. ", "true", reloadable); 586 assertEquals("The value of the swallowOutput parameter is not 'true'. ", "true", swallowOutput); 587 588 return wr; 589 } 590 591 598 private WebResponse testActions(WebResponse wr, JonasAdminUtils utils) throws Exception { 599 WebLink link; 600 TableCell reloadCell; 601 TableCell startCell; 602 TableCell stopCell; 603 WebTable tabTable; 604 WebConversation wc2 = new WebConversation(); 605 int selectedTab = 2; 606 WebTable table = utils.getTable(wr, 1).getTableCell(0, 0).getTables()[0]; 607 startCell = table.getTableCell(0, 1); 608 assertEquals("There is a link for the 'Start' button. ", 0, startCell.getLinks().length); 610 assertEquals("The 'Start' button is not grey. ", 1, 612 startCell.getElementsWithAttribute("class", "btnDisabled").length); 613 614 link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, BUTTON_WEBAPP_STOP); 616 link.click(); 617 wr = wc.getFrameContents(FRAME_CONTENT); 618 table = utils.getTable(wr, 1).getTableCell(0, 0).getTables()[0]; 619 reloadCell = table.getTableCell(0, 0); 620 startCell = table.getTableCell(0, 1); 621 stopCell = table.getTableCell(0, 2); 622 assertEquals("There is a link for the 'Reload' button. ", 0, reloadCell.getLinks().length); 624 assertEquals("There is a link for the 'Stop' button. ", 0, stopCell.getLinks().length); 625 assertEquals("The 'Reload' button is not grey. ", 1, reloadCell 627 .getElementsWithAttribute("class", "btnDisabled").length); 628 assertEquals("The 'Start' button is grey. ", 0, 629 startCell.getElementsWithAttribute("class", "btnDisabled").length); 630 assertEquals("The 'Stop' button is not grey. ", 1, 631 stopCell.getElementsWithAttribute("class", "btnDisabled").length); 632 String urlRoot = prefixUrl + "/"; 634 int code = wc2.getResponse(urlRoot).getResponseCode(); 635 assertTrue("The page " + urlRoot + " is found. ", code != 200); 636 637 tabTable = utils.getTabTable(wr); 639 testTabs(tabTable, NUMBER_OF_TABS_FOR_STOPPED_ROOT, selectedTab); 640 assertTrue("The link " + URL_JONASADMIN_WEB_CONTAINERS + " is not found in the first tab. ", tabTable 642 .getTableCell(0, 0).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_WEB_CONTAINERS)); 643 assertTrue("The link " + URL_JONASADMIN_EDIT_WAR + " is not found in the second tab. ", tabTable.getTableCell( 644 0, 4).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_EDIT_WAR)); 645 assertTrue("The link " + URL_JONASADMIN_JONAS_XML + " is not found in the sixth tab. ", tabTable.getTableCell( 646 0, 6).getLinks()[0].getURLString().endsWith(URL_JONASADMIN_JONAS_XML)); 647 648 link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, BUTTON_WEBAPP_START); 650 link.click(); 651 wr = wc.getFrameContents(FRAME_CONTENT); 652 table = utils.getTable(wr, 1).getTableCell(0, 0).getTables()[0]; 653 reloadCell = table.getTableCell(0, 0); 654 startCell = table.getTableCell(0, 1); 655 stopCell = table.getTableCell(0, 2); 656 assertEquals("There is a link for the 'Start' button. ", 0, startCell.getLinks().length); 658 assertEquals("The 'Reload' button is grey. ", 0, 660 reloadCell.getElementsWithAttribute("class", "btnDisabled").length); 661 assertEquals("The 'Start' button is not grey. ", 1, 662 startCell.getElementsWithAttribute("class", "btnDisabled").length); 663 assertEquals("The 'Stop' button is grey. ", 0, stopCell.getElementsWithAttribute("class", "btnDisabled").length); 664 code = wc2.getResponse(urlRoot).getResponseCode(); 666 assertEquals("The page " + urlRoot + " is not found. ", 200, code); 667 668 link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, BUTTON_WEBAPP_RELOAD); 670 link.click(); 671 wr = wc.getFrameContents(FRAME_CONTENT); 672 table = utils.getTable(wr, 1).getTableCell(0, 0).getTables()[0]; 673 reloadCell = table.getTableCell(0, 0); 674 startCell = table.getTableCell(0, 1); 675 stopCell = table.getTableCell(0, 2); 676 assertEquals("There is a link for the 'Start' button. ", 0, startCell.getLinks().length); 678 assertEquals("The 'Reload' button is grey. ", 0, 680 reloadCell.getElementsWithAttribute("class", "btnDisabled").length); 681 assertEquals("The 'Start' button is not grey. ", 1, 682 startCell.getElementsWithAttribute("class", "btnDisabled").length); 683 assertEquals("The 'Stop' button is grey. ", 0, stopCell.getElementsWithAttribute("class", "btnDisabled").length); 684 code = wc2.getResponse(urlRoot).getResponseCode(); 686 assertEquals("The page " + urlRoot + " is not found. ", 200, code); 687 688 return wr; 689 } 690 691 698 private WebResponse testServlet(WebResponse wr, JonasAdminUtils utils) throws Exception { 699 WebLink link; 700 WebTable table; 701 table = utils.getTable(wr, 0); 702 int nbServlets = Integer.parseInt(table.getTableCell(0, 2).getText()); 703 704 table = utils.getTable(wr, 2); 705 assertEquals("There are not '" + nbServlets + "' rows in the 'Name' table. ", nbServlets, table.getRowCount()); 707 708 for (int i = 0; i < nbServlets; i++) { 710 String name = table.getTableCell(i, 0).getText(); 711 int code = wc.getResponse(prefixUrl + "/jonasAdmin/ListMBeanDetails.do?select=" + name).getResponseCode(); 712 assertEquals("The MBean details for '" + name + "' are not found. ", 200, code); 713 } 714 715 wc.getResponse(urlWelcome); 716 wr = wc.getFrameContents(FRAME_TREE); 717 link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, URL_JONASADMIN_WEB_CONTAINERS); 718 link.click(); 719 wr = wc.getFrameContents(FRAME_CONTENT); 720 table = utils.getTable(wr, 0); 721 int rowRoot = utils.getFirstRow("ROOT", table, 0).intValue(); 722 if (rowRoot != -1) { 723 link = table.getTableCell(rowRoot, 0).getLinks()[0]; 724 link.click(); 725 } else { 726 fail("The WebContainer 'ROOT' was not found in the web container list. "); 727 } 728 wr = wc.getFrameContents(FRAME_CONTENT); 729 link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, URL_JONASADMIN_SERVLETS); 730 link.click(); 731 wr = wc.getFrameContents(FRAME_CONTENT); 732 733 return wr; 734 } 735 736 private void testInApplicationContainer(WebTable table) throws Exception { 737 String path = table.getTableCell(0, 2).getText(); 739 assertTrue("The path doesn't end with 'apps" + File.separator + "alarm.ear'. ", path.endsWith("apps" 740 + File.separator + "alarm.ear")); 741 742 String name = table.getTableCell(0, 0).getText(); 744 assertEquals("The name of the application container is not 'alarm.ear'. ", "alarm.ear", name); 745 WebLink link = table.getTableCell(0, 0).getLinks()[0]; 746 try { 747 int code = wc.sendRequest(link.getRequest()).getResponseCode(); 748 assertEquals("The page 'alarm.ear' is not found (link = '" + link.getURLString() + "'). ", 200, code); 749 } catch (Exception e) { 750 fail("The link '" + link.getURLString() + "' creates an error. "); 751 } 752 } 753 } 754 | Popular Tags |