Source Code Cross Referenced for F_JonasAdminDeploy.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » jonasadmin » test » deploy » 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.deploy 
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_JonasAdminDeploy.java 7381 2005-09-14 16:00:02Z kemlerp $
023:         * --------------------------------------------------------------------------
024:         */
025:
026:        package org.objectweb.jonas.jonasadmin.test.deploy;
027:
028:        import junit.framework.TestSuite;
029:
030:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminAuth;
031:        import org.objectweb.jonas.jonasadmin.test.util.JonasAdminTestCase;
032:
033:        import com.meterware.httpunit.HttpUnitOptions;
034:        import com.meterware.httpunit.TableCell;
035:        import com.meterware.httpunit.WebForm;
036:        import com.meterware.httpunit.WebResponse;
037:        import com.meterware.httpunit.WebTable;
038:
039:        /**
040:         * Define a class to test the JOnAS Admin console
041:         * Test authentication and deploy/undeploy ears
042:         * @author Florent Benoit
043:         */
044:        public class F_JonasAdminDeploy extends JonasAdminTestCase {
045:
046:            /**
047:             * number of tabs when you are in the deployment tabs
048:             */
049:            private static final int NUMBER_OF_TABS_FOR_DEPLOY = 3;
050:
051:            /**
052:             * Main method
053:             * @param args the arguments
054:             */
055:            public static void main(String[] args) {
056:
057:                String testtorun = null;
058:                // Get args
059:                for (int argn = 0; argn < args.length; argn++) {
060:                    String sArg = args[argn];
061:                    if (sArg.equals("-n")) {
062:                        testtorun = args[++argn];
063:                    }
064:                }
065:                if (testtorun == null) {
066:                    junit.textui.TestRunner.run(suite());
067:                } else {
068:                    junit.textui.TestRunner.run(new F_JonasAdminDeploy(
069:                            testtorun));
070:                }
071:            }
072:
073:            /**
074:             * Get a new TestSuite for this class
075:             * @return a new TestSuite for this class
076:             */
077:            public static TestSuite suite() {
078:                return new TestSuite(F_JonasAdminDeploy.class);
079:            }
080:
081:            /**
082:             * Setup need for these tests
083:             * jonasAdmin is required
084:             * @throws Exception if it fails
085:             */
086:            protected void setUp() throws Exception {
087:                super .setUp();
088:
089:                if (wc.getCurrentPage().getURL() == null) {
090:                    useWar("jonasAdmin");
091:                } else {
092:                    // if there was an error, the connection must be restablished
093:                    try {
094:                        wc.getFrameContents(FRAME_TREE);
095:                    } catch (Exception e) {
096:                        wc.getResponse(urlLogOut);
097:                    }
098:                }
099:            }
100:
101:            /**
102:             * Constructor with a specified name
103:             * @param s name
104:             */
105:            public F_JonasAdminDeploy(String s) {
106:                super (s, URL_JONASADMIN);
107:            }
108:
109:            /**
110:             * Try to authenticate with a bad login/password
111:             * @throws Exception if an error occurs
112:             */
113:            public void testTryBadAuth() throws Exception {
114:                // login to jonas admin
115:                WebResponse wRes = JonasAdminAuth.doAuth(wc, url, "bad", "bad");
116:                String txt = wRes.getText();
117:
118:                if (txt.indexOf("Invalid username or password") == -1) {
119:                    fail("The login/password bad/bad can't be a valid l/p.");
120:                }
121:            }
122:
123:            /**
124:             * Try to authenticate with a right login/password
125:             * @throws Exception if an error occurs
126:             */
127:            public void testTryWithGoodAuth() throws Exception {
128:                WebResponse wRes = JonasAdminAuth.doValidAuth(wc, url);
129:                String txt = wRes.getText();
130:
131:                if (txt.indexOf("Invalid username or password") != -1) {
132:                    fail("The login/password jadmin/jonas must be valid.");
133:                }
134:            }
135:
136:            /**
137:             * Return the text of the deployed table or the deployable table
138:             * @param wr the WebResponse to use
139:             * @param deployed if true return the text deployed table, if false text of deployable
140:             * @return the text of the deployed table or the deployable table
141:             * @throws Exception if an error occurs
142:             */
143:            private String getDeployTable(WebResponse wr, boolean deployed)
144:                    throws Exception {
145:
146:                //Extract right table
147:                WebTable bigTable = wr.getTables()[0];
148:                WebTable firstTable = bigTable.getTableCell(1, 0).getTables()[0];
149:                WebTable cellTable = firstTable.getTableCell(0, 0).getTables()[0];
150:                WebTable subTable = cellTable.getTableCell(0, 0).getTables()[0];
151:
152:                TableCell deployableCell = subTable.getTableCell(1, 0);
153:                TableCell deployedCell = subTable.getTableCell(1, 2);
154:
155:                if (deployed) {
156:                    return deployedCell.getText();
157:                } else {
158:                    return deployableCell.getText();
159:                }
160:            }
161:
162:            /**
163:             * Deploy the ear with the testcase method and then, try to undeploy the ear with jonaAdmin
164:             * If it was undeployed, deploy it again with jonasAdmin
165:             * @param name of the ear (without extension) to test
166:             * @throws Exception if an error occurs
167:             */
168:            private void unDeployAndDeployEar(String name) throws Exception {
169:                String fileName = name + ".ear";
170:                String url = URL_JONASADMIN_DEPLOYEAR;
171:
172:                //First load Ear
173:                useEar(name);
174:
175:                WebResponse wr = wc.getResponse(getAbsoluteUrl(url));
176:
177:                String txt = getDeployTable(wr, true);
178:
179:                if (txt.indexOf(fileName) == -1) {
180:                    fail("The file" + fileName + " was not found as deployed.");
181:                }
182:
183:                WebForm[] webForms = wr.getForms();
184:                WebForm webForm = webForms[0];
185:
186:                String params = webForm.getParameterValue("undeploy");
187:                WebForm.Scriptable script = webForm.getScriptableObject();
188:
189:                // Disable errors of javascript
190:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
191:
192:                if (params.length() == 0) {
193:                    params += fileName;
194:                } else {
195:                    params += "," + fileName;
196:                }
197:
198:                script.setParameterValue("undeploy", params);
199:
200:                WebResponse submitUndeploy = webForm.submit();
201:
202:                // ear is in the table
203:                webForms = submitUndeploy.getForms();
204:                webForm = webForms[0];
205:
206:                WebResponse endResp = webForm.submit();
207:
208:                wr = wc.getResponse(getAbsoluteUrl(url));
209:                txt = getDeployTable(wr, true);
210:
211:                if (txt.indexOf(fileName) != -1) {
212:                    fail("The jonasAdmin webApp has not removed. " + fileName);
213:                }
214:
215:                //now deploy
216:                webForms = wr.getForms();
217:                webForm = webForms[0];
218:
219:                params = webForm.getParameterValue("deploy");
220:                script = webForm.getScriptableObject();
221:
222:                if (params.length() == 0) {
223:                    params += fileName;
224:                } else {
225:                    params += "," + fileName;
226:                }
227:
228:                script.setParameterValue("deploy", params);
229:
230:                submitUndeploy = webForm.submit();
231:
232:                // ear is in the table
233:                webForms = submitUndeploy.getForms();
234:                webForm = webForms[0];
235:
236:                endResp = webForm.submit();
237:
238:                wr = wc.getResponse(getAbsoluteUrl(url));
239:                txt = getDeployTable(wr, true);
240:
241:                if (txt.indexOf(fileName) == -1) {
242:                    fail("The file " + fileName + " was not found as deployed.");
243:                }
244:            }
245:
246:            /**
247:             * Deploy the ear with the testcase method and then, try to undeploy the ear with jonaAdmin
248:             * If it was undeployed, deploy it again with jonasAdmin
249:             * Test with ears alarm cmp2 and earsample
250:             * @throws Exception if an error occurs
251:             */
252:            public void testTryDeployUndeployEars() throws Exception {
253:                // login to jonas admin
254:                if (wc.getCurrentPage().getURL() == null) {
255:                    // login to jonas admin
256:                    try {
257:                        JonasAdminAuth.doValidAuth(wc, url);
258:                    } catch (Exception e) {
259:                        fail("authentification failed :  " + e);
260:                    }
261:                } else {
262:                    // if there was an error, the connection must be restablished
263:                    try {
264:                        wc.getFrameContents(FRAME_TREE);
265:                    } catch (Exception e) {
266:                        wc.getResponse(urlLogOut);
267:                        // login to jonas admin
268:                        try {
269:                            JonasAdminAuth.doValidAuth(wc, url);
270:                        } catch (Exception auth) {
271:                            fail("authentification failed :  " + auth);
272:                        }
273:                    }
274:                }
275:
276:                unDeployAndDeployEar("alarm");
277:                unDeployAndDeployEar("cmp2");
278:                if (jProp.isResource()) {
279:                    unDeployAndDeployEar("earsample");
280:                }
281:            }
282:
283:            /**
284:             * Tear Down cleanUp action
285:             * @throws Exception if an error occurs
286:             */
287:            public void tearDown() throws Exception {
288:                super.tearDown();
289:            }
290:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.