Source Code Cross Referenced for ConnectorUtils.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: ConnectorUtils.java 7358 2005-09-09 09:18:55Z danesa $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas.jonasadmin.test.catalina;
025:
026:        import java.io.IOException;
027:        import java.net.ServerSocket;
028:
029:        import org.xml.sax.SAXException;
030:
031:        import com.meterware.httpunit.SubmitButton;
032:        import com.meterware.httpunit.WebConversation;
033:        import com.meterware.httpunit.WebForm;
034:        import com.meterware.httpunit.WebLink;
035:        import com.meterware.httpunit.WebResponse;
036:
037:        /**
038:         * Class for using connectors from jonasAdmin, for example create a new connector.
039:         * @author Paul Kemler
040:         *
041:         */
042:        public class ConnectorUtils {
043:
044:            /**
045:             * NAME of FRAME content
046:             */
047:            protected static final String FRAME_CONTENT = "content";
048:
049:            /**
050:             * NAME of FRAME tree
051:             */
052:            protected static final String FRAME_TREE = "tree";
053:
054:            /**
055:             * URL of the Catalina connectors
056:             */
057:            private static final String URL_JONASADMIN_CATALINA_CONNECTOR = "ListCatalinaConnectors.do";
058:
059:            /**
060:             * URL for creating a catalina connector
061:             */
062:            private static final String URL_JONASADMIN_CREATE_CATALINA_CONNECTOR = "CreateCatalinaConnector.do";
063:
064:            /**
065:             * Create a new connector
066:             * @param wc logged to jonasAdmin
067:             * @return port of the new connector
068:             * @throws Exception if an error occurs
069:             */
070:            public static String createNewConnector(WebConversation wc)
071:                    throws Exception {
072:                // Call method createNewConnector(WebConversation wc, String protocol)
073:                return createNewConnector(wc, "http");
074:            }
075:
076:            /**
077:             * Create a new connector
078:             * @param wc logged to jonasAdmin
079:             * @param protocol protocol to create ("http", "https" or "ajp")
080:             * @return port of the new connector
081:             * @throws Exception if an error occurs
082:             */
083:            public static String createNewConnector(WebConversation wc,
084:                    String protocol) throws Exception {
085:                WebResponse wr = null;
086:                WebLink link = null;
087:                WebForm form = null;
088:                String portText = null;
089:
090:                // Go to connector page
091:                wr = getConnectorPage(wc);
092:
093:                // Go to CreateCatalinaConnector.do?type= <protocol>
094:                link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
095:                        URL_JONASADMIN_CREATE_CATALINA_CONNECTOR + "?type="
096:                                + protocol);
097:                link.click();
098:                wr = wc.getFrameContents(FRAME_CONTENT);
099:
100:                portText = "" + findPort();
101:
102:                if (protocol.equals("http")) {
103:
104:                    form = wr.getForms()[0];
105:                    String maxSpareThreadsText = form
106:                            .getParameterValue("maxSpareThreadsText");
107:                    String URIEncoding = form.getParameterValue("URIEncoding");
108:                    String minSpareThreadsText = form
109:                            .getParameterValue("minSpareThreadsText");
110:                    String address = form.getParameterValue("address");
111:                    String tcpNoDelay = form.getParameterValue("tcpNoDelay");
112:                    String maxThreadsText = form
113:                            .getParameterValue("maxThreadsText");
114:                    String xpoweredBy = form.getParameterValue("xpoweredBy");
115:                    String connectorType = form
116:                            .getParameterValue("connectorType");
117:                    String objectName = form.getParameterValue("objectName");
118:                    String secure = form.getParameterValue("secure");
119:                    String action = form.getParameterValue("action");
120:                    String save = form.getParameterValue("save");
121:                    String emptySessionPath = form
122:                            .getParameterValue("emptySessionPath");
123:                    String acceptCountText = form
124:                            .getParameterValue("acceptCountText");
125:                    String bufferSizeText = form
126:                            .getParameterValue("bufferSizeText");
127:                    String proxyName = form.getParameterValue("proxyName");
128:                    String useBodyEncodingForURI = form
129:                            .getParameterValue("useBodyEncodingForURI");
130:                    String connTimeOutText = form
131:                            .getParameterValue("connTimeOutText");
132:                    String redirectPortText = form
133:                            .getParameterValue("redirectPortText");
134:                    String enableLookups = form
135:                            .getParameterValue("enableLookups");
136:                    String allowTrace = form.getParameterValue("allowTrace");
137:                    String proxyPortText = form
138:                            .getParameterValue("proxyPortText");
139:                    String maxPostSizeText = form
140:                            .getParameterValue("maxPostSizeText");
141:
142:                    createNewHttpConnector(form, maxSpareThreadsText,
143:                            URIEncoding, portText, minSpareThreadsText,
144:                            address, tcpNoDelay, maxThreadsText, xpoweredBy,
145:                            connectorType, objectName, secure, action, save,
146:                            emptySessionPath, acceptCountText, bufferSizeText,
147:                            proxyName, useBodyEncodingForURI, connTimeOutText,
148:                            redirectPortText, enableLookups, allowTrace,
149:                            proxyPortText, maxPostSizeText);
150:                } else if (protocol.equals("https")) {
151:                    form = wr.getForms()[0];
152:                    String maxSpareThreadsText = form
153:                            .getParameterValue("maxSpareThreadsText");
154:                    String keystorePass = form
155:                            .getParameterValue("keystorePass");
156:                    String URIEncoding = form.getParameterValue("URIEncoding");
157:                    String minSpareThreadsText = form
158:                            .getParameterValue("minSpareThreadsText");
159:                    String address = form.getParameterValue("address");
160:                    String keystoreType = form
161:                            .getParameterValue("keystoreType");
162:                    String algorithm = form.getParameterValue("algorithm");
163:                    String tcpNoDelay = form.getParameterValue("tcpNoDelay");
164:                    String maxThreadsText = form
165:                            .getParameterValue("maxThreadsText");
166:                    String xpoweredBy = form.getParameterValue("xpoweredBy");
167:                    String connectorType = form
168:                            .getParameterValue("connectorType");
169:                    String sslProtocol = form.getParameterValue("sslProtocol");
170:                    String objectName = form.getParameterValue("objectName");
171:                    String secure = form.getParameterValue("secure");
172:                    String action = form.getParameterValue("action");
173:                    String save = form.getParameterValue("save");
174:                    String emptySessionPath = form
175:                            .getParameterValue("emptySessionPath");
176:                    String keystoreFile = form
177:                            .getParameterValue("keystoreFile");
178:                    String acceptCountText = form
179:                            .getParameterValue("acceptCountText");
180:                    String bufferSizeText = form
181:                            .getParameterValue("bufferSizeText");
182:                    String proxyName = form.getParameterValue("proxyName");
183:                    String useBodyEncodingForURI = form
184:                            .getParameterValue("useBodyEncodingForURI");
185:                    String connTimeOutText = form
186:                            .getParameterValue("connTimeOutText");
187:                    String redirectPortText = form
188:                            .getParameterValue("redirectPortText");
189:                    String enableLookups = form
190:                            .getParameterValue("enableLookups");
191:                    String clientAuth = form.getParameterValue("clientAuth");
192:                    String allowTrace = form.getParameterValue("allowTrace");
193:                    String ciphers = form.getParameterValue("ciphers");
194:                    String proxyPortText = form
195:                            .getParameterValue("proxyPortText");
196:                    String maxPostSizeText = form
197:                            .getParameterValue("maxPostSizeText");
198:
199:                    createNewHttpsConnector(form, maxSpareThreadsText,
200:                            keystorePass, URIEncoding, portText,
201:                            minSpareThreadsText, address, keystoreType,
202:                            algorithm, tcpNoDelay, maxThreadsText, xpoweredBy,
203:                            connectorType, sslProtocol, objectName, secure,
204:                            action, save, emptySessionPath, keystoreFile,
205:                            acceptCountText, bufferSizeText, proxyName,
206:                            useBodyEncodingForURI, connTimeOutText,
207:                            redirectPortText, enableLookups, clientAuth,
208:                            allowTrace, ciphers, proxyPortText, maxPostSizeText);
209:                } else if (protocol.equals("ajp")) {
210:                    form = wr.getForms()[0];
211:                    String maxSpareThreadsText = form
212:                            .getParameterValue("maxSpareThreadsText");
213:                    String URIEncoding = form.getParameterValue("URIEncoding");
214:                    String minSpareThreadsText = form
215:                            .getParameterValue("minSpareThreadsText");
216:                    String address = form.getParameterValue("address");
217:                    String tcpNoDelay = form.getParameterValue("tcpNoDelay");
218:                    String maxThreadsText = form
219:                            .getParameterValue("maxThreadsText");
220:                    String xpoweredBy = form.getParameterValue("xpoweredBy");
221:                    String connectorType = form
222:                            .getParameterValue("connectorType");
223:                    String objectName = form.getParameterValue("objectName");
224:                    String secure = form.getParameterValue("secure");
225:                    String action = form.getParameterValue("action");
226:                    String save = form.getParameterValue("save");
227:                    String emptySessionPath = form
228:                            .getParameterValue("emptySessionPath");
229:                    String acceptCountText = form
230:                            .getParameterValue("acceptCountText");
231:                    String bufferSizeText = form
232:                            .getParameterValue("bufferSizeText");
233:                    String useBodyEncodingForURI = form
234:                            .getParameterValue("useBodyEncodingForURI");
235:                    String connTimeOutText = form
236:                            .getParameterValue("connTimeOutText");
237:                    String redirectPortText = form
238:                            .getParameterValue("redirectPortText");
239:                    String enableLookups = form
240:                            .getParameterValue("enableLookups");
241:                    String allowTrace = form.getParameterValue("allowTrace");
242:                    String maxPostSizeText = form
243:                            .getParameterValue("maxPostSizeText");
244:
245:                    createNewAjpConnector(form, maxSpareThreadsText,
246:                            URIEncoding, portText, minSpareThreadsText,
247:                            address, tcpNoDelay, maxThreadsText, xpoweredBy,
248:                            connectorType, objectName, secure, action, save,
249:                            emptySessionPath, acceptCountText, bufferSizeText,
250:                            useBodyEncodingForURI, connTimeOutText,
251:                            redirectPortText, enableLookups, allowTrace,
252:                            maxPostSizeText);
253:                }
254:                return portText;
255:            }
256:
257:            /**
258:             * Get connector page when it is catalina
259:             * @param wc logged to jonasAdmin with catalina
260:             * @return WebResponse: content frame with list of connectors
261:             * @throws SAXException if an error occurs when link is matched or clicked
262:             * @throws IOException if an error occurs when link is clicked
263:             */
264:            public static WebResponse getConnectorPage(WebConversation wc)
265:                    throws SAXException, IOException {
266:                // Go to connector page (ListCatalinaConnectors.do)
267:                WebResponse wr;
268:                WebLink link;
269:
270:                wr = wc.getFrameContents(FRAME_TREE);
271:                link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
272:                        URL_JONASADMIN_CATALINA_CONNECTOR);
273:                if (link == null) {
274:                    throw new IllegalStateException(
275:                            "No link found for link : '"
276:                                    + URL_JONASADMIN_CATALINA_CONNECTOR + "'.");
277:                }
278:                link.click();
279:
280:                wr = wc.getFrameContents(FRAME_CONTENT);
281:                return wr;
282:            }
283:
284:            /**
285:             * Get a free port
286:             * @return number of a free port
287:             * @throws Exception if an error occurs to find a port
288:             */
289:            private static int findPort() throws Exception {
290:                int port = 0;
291:
292:                ServerSocket ss;
293:                ss = new ServerSocket(port); // free port if port == 0
294:                port = ss.getLocalPort();
295:                ss.close();
296:                return port;
297:            }
298:
299:            /**
300:             * Create New Http Connector
301:             * @param form Web Form to create http connector
302:             * @param maxSpareThreadsText a string
303:             * @param URIEncoding a string
304:             * @param portText a string
305:             * @param minSpareThreadsText a string
306:             * @param address a string
307:             * @param tcpNoDelay a string
308:             * @param maxThreadsText a string
309:             * @param xpoweredBy a string
310:             * @param connectorType a string
311:             * @param objectName a string
312:             * @param secure a string
313:             * @param action a string
314:             * @param save a string
315:             * @param emptySessionPath a string
316:             * @param acceptCountText a string
317:             * @param bufferSizeText a string
318:             * @param proxyName a string
319:             * @param useBodyEncodingForURI a string
320:             * @param connTimeOutText a string
321:             * @param redirectPortText a string
322:             * @param enableLookups a string
323:             * @param allowTrace a string
324:             * @param proxyPortText a string
325:             * @param maxPostSizeText a string
326:             * @throws Exception if an error occurs when button is clicked.
327:             */
328:            public static void createNewHttpConnector(WebForm form,
329:                    String maxSpareThreadsText, String URIEncoding,
330:                    String portText, String minSpareThreadsText,
331:                    String address, String tcpNoDelay, String maxThreadsText,
332:                    String xpoweredBy, String connectorType, String objectName,
333:                    String secure, String action, String save,
334:                    String emptySessionPath, String acceptCountText,
335:                    String bufferSizeText, String proxyName,
336:                    String useBodyEncodingForURI, String connTimeOutText,
337:                    String redirectPortText, String enableLookups,
338:                    String allowTrace, String proxyPortText,
339:                    String maxPostSizeText) throws Exception {
340:
341:                SubmitButton button = null;
342:
343:                form.setParameter("maxSpareThreadsText", maxSpareThreadsText);
344:                form.setParameter("URIEncoding", URIEncoding);
345:                form.setParameter("portText", portText);
346:                form.setParameter("minSpareThreadsText", minSpareThreadsText);
347:                form.setParameter("address", address);
348:                form.setParameter("tcpNoDelay", tcpNoDelay);
349:                form.setParameter("maxThreadsText", maxThreadsText);
350:                form.setParameter("xpoweredBy", xpoweredBy);
351:                form.setParameter("connectorType", connectorType);
352:                form.setParameter("objectName", objectName);
353:                form.setParameter("secure", secure);
354:                form.setParameter("action", action);
355:                form.setParameter("save", save);
356:                form.setParameter("emptySessionPath", emptySessionPath);
357:                form.setParameter("acceptCountText", acceptCountText);
358:                form.setParameter("bufferSizeText", bufferSizeText);
359:                form.setParameter("proxyName", proxyName);
360:                form.setParameter("useBodyEncodingForURI",
361:                        useBodyEncodingForURI);
362:                form.setParameter("connTimeOutText", connTimeOutText);
363:                form.setParameter("redirectPortText", redirectPortText);
364:                form.setParameter("enableLookups", enableLookups);
365:                form.setParameter("allowTrace", allowTrace);
366:                form.setParameter("proxyPortText", proxyPortText);
367:                form.setParameter("maxPostSizeText", maxPostSizeText);
368:
369:                button = form.getSubmitButton("btn_apply");
370:                button.click();
371:            }
372:
373:            /**
374:             * Create New Https Connector
375:             * @param form Web Form to create https connector
376:             * @param maxSpareThreadsText a string
377:             * @param keystorePass a string
378:             * @param URIEncoding a string
379:             * @param portText a string
380:             * @param minSpareThreadsText a string
381:             * @param address a string
382:             * @param keystoreType a string
383:             * @param algorithm a string
384:             * @param tcpNoDelay a string
385:             * @param maxThreadsText a string
386:             * @param xpoweredBy a string
387:             * @param connectorType a string
388:             * @param sslProtocol a string
389:             * @param objectName a string
390:             * @param secure a string
391:             * @param action a string
392:             * @param save a string
393:             * @param emptySessionPath a string
394:             * @param keystoreFile a string
395:             * @param acceptCountText a string
396:             * @param bufferSizeText a string
397:             * @param proxyName a string
398:             * @param useBodyEncodingForURI a string
399:             * @param connTimeOutText a string
400:             * @param redirectPortText a string
401:             * @param enableLookups a string
402:             * @param clientAuth a string
403:             * @param allowTrace a string
404:             * @param ciphers a string
405:             * @param proxyPortText a string
406:             * @param maxPostSizeText a string
407:             * @throws Exception if an error occurs when button is clicked.
408:             */
409:            public static void createNewHttpsConnector(WebForm form,
410:                    String maxSpareThreadsText, String keystorePass,
411:                    String URIEncoding, String portText,
412:                    String minSpareThreadsText, String address,
413:                    String keystoreType, String algorithm, String tcpNoDelay,
414:                    String maxThreadsText, String xpoweredBy,
415:                    String connectorType, String sslProtocol,
416:                    String objectName, String secure, String action,
417:                    String save, String emptySessionPath, String keystoreFile,
418:                    String acceptCountText, String bufferSizeText,
419:                    String proxyName, String useBodyEncodingForURI,
420:                    String connTimeOutText, String redirectPortText,
421:                    String enableLookups, String clientAuth, String allowTrace,
422:                    String ciphers, String proxyPortText, String maxPostSizeText)
423:                    throws Exception {
424:
425:                SubmitButton button = null;
426:
427:                form.setParameter("maxSpareThreadsText", maxSpareThreadsText);
428:                form.setParameter("keystorePass", keystorePass);
429:                form.setParameter("URIEncoding", URIEncoding);
430:                form.setParameter("portText", portText);
431:                form.setParameter("minSpareThreadsText", minSpareThreadsText);
432:                form.setParameter("address", address);
433:                form.setParameter("keystoreType", keystoreType);
434:                form.setParameter("algorithm", algorithm);
435:                form.setParameter("tcpNoDelay", tcpNoDelay);
436:                form.setParameter("maxThreadsText", maxThreadsText);
437:                form.setParameter("xpoweredBy", xpoweredBy);
438:                form.setParameter("connectorType", connectorType);
439:                form.setParameter("sslProtocol", sslProtocol);
440:                form.setParameter("objectName", objectName);
441:                form.setParameter("secure", secure);
442:                form.setParameter("action", action);
443:                form.setParameter("save", save);
444:                form.setParameter("emptySessionPath", emptySessionPath);
445:                form.setParameter("keystoreFile", keystoreFile);
446:                form.setParameter("acceptCountText", acceptCountText);
447:                form.setParameter("bufferSizeText", bufferSizeText);
448:                form.setParameter("proxyName", proxyName);
449:                form.setParameter("useBodyEncodingForURI",
450:                        useBodyEncodingForURI);
451:                form.setParameter("connTimeOutText", connTimeOutText);
452:                form.setParameter("redirectPortText", redirectPortText);
453:                form.setParameter("enableLookups", enableLookups);
454:                form.setParameter("clientAuth", clientAuth);
455:                form.setParameter("allowTrace", allowTrace);
456:                form.setParameter("ciphers", ciphers);
457:                form.setParameter("proxyPortText", proxyPortText);
458:                form.setParameter("maxPostSizeText", maxPostSizeText);
459:
460:                button = form.getSubmitButton("btn_apply");
461:                button.click();
462:            }
463:
464:            /**
465:             * Create New Ajp Connector
466:             * @param form Web Form to create ajp connector
467:             * @param maxSpareThreadsText a string
468:             * @param URIEncoding a string
469:             * @param portText a string
470:             * @param minSpareThreadsText a string
471:             * @param address a string
472:             * @param tcpNoDelay a string
473:             * @param maxThreadsText a string
474:             * @param xpoweredBy a string
475:             * @param connectorType a string
476:             * @param objectName a string
477:             * @param secure a string
478:             * @param action a string
479:             * @param save a string
480:             * @param emptySessionPath a string
481:             * @param acceptCountText a string
482:             * @param bufferSizeText a string
483:             * @param useBodyEncodingForURI a string
484:             * @param connTimeOutText a string
485:             * @param redirectPortText a string
486:             * @param enableLookups a string
487:             * @param allowTrace a string
488:             * @param maxPostSizeText a string
489:             * @throws Exception if an error occurs when button is clicked.
490:             */
491:            public static void createNewAjpConnector(WebForm form,
492:                    String maxSpareThreadsText, String URIEncoding,
493:                    String portText, String minSpareThreadsText,
494:                    String address, String tcpNoDelay, String maxThreadsText,
495:                    String xpoweredBy, String connectorType, String objectName,
496:                    String secure, String action, String save,
497:                    String emptySessionPath, String acceptCountText,
498:                    String bufferSizeText, String useBodyEncodingForURI,
499:                    String connTimeOutText, String redirectPortText,
500:                    String enableLookups, String allowTrace,
501:                    String maxPostSizeText) throws Exception {
502:
503:                SubmitButton button = null;
504:
505:                form.setParameter("maxSpareThreadsText", maxSpareThreadsText);
506:                form.setParameter("URIEncoding", URIEncoding);
507:                form.setParameter("portText", portText);
508:                form.setParameter("minSpareThreadsText", minSpareThreadsText);
509:                form.setParameter("address", address);
510:                form.setParameter("tcpNoDelay", tcpNoDelay);
511:                form.setParameter("maxThreadsText", maxThreadsText);
512:                form.setParameter("xpoweredBy", xpoweredBy);
513:                form.setParameter("connectorType", connectorType);
514:                form.setParameter("objectName", objectName);
515:                form.setParameter("secure", secure);
516:                form.setParameter("action", action);
517:                form.setParameter("save", save);
518:                form.setParameter("emptySessionPath", emptySessionPath);
519:                form.setParameter("acceptCountText", acceptCountText);
520:                form.setParameter("bufferSizeText", bufferSizeText);
521:                form.setParameter("useBodyEncodingForURI",
522:                        useBodyEncodingForURI);
523:                form.setParameter("connTimeOutText", connTimeOutText);
524:                form.setParameter("redirectPortText", redirectPortText);
525:                form.setParameter("enableLookups", enableLookups);
526:                form.setParameter("allowTrace", allowTrace);
527:                form.setParameter("maxPostSizeText", maxPostSizeText);
528:
529:                button = form.getSubmitButton("btn_apply");
530:                button.click();
531:            }
532:
533:            /**
534:             * Remove a connector
535:             * @param wc logged to jonasAdmin
536:             * @param port port number of the connector to remove
537:             * @throws Exception if an error occurs when connector is deleted
538:             */
539:            public static void deleteConnector(WebConversation wc, String port)
540:                    throws Exception {
541:                String[] tabPort = { port };
542:                deleteConnectors(wc, tabPort);
543:            }
544:
545:            /**
546:             * Remove connectors
547:             * @param wc logged to jonasAdmin
548:             * @param port port number of the connector to remove
549:             * @throws Exception if an error occurs
550:             */
551:            public static void deleteConnectors(WebConversation wc,
552:                    String[] tabPort) throws Exception {
553:                WebResponse wr = null;
554:                WebForm form = null;
555:                WebLink link = null;
556:                SubmitButton button = null;
557:
558:                String action = "";
559:
560:                wr = getConnectorPage(wc);
561:
562:                // Select connectors to remove
563:                form = wr.getForms()[0];
564:                action = form.getParameterValue("action");
565:                for (int i = 0; i < tabPort.length; i++) {
566:                    form.setCheckbox("selectedItems",
567:                            "jonas:type=Connector,port=" + tabPort[i], true);
568:                }
569:
570:                // Choose remove action
571:                link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
572:                        "remove");
573:                link.click();
574:                wr = wc.getFrameContents(FRAME_CONTENT);
575:
576:                // Confirm
577:                form = wr.getForms()[0];
578:                button = form.getSubmitButton("btnSubmit");
579:                button.click();
580:            }
581:
582:            /**
583:             * Modify a connector
584:             * @param wc logged to jonasAdmin
585:             * @param port number of the port of the connector to modify
586:             * @param acceptCountText a string
587:             * @param maxPostSizeText a string
588:             * @param connTimeOutText a string
589:             * @param URIEncoding a string
590:             * @param bufferSizeText a string
591:             * @param address a string
592:             * @param redirectPortText a string
593:             * @param maxThreadsText a string
594:             * @param minSpareThreadsText a string
595:             * @param maxSpareThreadsText a string
596:             * @param proxyName a string
597:             * @param proxyPortText a string
598:             * @throws Exception if an error occurs
599:             */
600:            public static void modifyHttpConnector(WebForm form,
601:                    String acceptCountText, String maxPostSizeText,
602:                    String connTimeOutText, String URIEncoding,
603:                    String bufferSizeText, String address,
604:                    String redirectPortText, String maxThreadsText,
605:                    String minSpareThreadsText, String maxSpareThreadsText,
606:                    String proxyName, String proxyPortText, String allowTrace,
607:                    String emptySessionPath, String enableLookups,
608:                    String useBodyEncodingForURI, String xpoweredBy,
609:                    String tcpNoDelay) throws Exception {
610:
611:                SubmitButton button = null;
612:
613:                String objectName = null;
614:                String action = null;
615:                String save = null;
616:                String connectorType = null;
617:                String portText = null;
618:
619:                // get hidden params
620:                objectName = form.getParameterValue("objectName");
621:                action = form.getParameterValue("action");
622:                save = form.getParameterValue("save");
623:                connectorType = form.getParameterValue("connectorType");
624:                portText = form.getParameterValue("portText");
625:
626:                form.setParameter("objectName", objectName);
627:                form.setParameter("action", action);
628:                form.setParameter("save", save);
629:                form.setParameter("connectorType", connectorType);
630:                form.setParameter("portText", portText);
631:                form.setParameter("acceptCountText", acceptCountText);
632:                form.setParameter("maxPostSizeText", maxPostSizeText);
633:                form.setParameter("connTimeOutText", connTimeOutText);
634:                form.setParameter("URIEncoding", URIEncoding);
635:                form.setParameter("bufferSizeText", bufferSizeText);
636:                form.setParameter("address", address);
637:                form.setParameter("redirectPortText", redirectPortText);
638:                form.setParameter("maxThreadsText", maxThreadsText);
639:                form.setParameter("minSpareThreadsText", minSpareThreadsText);
640:                form.setParameter("maxSpareThreadsText", maxSpareThreadsText);
641:                form.setParameter("proxyName", proxyName);
642:                form.setParameter("proxyPortText", proxyPortText);
643:                form.setParameter("allowTrace", allowTrace);
644:                form.setParameter("emptySessionPath", emptySessionPath);
645:                form.setParameter("enableLookups", enableLookups);
646:                form.setParameter("useBodyEncodingForURI",
647:                        useBodyEncodingForURI);
648:                form.setParameter("xpoweredBy", xpoweredBy);
649:                form.setParameter("tcpNoDelay", tcpNoDelay);
650:
651:                button = form.getSubmitButton("btn_apply");
652:                button.click();
653:            }
654:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.