Source Code Cross Referenced for F_JonasAdminJoramDestination.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » jonasadmin » test » joram » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » JOnAS 4.8.6 » org.objectweb.jonas.jonasadmin.test.joram 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 2005 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or 1any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: F_JonasAdminJoramDestination.java 8127 2006-03-14 13:56:08Z danesa $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas.jonasadmin.test.joram;
025:
026:        import javax.management.MBeanServerConnection;
027:        import javax.management.ObjectName;
028:
029:        import junit.framework.TestSuite;
030:
031:        import org.objectweb.jonas.jonasadmin.test.service.container.F_JonasAdminEjbContainer;
032:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminAuth;
033:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminTestCase;
034:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminUtils;
035:
036:        import com.meterware.httpunit.HttpUnitOptions;
037:        import com.meterware.httpunit.SubmitButton;
038:        import com.meterware.httpunit.TableCell;
039:        import com.meterware.httpunit.WebForm;
040:        import com.meterware.httpunit.WebLink;
041:        import com.meterware.httpunit.WebResponse;
042:        import com.meterware.httpunit.WebTable;
043:
044:        /**
045:         * Class for testing JORAM destinations
046:         * @author Paul Kemler
047:         *
048:         */
049:        public class F_JonasAdminJoramDestination extends JonasAdminTestCase {
050:
051:            /**
052:             * URL of the Joram Platform
053:             */
054:            private static final String URL_JONASADMIN_JORAM = "EditJoramPlatform.do";
055:
056:            /**
057:             * URL of the Joram Servers
058:             */
059:            private static final String URL_JONASADMIN_JORAM_SERVERS = "joramplatform/joramservers.jsp";
060:
061:            /**
062:             * URL of "Create Jms Destination"
063:             */
064:            private static final String URL_JONASADMIN_JORAM_CREATE_DESTINATION = "CreateJoramDestination.do";
065:
066:            /**
067:             * URL of the Remove Button
068:             */
069:            private static final String URL_JONASADMIN_JORAM_REMOVE = "RemoveConfirmDestinations.do";
070:
071:            /**
072:             * URL of the 'Used By' tab for a topic
073:             */
074:            private static final String URL_JONASADMIN_TOPIC_USED_BY = "joramplatform/topicUsedBy.jsp";
075:
076:            /**
077:             * Constructor with a specified name
078:             * @param s name
079:             */
080:            public F_JonasAdminJoramDestination(String s) {
081:                super (s, URL_JONASADMIN);
082:            }
083:
084:            /**
085:             * Main method
086:             * @param args the arguments
087:             */
088:            public static void main(String[] args) {
089:
090:                String testtorun = null;
091:                // Get args
092:                for (int argn = 0; argn < args.length; argn++) {
093:                    String sArg = args[argn];
094:                    if (sArg.equals("-n")) {
095:                        testtorun = args[++argn];
096:                    }
097:                }
098:                if (testtorun == null) {
099:                    junit.textui.TestRunner.run(suite());
100:                } else {
101:                    junit.textui.TestRunner
102:                            .run(new F_JonasAdminJoramDestination(testtorun));
103:                }
104:            }
105:
106:            /**
107:             * Get a new TestSuite for this class
108:             * @return a new TestSuite for this class
109:             */
110:            public static TestSuite suite() {
111:                return new TestSuite(F_JonasAdminJoramDestination.class);
112:            }
113:
114:            /**
115:             * Setup need for these tests
116:             * jonasAdmin is required
117:             * @throws Exception if it fails
118:             */
119:            protected void setUp() throws Exception {
120:                super .setUp();
121:
122:                if (wc.getCurrentPage().getURL() == null) {
123:                    useWar("jonasAdmin");
124:                    // login to jonas admin
125:                    try {
126:                        JonasAdminAuth.doValidAuth(wc, url);
127:                    } catch (Exception e) {
128:                        fail("authentification failed :  " + e);
129:                    }
130:                } else {
131:                    // if there was an error, the connection must be restablished
132:                    try {
133:                        wc.getFrameContents(FRAME_TREE);
134:                    } catch (Exception e) {
135:                        wc.getResponse(urlLogOut);
136:                        // login to jonas admin
137:                        try {
138:                            JonasAdminAuth.doValidAuth(wc, url);
139:                        } catch (Exception auth) {
140:                            fail("authentification failed :  " + auth);
141:                        }
142:                    }
143:                }
144:            }
145:
146:            /**
147:             * Test the creation of a new topic
148:             * @throws Exception if error occurs
149:             *
150:             */
151:            public void testCreateNewTopic() throws Exception {
152:
153:                WebResponse wr;
154:                WebLink link;
155:                WebTable table;
156:                String createDestinationPage;
157:                /*
158:                 * To get some utils for WebTable
159:                 */
160:                JonasAdminUtils utils = new JonasAdminUtils();
161:
162:                // Disable errors of javascript
163:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
164:                // Disable exception thrown on error status
165:                HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
166:
167:                if (jProp.isResource()) {
168:                    // Joram platform is in jonas
169:                    //if (isRarLoaded("joram_for_jonas_ra")) {
170:                    if (isJoramRar()) {
171:                        // Go to Joram Platform
172:                        wr = wc.getFrameContents(FRAME_TREE);
173:                        link = wr.getFirstMatchingLink(
174:                                WebLink.MATCH_URL_STRING, URL_JONASADMIN_JORAM);
175:                        link.click();
176:                        wr = wc.getFrameContents(FRAME_CONTENT);
177:
178:                        // Go to Joram Servers
179:                        link = wr.getFirstMatchingLink(
180:                                WebLink.MATCH_URL_STRING,
181:                                URL_JONASADMIN_JORAM_SERVERS);
182:                        link.click();
183:                        wr = wc.getFrameContents(FRAME_CONTENT);
184:
185:                        // Go to Local Server
186:                        WebTable localTable = utils.getTable(wr, 1);
187:                        link = localTable.getTableCell(0, 0).getLinks()[0];
188:                        if (link == null) {
189:                            throw new IllegalStateException(
190:                                    "No link was found to a local server in the 'Joram servers' page. ");
191:                        }
192:                        link.click();
193:                        wr = wc.getFrameContents(FRAME_CONTENT);
194:
195:                        // Go to Create JMS Destination
196:                        link = wr.getFirstMatchingLink(
197:                                WebLink.MATCH_URL_STRING,
198:                                URL_JONASADMIN_JORAM_CREATE_DESTINATION);
199:                        link.click();
200:                        wr = wc.getFrameContents(FRAME_CONTENT);
201:
202:                        createDestinationPage = wr.getText(); // For comparing with the forwarded page after the creation
203:                        // Find a name
204:                        String topicName = "new_topic_";
205:                        int topicId = 0;
206:                        boolean found = false;
207:                        while (!found) {
208:                            if (!isTopic(topicName + topicId)) {
209:                                topicName = topicName + topicId;
210:                                found = true;
211:                            }
212:                            topicId++;
213:                        }
214:
215:                        // Create a new topic
216:                        createTopic(wr, topicName);
217:
218:                        wr = wc.getFrameContents(FRAME_CONTENT);
219:
220:                        // Verify topic is created
221:                        assertTrue("The '" + topicName
222:                                + "' topic was not created. ",
223:                                isTopic(topicName));
224:
225:                        // Verify the forwarded page
226:                        //assertEquals("The 'New Destination' page has changed. ", createDestinationPage, wr.getText());
227:                        // This asserion can't be verified for the moment as the 'New destination' page has th following
228:                        // <script language="JavaScript">refreshTree("/jonasAdmin/viewTree.do?select=domain*joramplatform*joramlocalserver&s=0.???????");</script>
229:                    }
230:                }
231:
232:            }
233:
234:            /**
235:             * Test the creation of a new queue
236:             * @throws Exception if error occurs
237:             *
238:             */
239:            public void testCreateNewQueue() throws Exception {
240:
241:                WebResponse wr;
242:                WebLink link;
243:                WebTable table;
244:                String createDestinationPage;
245:                /*
246:                 * To get some utils for WebTable
247:                 */
248:                JonasAdminUtils utils = new JonasAdminUtils();
249:
250:                // Disable errors of javascript
251:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
252:                // Disable exception thrown on error status
253:                HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
254:
255:                if (jProp.isResource()) {
256:                    // Joram platform is in jonas
257:                    //if (isRarLoaded("joram_for_jonas_ra")) {
258:                    if (isJoramRar()) {
259:                        // Go to Joram Platform
260:                        wr = wc.getFrameContents(FRAME_TREE);
261:                        link = wr.getFirstMatchingLink(
262:                                WebLink.MATCH_URL_STRING, URL_JONASADMIN_JORAM);
263:                        link.click();
264:                        wr = wc.getFrameContents(FRAME_CONTENT);
265:
266:                        // Go to Joram Servers
267:                        link = wr.getFirstMatchingLink(
268:                                WebLink.MATCH_URL_STRING,
269:                                URL_JONASADMIN_JORAM_SERVERS);
270:                        link.click();
271:                        wr = wc.getFrameContents(FRAME_CONTENT);
272:
273:                        // Go to Local Server
274:                        WebTable localTable = utils.getTable(wr, 1);
275:                        link = localTable.getTableCell(0, 0).getLinks()[0];
276:                        if (link == null) {
277:                            throw new IllegalStateException(
278:                                    "No link was found to a local server in the 'Joram servers' page. ");
279:                        }
280:                        link.click();
281:                        wr = wc.getFrameContents(FRAME_CONTENT);
282:
283:                        // Go to Create JMS Destination
284:                        link = wr.getFirstMatchingLink(
285:                                WebLink.MATCH_URL_STRING,
286:                                URL_JONASADMIN_JORAM_CREATE_DESTINATION);
287:                        link.click();
288:                        wr = wc.getFrameContents(FRAME_CONTENT);
289:
290:                        createDestinationPage = wr.getText(); // For comparing with the forwarded page after the creation
291:                        // Find a name
292:                        String queueName = "new_queue_";
293:                        int queueId = 0;
294:                        boolean found = false;
295:                        while (!found) {
296:                            if (!isQueue(queueName + queueId)) {
297:                                queueName = queueName + queueId;
298:                                found = true;
299:                            }
300:                            queueId++;
301:                        }
302:
303:                        // Create a new queue
304:                        createQueue(wr, queueName);
305:
306:                        wr = wc.getFrameContents(FRAME_CONTENT);
307:
308:                        // Verify queue is created
309:                        assertTrue("The '" + queueName
310:                                + "' queue was not created. ",
311:                                isQueue(queueName));
312:
313:                        // Verify the forwarded page
314:                        // assertEquals("The 'New Destination' page has changed. ", createDestinationPage, wr.getText());
315:                        // This asserion can't be verified for the moment as the 'New destination' page has th following
316:                        // <script language="JavaScript">refreshTree("/jonasAdmin/viewTree.do?select=domain*joramplatform*joramlocalserver&s=0.05622878568562584");</script>
317:                    } else {
318:
319:                        System.out.println("------joram jar not loaded");
320:                    }
321:                }
322:
323:            }
324:
325:            /**
326:             * Test to delete a topic
327:             * @throws Exception if error occurs
328:             *
329:             */
330:            public void testDeleteTopic() throws Exception {
331:
332:                WebResponse wr;
333:                WebLink link;
334:                WebTable table;
335:                /*
336:                 * To get some utils for WebTable
337:                 */
338:                JonasAdminUtils utils = new JonasAdminUtils();
339:
340:                // Disable errors of javascript
341:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
342:                // Disable exception thrown on error status
343:                HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
344:
345:                if (jProp.isResource()) {
346:                    // Joram platform is in jonas
347:                    //if (isRarLoaded("joram_for_jonas_ra")) {
348:                    if (isJoramRar()) {
349:                        // Find a name
350:                        String topicName = "new_topic_";
351:                        int topicId = 0;
352:                        boolean found = false;
353:                        while (!found) {
354:                            if (!isQueue(topicName + topicId)) {
355:                                topicName = topicName + topicId;
356:                                found = true;
357:                            }
358:                            topicId++;
359:                        }
360:
361:                        // Create a topic
362:                        createTopic(topicName, getLocalServerId());
363:
364:                        // Go to Joram Platform
365:                        wr = wc.getFrameContents(FRAME_TREE);
366:                        link = wr.getFirstMatchingLink(
367:                                WebLink.MATCH_URL_STRING, URL_JONASADMIN_JORAM);
368:                        link.click();
369:                        wr = wc.getFrameContents(FRAME_CONTENT);
370:
371:                        // Go to Joram Servers
372:                        link = wr.getFirstMatchingLink(
373:                                WebLink.MATCH_URL_STRING,
374:                                URL_JONASADMIN_JORAM_SERVERS);
375:                        link.click();
376:                        wr = wc.getFrameContents(FRAME_CONTENT);
377:
378:                        // Go to Local Server
379:                        WebTable localTable = utils.getTable(wr, 1);
380:                        link = localTable.getTableCell(0, 0).getLinks()[0];
381:                        if (link == null) {
382:                            throw new IllegalStateException(
383:                                    "No link was found to a local server in the 'Joram servers' page. ");
384:                        }
385:                        link.click();
386:                        wr = wc.getFrameContents(FRAME_CONTENT);
387:
388:                        // Delete the created JMS Destination
389:                        WebForm removeDestinationForm = wr.getForms()[0];
390:                        SubmitButton button = removeDestinationForm
391:                                .getSubmitButtons()[0];
392:                        removeDestinationForm.setCheckbox("selectedItems",
393:                                topicName, true);
394:                        button.click();
395:
396:                        wr = wc.getFrameContents(FRAME_CONTENT);
397:
398:                        // Confirm
399:                        link = wr.getFirstMatchingLink(
400:                                WebLink.MATCH_URL_STRING,
401:                                URL_JONASADMIN_JORAM_REMOVE);
402:                        link.click();
403:                        wr = wc.getFrameContents(FRAME_CONTENT);
404:
405:                        // Verify topic is deleted
406:                        assertTrue("The '" + topicName
407:                                + "' topic always exists. ", isTopic(topicName));
408:
409:                        // Verify console is updated
410:                        assertTrue(
411:                                "The '"
412:                                        + topicName
413:                                        + "' topic was found in jonasAdmin after deleting. ",
414:                                wr.getText().indexOf(topicName) == -1);
415:                    }
416:                }
417:
418:            }
419:
420:            /**
421:             * Test to delete a queue
422:             * @throws Exception if error occurs
423:             *
424:             */
425:            public void testDeleteQueue() throws Exception {
426:
427:                WebResponse wr;
428:                WebLink link;
429:                WebTable table;
430:                /*
431:                 * To get some utils for WebTable
432:                 */
433:                JonasAdminUtils utils = new JonasAdminUtils();
434:
435:                // Disable errors of javascript
436:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
437:                // Disable exception thrown on error status
438:                HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
439:
440:                if (jProp.isResource()) {
441:                    // Joram platform is in jonas
442:                    //if (isRarLoaded("joram_for_jonas_ra")) {
443:                    if (isJoramRar()) {
444:                        // Find a name
445:                        String queueName = "new_queue_";
446:                        int queueId = 0;
447:                        boolean found = false;
448:                        while (!found) {
449:                            if (!isQueue(queueName + queueId)) {
450:                                queueName = queueName + queueId;
451:                                found = true;
452:                            }
453:                            queueId++;
454:                        }
455:
456:                        // Create a queue
457:                        createQueue(queueName, getLocalServerId());
458:
459:                        // Go to Joram Platform
460:                        wr = wc.getFrameContents(FRAME_TREE);
461:                        link = wr.getFirstMatchingLink(
462:                                WebLink.MATCH_URL_STRING, URL_JONASADMIN_JORAM);
463:                        link.click();
464:                        wr = wc.getFrameContents(FRAME_CONTENT);
465:
466:                        // Go to Joram Servers
467:                        link = wr.getFirstMatchingLink(
468:                                WebLink.MATCH_URL_STRING,
469:                                URL_JONASADMIN_JORAM_SERVERS);
470:                        link.click();
471:                        wr = wc.getFrameContents(FRAME_CONTENT);
472:
473:                        // Go to Local Server
474:                        WebTable localTable = utils.getTable(wr, 1);
475:                        link = localTable.getTableCell(0, 0).getLinks()[0];
476:                        if (link == null) {
477:                            throw new IllegalStateException(
478:                                    "No link was found to a local server in the 'Joram servers' page. ");
479:                        }
480:                        link.click();
481:                        wr = wc.getFrameContents(FRAME_CONTENT);
482:
483:                        // Delete the created JMS Destination
484:                        WebForm removeDestinationForm = wr.getForms()[0];
485:                        SubmitButton button = removeDestinationForm
486:                                .getSubmitButtons()[0];
487:                        removeDestinationForm.setCheckbox("selectedItems",
488:                                queueName, true);
489:                        button.click();
490:
491:                        wr = wc.getFrameContents(FRAME_CONTENT);
492:
493:                        // Confirm
494:                        link = wr.getFirstMatchingLink(
495:                                WebLink.MATCH_URL_STRING,
496:                                URL_JONASADMIN_JORAM_REMOVE);
497:                        link.click();
498:                        wr = wc.getFrameContents(FRAME_CONTENT);
499:
500:                        // Verify queue is deleted
501:                        assertTrue("The '" + queueName
502:                                + "' queue always exists. ", isQueue(queueName));
503:
504:                        // Verify console is updated
505:                        assertTrue(
506:                                "The '"
507:                                        + queueName
508:                                        + "' queue was found in jonasAdmin after deleting. ",
509:                                wr.getText().indexOf(queueName) == -1);
510:                    }
511:                }
512:
513:            }
514:
515:            /**
516:             * Test a used topic
517:             * @throws Exception if error occurs
518:             *
519:             */
520:            public void testUsedTopic() throws Exception {
521:
522:                WebResponse wr;
523:                WebLink link;
524:                WebTable table;
525:                String topicName = "mdbTopic";
526:                /*
527:                 * To get some utils for WebTable
528:                 */
529:                JonasAdminUtils utils = new JonasAdminUtils();
530:
531:                // Disable errors of javascript
532:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
533:                // Disable exception thrown on error status
534:                HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
535:                if (jProp.isResource()) {
536:                    // Joram platform is in jonas
537:                    //if (isRarLoaded("joram_for_jonas_ra")) {
538:                    if (isJoramRar()) {
539:                        // Create a topic
540:                        createTopic(topicName, getLocalServerId());
541:
542:                        // Use samplemdb.jar
543:                        useBeans("samplemdb");
544:
545:                        // Go to Joram Platform
546:                        wr = wc.getFrameContents(FRAME_TREE);
547:                        link = wr.getFirstMatchingLink(
548:                                WebLink.MATCH_URL_STRING, URL_JONASADMIN_JORAM);
549:                        link.click();
550:                        wr = wc.getFrameContents(FRAME_CONTENT);
551:
552:                        // Go to Joram Servers
553:                        link = wr.getFirstMatchingLink(
554:                                WebLink.MATCH_URL_STRING,
555:                                URL_JONASADMIN_JORAM_SERVERS);
556:                        link.click();
557:                        wr = wc.getFrameContents(FRAME_CONTENT);
558:
559:                        // Go to Local Server
560:                        WebTable localTable = utils.getTable(wr, 1);
561:                        link = localTable.getTableCell(0, 0).getLinks()[0];
562:                        if (link == null) {
563:                            throw new IllegalStateException(
564:                                    "No link was found to a local server in the 'Joram servers' page. ");
565:                        }
566:                        link.click();
567:                        wr = wc.getFrameContents(FRAME_CONTENT);
568:
569:                        // Verify there is no checkbox for mdbTopic
570:                        table = utils.getTable(wr, 3);
571:                        int topicRow = utils.getRow(topicName, table, 1)
572:                                .intValue();
573:                        if (topicRow == -1) {
574:                            fail("'"
575:                                    + topicName
576:                                    + "' was not found in the destination list. ");
577:                        }
578:                        TableCell cell = table.getTableCell(topicRow, 0);
579:                        assertEquals("There is an element for the '"
580:                                + topicName + "'. ", 0,
581:                                cell.getElementNames().length); // if there is a checkbox, the number of element is 1
582:
583:                        // Go to topic
584:                        link = table.getTableCell(topicRow, 1).getLinks()[0];
585:                        link.click();
586:                        wr = wc.getFrameContents(FRAME_CONTENT);
587:
588:                        // Go to 'Used By' tab
589:                        link = wr.getFirstMatchingLink(
590:                                WebLink.MATCH_URL_STRING,
591:                                URL_JONASADMIN_TOPIC_USED_BY);
592:                        if (link == null) {
593:                            fail("There is no 'Used By' tab. ");
594:                        }
595:                        link.click();
596:                        wr = wc.getFrameContents(FRAME_CONTENT);
597:
598:                        // Verify there is the Mdb MessageDrivenBean
599:                        table = utils.getTable(wr, 0);
600:                        int mdbRow = utils.getRow("Mdb", table).intValue();
601:                        if (mdbRow == -1) {
602:                            fail("The 'Mdb' EJB was not found in the list of '"
603:                                    + topicName + "' users. ");
604:                        }
605:                        // Verify the type
606:                        assertEquals(
607:                                "In list of '"
608:                                        + topicName
609:                                        + "' users, the type of 'Mdb' is not a MessageDrivenBean",
610:                                "MessageDrivenBean", table.getTableCell(mdbRow,
611:                                        1).getText());
612:
613:                        // Click to go to the Mdb page
614:                        link = table.getTableCell(mdbRow, 0).getLinks()[0];
615:                        if (link == null) {
616:                            fail("There is no link for 'Mdb' in 'Used By' page. ");
617:                        }
618:                        link.click();
619:                        wr = wc.getFrameContents(FRAME_CONTENT);
620:
621:                        // Verify the link goes to "Domain ( jonas ) > Server JOnAS ( jonas ) > Services > EJB Container > samplemdb.jar"
622:                        /* This link is not present as the samplemdb.jar was not deployed with jonasAdmin sa the management
623:                         * tree is not refreshed
624:                        TableCell contentTitleTomThumbCell = wr.getTables()[0].getTableCell(0, 0);
625:                        assertTrue("The link of 'Mdb' in 'Used By' page is maybe wrong. ", contentTitleTomThumbCell.getText().endsWith("> Services > EJB Container > samplemdb.jar"));
626:                         */
627:
628:                        // Verify the Tabs
629:                        WebTable tabTable = utils.getTabTable(wr);
630:                        /*
631:                        for (int i = 0; i < tabTable.getColumnCount(); i++) {
632:                        	System.out.println("* " + i + " -- " + tabTable.getTableCell(0, i).getText());
633:                        }*/
634:                        int mdbIndex = F_JonasAdminEjbContainer
635:                                .getMdbTabIndex();
636:                        testTabs(tabTable, F_JonasAdminEjbContainer
637:                                .getNumberOfTabsForMdb(), mdbIndex,
638:                                "Problem in 'Mdb' tab.");
639:                        int mdbTabIndex = (mdbIndex - 1) * 2;
640:                        assertEquals("The selected tab is not Mdb",
641:                                F_JonasAdminEjbContainer.getMdbTabText(),
642:                                tabTable.getTableCell(0, mdbTabIndex).getText());
643:                    } else {
644:
645:                        System.out.println("------joram jar not loaded");
646:                    }
647:                }
648:            }
649:
650:            /**
651:             * Topic exists
652:             * @param name the name of the topic
653:             * @return true if the topic exists, false else
654:             * @throws Exception if an error occurs
655:             */
656:            private boolean isTopic(String name) throws Exception {
657:                MBeanServerConnection server = getMBeanServer();
658:                ObjectName on = ObjectName
659:                        .getInstance("joramClient:type=topic,name=" + name);
660:
661:                return server.isRegistered(on);
662:            }
663:
664:            /**
665:             * Queue exists
666:             * @param name the name of the queue
667:             * @return true if the queue exists, false else
668:             * @throws Exception if an errors occurs
669:             */
670:            private boolean isQueue(String name) throws Exception {
671:                MBeanServerConnection server = getMBeanServer();
672:                ObjectName on = ObjectName
673:                        .getInstance("joramClient:type=queue,name=" + name);
674:
675:                return server.isRegistered(on);
676:            }
677:
678:            /**
679:             * Create a topic
680:             * @param wr the content frame in the 'New Destination' page
681:             * @param name the name of the topic
682:             * @throws Exception if an error occurs
683:             */
684:            private void createTopic(WebResponse wr, String name)
685:                    throws Exception {
686:                createDestination(wr, name, "topic");
687:            }
688:
689:            /**
690:             * Create a queue
691:             * @param wr the content frame in the 'New Destination' page
692:             * @param name the name of the queue
693:             * @throws Exception if an error occurs
694:             */
695:            private void createQueue(WebResponse wr, String name)
696:                    throws Exception {
697:                createDestination(wr, name, "queue");
698:            }
699:
700:            /**
701:             * Create a jms destination
702:             * @param wr the content frame in the 'New Destination' page
703:             * @param name the name of the destination
704:             * @param type the type of the destination ("topic" or "queue").
705:             * @throws Exception if an error occurs
706:             */
707:            private void createDestination(WebResponse wr, String name,
708:                    String type) throws Exception {
709:                SubmitButton button;
710:                WebForm form = wr.getForms()[0];
711:                form.setParameter("type", type);
712:                form.setParameter("name", name);
713:
714:                // Submit
715:                button = form.getSubmitButtons()[0];
716:                button.click();
717:            }
718:
719:            /**
720:             * Get the local server id
721:             * @return id of the local server
722:             * @throws Exception if an errors occurs
723:             */
724:            private int getLocalServerId() throws Exception {
725:                MBeanServerConnection server = getMBeanServer();
726:                ObjectName on = ObjectName
727:                        .getInstance("joramClient:type=JoramAdapter,*");
728:                ObjectName joramAdapterON = (ObjectName) server.queryNames(on,
729:                        null).iterator().next();
730:
731:                return ((Short) server.getAttribute(joramAdapterON, "ServerId"))
732:                        .intValue();
733:            }
734:
735:            /**
736:             * Tear Down cleanUp action
737:             * @throws Exception if an error occurs
738:             */
739:            public void tearDown() throws Exception {
740:                super.tearDown();
741:            }
742:
743:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.