Source Code Cross Referenced for F_JonasAdminDeployJar.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_JonasAdminDeployJar.java 7381 2005-09-14 16:00:02Z kemlerp $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas.jonasadmin.test.deploy;
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.SubmitButton;
034:        import com.meterware.httpunit.TableCell;
035:        import com.meterware.httpunit.WebForm;
036:        import com.meterware.httpunit.WebLink;
037:        import com.meterware.httpunit.WebResponse;
038:        import com.meterware.httpunit.WebTable;
039:
040:        /**
041:         * Class for testing deploy/undeploy Jars
042:         * @author Paul Kemler
043:         */
044:        public class F_JonasAdminDeployJar extends JonasAdminTestCase {
045:
046:            /**
047:             * URL of the deployment of Jars
048:             */
049:            protected static final String URL_JONASADMIN_DEPLOYJAR = "EditDeploy.do?type=jar";
050:
051:            /**
052:             * URL of the deployment
053:             */
054:            protected static final String URL_JONASADMIN_DEPLOY = "EditDeploy.do";
055:
056:            /**
057:             * URL of UPLOAD
058:             */
059:            protected static final String URL_JONASADMIN_UPLOAD = "EditUpload.do";
060:
061:            /**
062:             * URL of REMOVE
063:             */
064:            protected static final String URL_JONASADMIN_REMOVE = "EditRemove.do";
065:
066:            /**
067:             * number of tabs when you are in the deployment tabs
068:             */
069:            private static final int NUMBER_OF_TABS_FOR_DEPLOYMENT = 3;
070:
071:            /**
072:             * number of tabs when you are in the CONFIRM tabs
073:             */
074:            private static final int NUMBER_OF_TABS_FOR_CONFIRM = 4;
075:
076:            /**
077:             * Constructor with a specified name
078:             * @param s name
079:             */
080:            public F_JonasAdminDeployJar(String s) {
081:                super (s, URL_JONASADMIN);
082:            }
083:
084:            /**
085:             * Main method
086:             * @param args the arguments
087:             */
088:            public static void main(String[] args) {
089:
090:                String testtorun = null;
091:                // Get args
092:                for (int argn = 0; argn < args.length; argn++) {
093:                    String sArg = args[argn];
094:                    if (sArg.equals("-n")) {
095:                        testtorun = args[++argn];
096:                    }
097:                }
098:                if (testtorun == null) {
099:                    junit.textui.TestRunner.run(suite());
100:                } else {
101:                    junit.textui.TestRunner.run(new F_JonasAdminDeployJar(
102:                            testtorun));
103:                }
104:            }
105:
106:            /**
107:             * Get a new TestSuite for this class
108:             * @return a new TestSuite for this class
109:             */
110:            public static TestSuite suite() {
111:                return new TestSuite(F_JonasAdminDeployJar.class);
112:            }
113:
114:            /**
115:             * Setup need for these tests jonasAdmin is required
116:             * @throws Exception if it fails
117:             */
118:            protected void setUp() throws Exception {
119:                super .setUp();
120:
121:                if (wc.getCurrentPage().getURL() == null) {
122:                    useWar("jonasAdmin");
123:                    // login to jonas admin
124:                    try {
125:                        JonasAdminAuth.doValidAuth(wc, url);
126:                    } catch (Exception e) {
127:                        fail("authentification failed :  " + e);
128:                    }
129:                } else {
130:                    // if there was an error, the connection must be restablished
131:                    try {
132:                        wc.getFrameContents(FRAME_TREE);
133:                    } catch (Exception e) {
134:                        wc.getResponse(urlLogOut);
135:                        // login to jonas admin
136:                        try {
137:                            JonasAdminAuth.doValidAuth(wc, url);
138:                        } catch (Exception auth) {
139:                            fail("authentification failed :  " + auth);
140:                        }
141:                    }
142:                }
143:            }
144:
145:            /**
146:             * Return the text of the deployed table or the deployable table
147:             * @param wr the WebResponse to use
148:             * @param deployed if true return the text deployed table, if false text of
149:             *        deployable
150:             * @return the text of the deployed table or the deployable table
151:             * @throws Exception if an error occurs
152:             */
153:            private String getDeployTable(WebResponse wr, boolean deployed)
154:                    throws Exception {
155:
156:                // Extract right table
157:                JonasAdminUtils utils = new JonasAdminUtils();
158:                WebTable table = utils.getTable(wr, 0);
159:
160:                TableCell deployableCell = table.getTableCell(1, 0);
161:                TableCell deployedCell = table.getTableCell(1, 2);
162:
163:                if (deployed) {
164:                    return deployedCell.getText();
165:                } else {
166:                    return deployableCell.getText();
167:                }
168:            }
169:
170:            /**
171:             * Deploy the war with the testcase method and then, try to undeploy the jar
172:             * with jonaAdmin If it was undeployed, deploy it again with jonasAdmin Test
173:             * with jar newsamplemdb.jar
174:             * @throws Exception if an error occurs
175:             */
176:            public void testTryDeployUndeployJars() throws Exception {
177:
178:                WebResponse wr;
179:                WebLink link;
180:                WebTable table;
181:                WebTable tabTable;
182:                int selectedTab;
183:                /*
184:                 * To get some utils for WebTable
185:                 */
186:                JonasAdminUtils utils = new JonasAdminUtils();
187:
188:                // Disable errors of javascript
189:                HttpUnitOptions.setExceptionsThrownOnScriptError(false);
190:                // Disable exception thrown on error status
191:                HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
192:
193:                // First load War
194:                String name = "samplemdb";
195:                String fileName = name + ".jar";
196:                useBeans(name);
197:
198:                // Go to Deployment/WebModules
199:                wr = wc.getFrameContents(FRAME_TREE);
200:                link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
201:                        URL_JONASADMIN_DEPLOYJAR);
202:                link.click();
203:                wr = wc.getFrameContents(FRAME_CONTENT);
204:                selectedTab = 1;
205:
206:                // Verify tabs
207:                tabTable = utils.getTabTable(wr);
208:                testTabs(tabTable, NUMBER_OF_TABS_FOR_DEPLOYMENT, selectedTab,
209:                        "Problem in 'Deployment' tab.");
210:                // - links
211:                assertTrue("The link " + URL_JONASADMIN_UPLOAD
212:                        + " is not found in the second tab. ", tabTable
213:                        .getTableCell(0, 2).getLinks()[0].getURLString()
214:                        .endsWith(URL_JONASADMIN_UPLOAD));
215:                assertTrue("The link " + URL_JONASADMIN_REMOVE
216:                        + " is not found in the third tab. ", tabTable
217:                        .getTableCell(0, 4).getLinks()[0].getURLString()
218:                        .endsWith(URL_JONASADMIN_REMOVE));
219:
220:                String txt = getDeployTable(wr, true);
221:
222:                if (txt.indexOf(fileName) == -1) {
223:                    fail("The file" + fileName + " was not found as deployed.");
224:                }
225:
226:                // Undeploy
227:                WebForm[] webForms = wr.getForms();
228:                WebForm webForm = webForms[0];
229:
230:                String params = webForm.getParameterValue("undeploy");
231:                WebForm.Scriptable script = webForm.getScriptableObject();
232:                if (params.length() == 0) {
233:                    params += fileName;
234:                } else {
235:                    params += "," + fileName;
236:                }
237:                script.setParameterValue("undeploy", params);
238:
239:                SubmitButton button = webForm.getSubmitButtons()[0];
240:                button.click();
241:
242:                // Confirm
243:                WebResponse submitUndeploy = wc.getFrameContents(FRAME_CONTENT);
244:                selectedTab = 2;
245:
246:                // Verify tabs
247:                tabTable = utils.getTabTable(submitUndeploy);
248:                testTabs(tabTable, NUMBER_OF_TABS_FOR_CONFIRM, selectedTab,
249:                        "Problem in 'Confirm' tab.");
250:                // - links
251:                assertTrue("The link " + URL_JONASADMIN_DEPLOY
252:                        + " is not found in the first tab. ", tabTable
253:                        .getTableCell(0, 0).getLinks()[0].getURLString()
254:                        .endsWith(URL_JONASADMIN_DEPLOY));
255:                assertTrue("The link " + URL_JONASADMIN_UPLOAD
256:                        + " is not found in the third tab. ", tabTable
257:                        .getTableCell(0, 4).getLinks()[0].getURLString()
258:                        .endsWith(URL_JONASADMIN_UPLOAD));
259:                assertTrue("The link " + URL_JONASADMIN_REMOVE
260:                        + " is not found in the fourth tab. ", tabTable
261:                        .getTableCell(0, 6).getLinks()[0].getURLString()
262:                        .endsWith(URL_JONASADMIN_REMOVE));
263:
264:                webForms = submitUndeploy.getForms();
265:                webForm = webForms[0];
266:
267:                button = webForm.getSubmitButtons()[0];
268:                button.click();
269:                wr = wc.getFrameContents(FRAME_CONTENT);
270:
271:                // Verify tabs
272:                tabTable = utils.getTabTable(wr);
273:                testTabs(tabTable, NUMBER_OF_TABS_FOR_CONFIRM, selectedTab,
274:                        "Problem in 'Result' tab.");
275:                // - links
276:                assertTrue("The link " + URL_JONASADMIN_DEPLOY
277:                        + " is not found in the first tab. ", tabTable
278:                        .getTableCell(0, 0).getLinks()[0].getURLString()
279:                        .endsWith(URL_JONASADMIN_DEPLOY));
280:                assertTrue("The link " + URL_JONASADMIN_UPLOAD
281:                        + " is not found in the third tab. ", tabTable
282:                        .getTableCell(0, 4).getLinks()[0].getURLString()
283:                        .endsWith(URL_JONASADMIN_UPLOAD));
284:                assertTrue("The link " + URL_JONASADMIN_REMOVE
285:                        + " is not found in the fourth tab. ", tabTable
286:                        .getTableCell(0, 6).getLinks()[0].getURLString()
287:                        .endsWith(URL_JONASADMIN_REMOVE));
288:
289:                // Go back to Deployment
290:                link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
291:                        URL_JONASADMIN_DEPLOY);
292:                link.click();
293:                wr = wc.getFrameContents(FRAME_CONTENT);
294:                selectedTab = 1;
295:
296:                // Verify tabs
297:                tabTable = utils.getTabTable(wr);
298:                testTabs(tabTable, NUMBER_OF_TABS_FOR_DEPLOYMENT, selectedTab,
299:                        "Problem in 'Deployment' tab.");
300:                // - links
301:                assertTrue("The link " + URL_JONASADMIN_UPLOAD
302:                        + " is not found in the second tab. ", tabTable
303:                        .getTableCell(0, 2).getLinks()[0].getURLString()
304:                        .endsWith(URL_JONASADMIN_UPLOAD));
305:                assertTrue("The link " + URL_JONASADMIN_REMOVE
306:                        + " is not found in the third tab. ", tabTable
307:                        .getTableCell(0, 4).getLinks()[0].getURLString()
308:                        .endsWith(URL_JONASADMIN_REMOVE));
309:
310:                txt = getDeployTable(wr, true);
311:
312:                if (txt.indexOf(fileName) != -1) {
313:                    fail("The jonasAdmin webApp has not removed. " + fileName);
314:                }
315:
316:                // now deploy
317:                webForms = wr.getForms();
318:                webForm = webForms[0];
319:
320:                params = webForm.getParameterValue("deploy");
321:                script = webForm.getScriptableObject();
322:
323:                if (params.length() == 0) {
324:                    params += fileName;
325:                } else {
326:                    params += "," + fileName;
327:                }
328:
329:                script.setParameterValue("deploy", params);
330:                button = webForm.getSubmitButtons()[0];
331:                button.click();
332:
333:                // Confirm
334:                submitUndeploy = wc.getFrameContents(FRAME_CONTENT);
335:                // war is in the table
336:                webForms = submitUndeploy.getForms();
337:                webForm = webForms[0];
338:
339:                button = webForm.getSubmitButtons()[0];
340:                button.click();
341:
342:                // Go back to Deployment
343:                wr = wc.getFrameContents(FRAME_CONTENT);
344:                link = wr.getFirstMatchingLink(WebLink.MATCH_URL_STRING,
345:                        URL_JONASADMIN_DEPLOY);
346:                link.click();
347:                wr = wc.getFrameContents(FRAME_CONTENT);
348:
349:                txt = getDeployTable(wr, true);
350:
351:                if (txt.indexOf(fileName) == -1) {
352:                    fail("The file " + fileName + " was not found as deployed.");
353:                }
354:            }
355:
356:            /**
357:             * Tear Down cleanUp action
358:             * @throws Exception if an error occurs
359:             */
360:            public void tearDown() throws Exception {
361:                super.tearDown();
362:            }
363:
364:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.