Source Code Cross Referenced for F_JonasAdminConnector.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » jonasadmin » test » catalina » 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.catalina 
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_JonasAdminConnector.java 7384 2005-09-15 07:44:03Z kemlerp $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas.jonasadmin.test.catalina;
025:
026:        import java.util.Iterator;
027:
028:        import javax.management.MBeanServerConnection;
029:        import javax.management.ObjectName;
030:
031:        import junit.framework.TestSuite;
032:
033:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminAuth;
034:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminTestCase;
035:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminUtils;
036:        import org.xml.sax.SAXException;
037:
038:        import com.meterware.httpunit.HTMLElement;
039:        import com.meterware.httpunit.HttpUnitOptions;
040:        import com.meterware.httpunit.TableCell;
041:        import com.meterware.httpunit.WebConversation;
042:        import com.meterware.httpunit.WebForm;
043:        import com.meterware.httpunit.WebLink;
044:        import com.meterware.httpunit.WebResponse;
045:        import com.meterware.httpunit.WebTable;
046:
047:        /**
048:         * Define a class to test the JOnAS Admin console Test connectors
049:         * @author Paul Kemler
050:         */
051:        public class F_JonasAdminConnector extends JonasAdminTestCase {
052:
053:            /**
054:             * URL of Jonas Logger
055:             */
056:            private static final String URL_JONASADMIN_JONAS_LOGGER = "/EditLoggingJonas.do";
057:
058:            /**
059:             * URL to modify a connector
060:             */
061:            private static final String URL_JONASADMIN_MODIFY_CONNECTOR = "EditCatalinaConnector.do?select=jonas%3Atype%3DConnector%2Cport%3D";
062:
063:            /**
064:             * URL of connectors
065:             */
066:            private static final String URL_JONASADMIN_CONNECTORS = "ListCatalinaConnectors.do";
067:
068:            /**
069:             * INPUT Checkbox
070:             */
071:            private static final String INPUT_CHECKBOX = "input type=\"checkbox\"";
072:
073:            /**
074:             * Title port
075:             */
076:            private static final String TITLE_PORT = "Port";
077:
078:            /**
079:             * Title address
080:             */
081:            private static final String TITLE_ADDRESS = "Address";
082:
083:            /**
084:             * Title type
085:             */
086:            private static final String TITLE_TYPE = "Type";
087:
088:            /**
089:             * Button 'Save'
090:             */
091:            private static final String BUTTON_SAVE = "/EditServletServer.do?forward=ActionListCatalinaConnectors";
092:
093:            /**
094:             * SUCCESS CODE
095:             */
096:            private static final int HTTP_SUCCESS_CODE = 200;
097:
098:            /**
099:             * A 2nd connection to jonasAdmin
100:             */
101:            private static WebConversation wc2 = new WebConversation();
102:
103:            /**
104:             * Port of the http connector
105:             */
106:            String portHttp;
107:
108:            /**
109:             * Port of the https connector
110:             */
111:            String portHttps;
112:
113:            /**
114:             * Port of the ajp connector
115:             */
116:            String portAjp;
117:
118:            /**
119:             * Accept Count
120:             */
121:            private static final String acceptCount = "128";
122:            /**
123:             * Allow Trace
124:             */
125:            private static final String allowTrace = "true";
126:            /**
127:             * Empty Session Path
128:             */
129:            private static final String emptySessionPath = "true";
130:            /**
131:             * Enable DNS Lookups
132:             */
133:            private static final String enableLookups = "true";
134:            /**
135:             * Max Bytes in a Post
136:             */
137:            private static final String maxPostSize = "1048576";
138:            /**
139:             * Connection Timeout
140:             */
141:            private static final String connTimeOut = "10000";
142:            /**
143:             * URI Encoding
144:             */
145:            private static final String URIEncoding = "";
146:            /**
147:             * Use Body Encoding for URI
148:             */
149:            private static final String useBodyEncodingForURI = "true";
150:            /**
151:             * X-Powered-By Generation Enabled
152:             */
153:            private static final String xpoweredBy = "true";
154:            /**
155:             * Should we use TCP no delay
156:             */
157:            private static final String tcpNoDelay = "false";
158:            /**
159:             * Default Buffer Size
160:             */
161:            private static final String bufferSize = "2048";
162:            /**
163:             * IP Address
164:             */
165:            private static final String address = "";
166:            /**
167:             * Redirect Port Number
168:             */
169:            private static final String redirectPort = "9043";
170:            /**
171:             * Maximum Threads
172:             */
173:            private static final String maxThreads = "50";
174:            /**
175:             * Minimum Spare Threads
176:             */
177:            private static final String minSpareThreads = "10";
178:            /**
179:             * Maximum Spare Threads
180:             */
181:            private static final String maxSpareThreads = "25";
182:            /**
183:             * Proxy Name
184:             */
185:            private static final String proxyName = "";
186:            /**
187:             * Proxy Port Number
188:             */
189:            private static final String proxyPort = "0";
190:
191:            /**
192:             * Constructor with a specified name
193:             * @param s name
194:             */
195:            public F_JonasAdminConnector(String s) {
196:                super (s, URL_JONASADMIN);
197:            }
198:
199:            /**
200:             * Main method
201:             * @param args the arguments
202:             */
203:            public static void main(String[] args) {
204:
205:                String testtorun = null;
206:                // Get args
207:                for (int argn = 0; argn < args.length; argn++) {
208:                    String sArg = args[argn];
209:                    if (sArg.equals("-n")) {
210:                        testtorun = args[++argn];
211:                    }
212:                }
213:                if (testtorun == null) {
214:                    junit.textui.TestRunner.run(suite());
215:                } else {
216:                    junit.textui.TestRunner.run(new F_JonasAdminConnector(
217:                            testtorun));
218:                }
219:            }
220:
221:            /**
222:             * Get a new TestSuite for this class
223:             * @return a new TestSuite for this class
224:             */
225:            public static TestSuite suite() {
226:                return new TestSuite(F_JonasAdminConnector.class);
227:            }
228:
229:            /**
230:             * Setup need for these tests jonasAdmin is required
231:             * @throws Exception if it fails
232:             */
233:            protected void setUp() throws Exception {
234:                super .setUp();
235:
236:                if (wc.getCurrentPage().getURL() == null) {
237:                    useWar("jonasAdmin");
238:                    // login to jonas admin
239:                    try {
240:                        JonasAdminAuth.doValidAuth(wc, url);
241:                    } catch (Exception e) {
242:                        fail("authentification failed :  " + e);
243:                    }
244:                } else {
245:                    // if there was an error, the connection must be restablished
246:                    try {
247:                        wc.getFrameContents(FRAME_TREE);
248:                    } catch (Exception e) {
249:                        wc.getResponse(urlLogOut);
250:                        // login to jonas admin
251:                        try {
252:                            JonasAdminAuth.doValidAuth(wc, url);
253:                        } catch (Exception auth) {
254:                            fail("authentification failed :  " + auth);
255:                        }
256:                    }
257:                }
258:                undeployAllEar();
259:                undeployAllJar();
260:
261:                useEar("autoload/mejb");
262:            }
263:
264:            /**
265:             * Test connectors
266:             * @throws Exception if error occurs
267:             */
268:            public void testConnectors() throws Exception {
269:
270:                WebResponse wr;
271:                WebLink link;
272:                WebTable table;
273:                WebForm form;
274:
275:                int row;
276:                int portColumn;
277:                int addressColumn;
278:                int typeColumn;
279:                int rowHttp;
280:                int rowHttps;
281:                int rowAjp;
282:                String testUrl;
283:                JonasAdminUtils utils = new JonasAdminUtils();
284:
285:                // Disable errors of javascript
286:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
287:                // Disable exception thrown on error status
288:                HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
289:
290:                // OPEN A SECOND CONNECTION
291:                // login to jonas admin
292:                try {
293:                    JonasAdminAuth.doValidAuth(wc2, url);
294:                } catch (Exception e) {
295:                    fail("authentification failed :  " + e);
296:                }
297:
298:                if (jProp.isCatalina()) {
299:                    wr = ConnectorUtils.getConnectorPage(wc);
300:                    table = utils.getTable(wr, 3);
301:                    portColumn = utils.getColumn(TITLE_PORT, table).intValue();
302:                    if (portColumn == -1) {
303:                        throw new IllegalThreadStateException(
304:                                "There is no column, which contains '"
305:                                        + TITLE_PORT + "'. ");
306:                    }
307:                    addressColumn = utils.getColumn(TITLE_ADDRESS, table)
308:                            .intValue();
309:                    if (portColumn == -1) {
310:                        throw new IllegalThreadStateException(
311:                                "There is no column, which contains '"
312:                                        + TITLE_ADDRESS + "'. ");
313:                    }
314:                    typeColumn = utils.getColumn(TITLE_TYPE, table).intValue();
315:                    if (portColumn == -1) {
316:                        throw new IllegalThreadStateException(
317:                                "There is no column, which contains '"
318:                                        + TITLE_TYPE + "'. ");
319:                    }
320:
321:                    // Verify 'remove' button
322:                    if (table.getRowCount() == 2) {
323:                        assertFalse("There is a checkbox. ", wr.getText()
324:                                .indexOf(INPUT_CHECKBOX) != -1);
325:
326:                        // Choose remove action
327:                        link = wr.getFirstMatchingLink(
328:                                WebLink.MATCH_URL_STRING, "remove");
329:                        link.click();
330:                        wr = wc.getFrameContents(FRAME_CONTENT);
331:                        // ERROR: "No connector found !"
332:                        assertTrue("There is no error message. ", wr.getText()
333:                                .indexOf("<tr class=\"errors\">") != -1);
334:                        link = wr.getFirstMatchingLink(
335:                                WebLink.MATCH_URL_STRING,
336:                                URL_JONASADMIN_CONNECTORS);
337:                        link.click();
338:                        wr = wc.getFrameContents(FRAME_CONTENT);
339:                    } else {
340:                        assertTrue(
341:                                "There is no remove button but there is no one and only one connector. ",
342:                                wr.getText().indexOf("'remove'") != -1);
343:                        assertTrue(
344:                                "There is no checkbox but there is no one and only one connector. ",
345:                                wr.getText().indexOf(INPUT_CHECKBOX) != -1);
346:                    }
347:
348:                    // Open connectors branch in the tree to verify if a connector is
349:                    // well added.
350:                    wr = wc.getFrameContents(FRAME_TREE);
351:                    table = wr.getTables()[0];
352:                    int rowConnectors = utils.getFirstRow("Connectors", table,
353:                            6).intValue();
354:                    if (rowConnectors == -1) {
355:                        throw new IllegalThreadStateException(
356:                                "Connectors was not found in the tree. ");
357:                    }
358:                    TableCell cell = table.getTableCell(rowConnectors, 4);
359:                    HTMLElement[] elements = cell.getElementsWithAttribute(
360:                            "src", "images/tree/node_close_last.gif");
361:                    if (elements.length == 1) {
362:                        if (elements[0].getAttribute("src").indexOf(
363:                                "node_close") != -1) {
364:                            link = cell.getLinks()[0];
365:                            link.click();
366:                        }
367:                    }
368:
369:                    // 1-Create new connectors
370:                    portHttp = ConnectorUtils.createNewConnector(wc, "http");
371:                    // Verify
372:                    wr = wc.getFrameContents(FRAME_TREE);
373:                    assertTrue("The port " + portHttp
374:                            + " is not found in the tree. ", wr.getText()
375:                            .indexOf(portHttp) != -1);
376:                    wr = wc.getFrameContents(FRAME_CONTENT);
377:                    assertTrue("It is not the connectors.jsp page. ", wr
378:                            .getText().indexOf("catalina/connectors.jsp") != -1);
379:
380:                    wr = ConnectorUtils.getConnectorPage(wc);
381:                    table = utils.getTable(wr, 3);
382:                    form = wr.getForms()[0];
383:                    row = utils.getFirstRow(port, table, portColumn).intValue();
384:                    if (row == -1) {
385:                        throw new IllegalThreadStateException(
386:                                "There is no row, which contains '" + port
387:                                        + "' in the 'Port' column. ");
388:                    }
389:                    rowHttp = utils.getFirstRow(portHttp, table, portColumn)
390:                            .intValue();
391:                    if (rowHttp == -1) {
392:                        throw new IllegalThreadStateException(
393:                                "There is no row, which contains '" + portHttp
394:                                        + "' in the 'Port' column. ");
395:                    }
396:                    assertEquals(
397:                            "There is no the correct number of connectors. ",
398:                            3, table.getRowCount());
399:                    assertTrue("There is no remove button. ", wr.getText()
400:                            .indexOf("'remove'") != -1);
401:                    assertEquals(
402:                            "There is no the correct number of parameters in the form. ",
403:                            2, form.getParameterNames().length);
404:                    assertTrue("There is a checkbox for " + port + "port. ",
405:                            table.getTableCell(row, 0).getElementsWithName(
406:                                    "selectedItems").length == 0);
407:                    assertEquals("There is no checkbox for " + portHttp
408:                            + "port. ", 1, table.getTableCell(rowHttp, 0)
409:                            .getElementsWithName("selectedItems").length);
410:                    assertEquals("The connector address is not null. ", "",
411:                            table.getTableCell(rowHttp, addressColumn)
412:                                    .getText());
413:                    assertEquals("The connector type is not 'HTTP'. ", "HTTP",
414:                            table.getTableCell(rowHttp, typeColumn).getText());
415:                    testUrl = "http://localhost:" + portHttp + "/jonasAdmin/";
416:                    wr = wc2.getResponse(testUrl);
417:                    assertEquals(
418:                            "A code of 200 (success) should be returned. ",
419:                            HTTP_SUCCESS_CODE, wr.getResponseCode());
420:
421:                    portHttps = ConnectorUtils.createNewConnector(wc, "https");
422:                    // Verify
423:                    wr = ConnectorUtils.getConnectorPage(wc);
424:                    table = utils.getTable(wr, 3);
425:                    form = wr.getForms()[0];
426:                    row = utils.getFirstRow(port, table, portColumn).intValue();
427:                    if (row == -1) {
428:                        throw new IllegalThreadStateException(
429:                                "There is no row, which contains '" + port
430:                                        + "' in the 'Port' column. ");
431:                    }
432:                    rowHttps = utils.getFirstRow(portHttps, table, portColumn)
433:                            .intValue();
434:                    if (rowHttps == -1) {
435:                        throw new IllegalThreadStateException(
436:                                "There is no row, which contains '" + portHttps
437:                                        + "' in the 'Port' column. ");
438:                    }
439:                    assertEquals(
440:                            "There is no the correct number of connectors. ",
441:                            4, table.getRowCount());
442:                    assertTrue("There is no remove button. ", wr.getText()
443:                            .indexOf("'remove'") != -1);
444:                    assertEquals(
445:                            "There is no the correct number of parameters in the form. ",
446:                            2, form.getParameterNames().length);
447:                    assertEquals("There is no checkbox for " + portHttps
448:                            + "port. ", 1, table.getTableCell(rowHttps, 0)
449:                            .getElementsWithName("selectedItems").length);
450:                    assertEquals("The connector address is not null. ", "",
451:                            table.getTableCell(rowHttps, addressColumn)
452:                                    .getText());
453:                    assertEquals("The connector type is not 'HTTPS'. ",
454:                            "HTTPS", table.getTableCell(rowHttps, typeColumn)
455:                                    .getText());
456:
457:                    portAjp = ConnectorUtils.createNewConnector(wc, "ajp");
458:                    // Verify
459:                    wr = ConnectorUtils.getConnectorPage(wc);
460:                    table = utils.getTable(wr, 3);
461:                    form = wr.getForms()[0];
462:                    row = utils.getFirstRow(port, table, portColumn).intValue();
463:                    if (row == -1) {
464:                        throw new IllegalThreadStateException(
465:                                "There is no row, which contains '" + port
466:                                        + "' in the 'Port' column. ");
467:                    }
468:                    rowAjp = utils.getFirstRow(portAjp, table, portColumn)
469:                            .intValue();
470:                    if (rowAjp == -1) {
471:                        throw new IllegalThreadStateException(
472:                                "There is no row, which contains '" + portAjp
473:                                        + "' in the 'Port' column. ");
474:                    }
475:                    assertEquals(
476:                            "There is no the correct number of connectors. ",
477:                            5, table.getRowCount());
478:                    assertTrue("There is no remove button. ", wr.getText()
479:                            .indexOf("'remove'") != -1);
480:                    assertEquals(
481:                            "There is no the correct number of parameters in the form. ",
482:                            2, form.getParameterNames().length);
483:                    assertEquals("There is no checkbox for " + portAjp
484:                            + "port. ", 1, table.getTableCell(rowAjp, 0)
485:                            .getElementsWithName("selectedItems").length);
486:                    assertEquals("The connector address is not null. ", "",
487:                            table.getTableCell(rowAjp, addressColumn).getText());
488:                    assertEquals("The connector type is not 'AJP'. ", "AJP",
489:                            table.getTableCell(rowAjp, typeColumn).getText());
490:
491:                    // 2-Modify connectors
492:                    // Get form
493:                    wr = ConnectorUtils.getConnectorPage(wc);
494:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
495:                            URL_JONASADMIN_MODIFY_CONNECTOR + portHttp);
496:                    if (link != null) {
497:                        link.click();
498:                    } else {
499:                        throw new IllegalThreadStateException("The link "
500:                                + URL_JONASADMIN_MODIFY_CONNECTOR + portHttp
501:                                + " is not found. ");
502:                    }
503:                    wr = wc.getFrameContents(FRAME_CONTENT);
504:
505:                    table = utils.getTable(wr, 1);
506:                    // Verify
507:                    assertTrue("The value of 'Type' row is not 'HTTP'", table
508:                            .getTableCell(0, 2).getText().indexOf("HTTP") != -1);
509:                    assertTrue("The value of 'Scheme' row is not 'http'", table
510:                            .getTableCell(1, 2).getText().indexOf("http") != -1);
511:                    assertTrue(
512:                            "The value of 'Coyote Protocol Handler' row is not 'HTTP/1.1'",
513:                            table.getTableCell(2, 2).getText().indexOf(
514:                                    "HTTP/1.1") != -1);
515:                    assertTrue(
516:                            "The value of 'Secure (SSL) Connector' row is not 'false'",
517:                            table.getTableCell(3, 2).getText().indexOf("false") != -1);
518:
519:                    table = utils.getTable(wr, 4);
520:                    // Verify
521:                    assertTrue("The value of 'Port Number' row is not '"
522:                            + portHttp + "'", table.getTableCell(0, 2)
523:                            .getText().indexOf(portHttp) != -1);
524:
525:                    table = utils.getTable(wr, 10);
526:
527:                    form = wr.getForms()[0];
528:                    ConnectorUtils.modifyHttpConnector(form, acceptCount,
529:                            maxPostSize, connTimeOut, URIEncoding, bufferSize,
530:                            address, redirectPort, maxThreads, minSpareThreads,
531:                            maxSpareThreads, proxyName, proxyPort, allowTrace,
532:                            emptySessionPath, enableLookups,
533:                            useBodyEncodingForURI, xpoweredBy, tcpNoDelay);
534:
535:                    // Verify
536:                    // Add Go back to the Editor page
537:                    // -------------------------------
538:                    wr = ConnectorUtils.getConnectorPage(wc);
539:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
540:                            URL_JONASADMIN_MODIFY_CONNECTOR + portHttp);
541:                    if (link != null) {
542:                        link.click();
543:                    } else {
544:                        throw new IllegalThreadStateException("The link "
545:                                + URL_JONASADMIN_MODIFY_CONNECTOR + portHttp
546:                                + " is not found. ");
547:                    }
548:                    wr = wc.getFrameContents(FRAME_CONTENT);
549:                    verifyConnector(wr, acceptCount, maxPostSize, connTimeOut,
550:                            URIEncoding, bufferSize, address, redirectPort,
551:                            maxThreads, minSpareThreads, maxSpareThreads,
552:                            proxyName, proxyPort, allowTrace, emptySessionPath,
553:                            enableLookups, useBodyEncodingForURI, xpoweredBy,
554:                            tcpNoDelay);
555:
556:                    // 3-Remove connectors
557:                    String[] tabPort = { portHttp, portHttps, portAjp };
558:                    ConnectorUtils.deleteConnectors(wc, tabPort);
559:                    // Verify
560:                    wr = ConnectorUtils.getConnectorPage(wc);
561:                    table = utils.getTable(wr, 3);
562:                    assertEquals("The number of connectors is not 1. ", 2,
563:                            table.getRowCount());
564:
565:                    // 4-Button 'Save'
566:                    wr = wc.getFrameContents(FRAME_CONTENT);
567:                    link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
568:                            BUTTON_SAVE);
569:                    if (link == null) {
570:                        throw new IllegalStateException(
571:                                "No link found for button : '" + BUTTON_SAVE
572:                                        + "'.");
573:                    }
574:                    wr = link.click();
575:                    assertTrue("It is not the servletServer.jsp page. ",
576:                            wr.getText().indexOf(
577:                                    "jonasserver/servletServer.jsp") != -1);
578:                }
579:            }
580:
581:            /**
582:             * Verify value of parameters in connector form
583:             * @param wr the content frame
584:             * @param acceptCountText value of the acceptCountText param
585:             * @param maxPostSizeText value of the maxPostSizeText param
586:             * @param connTimeOutText value of the connTimeOutText param
587:             * @param URIEncoding value of the URIEncoding param
588:             * @param bufferSizeText value of the bufferSizeText param
589:             * @param address value of the address param
590:             * @param redirectPortText value of the redirectPortText param
591:             * @param maxThreadsText value of the maxThreadsText param
592:             * @param minSpareThreadsText value of the minSpareThreadsText param
593:             * @param maxSpareThreadsText value of the maxSpareThreadsText param
594:             * @param proxyName value of the proxyName param
595:             * @param proxyPortText value of the proxyPortText param
596:             * @param allowTrace value of the allowTrace param
597:             * @param emptySessionPath value of the emptySessionPath param
598:             * @param enableLookups value of the enableLookups param
599:             * @param useBodyEncodingForURI value of the useBodyEncodingForURI param
600:             * @param xpoweredBy value of the xpoweredBy param
601:             * @param tcpNoDelay value of the tcpNoDelay param
602:             * @throws SAXException if there is not a form.
603:             */
604:            private void verifyConnector(WebResponse wr,
605:                    String acceptCountText, String maxPostSizeText,
606:                    String connTimeOutText, String URIEncoding,
607:                    String bufferSizeText, String address,
608:                    String redirectPortText, String maxThreadsText,
609:                    String minSpareThreadsText, String maxSpareThreadsText,
610:                    String proxyName, String proxyPortText, String allowTrace,
611:                    String emptySessionPath, String enableLookups,
612:                    String useBodyEncodingForURI, String xpoweredBy,
613:                    String tcpNoDelay) throws SAXException {
614:                WebForm form = wr.getForms()[0];
615:                assertEquals("Accept count value is not " + acceptCountText
616:                        + ". ", acceptCountText, form
617:                        .getParameterValue("acceptCountText"));
618:                assertEquals("Max Bytes in a Post value is not "
619:                        + maxPostSizeText + ". ", maxPostSizeText, form
620:                        .getParameterValue("maxPostSizeText"));
621:                assertEquals("Connection Timeout value is not "
622:                        + connTimeOutText + ". ", connTimeOutText, form
623:                        .getParameterValue("connTimeOutText"));
624:                assertEquals("URI Encoding value is not " + URIEncoding + ". ",
625:                        URIEncoding, form.getParameterValue("URIEncoding"));
626:                assertEquals("Default Buffer Size value is not "
627:                        + bufferSizeText + ". ", bufferSizeText, form
628:                        .getParameterValue("bufferSizeText"));
629:                assertEquals("IP Address value is not " + address + ". ",
630:                        address, form.getParameterValue("address"));
631:                assertEquals("Redirect Port Number value is not "
632:                        + redirectPortText + ". ", redirectPortText, form
633:                        .getParameterValue("redirectPortText"));
634:                assertEquals("Maximum Threads value is not " + maxThreadsText
635:                        + ". ", maxThreadsText, form
636:                        .getParameterValue("maxThreadsText"));
637:                assertEquals("Minimum Spare Threads value is not "
638:                        + minSpareThreadsText + ". ", minSpareThreadsText, form
639:                        .getParameterValue("minSpareThreadsText"));
640:                assertEquals("Maximum Spare Threads value is not "
641:                        + maxSpareThreadsText + ". ", maxSpareThreadsText, form
642:                        .getParameterValue("maxSpareThreadsText"));
643:                assertEquals("Proxy Name value is not " + proxyName + ". ",
644:                        proxyName, form.getParameterValue("proxyName"));
645:                assertEquals("Proxy Port Number value is not " + proxyPortText
646:                        + ". ", proxyPortText, form
647:                        .getParameterValue("proxyPortText"));
648:                assertEquals("Allow Trace value is not " + allowTrace + ". ",
649:                        allowTrace, form.getParameterValue("allowTrace"));
650:                assertEquals("Empty Session Path value is not "
651:                        + emptySessionPath + ". ", emptySessionPath, form
652:                        .getParameterValue("emptySessionPath"));
653:                assertEquals("Enable DNS Lookups value is not " + enableLookups
654:                        + ". ", enableLookups, form
655:                        .getParameterValue("enableLookups"));
656:                assertEquals("Use Body Encoding for URI value is not "
657:                        + useBodyEncodingForURI + ". ", useBodyEncodingForURI,
658:                        form.getParameterValue("useBodyEncodingForURI"));
659:                assertEquals("X-Powered-By Generation Enabled value is not "
660:                        + xpoweredBy + ". ", xpoweredBy, form
661:                        .getParameterValue("xpoweredBy"));
662:                assertEquals("Should we use TCP no delay value is not "
663:                        + tcpNoDelay + ". ", tcpNoDelay, form
664:                        .getParameterValue("tcpNoDelay"));
665:            }
666:
667:            /**
668:             * Tear Down
669:             * cleanUp action: remove all connectors except default port connector
670:             */
671:            public void tearDown() throws Exception {
672:                MBeanServerConnection server = getMBeanServer();
673:                ObjectName on = ObjectName
674:                        .getInstance("jonas:type=Connector,*");
675:
676:                Iterator connectorList = server.queryNames(on, null).iterator();
677:
678:                while (connectorList.hasNext()) {
679:                    ObjectName connectorON = (ObjectName) connectorList.next();
680:                    String connectorPort = connectorON.getKeyProperty("port");
681:                    if (!connectorPort.equals(port)) {
682:                        server.invoke(connectorON, "destroy", new Object[] {},
683:                                new String[] {});
684:                    }
685:                }
686:                super.tearDown();
687:            }
688:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.