Source Code Cross Referenced for F_JonasAdminServiceMail.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » jonasadmin » test » service » mail » 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.service.mail 
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_JonasAdminServiceMail.java 7381 2005-09-14 16:00:02Z kemlerp $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas.jonasadmin.test.service.mail;
025:
026:        import junit.framework.TestSuite;
027:
028:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminAuth;
029:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminTestCase;
030:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminUtils;
031:
032:        import com.meterware.httpunit.HttpUnitOptions;
033:        import com.meterware.httpunit.WebConversation;
034:        import com.meterware.httpunit.WebForm;
035:        import com.meterware.httpunit.WebLink;
036:        import com.meterware.httpunit.WebResponse;
037:        import com.meterware.httpunit.WebTable;
038:
039:        /**
040:         * Class for testing ...
041:         * @author Paul Kemler
042:         *
043:         */
044:        public class F_JonasAdminServiceMail extends JonasAdminTestCase {
045:
046:            /**
047:             * URL of mail service
048:             */
049:            private static final String URL_JONASADMIN_MAIL_SERVICE = "EditMailService.do";
050:
051:            /**
052:             * URL of Mail resource
053:             */
054:            private static final String URL_JONASADMIN_MAIL = "EditDeploy.do?type=mail";
055:
056:            /**
057:             * URL of Mail resource viewTree
058:             */
059:            private static final String URL_JONASADMIN_VIEW_MAIL = "viewTree.do?tree=domain*jonas*resources";
060:
061:            /**
062:             * URL of Session Mail Factories
063:             */
064:            private static final String URL_JONASADMIN_SESSION_MF = "ListSessionMailFactories.do";
065:
066:            /**
067:             * URL of Mime part datasource Mail Factories
068:             */
069:            private static final String URL_JONASADMIN_MIME_PART_DATASOURCE_MF = "ListMimePartMailFactories.do";
070:
071:            /**
072:             * number of tabs when you are in the mail tabs
073:             */
074:            private static final int NUMBER_OF_TABS_FOR_MAIL = 3;
075:
076:            /**
077:             * number of tabs when you are in the Session Mail Factory tab
078:             */
079:            private static final int NUMBER_OF_TABS_FOR_SESSION = 4;
080:
081:            /**
082:             * number of tabs when you are in the MimePartDS Mail Factory tab
083:             */
084:            private static final int NUMBER_OF_TABS_FOR_MIME_PART_DS = 4;
085:
086:            /**
087:             * Constructor with a specified name
088:             * @param s name
089:             */
090:            public F_JonasAdminServiceMail(String s) {
091:                super (s, URL_JONASADMIN);
092:            }
093:
094:            /**
095:             * Main method
096:             * @param args the arguments
097:             */
098:            public static void main(String[] args) {
099:
100:                String testtorun = null;
101:                // Get args
102:                for (int argn = 0; argn < args.length; argn++) {
103:                    String sArg = args[argn];
104:                    if (sArg.equals("-n")) {
105:                        testtorun = args[++argn];
106:                    }
107:                }
108:                if (testtorun == null) {
109:                    junit.textui.TestRunner.run(suite());
110:                } else {
111:                    junit.textui.TestRunner.run(new F_JonasAdminServiceMail(
112:                            testtorun));
113:                }
114:            }
115:
116:            /**
117:             * Get a new TestSuite for this class
118:             * @return a new TestSuite for this class
119:             */
120:            public static TestSuite suite() {
121:                return new TestSuite(F_JonasAdminServiceMail.class);
122:            }
123:
124:            /**
125:             * Setup need for these tests
126:             * jonasAdmin is required
127:             * @throws Exception if it fails
128:             */
129:            protected void setUp() throws Exception {
130:                super .setUp();
131:
132:                if (wc.getCurrentPage().getURL() == null) {
133:                    useWar("jonasAdmin");
134:                    // login to jonas admin
135:                    try {
136:                        JonasAdminAuth.doValidAuth(wc, url);
137:                    } catch (Exception e) {
138:                        fail("authentification failed :  " + e);
139:                    }
140:                } else {
141:                    // if there was an error, the connection must be restablished
142:                    try {
143:                        wc.getFrameContents(FRAME_TREE);
144:                    } catch (Exception e) {
145:                        wc.getResponse(urlLogOut);
146:                        // login to jonas admin
147:                        try {
148:                            JonasAdminAuth.doValidAuth(wc, url);
149:                        } catch (Exception auth) {
150:                            fail("authentification failed :  " + auth);
151:                        }
152:                    }
153:                }
154:            }
155:
156:            /**
157:             * Test mail service without mail factory
158:             * @throws Exception if error occurs
159:             *
160:             */
161:            public void testNoDeployedMailFactory() throws Exception {
162:
163:                WebResponse wr;
164:                WebLink link;
165:                WebTable table;
166:                WebTable tabTable;
167:                int selectedTab;
168:                /*
169:                 * To get some utils for WebTable
170:                 */
171:                JonasAdminUtils utils = new JonasAdminUtils();
172:
173:                // Disable errors of javascript
174:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
175:                // Disable exception thrown on error status
176:                HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
177:
178:                if (jProp.isMail()) {
179:
180:                    // Undeploy mail factories
181:                    undeployMailFactories(wc);
182:
183:                    // Go to mail service
184:                    wr = wc.getFrameContents(FRAME_TREE);
185:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
186:                            URL_JONASADMIN_MAIL_SERVICE);
187:                    link.click();
188:                    wr = wc.getFrameContents(FRAME_CONTENT);
189:                    selectedTab = 1;
190:
191:                    // Verify numbers
192:                    table = utils.getTable(wr, 1);
193:                    int sessionMF = Integer.parseInt(table.getTableCell(0, 2)
194:                            .getText());
195:                    int mimePartDatasourceMF = Integer.parseInt(table
196:                            .getTableCell(1, 2).getText());
197:                    int total = Integer.parseInt(table.getTableCell(2, 2)
198:                            .getText());
199:
200:                    // Session factories    0
201:                    assertEquals(
202:                            "The number of Session Factories is not '0'. ", 0,
203:                            sessionMF);
204:                    // MimePartDataSource   0
205:                    assertEquals(
206:                            "The number of MimePartDataSource is not '0'. ", 0,
207:                            mimePartDatasourceMF);
208:                    // total = sessionMF + mimePartDatasourceMF
209:                    assertEquals(
210:                            "The total is not the sum of Session factories and MimePartDataSource. ",
211:                            sessionMF + mimePartDatasourceMF, total);
212:
213:                    // Verify tabs
214:                    tabTable = utils.getTabTable(wr);
215:                    testTabs(tabTable, NUMBER_OF_TABS_FOR_MAIL, selectedTab,
216:                            "Problem in 'Mail' tab.");
217:                    // - links
218:                    assertTrue("The link " + URL_JONASADMIN_SESSION_MF
219:                            + " is not found in the second tab. ", tabTable
220:                            .getTableCell(0, 2).getLinks()[0].getURLString()
221:                            .endsWith(URL_JONASADMIN_SESSION_MF));
222:                    assertTrue("The link "
223:                            + URL_JONASADMIN_MIME_PART_DATASOURCE_MF
224:                            + " is not found in the third tab. ", tabTable
225:                            .getTableCell(0, 4).getLinks()[0].getURLString()
226:                            .endsWith(URL_JONASADMIN_MIME_PART_DATASOURCE_MF));
227:
228:                    // Go to Session factories
229:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
230:                            URL_JONASADMIN_SESSION_MF);
231:                    link.click();
232:                    wr = wc.getFrameContents(FRAME_CONTENT);
233:
234:                    // Verify tree
235:                    WebResponse tree = wc.getFrameContents(FRAME_TREE);
236:                    assertTrue(
237:                            "The node 'Session Factories' is not found in the tree. ",
238:                            tree.getText().indexOf("Session Factories") != -1);
239:
240:                    // Verify Message : "No Session mail factories !"
241:                    table = utils.getTable(wr, 0);
242:                    assertEquals(
243:                            "There is not 1 row in the 'Session Mail Factories' table. ",
244:                            1, table.getRowCount());
245:
246:                    String messageNoSessionMF = "No Session mail factories !";
247:                    assertEquals("There is not the expected message: '"
248:                            + messageNoSessionMF + "'. ", messageNoSessionMF,
249:                            table.getTableCell(0, 0).getText());
250:
251:                    // Verify tabs
252:                    tabTable = utils.getTabTable(wr);
253:                    testTabs(tabTable, NUMBER_OF_TABS_FOR_MAIL, selectedTab,
254:                            "Problem in 'Session Mail Factories' tab.");
255:                    // - links
256:                    assertTrue("The link " + URL_JONASADMIN_MAIL_SERVICE
257:                            + " is not found in the first tab. ", tabTable
258:                            .getTableCell(0, 0).getLinks()[0].getURLString()
259:                            .endsWith(URL_JONASADMIN_MAIL_SERVICE));
260:                    assertTrue("The link "
261:                            + URL_JONASADMIN_MIME_PART_DATASOURCE_MF
262:                            + " is not found in the third tab. ", tabTable
263:                            .getTableCell(0, 4).getLinks()[0].getURLString()
264:                            .endsWith(URL_JONASADMIN_MIME_PART_DATASOURCE_MF));
265:
266:                    // Go to MimePartDataSource Mail Factories
267:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
268:                            URL_JONASADMIN_MIME_PART_DATASOURCE_MF);
269:                    link.click();
270:                    wr = wc.getFrameContents(FRAME_CONTENT);
271:
272:                    // Verify Message : "No MimePartDataSource mail factories !"
273:                    table = utils.getTable(wr, 0);
274:                    assertEquals(
275:                            "There is not 1 row in the 'Session Mail Factories' table. ",
276:                            1, table.getRowCount());
277:
278:                    String messageNoMimePartMF = "No MimePartDataSource mail factories !";
279:                    assertEquals("There is not the expected message: '"
280:                            + messageNoMimePartMF + "'. ", messageNoMimePartMF,
281:                            table.getTableCell(0, 0).getText());
282:
283:                    // Verify tabs
284:                    tabTable = utils.getTabTable(wr);
285:                    testTabs(tabTable, NUMBER_OF_TABS_FOR_MAIL, selectedTab,
286:                            "Problem in 'MimePartDataSource Mail Factories' tab.");
287:                    // - links
288:                    assertTrue("The link " + URL_JONASADMIN_MAIL_SERVICE
289:                            + " is not found in the first tab. ", tabTable
290:                            .getTableCell(0, 0).getLinks()[0].getURLString()
291:                            .endsWith(URL_JONASADMIN_MAIL_SERVICE));
292:                    assertTrue("The link " + URL_JONASADMIN_SESSION_MF
293:                            + " is not found in the second tab. ", tabTable
294:                            .getTableCell(0, 2).getLinks()[0].getURLString()
295:                            .endsWith(URL_JONASADMIN_SESSION_MF));
296:
297:                }
298:
299:            }
300:
301:            /**
302:             * Test mail service with mail factories
303:             * @throws Exception if error occurs
304:             *
305:             */
306:            public void testDeployedMailFactory() throws Exception {
307:
308:                WebResponse wr;
309:                WebLink link;
310:                WebTable table;
311:                WebTable tabTable;
312:                int selectedTab;
313:                /*
314:                 * To get some utils for WebTable
315:                 */
316:                JonasAdminUtils utils = new JonasAdminUtils();
317:
318:                // Disable errors of javascript
319:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
320:                // Disable exception thrown on error status
321:                HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
322:
323:                if (jProp.isMail()) {
324:
325:                    // Deploy mail factories
326:                    deployMailFactories(wc);
327:
328:                    // Go to mail service
329:                    wr = wc.getFrameContents(FRAME_TREE);
330:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
331:                            URL_JONASADMIN_MAIL_SERVICE);
332:                    link.click();
333:                    wr = wc.getFrameContents(FRAME_CONTENT);
334:                    selectedTab = 1;
335:
336:                    // Verify numbers
337:                    table = utils.getTable(wr, 1);
338:                    int sessionMF = Integer.parseInt(table.getTableCell(0, 2)
339:                            .getText());
340:                    int mimePartDatasourceMF = Integer.parseInt(table
341:                            .getTableCell(1, 2).getText());
342:                    int total = Integer.parseInt(table.getTableCell(2, 2)
343:                            .getText());
344:
345:                    // Session factories    > 0
346:                    assertTrue(
347:                            "The number of Session Factories is not positif. ",
348:                            sessionMF > 0);
349:                    // MimePartDataSource   > 0
350:                    assertTrue(
351:                            "The number of MimePartDataSource is not positif. ",
352:                            mimePartDatasourceMF > 0);
353:                    // total = sessionMF + mimePartDatasourceMF
354:                    assertEquals(
355:                            "The total is not the sum of Session factories and MimePartDataSource. ",
356:                            sessionMF + mimePartDatasourceMF, total);
357:
358:                    // Verify tabs
359:                    tabTable = utils.getTabTable(wr);
360:                    testTabs(tabTable, NUMBER_OF_TABS_FOR_MAIL, selectedTab,
361:                            "Problem in 'Mail' tab.");
362:                    // - links
363:                    assertTrue("The link " + URL_JONASADMIN_SESSION_MF
364:                            + " is not found in the second tab. ", tabTable
365:                            .getTableCell(0, 2).getLinks()[0].getURLString()
366:                            .endsWith(URL_JONASADMIN_SESSION_MF));
367:                    assertTrue("The link "
368:                            + URL_JONASADMIN_MIME_PART_DATASOURCE_MF
369:                            + " is not found in the third tab. ", tabTable
370:                            .getTableCell(0, 4).getLinks()[0].getURLString()
371:                            .endsWith(URL_JONASADMIN_MIME_PART_DATASOURCE_MF));
372:
373:                    // Go to Session factories
374:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
375:                            URL_JONASADMIN_SESSION_MF);
376:                    link.click();
377:                    wr = wc.getFrameContents(FRAME_CONTENT);
378:
379:                    // Verify tree
380:                    WebResponse tree = wc.getFrameContents(FRAME_TREE);
381:                    assertTrue(
382:                            "The node 'Session Factories' is not found in the tree. ",
383:                            tree.getText().indexOf("Session Factories") != -1);
384:
385:                    // Verify Session mail factories table
386:                    table = utils.getTable(wr, 0);
387:                    assertTrue(
388:                            "There are not more than 1 row in the 'Session Mail Factories' table. ",
389:                            1 < table.getRowCount());
390:                    int rowMailSession = utils.getFirstRow("mailSession_1",
391:                            table, 0).intValue();
392:                    if (rowMailSession == -1) {
393:                        throw new IllegalStateException(
394:                                "'mailSession_1' is not found in the table. ");
395:                    }
396:                    // JNDI name    mailSession_1
397:                    assertEquals(
398:                            "It is not the JNDI name of 'mailSession_1'. ",
399:                            "mailSession_1", table.getTableCell(rowMailSession,
400:                                    1).getText());
401:
402:                    // Verify tabs
403:                    tabTable = utils.getTabTable(wr);
404:                    testTabs(tabTable, NUMBER_OF_TABS_FOR_MAIL, selectedTab,
405:                            "Problem in 'Session Mail Factories' tab.");
406:                    // - links
407:                    assertTrue("The link " + URL_JONASADMIN_MAIL_SERVICE
408:                            + " is not found in the first tab. ", tabTable
409:                            .getTableCell(0, 0).getLinks()[0].getURLString()
410:                            .endsWith(URL_JONASADMIN_MAIL_SERVICE));
411:                    assertTrue("The link "
412:                            + URL_JONASADMIN_MIME_PART_DATASOURCE_MF
413:                            + " is not found in the third tab. ", tabTable
414:                            .getTableCell(0, 4).getLinks()[0].getURLString()
415:                            .endsWith(URL_JONASADMIN_MIME_PART_DATASOURCE_MF));
416:
417:                    // Go to url of the link
418:                    link = table.getTableCell(rowMailSession, 0).getLinks()[0];
419:                    link.click();
420:                    wr = wc.getFrameContents(FRAME_CONTENT);
421:
422:                    // Verify tree
423:                    tree = wc.getFrameContents(FRAME_TREE);
424:                    assertTrue(
425:                            "The node 'mailSession_1' is not found in the tree.",
426:                            tree.getText().indexOf("mailSession_1") != -1);
427:
428:                    // Verify number of tables
429:                    try {
430:                        table = utils.getTable(wr, 9);
431:                    } catch (Exception e) {
432:                        fail("There are not enough tables in 'mailSession_1' page.");
433:                    }
434:                    try {
435:                        table = utils.getTable(wr, 10);
436:                        fail("There are not too tables in 'mailSession_1' page.");
437:                    } catch (Exception e) {
438:                        // ok
439:                    }
440:
441:                    // Type     Session
442:                    table = utils.getTable(wr, 1);
443:                    assertEquals(
444:                            "It is not the expected type of 'mailSession_1'. ",
445:                            "Session", table.getTableCell(0, 2).getText());
446:
447:                    // Verify tabs
448:                    tabTable = utils.getTabTable(wr);
449:                    testTabs(tabTable, NUMBER_OF_TABS_FOR_SESSION, selectedTab,
450:                            "Problem in 'mailSession_1' tab.");
451:                    // - links
452:                    assertTrue("The link " + URL_JONASADMIN_MAIL_SERVICE
453:                            + " is not found in the first tab. ", tabTable
454:                            .getTableCell(0, 0).getLinks()[0].getURLString()
455:                            .endsWith(URL_JONASADMIN_MAIL_SERVICE));
456:                    assertTrue("The link " + URL_JONASADMIN_SESSION_MF
457:                            + " is not found in the second tab. ", tabTable
458:                            .getTableCell(0, 2).getLinks()[0].getURLString()
459:                            .endsWith(URL_JONASADMIN_SESSION_MF));
460:                    assertTrue("The link "
461:                            + URL_JONASADMIN_MIME_PART_DATASOURCE_MF
462:                            + " is not found in the fourth tab. ", tabTable
463:                            .getTableCell(0, 6).getLinks()[0].getURLString()
464:                            .endsWith(URL_JONASADMIN_MIME_PART_DATASOURCE_MF));
465:
466:                    // Go to MimePartDataSource Mail Factories
467:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
468:                            URL_JONASADMIN_MIME_PART_DATASOURCE_MF);
469:                    link.click();
470:                    wr = wc.getFrameContents(FRAME_CONTENT);
471:
472:                    // Verify MimePartDatasource mail factories table
473:                    table = utils.getTable(wr, 0);
474:                    assertTrue(
475:                            "There are not more than 1 row in the 'MimePartDatasource Mail Factories' table. ",
476:                            1 < table.getRowCount());
477:                    int rowMailMime = utils.getFirstRow("mailMimePartDS_1",
478:                            table, 0).intValue();
479:                    if (rowMailMime == -1) {
480:                        throw new IllegalStateException(
481:                                "'mailMimePartDS_1' is not found in the table. ");
482:                    }
483:                    // JNDI name    mailMimePartDS_1
484:                    assertEquals(
485:                            "It is not the JNDI name of 'mailMimePartDS_1'. ",
486:                            "mailMimePartDS_1", table.getTableCell(rowMailMime,
487:                                    1).getText());
488:
489:                    // Verify tabs
490:                    tabTable = utils.getTabTable(wr);
491:                    testTabs(tabTable, NUMBER_OF_TABS_FOR_MAIL, selectedTab,
492:                            "Problem in 'MimePartDataSource Mail Factories' tab.");
493:                    // - links
494:                    assertTrue("The link " + URL_JONASADMIN_MAIL_SERVICE
495:                            + " is not found in the first tab. ", tabTable
496:                            .getTableCell(0, 0).getLinks()[0].getURLString()
497:                            .endsWith(URL_JONASADMIN_MAIL_SERVICE));
498:                    assertTrue("The link " + URL_JONASADMIN_SESSION_MF
499:                            + " is not found in the second tab. ", tabTable
500:                            .getTableCell(0, 2).getLinks()[0].getURLString()
501:                            .endsWith(URL_JONASADMIN_SESSION_MF));
502:
503:                    // Go to url of the link
504:                    link = table.getTableCell(rowMailMime, 0).getLinks()[0];
505:                    link.click();
506:                    wr = wc.getFrameContents(FRAME_CONTENT);
507:
508:                    // Verify tree
509:                    tree = wc.getFrameContents(FRAME_TREE);
510:                    assertTrue(
511:                            "The node 'mailMimePartDS_1' is not found in the tree.",
512:                            tree.getText().indexOf("mailMimePartDS_1") != -1);
513:
514:                    // Verify number of tables
515:                    try {
516:                        table = utils.getTable(wr, 12);
517:                    } catch (Exception e) {
518:                        fail("There are not enough tables in 'mailMimePartDS_1' page.");
519:                    }
520:                    try {
521:                        table = utils.getTable(wr, 13);
522:                        fail("There are not too tables in 'mailMimePartDS_1' page.");
523:                    } catch (Exception e) {
524:                        // ok
525:                    }
526:
527:                    // Type     MimePartDataSource
528:                    table = utils.getTable(wr, 1);
529:                    assertEquals(
530:                            "It is not the expected type of 'mailMimePartDS_1'. ",
531:                            "MimePartDataSource", table.getTableCell(0, 2)
532:                                    .getText());
533:
534:                    // Verify tabs
535:                    tabTable = utils.getTabTable(wr);
536:                    testTabs(tabTable, NUMBER_OF_TABS_FOR_MIME_PART_DS,
537:                            selectedTab, "Problem in 'mailMimePartDS_1' tab.");
538:                    // - links
539:                    assertTrue("The link " + URL_JONASADMIN_MAIL_SERVICE
540:                            + " is not found in the first tab. ", tabTable
541:                            .getTableCell(0, 0).getLinks()[0].getURLString()
542:                            .endsWith(URL_JONASADMIN_MAIL_SERVICE));
543:                    assertTrue("The link " + URL_JONASADMIN_SESSION_MF
544:                            + " is not found in the second tab. ", tabTable
545:                            .getTableCell(0, 2).getLinks()[0].getURLString()
546:                            .endsWith(URL_JONASADMIN_SESSION_MF));
547:                    assertTrue("The link "
548:                            + URL_JONASADMIN_MIME_PART_DATASOURCE_MF
549:                            + " is not found in the fourth tab. ", tabTable
550:                            .getTableCell(0, 4).getLinks()[0].getURLString()
551:                            .endsWith(URL_JONASADMIN_MIME_PART_DATASOURCE_MF));
552:
553:                }
554:
555:            }
556:
557:            /**
558:             * Undeploy all mail factories
559:             * @param wc The jonasAdmin connexion
560:             * @throws Exception if an error occurs
561:             */
562:            private void undeployMailFactories(WebConversation wc)
563:                    throws Exception {
564:                WebLink link = null;
565:
566:                // Go to Mail
567:                WebResponse wr = wc.getFrameContents(FRAME_TREE);
568:                link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
569:                        URL_JONASADMIN_MAIL);
570:                if (link != null) {
571:                    link.click();
572:                    wr = wc.getFrameContents(FRAME_CONTENT);
573:                } else {
574:                    // branch is not opened
575:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
576:                            URL_JONASADMIN_VIEW_MAIL);
577:                    if (link != null) {
578:                        link.click();
579:                        wr = wc.getFrameContents(FRAME_TREE);
580:                        link = wr.getFirstMatchingLink(
581:                                WebLink.MATCH_URL_STRING, URL_JONASADMIN_MAIL);
582:                        if (link == null) {
583:                            throw new IllegalStateException("The link "
584:                                    + URL_JONASADMIN_MAIL
585:                                    + " is not found in tree. ");
586:                        }
587:                        link.click();
588:                        wr = wc.getFrameContents(FRAME_CONTENT);
589:                    } else {
590:                        throw new IllegalStateException("The link "
591:                                + URL_JONASADMIN_MAIL
592:                                + " is not found in tree. ");
593:                    }
594:                }
595:
596:                // Undeploy all Mail Factories
597:                WebForm[] webForms = wr.getForms();
598:                WebForm webForm = webForms[0];
599:
600:                String params = webForm.getParameterValue("deploy");
601:                WebForm.Scriptable script = webForm.getScriptableObject();
602:
603:                // Disable errors of javascript
604:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
605:
606:                script.setParameterValue("undeploy", params);
607:
608:                WebResponse submitUndeploy = webForm.submit();
609:
610:                webForms = submitUndeploy.getForms();
611:                webForm = webForms[0];
612:
613:                WebResponse endResp = webForm.submit();
614:            }
615:
616:            /**
617:             * Deploy all mail factories
618:             * @param wc The jonasAdmin connexion
619:             * @throws Exception if an error occurs
620:             */
621:            private void deployMailFactories(WebConversation wc)
622:                    throws Exception {
623:                WebLink link = null;
624:
625:                // Go to Mail
626:                WebResponse wr = wc.getFrameContents(FRAME_TREE);
627:                link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
628:                        URL_JONASADMIN_MAIL);
629:                if (link != null) {
630:                    link.click();
631:                    wr = wc.getFrameContents(FRAME_CONTENT);
632:                } else {
633:                    // branch is not opened
634:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
635:                            URL_JONASADMIN_VIEW_MAIL);
636:                    if (link != null) {
637:                        link.click();
638:                        wr = wc.getFrameContents(FRAME_TREE);
639:                        link = wr.getFirstMatchingLink(
640:                                WebLink.MATCH_URL_STRING, URL_JONASADMIN_MAIL);
641:                        if (link == null) {
642:                            throw new IllegalStateException("The link "
643:                                    + URL_JONASADMIN_MAIL
644:                                    + " is not found in tree. ");
645:                        }
646:                        link.click();
647:                        wr = wc.getFrameContents(FRAME_CONTENT);
648:                    } else {
649:                        throw new IllegalStateException("The link "
650:                                + URL_JONASADMIN_MAIL
651:                                + " is not found in tree. ");
652:                    }
653:                }
654:
655:                // Undeploy all Mail Factories
656:                WebForm[] webForms = wr.getForms();
657:                WebForm webForm = webForms[0];
658:
659:                String params = webForm.getParameterValue("undeploy");
660:                WebForm.Scriptable script = webForm.getScriptableObject();
661:
662:                // Disable errors of javascript
663:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
664:
665:                script.setParameterValue("deploy", params);
666:
667:                WebResponse submitUndeploy = webForm.submit();
668:
669:                webForms = submitUndeploy.getForms();
670:                webForm = webForms[0];
671:
672:                WebResponse endResp = webForm.submit();
673:            }
674:
675:            /**
676:             * Tear Down cleanUp action
677:             * @throws Exception if an error occurs
678:             */
679:            public void tearDown() throws Exception {
680:                super.tearDown();
681:            }
682:
683:        }
w___w__w_._j___a___v__a___2_s__._c__o___m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.