KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jonasadmin > test > navigation > F_JonasAdminNavigation


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2005 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or 1any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: F_JonasAdminNavigation.java,v 1.18 2005/07/25 12:40:36 kemlerp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jonasadmin.test.navigation;
27
28 import java.io.IOException JavaDoc;
29 import java.util.Vector JavaDoc;
30
31 import junit.framework.TestSuite;
32
33 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminAuth;
34 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminFiles;
35 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminTestCase;
36 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminTree;
37 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminUtils;
38 import org.xml.sax.SAXException JavaDoc;
39
40 import com.meterware.httpunit.HttpException;
41 import com.meterware.httpunit.HttpNotFoundException;
42 import com.meterware.httpunit.HttpUnitOptions;
43 import com.meterware.httpunit.TableCell;
44 import com.meterware.httpunit.WebConversation;
45 import com.meterware.httpunit.WebLink;
46 import com.meterware.httpunit.WebResponse;
47 import com.meterware.httpunit.WebTable;
48
49 /**
50  * Define a class to test the JOnAS Admin console
51  * Test all links, content title, selected tree item
52  * @author kemlerp
53  *
54  */

55 public class F_JonasAdminNavigation extends JonasAdminTestCase {
56
57     /**
58      * SUCCESS CODE
59      */

60     private static final int HTTP_SUCCESS_CODE = 200;
61
62     /**
63      * NAME OF THE EAR LINK
64      */

65     private static final String JavaDoc EAR_LINK_NAME = "Applications (EAR)";
66
67     /**
68      * URL of the bean alarm record
69      */

70     private static final String JavaDoc URL_JONASADMIN_ALARM_RECORD = "/jonasAdmin/EditEjbEnt.do?select=jonas:j2eeType=EntityBean,name=AlarmRecord,EJBModule=alarm,J2EEApplication=alarm,J2EEServer=jonas";
71
72     /**
73      * URL of the synchronize button
74      */

75     private static final String JavaDoc URL_JONASADMIN_SYNCHRONIZE = "/jonasAdmin/ExecuteEjb.do?action=synchronize";
76
77     /**
78      * URL of the reduce instance button
79      */

80     private static final String JavaDoc URL_JONASADMIN_REDUCE = "/jonasAdmin/ExecuteEjb.do?action=reduceCache";
81
82     /**
83      * URL of the reduce pool instance button
84      */

85     private static final String JavaDoc URL_JONASADMIN_REDUCE_POOL = "/jonasAdmin/ExecuteEjb.do?action=reducePool";
86
87     /**
88      * URL of the new group instance button
89      */

90     private static final String JavaDoc URL_JONASADMIN_NEW_GROUP = "/jonasAdmin/EditNewGroupMemoryRealm.do?action=create";
91
92     /**
93      * URL of the new user instance button
94      */

95     private static final String JavaDoc URL_JONASADMIN_NEW_USER = "/jonasAdmin/EditNewUserMemoryRealm.do?action=create";
96
97     /**
98      * Class value of the selected tree control
99      */

100     private static final String JavaDoc CLASS_TREE_CONTROL_SELECTED = "tree-control-selected";
101
102     /**
103      * Name of the property navigation.mbean
104      */

105     private static final String JavaDoc NAVIGATION_MBEAN = "navigation.mbean";
106
107     /**
108      * Name of the property navigation.link
109      */

110     private static final String JavaDoc NAVIGATION_LINK = "navigation.link";
111
112     /**
113      * Name of the property navigation.contentTitle
114      */

115     private static final String JavaDoc NAVIGATION_CONTENT_TITLE = "navigation.contentTitle";
116
117     /**
118      * Name of the property navigation.selectedItem
119      */

120     private static final String JavaDoc NAVIGATION_SELECTED_ITEM = "navigation.selectedItem";
121
122     /**
123      * Name of the property navigation.titleTomThumb
124      */

125     private static final String JavaDoc NAVIGATION_TITLE_TOM_THUMB = "navigation.titleTomThumb";
126
127     /**
128      * Name of the property navigation.rarInEar
129      */

130     private static final String JavaDoc NAVIGATION_RAR_IN_EAR = "navigation.rarInEar";
131
132     /**
133      * Time of beginning testAllLinks
134      */

135     private String JavaDoc beginTime;
136
137     /**
138      * Time of ending testAllLinks
139      */

140     private String JavaDoc endTime;
141
142
143     /**
144      * Constructor with a specified name
145      * @param s name
146      */

147     public F_JonasAdminNavigation(String JavaDoc s) {
148         super(s, URL_JONASADMIN);
149     }
150
151     /**
152      * Constructor with a specified name
153      * @param wc the WebConversation of the suite test
154      * @param s name
155      */

156     public F_JonasAdminNavigation(WebConversation wc, String JavaDoc s) {
157         super(wc, s, URL_JONASADMIN);
158     }
159
160     /**
161      * Main method
162      * @param args the arguments
163      */

164     public static void main(String JavaDoc[] args) {
165
166         String JavaDoc testtorun = null;
167         // Get args
168
for (int argn = 0; argn < args.length; argn++) {
169             String JavaDoc sArg = args[argn];
170             if (sArg.equals("-n")) {
171                 testtorun = args[++argn];
172             }
173         }
174         if (testtorun == null) {
175             junit.textui.TestRunner.run(suite());
176         } else {
177             junit.textui.TestRunner.run(new F_JonasAdminNavigation(testtorun));
178         }
179     }
180
181     /**
182      * Get a new TestSuite for this class
183      * @return a new TestSuite for this class
184      */

185     public static TestSuite suite() {
186         return new TestSuite(F_JonasAdminNavigation.class);
187     }
188
189     /**
190      * Get a new TestSuite for this class
191      * @param wc the WebConversation
192      * @return a new TestSuite for this class with the WebConversation instance
193      */

194     public static TestSuite suite(WebConversation wc) {
195         TestSuite suite = new TestSuite();
196         suite.addTest(new F_JonasAdminNavigation(wc, "testAll"));
197         return suite;
198     }
199
200     /**
201      * Setup need for these tests
202      * jonasAdmin is required
203      * @throws Exception if it fails
204      */

205     protected void setUp() throws Exception JavaDoc {
206         super.setUp();
207
208         // Get time
209
beginTime = getTime();
210
211         if (wc.getCurrentPage().getURL() == null) {
212             useWar("jonasAdmin");
213             // login to jonas admin
214
try {
215                 JonasAdminAuth.doValidAuth(wc, url);
216             } catch (Exception JavaDoc e) {
217                 fail("authentification failed : " + e);
218             }
219         } else {
220             // if there was an error, the connection must be restablished
221
try {
222                 wc.getFrameContents(FRAME_TREE);
223             } catch (Exception JavaDoc e) {
224                 wc.getResponse(urlLogOut);
225                 // login to jonas admin
226
try {
227                     JonasAdminAuth.doValidAuth(wc, url);
228                 } catch (Exception JavaDoc auth) {
229                     fail("authentification failed : " + auth);
230                 }
231             }
232         }
233         undeployAllEar();
234         undeployAllJar();
235
236         useEar("autoload/mejb");
237     }
238
239     /**
240      * Test all about the navigation
241      * @throws Exception if error occurs
242      *
243      */

244     public void testAll() throws Exception JavaDoc {
245
246         Vector JavaDoc viewedURLs = new Vector JavaDoc();
247         WebResponse wr;
248
249         viewedURLs.add(URL_JONASADMIN);
250
251         // Disable errors of javascript
252
HttpUnitOptions.setExceptionsThrownOnScriptError(false);
253         // Disable exception thrown on error status
254
HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
255
256         // add links
257
// deploy ear
258
if (jProp.isEar()) {
259             useEar("alarm");
260             if (jProp.isResource()) {
261                 if (configFile != null) {
262                     if (configFile.get(NAVIGATION_RAR_IN_EAR).equals("on")) {
263                         useEar("earsample");
264                     }
265                 } else {
266                     useEar("earsample");
267                 }
268             }
269             // Reload the page
270
wc.getResponse(getAbsoluteUrl(URL_JONASADMIN));
271         }
272
273         // Get the frame "tree"
274
WebResponse treeFrame = wc.getFrameContents(FRAME_TREE);
275
276         // Open tree
277
try {
278             treeFrame = JonasAdminTree.openTree(treeFrame, wc);
279         } catch (IOException JavaDoc e) {
280             fail("failed to open tree. " + e);
281         }
282
283         // When EJB service is actived
284
if (jProp.isEjb()) {
285             // Particular cases because of values of the session do not correspond at the page
286
// 1-"/jonasAdmin/ExecuteEjb.do?action=synchronize"
287
testParticularCase("name=AlarmRecord", "synchronize", URL_JONASADMIN_SYNCHRONIZE, viewedURLs);
288
289             // 2-"/jonasAdmin/ExecuteEjb.do?action=reduceCache"
290
testParticularCase("name=AlarmRecord", "reduceCache", URL_JONASADMIN_REDUCE, viewedURLs);
291
292             // 3-"/jonasAdmin/ExecuteEjb.do?action=reducePool"
293
testParticularCase("EditEjbSbl.do?select=jonas:j2eeType=StatelessSessionBean,name=MEJB,EJBModule=mejb,J2EEApplication=mejb,J2EEServer=jonas", "reducePool", URL_JONASADMIN_REDUCE_POOL, viewedURLs);
294         }
295
296         // 4-"/jonasAdmin/EditNewGroupMemoryRealm.do?action=create"
297
testParticularCase("memrlm_1", "Groups.do", "action=create", URL_JONASADMIN_NEW_GROUP, viewedURLs);
298
299         // 5-"/jonasAdmin/EditNewUserMemoryRealm.do?action=create"
300
testParticularCase("memrlm_1", "Users.do", "action=create", URL_JONASADMIN_NEW_USER, viewedURLs);
301
302         // Verify all links are not viewTree.do
303
try {
304             verifyLinks(treeFrame, viewedURLs);
305         } catch (IOException JavaDoc e) {
306             throw new IllegalStateException JavaDoc("Problem to verify all links. " + e);
307         } catch (Exception JavaDoc e) {
308             throw new IllegalStateException JavaDoc("Problem to verify all links. " + e);
309         }
310
311         // Test MBean
312
if (configFile.get(NAVIGATION_MBEAN).equals("on")) {
313             testMBean(viewedURLs);
314         }
315     }
316
317     /**
318      * Verify all links in frame
319      * @param frame The frame
320      * @param viewedURLs All URLs have just been viewed
321      * @throws IOException if error occurs to get response
322      * @throws Exception if error occurs to get response
323      */

324     public void verifyLinks(WebResponse frame, Vector JavaDoc viewedURLs) throws Exception JavaDoc, IOException JavaDoc {
325
326         WebLink[] links = null;
327
328         // Disable errors of javascript
329
HttpUnitOptions.setExceptionsThrownOnScriptError(false);
330         // Disable exception thrown on error status
331
HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
332
333         // Get links
334
links = frame.getLinks();
335         WebResponse wr;
336
337         for (int i = 0; i < links.length; i++) {
338             // Verify all links are not viewTree.do and don't contain "://"
339
if (links[i].getURLString().indexOf("viewTree.do") == -1 && links[i].getURLString().indexOf("ListMBeanDetails.do") == -1 && links[i].getURLString().indexOf("://") == -1) {
340                 if (!viewedURLs.contains(links[i].getURLString())) {
341                     executeTests(frame, links[i], viewedURLs);
342
343                     // Verify content frame links
344
WebResponse contentFrame = wc.getFrameContents(FRAME_CONTENT);
345                     verifyLinks(contentFrame, viewedURLs);
346                 }
347             }
348         }
349     }
350
351     /**
352      * Test links and content titles for a particular case
353      * @param treeLink the link of the tree frame to click
354      * @param contentLink the link of the content frame to click
355      * @param url the url to test
356      * @param viewedURLs All URLs have just been viewed
357      * @throws Exception if an error occurs
358      */

359     private void testParticularCase(String JavaDoc treeLink, String JavaDoc contentLink, String JavaDoc url, Vector JavaDoc viewedURLs) throws Exception JavaDoc {
360         WebLink link;
361         WebResponse wr;
362         WebResponse frame;
363
364         frame = wc.getFrameContents(FRAME_TREE);
365         link = frame.getFirstMatchingLink( WebLink.MATCH_URL_STRING, treeLink);
366         if (link == null) {
367             throw new IllegalStateException JavaDoc("No link found for treelink : '" + treeLink + "'.");
368         }
369         wr = link.click();
370
371         frame = wc.getFrameContents(FRAME_CONTENT);
372         link = frame.getFirstMatchingLink( WebLink.MATCH_URL_STRING, contentLink);
373
374         if (link == null) {
375             throw new IllegalStateException JavaDoc("No link found for treelink : '" + treeLink + "'.");
376         }
377         executeTests(frame, link, viewedURLs);
378     }
379
380     /**
381      * Test links and content titles for a particular case
382      * @param treeLink the link of the tree frame to click
383      * @param contentLink the link of the content frame to click
384      * @param contentLink2 the second link of the content frame to click
385      * @param url the url to test
386      * @param viewedURLs All URLs have just been viewed
387      * @throws Exception if an error occurs
388      */

389     private void testParticularCase(String JavaDoc treeLink, String JavaDoc contentLink, String JavaDoc contentLink2, String JavaDoc url, Vector JavaDoc viewedURLs) throws Exception JavaDoc {
390
391         WebLink link;
392         WebResponse wr;
393         WebResponse frame;
394
395         frame = wc.getFrameContents(FRAME_TREE);
396         link = frame.getFirstMatchingLink(WebLink.MATCH_URL_STRING, treeLink);
397         if (link == null) {
398             throw new IllegalStateException JavaDoc("No link found for treelink : '" + treeLink + "'.");
399         }
400         wr = link.click();
401
402         frame = wc.getFrameContents(FRAME_CONTENT);
403         link = frame.getFirstMatchingLink(WebLink.MATCH_URL_STRING, contentLink);
404         if (link == null) {
405             throw new IllegalStateException JavaDoc("No link found for contentLink : '" + contentLink + "'.");
406         }
407         wr = link.click();
408
409         frame = wc.getFrameContents(FRAME_CONTENT);
410         link = frame.getFirstMatchingLink(WebLink.MATCH_URL_STRING, contentLink2);
411         if (link == null) {
412             throw new IllegalStateException JavaDoc("No link found for contentLink2 : '" + contentLink2 + "'.");
413         }
414
415         executeTests(frame, link, viewedURLs);
416     }
417
418     /**
419      * call the tests
420      * @param frame The frame where the link is
421      * @param link A no null link
422      * @param viewedURLs All URLs have just been viewed
423      * @throws SAXException If an error occurs
424      */

425     private void executeTests(WebResponse frame, WebLink link, Vector JavaDoc viewedURLs) throws SAXException JavaDoc {
426
427         WebResponse wr;
428         try {
429             wr = link.click();
430             // To check if the link is correct
431
if (configFile.get(NAVIGATION_LINK).equals("on")) {
432                 testLinks(wr);
433             }
434         } catch (HttpNotFoundException e) {
435             if (configFile.get(NAVIGATION_LINK).equals("on")) {
436                 fail("failed to click : link = " + link.getText() + ", URL = " + link.getURLString() + ", page = " + viewedURLs.lastElement() + ". " + e);
437             }
438         } catch (HttpException e) {
439             if (configFile.get(NAVIGATION_LINK).equals("on")) {
440                 fail("failed to click : link = " + link.getText() + ", URL = " + link.getURLString() + ", page = " + viewedURLs.lastElement() + ". " + e);
441             }
442         } catch (IOException JavaDoc e) {
443             if (configFile.get(NAVIGATION_LINK).equals("on")) {
444                 fail("failed to click : link = " + link.getText() + ", URL = " + link.getURLString() + ", page = " + viewedURLs.lastElement() + ". " + e);
445             }
446         }
447
448         // To check if the content title is correct
449
if (configFile.get(NAVIGATION_CONTENT_TITLE).equals("on")) {
450             testContentTitle(link.getURLString());
451         }
452
453         // To check if the selected item is correct for links of the tree frame
454
if (frame.getFrameName().equalsIgnoreCase(FRAME_TREE)) {
455             if (configFile.get(NAVIGATION_SELECTED_ITEM).equals("on")) {
456                 testTreeSelected(link.getURLString());
457             }
458         }
459
460         // To check if the title tom thumb is correct
461
if (configFile.get(NAVIGATION_TITLE_TOM_THUMB).equals("on")) {
462             testTitleTomThumb(link.getURLString());
463         }
464
465         // Add URL to viewed URLs
466
viewedURLs.add(link.getURLString());
467     }
468
469     /**
470      * Test if the response is a success
471      * @param wr
472      */

473     private void testLinks(WebResponse wr) {
474         assertEquals("a code of 200 (success) should be returned. ", HTTP_SUCCESS_CODE, wr.getResponseCode());
475     }
476
477     /**
478      * Test jonasAdmin content titles
479      * @param url The url of the link that was clicked
480      * @throws SAXException if an error occurs when getElementsWithAttribute is called
481      */

482     private void testContentTitle(String JavaDoc url) throws SAXException JavaDoc {
483
484         WebResponse tree = null;
485         WebResponse content = null;
486         String JavaDoc treeTitle = null;
487         String JavaDoc contentTitle = null;
488
489         // Verify content title of the content frame
490
content = wc.getFrameContents(FRAME_CONTENT);
491         tree = wc.getFrameContents(FRAME_TREE);
492
493         // Get title from the tree frame
494
if (tree.getElementsWithAttribute("class", CLASS_TREE_CONTROL_SELECTED).length == 1) {
495             treeTitle = new String JavaDoc(tree.getElementsWithAttribute("class", CLASS_TREE_CONTROL_SELECTED)[0].getText());
496         }
497
498         // Get title from the content frame
499
if (content.getElementsWithAttribute("class", "contentTitle").length == 1) {
500             contentTitle = new String JavaDoc(content.getElementsWithAttribute("class", "contentTitle")[0].getText());
501         }
502         if (treeTitle != null && contentTitle != null) {
503             assertEquals("The content title (" + contentTitle + ") is different of the link name (" + treeTitle + "). Clicked link was " + url, treeTitle, contentTitle);
504         } else {
505             if (!url.equals(URL_JONASADMIN)) {
506                 if (treeTitle != null) {
507                     try {
508                         fail("Content title is null. Name of the selected link was " + treeTitle + ". Link URL: " + url + " Content frame: " + content.getText());
509                     } catch (IOException JavaDoc e) {
510                         fail("Content title is null. Name of the selected link was " + treeTitle + ". Link URL: " + url + " Error to get content frame text");
511                     }
512                 } else {
513                     if (contentTitle != null) {
514                         fail("No link is selected. Content title was " + contentTitle);
515                     } else {
516                         try {
517                             fail("No link and no content title are found. Tree frame: " + tree.getText() + ". Content frame: " + content.getText());
518                         } catch (IOException JavaDoc e) {
519                             fail("No link and no content title are found because there is a problem in tree frame or content frame. ");
520                         }
521                     }
522                 }
523             }
524         }
525
526         // To free memory
527
content = null;
528         tree = null;
529     }
530
531     /**
532      * Test jonasAdmin selection of tree items
533      * @param selectedLink The url of the link that was clicked
534      */

535     private void testTreeSelected(String JavaDoc selectedLink) {
536
537         WebResponse tree = null;
538
539         // Verify tree frame
540
tree = wc.getFrameContents(FRAME_TREE);
541
542         try {
543             if (!JonasAdminTree.treeControlSelected(tree, selectedLink)) {
544                 fail("The name of the link " + selectedLink + " is not selected in the tree.");
545             }
546         } catch (SAXException JavaDoc sax) {
547             fail("" + sax);
548         }
549
550         tree = null;
551     }
552
553     /**
554      * Test the jonasAdmin title tom thumb
555      * @param url The url of the link that was clicked
556      */

557     private void testTitleTomThumb(String JavaDoc url) {
558         WebResponse contentFrame = wc.getFrameContents(FRAME_CONTENT);
559         WebResponse treeFrame = wc.getFrameContents(FRAME_TREE);
560         WebTable thumbTable = null;
561         WebTable treeTable = null;
562         TableCell thumbCell = null;
563         TableCell treeCell = null;
564         String JavaDoc text = null;
565         String JavaDoc[] thumbs = null;
566         String JavaDoc[] treeThumbs = null;
567         JonasAdminUtils utils = new JonasAdminUtils();
568         int row;
569         int column;
570
571         try {
572             thumbTable = contentFrame.getTables()[0];
573         } catch (SAXException JavaDoc e) {
574             fail("There is no table in content frame: " + e);
575         }
576
577         thumbCell = thumbTable.getTableCell(0, 0);
578         text = thumbCell.getText();
579         thumbs = text.split(" > ");
580
581
582         try {
583             treeTable = treeFrame.getTables()[0];
584         } catch (SAXException JavaDoc e) {
585             fail("There is no table in tree frame: " + e);
586         }
587         JonasAdminUtils.CoordCell coord = utils.getSelectedItemRow(treeTable);
588
589         if (!url.equals(URL_JONASADMIN)) {
590             row = coord.getRow().intValue();
591             column = coord.getColumn().intValue();
592             // get parents of the selected item
593
treeThumbs = new String JavaDoc[thumbs.length];
594             int i = thumbs.length;
595             while (row > 0 && column > 3 && i > 0) {
596                 boolean found = false;
597                 column--;
598                 i--;
599                 // get the row parent
600
int nextRow = row;
601                 while (nextRow > 0 && !found) {
602                     nextRow--;
603                     treeCell = treeTable.getTableCell(nextRow, column-2);
604                     if (treeCell.getElementsWithAttribute("src", "images/tree/node_open_middle.gif").length == 1) {
605                         treeCell = treeTable.getTableCell(nextRow, column);
606                         treeThumbs[i] = treeCell.getText();
607                         found = true;
608                         assertEquals("For the link " + url, treeThumbs[i], thumbs[i]);
609                     } else if (treeCell.getElementsWithAttribute("src", "images/tree/node_open_last.gif").length == 1) {
610                         treeCell = treeTable.getTableCell(nextRow, column);
611                         treeThumbs[i] = treeCell.getText();
612                         found = true;
613                         assertEquals("For the link " + url, treeThumbs[i], thumbs[i]);
614                     } else if (treeCell.getElementsWithAttribute("src", "images/tree/node_open_first.gif").length == 1) {
615                         treeCell = treeTable.getTableCell(nextRow, column);
616                         treeThumbs[i] = treeCell.getText();
617                         found = true;
618                         assertEquals("For the link " + url, treeThumbs[i], thumbs[i]);
619                     } else if (treeCell.getElementsWithAttribute("src", "images/tree/node_open.gif").length == 1) {
620                         treeCell = treeTable.getTableCell(nextRow, column);
621                         treeThumbs[i] = treeCell.getText();
622                         found = true;
623                         assertEquals("For the link " + url, treeThumbs[i], thumbs[i]);
624                     }
625                 }
626                 row = nextRow;
627             }
628         }
629     }
630
631     /**
632      * Test links, content titles, selected tree of mbeans
633      * @throws Exception if an error occurs
634      */

635     private void testMBean(Vector JavaDoc viewedURLs) throws Exception JavaDoc {
636         WebResponse wr = wc.getFrameContents(FRAME_TREE);
637         WebLink link;
638
639         // Open MBean branch
640
if (wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, "viewTree.do?tree=domain*mbeans*j2ee") == null) {
641             link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, "viewTree.do?tree=domain*mbeans");
642             if (link == null) {
643                 throw new IllegalStateException JavaDoc("The link viewTree.do?domain*mbeans is not found in tree. ");
644             }
645             wr = link.click();
646         }
647         // J2EE MBeans
648
link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, "viewTree.do?tree=domain*mbeans*j2ee");
649         if (link == null) {
650             throw new IllegalStateException JavaDoc("The link viewTree.do?domain*mbeans*j2ee is not found in tree. ");
651         }
652         wr = link.click();
653
654         link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, "viewTree.do?tree=domain*mbeans*j2ee*");
655         if (link == null) {
656             throw new IllegalStateException JavaDoc("The link viewTree.do?domain*mbeans*j2ee* is not found in tree. ");
657         }
658         wr = link.click();
659
660         link = wr.getMatchingLinks(WebLink.MATCH_URL_STRING, "viewTree.do?tree=domain*mbeans*j2ee*")[1];
661         if (link == null) {
662             throw new IllegalStateException JavaDoc("The 2nd link viewTree.do?domain*mbeans*j2ee* is not found in tree. ");
663         }
664         wr = link.click();
665         // OWNER MBeans
666
link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, "viewTree.do?tree=domain*mbeans*owner");
667         if (link == null) {
668             throw new IllegalStateException JavaDoc("The link viewTree.do?domain*mbeans*owner is not found in tree. ");
669         }
670         wr = link.click();
671
672         link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, "viewTree.do?tree=domain*mbeans*owner*");
673         if (link == null) {
674             throw new IllegalStateException JavaDoc("The link viewTree.do?domain*mbeans*owner* is not found in tree. ");
675         }
676         wr = link.click();
677
678         link = wr.getMatchingLinks(WebLink.MATCH_URL_STRING, "viewTree.do?tree=domain*mbeans*owner*")[1];
679         if (link == null) {
680             throw new IllegalStateException JavaDoc("The 2nd link viewTree.do?domain*mbeans*owner* is not found in tree. ");
681         }
682         wr = link.click();
683
684         // OTHER MBeans
685
link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, "viewTree.do?tree=domain*mbeans*unknown");
686         if (link == null) {
687             throw new IllegalStateException JavaDoc("The link viewTree.do?domain*mbeans*unknow is not found in tree. ");
688         }
689         wr = link.click();
690
691         link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, "viewTree.do?tree=domain*mbeans*unknown*");
692         if (link == null) {
693             throw new IllegalStateException JavaDoc("The link viewTree.do?domain*mbeans*unknow* is not found in tree. ");
694         }
695         wr = link.click();
696
697         link = wr.getMatchingLinks(WebLink.MATCH_URL_STRING, "viewTree.do?tree=domain*mbeans*unknown*")[1];
698         if (link == null) {
699             throw new IllegalStateException JavaDoc("The 2nd link viewTree.do?domain*mbeans*unknow* is not found in tree. ");
700         }
701         wr = link.click();
702
703         // Tests - ListMBeans.do
704
wr = wc.getFrameContents(FRAME_TREE);
705         link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, "ListMBeans.do");
706         if (link == null) {
707             throw new IllegalStateException JavaDoc("ListMBeans.do was not found in tree. ");
708         }
709         executeTests(wr, link, viewedURLs);
710
711         // Tests - ListJ2eeMBeans.do
712
wr = wc.getFrameContents(FRAME_TREE);
713         link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, "ListJ2eeMBeans.do");
714         if (link == null) {
715             throw new IllegalStateException JavaDoc("ListJ2eeMBeans.do was not found in tree. ");
716         }
717         executeTests(wr, link, viewedURLs);
718
719         // Tests - ListOwnerMBeans.do
720
wr = wc.getFrameContents(FRAME_TREE);
721         link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, "ListOwnerMBeans.do");
722         if (link == null) {
723             throw new IllegalStateException JavaDoc("ListOwnerMBeans.do was not found in tree. ");
724         }
725         executeTests(wr, link, viewedURLs);
726
727         // Tests - ListUnknownMBeans.do
728
wr = wc.getFrameContents(FRAME_TREE);
729         link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, "ListUnknownMBeans.do");
730         if (link == null) {
731             throw new IllegalStateException JavaDoc("ListUnknownMBeans.do was not found in tree. ");
732         }
733         executeTests(wr, link, viewedURLs);
734
735         // Tests - ListMBeanDetails.do
736
wr = wc.getFrameContents(FRAME_TREE);
737         link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, "ListMBeanDetails.do");
738         if (link == null) {
739             throw new IllegalStateException JavaDoc("ListMBeanDetails.do was not found in tree. ");
740         }
741         executeTests(wr, link, viewedURLs);
742
743         // Tests - ListMBeanAttributes.do
744
wr = wc.getFrameContents(FRAME_CONTENT);
745         link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, "ListMBeanAttributes.do");
746         if (link == null) {
747             throw new IllegalStateException JavaDoc("ListMBeansAttributes.do was not found in tree. ");
748         }
749         executeTests(wr, link, viewedURLs);
750
751         // Tests - ListMBeanOperations.do
752
wr = wc.getFrameContents(FRAME_CONTENT);
753         link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, "ListMBeanOperations.do");
754         if (link == null) {
755             throw new IllegalStateException JavaDoc("ListMBeansOperations.do was not found in tree. ");
756         }
757         executeTests(wr, link, viewedURLs);
758
759         // Tests - ListMBeanProperties.do
760
wr = wc.getFrameContents(FRAME_CONTENT);
761         link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING, "ListMBeanProperties.do");
762         if (link == null) {
763             throw new IllegalStateException JavaDoc("ListMBeansProperties.do was not found in tree. ");
764         }
765         executeTests(wr, link, viewedURLs);
766     }
767
768     /**
769      * Tear Down cleanUp action
770      */

771     public void tearDown() {
772         // Get time
773
endTime = getTime();
774
775         // Delete created files: server.xml
776
JonasAdminFiles.recoverServerConf(beginTime, endTime);
777     }
778 }
779
Popular Tags