Source Code Cross Referenced for ServerExplorerOperator.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » modules » visualweb » gravy » dataconnectivity » 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 » IDE Netbeans » visualweb.api.designer » org.netbeans.modules.visualweb.gravy.dataconnectivity 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.modules.visualweb.gravy.dataconnectivity;
043:
044:        import org.netbeans.modules.visualweb.gravy.DNDDriver;
045:        import org.netbeans.modules.visualweb.gravy.TestUtils;
046:        import org.netbeans.modules.visualweb.gravy.TopComponentOperator;
047:        import org.netbeans.modules.visualweb.gravy.Util;
048:        import org.netbeans.modules.visualweb.gravy.websvc.AddWebServiceOperator;
049:        import org.netbeans.modules.visualweb.gravy.nodes.WebServicesNode;
050:        import org.netbeans.modules.visualweb.gravy.designer.DesignerPaneOperator;
051:        import org.netbeans.modules.visualweb.gravy.actions.ActionNoBlock;
052:        import org.netbeans.modules.visualweb.gravy.model.deployment.DeploymentTargetDescriptor;
053:        import org.netbeans.jellytools.Bundle;
054:        import org.netbeans.jellytools.NbDialogOperator;
055:        import org.netbeans.jellytools.WizardOperator;
056:        import org.netbeans.jemmy.JemmyProperties;
057:        import org.netbeans.jemmy.QueueTool;
058:        import org.netbeans.jemmy.TimeoutExpiredException;
059:        import org.netbeans.jemmy.operators.*;
060:        import javax.swing.*;
061:        import javax.swing.tree.TreePath;
062:        import javax.swing.tree.TreeNode;
063:        import java.awt.*;
064:        import java.awt.event.KeyEvent;
065:        import org.netbeans.jemmy.Waitable;
066:        import org.netbeans.jemmy.Waiter;
067:        import java.util.Hashtable;
068:
069:        /**
070:         * This class implements test functionality for the window "ServerExplorer".
071:         */
072:        public class ServerExplorerOperator extends TopComponentOperator {
073:
074:            public static final String STR_NAME_WEBLOGIC = "BEA WebLogic Server",
075:                    STR_NAME_JBOSS = "JBoss Application Server",
076:                    STR_NAME_APPSERVER = "Sun Java System Application Server",
077:                    STR_NAME_GLASSFISH_V1 = "GlassFish V1",
078:                    STR_NAME_GLASSFISH_V2 = "GlassFish V2",
079:                    STR_NAME_TOMCAT50 = "Tomcat 5.0",
080:                    STR_NAME_TOMCAT55 = "Tomcat 5.5",
081:                    STR_NAME_TOMCAT60 = "Tomcat 6.0",
082:                    STR_MENU_ITEM_SERVER_MANAGER = "Tools|Servers",
083:                    STR_DIALOG_TITLE_SERVER_MANAGER = "Servers",
084:                    STR_WIZARD_TITLE_ADD_SERVER = "Add Server Instance",
085:                    STR_BUTTON_TITLE_ADD_SERVER = "Add Server...",
086:                    STR_BUTTON_TITLE_CLOSE = "Close",
087:                    STR_BUTTON_TITLE_CHOOSE = "Choose",
088:                    STR_MENU_ITEM_START = "Start",
089:                    STR_MENU_ITEM_STOP = "Stop",
090:                    STR_SERVERS_PATH = "Servers|",
091:                    STR_SERVER_START = "Starting ",
092:                    STR_SERVER_STOP = "Stopping ";
093:
094:            JTreeOperator tree = null;
095:
096:            /**
097:             * Creates a new instance of this class
098:             * @param parent an object ContainerOperator related to container, which 
099:             * includes window "Server Explorer".
100:             */
101:            public ServerExplorerOperator(ContainerOperator parent) {
102:                super (parent, "Services");
103:            }
104:
105:            /**
106:             * Creates a new instance of this class
107:             */
108:            public ServerExplorerOperator() {
109:                this (Util.getMainWindow());
110:            }
111:
112:            /**
113:             * Returns a tree, which is contained in the window "Server Explorer".
114:             * @return an object JTreeOperator
115:             */
116:            public JTreeOperator getTree() {
117:                if (tree == null) {
118:                    makeComponentVisible();
119:                    tree = new JTreeOperator(this );
120:                }
121:                return (tree);
122:            }
123:
124:            /**
125:             * Selects a tree node according to a required tree path.
126:             * @param treePath a path of required tree node
127:             */
128:            public void selectPath(String treePath) {
129:                makeComponentVisible();
130:                TestUtils.wait(500);
131:                TreePath path = getTree().findPath(treePath);
132:                TestUtils.wait(500);
133:                tree.selectPath(path);
134:            }
135:
136:            /**
137:             * Clicks an item of popup menu, related to required tree node.
138:             * @param treePath a path of required tree node
139:             * @param menu a name of menu item
140:             */
141:            public void pushPopup(String treePath, String menu) {
142:                pushPopup(getTree(), treePath, menu);
143:            }
144:
145:            /**
146:             * Clicks an item of popup menu, related to required tree node.
147:             * @param tree an object JTreeOperator, related to a tree
148:             * @param treePath a path of required tree node
149:             * @param menu a name of menu item
150:             */
151:            public void pushPopup(JTreeOperator tree, String treePath,
152:                    String menu) {
153:                new JPopupMenuOperator(getTree().callPopupOnPath(
154:                        getTree().findPath(treePath))).pushMenuNoBlock(menu);
155:                new QueueTool().waitEmpty();
156:                TestUtils.wait(100);
157:            }
158:
159:            /**
160:             * Clicks an item of popup menu, related to required tree node.
161:             * @param treePath a string array with path of required tree node 
162:             * (sequence of node names from the root node to a required node)
163:             * @param menu a name of menu item
164:             */
165:            public void pushPopup(String[] treePath, String menu) {
166:                new JPopupMenuOperator(getTree().callPopupOnPath(
167:                        getTree().findPath(treePath))).pushMenuNoBlock(menu);
168:                new QueueTool().waitEmpty();
169:                TestUtils.wait(100);
170:            }
171:
172:            /**
173:             * Adds database table on Design View via popup menu, related to its tree node.
174:             * @param treePath a path of required tree node
175:             */
176:            public void addTable(String treePath) {
177:                selectPath(treePath);
178:                pushPopup(getTree(), treePath, "Add to Form");
179:            }
180:
181:            /**
182:             * Adds database table on Design View via popup menu, related to its tree node.
183:             * @param treePath a path of required tree node
184:             * @param designer an object DesignerPaneOperator
185:             */
186:            public void addTable(String treePath, DesignerPaneOperator designer) {
187:                addTable(treePath, designer, new Point(1, 1));
188:            }
189:
190:            /**
191:             * Adds database table on Design View via popup menu, related to its tree node.
192:             * @param treePath a path of required tree node as object TreePath
193:             * @param designer an object DesignerPaneOperator
194:             */
195:            public void addTable(TreePath treePath,
196:                    DesignerPaneOperator designer) {
197:                addTable(treePath, designer, new Point(1, 1));
198:            }
199:
200:            /**
201:             * Adds database table on Design View via popup menu, related to its tree node.
202:             * @param treePath a path of required tree node
203:             * @param designer an object DesignerPaneOperator
204:             * @param location a point on Design View for mouse clicking
205:             */
206:            public void addTable(String treePath,
207:                    DesignerPaneOperator designer, Point location) {
208:                addTable(tree.findPath(treePath), designer, location);
209:            }
210:
211:            /**
212:             * Adds database table on Design View via popup menu, related to its tree node.
213:             * @param treePath a path of required tree node as object TreePath
214:             * @param designer an object DesignerPaneOperator
215:             * @param location a point on Design View for mouse clicking
216:             */
217:            public void addTable(TreePath treePath,
218:                    DesignerPaneOperator designer, Point location) {
219:                makeComponentVisible();
220:                TestUtils.wait(2000);
221:                //ServerNavigatorOperator.showNavigatorOperator();
222:                TestUtils.wait(500);
223:                tree.selectPath(treePath);
224:                TestUtils.wait(3000);
225:                new DNDDriver().dnd(tree, tree.getPointToClick(treePath),
226:                        designer, location);
227:                TestUtils.wait(3000);
228:            }
229:
230:            /**
231:             * Undeploys a project from an application server.
232:             * @param server a name of application server
233:             * @param prj a name of project
234:             * @param parse boolean parameter: true - only the first 2 chars of the 
235:             * project name are considered, false - full project name is valuable
236:             */
237:            public static void undeployProject(String server, String prj,
238:                    boolean parse) {
239:
240:                String serverPath = null;
241:
242:                serverPath = "Deployment Server";
243:
244:                System.out.println("default is " + serverPath);
245:
246:                // Select the Server Navigator and set the JTreeOperator   
247:                new QueueTool().waitEmpty(100);
248:                ServerNavigatorOperator explorer = ServerNavigatorOperator
249:                        .showNavigatorOperator();
250:                explorer.makeComponentVisible();
251:                JTreeOperator tree = explorer.getTree();
252:
253:                // Sleep 4 secs to make sure Server Navigator is in focus
254:                Util.wait(4000);
255:
256:                // Need to refresh J2EE AppServer node
257:                explorer.pushPopup(tree, serverPath, "Refresh");
258:
259:                // Increase timeout for tree to redisplay after refresh
260:                tree.getTimeouts().setTimeout(
261:                        "JTreeOperator.WaitNodeExpandedTimeout", 60000);
262:                tree.getTimeouts().setTimeout(
263:                        "JTreeOperator.WaitNextNodeTimeout", 60000);
264:                tree.getTimeouts().setTimeout(
265:                        "JTreeOperator.WaitNodeVisibleTimeout", 60000);
266:
267:                TestUtils.wait(1000);
268:                explorer.selectPath(serverPath + "|Deployed Components");
269:                explorer.getTree().expandPath(
270:                        explorer.getTree().findPath(
271:                                serverPath + "|Deployed Components"));
272:                System.out.println("TRACE: Path =" + serverPath
273:                        + "|Deployed Components");
274:                TestUtils.wait(1000);
275:
276:                //      TODO delete workaround
277:                //      ************* workaround *************
278:                explorer.pushPopup(tree, serverPath, "Refresh");
279:                TestUtils.wait(1000);
280:                explorer.selectPath(serverPath + "|Deployed Components");
281:                explorer.getTree().expandPath(
282:                        explorer.getTree().findPath(
283:                                serverPath + "|Deployed Components"));
284:                System.out.println("TRACE: Path =" + serverPath
285:                        + "|Deployed Components");
286:                TestUtils.wait(1000);
287:                //      ************* workaround *************
288:
289:                explorer
290:                        .selectPath(serverPath + "|Deployed Components|/" + prj);
291:                System.out.println("TRACE: Path =" + serverPath
292:                        + "|Deployed Components|/" + prj);
293:                TestUtils.wait(1000);
294:                System.out.println("TRACE: Push Menu Undeploy...");
295:                explorer.pushPopup(explorer.getTree(), serverPath
296:                        + "|Deployed Components|/" + prj, "Undeploy");
297:            }
298:
299:            /**
300:             * Checks undeployment of a project from an application server.
301:             * @param server a name of application server
302:             * @param prj a name of project
303:             * @param parse boolean parameter: true - only the first 2 chars of the 
304:             * project name are considered, false - full project name is valuable
305:             */
306:            public static boolean verifyUndeployment(String server, String prj,
307:                    boolean parse) {
308:
309:                System.out.println("Started!");
310:
311:                String serverPath = null;
312:                String pePath = "Deployment Server";
313:                String deploymentPath = null;
314:                String defaultServer = null;
315:
316:                serverPath = pePath;
317:                serverPath = "Deployment Server";
318:
319:                // Select the Server Navigator and set the JTreeOperator   
320:                new QueueTool().waitEmpty(100);
321:                ServerNavigatorOperator explorer = ServerNavigatorOperator
322:                        .showNavigatorOperator();
323:                explorer.makeComponentVisible();
324:                JTreeOperator tree = explorer.getTree();
325:
326:                // Need to refresh J2EE AppServer node
327:                explorer.pushPopup(tree, serverPath, "Refresh");
328:
329:                // Increase timeout for tree to redisplay after refresh
330:                tree.getTimeouts().setTimeout(
331:                        "JTreeOperator.WaitNodeExpandedTimeout", 60000);
332:                tree.getTimeouts().setTimeout(
333:                        "JTreeOperator.WaitNextNodeTimeout", 60000);
334:                tree.getTimeouts().setTimeout(
335:                        "JTreeOperator.WaitNodeVisibleTimeout", 60000);
336:
337:                // Get treepath of the parent node of Deployed components
338:                //recreate operator (just in case - to avoid caching)
339:                JTreeOperator oldTree = tree;
340:                tree = new JTreeOperator((JTree) tree.getSource());
341:                tree.copyEnvironment(oldTree);
342:                //do it two times 'cause refresh is delayed.
343:                TreePath deployedComps;
344:
345:                try {
346:                    deployedComps = tree.findPath(serverPath
347:                            + "|Deployed Components");
348:                } catch (TimeoutExpiredException e) {
349:                    deployedComps = tree.findPath(serverPath
350:                            + "|Deployed Components");
351:                }
352:
353:                // Expand the SN to the Deployed Components node
354:                explorer.getTree().selectPath(deployedComps);
355:                explorer.getTree().expandPath(deployedComps);
356:
357:                Util.wait(1000);
358:                new QueueTool().waitEmpty(100);
359:
360:                // Get a TreePath array of the deployed components
361:                TreePath[] aDeployedComps = tree.getChildPaths(deployedComps);
362:
363:                boolean undeployed = true;
364:                // Search for a project matching prj if matches then undeploy
365:                for (int i = 0; i < aDeployedComps.length; i++) {
366:
367:                    // Get the index (position) of the project in the TreePath
368:                    String prjNode = aDeployedComps[i].getLastPathComponent()
369:                            .toString();
370:                    if (parse)
371:                        prjNode = prjNode.substring(0, 3);
372:
373:                    JemmyProperties.getCurrentOutput().printLine(
374:                            aDeployedComps[i].toString());
375:                    JemmyProperties.getCurrentOutput()
376:                            .printLine(
377:                                    aDeployedComps[i].getLastPathComponent()
378:                                            .toString());
379:
380:                    if (prjNode.equals("/" + prj)) {
381:                        Util.wait(1000);
382:                        undeployed = false;
383:                        new QueueTool().waitEmpty(100);
384:                    }
385:                } // end for
386:
387:                return undeployed;
388:            }
389:
390:            /**
391:             * Removes a resource from an application server.
392:             * @param resource a name of resource (tree node)
393:             */
394:            public static void deleteResource(String resource) {
395:
396:                System.out.println("Started!");
397:
398:                String serverPath = null;
399:                String pePath = "Deployment Server";
400:                TreePath resourcePath = null;
401:                String defaultServer = null;
402:
403:                serverPath = pePath;
404:                serverPath = "Deployment Server";
405:
406:                // Select the Server Navigator and set the JTreeOperator   
407:                new QueueTool().waitEmpty(100);
408:                ServerNavigatorOperator explorer = ServerNavigatorOperator
409:                        .showNavigatorOperator();
410:                explorer.makeComponentVisible();
411:                JTreeOperator tree = explorer.getTree();
412:
413:                // Need to refresh J2EE AppServer node
414:                explorer.pushPopup(tree, serverPath, "Refresh");
415:
416:                // Increase timeout for tree to redisplay after refresh
417:                tree.getTimeouts().setTimeout(
418:                        "JTreeOperator.WaitNodeExpandedTimeout", 60000);
419:                tree.getTimeouts().setTimeout(
420:                        "JTreeOperator.WaitNextNodeTimeout", 60000);
421:                tree.getTimeouts().setTimeout(
422:                        "JTreeOperator.WaitNodeVisibleTimeout", 60000);
423:
424:                // Get treepath of the parent node of Deployed components
425:                //recreate operator (just in case - to avoid caching)
426:                JTreeOperator oldTree = tree;
427:                tree = new JTreeOperator((JTree) tree.getSource());
428:                tree.copyEnvironment(oldTree);
429:                //do it two times 'cause refresh is delayed.
430:
431:                try {
432:                    explorer.makeComponentVisible();
433:                    TestUtils.wait(500);
434:                    resourcePath = tree.findPath(serverPath + "|Resources");
435:                } catch (TimeoutExpiredException e) {
436:                    explorer.makeComponentVisible();
437:                    TestUtils.wait(500);
438:                    resourcePath = tree.findPath(serverPath + "|Resources");
439:                }
440:
441:                TestUtils.wait(500);
442:                // Expand the SN to the Deployed Components node
443:                explorer.getTree().selectPath(resourcePath);
444:                explorer.getTree().expandPath(resourcePath);
445:
446:                try {
447:                    Thread.sleep(1000);
448:                } catch (Exception e) {
449:                }
450:                new QueueTool().waitEmpty(100);
451:
452:                // Get a TreePath array of the deployed components
453:                TreePath[] aResources = tree.getChildPaths(resourcePath);
454:
455:                // Search for a project matching prj if matches then undeploy
456:                for (int i = 0; i < aResources.length; i++) {
457:                    // Get the index (position) of the project in the TreePath
458:                    String resNode = aResources[i].getLastPathComponent()
459:                            .toString();
460:
461:                    JemmyProperties.getCurrentOutput().printLine(
462:                            aResources[i].toString());
463:                    JemmyProperties.getCurrentOutput().printLine(
464:                            aResources[i].getLastPathComponent().toString());
465:
466:                    if (resNode.equals(resource)) {
467:                        Util.wait(1000);
468:                        new QueueTool().waitEmpty(100);
469:                        //Remove resource
470:                        explorer.pushPopup(tree, serverPath + "|Resources|"
471:                                + resource, "Delete");
472:                        new QueueTool().waitEmpty(100);
473:                    }
474:                } // end for
475:            }
476:
477:            /** 
478:             * Stops an application server.
479:             * @param server a name of an application server (name of tree node)
480:             */
481:            public static void stopServer(String server) {
482:                // Select the Runtime and set the JTreeOperator
483:                new QueueTool().waitEmpty(100);
484:                ServerNavigatorOperator explorer = ServerNavigatorOperator
485:                        .showNavigatorOperator();
486:                TestUtils.wait(2000);
487:                JTreeOperator tree = explorer.getTree();
488:                TestUtils.wait(1000);
489:
490:                // Select the requested server node
491:                tree.selectPath(tree.findPath(STR_SERVERS_PATH + server));
492:                TestUtils.wait(5000);
493:                // open context menu on the requested server node
494:                new QueueTool().waitEmpty(100);
495:                tree.callPopupOnPath(tree.findPath(STR_SERVERS_PATH + server));
496:                TestUtils.wait(500);
497:                JPopupMenuOperator snpm = new JPopupMenuOperator();
498:                TestUtils.wait(1000);
499:                if (!(new JMenuItemOperator(snpm, STR_MENU_ITEM_STOP)
500:                        .isEnabled()))
501:                    tree.pushKey(KeyEvent.VK_ESCAPE);
502:                else {
503:                    JLabelOperator jlo = new JLabelOperator(Util
504:                            .getMainWindow(), 1);
505:                    new JMenuItemOperator(snpm, STR_MENU_ITEM_STOP).push();
506:                    while (jlo.getText() == null
507:                            || !jlo.getText().equals(STR_SERVER_STOP + server)) {
508:                        jlo = new JLabelOperator(Util.getMainWindow(), 1);
509:                        System.out.println("label in first cycle = "
510:                                + jlo.getText());
511:                        TestUtils.wait(1000);
512:                    }
513:                    while (jlo.getText() != null
514:                            && jlo.getText().equals(STR_SERVER_STOP + server)) {
515:                        jlo = new JLabelOperator(Util.getMainWindow(), 1);
516:                        TestUtils.wait(1000);
517:                    }
518:                    TestUtils.wait(1000);
519:                }
520:                new QueueTool().waitEmpty(100);
521:                TestUtils.wait(5000);
522:            }
523:
524:            /** 
525:             * Checks if an application server is started or not.
526:             * @param server a name of an application server (name of tree node)
527:             * @return true - server is running, false - otherwise.
528:             */
529:            public static boolean isServerStarted(String server)
530:                    throws Exception {
531:                String serverPath = null;
532:                String pePath = "Deployment Server";
533:                String deploymentPath = null;
534:
535:                // Select the Server Navigator and set the JTreeOperator
536:                new QueueTool().waitEmpty(100);
537:                ServerNavigatorOperator explorer = ServerNavigatorOperator
538:                        .showNavigatorOperator();
539:                explorer.makeComponentVisible();
540:                JTreeOperator tree = explorer.getTree();
541:
542:                // Sleep 4 secs to make sure Server Navigator is in focus
543:                Util.wait(1000);
544:
545:                serverPath = pePath;
546:
547:                // Select the requested server node
548:                TreePath serverNode = tree.findPath(serverPath);
549:                explorer.getTree().selectPath(serverNode);
550:                explorer.getTree().expandPath(serverNode);
551:                TreePath serverSubNode = tree.findPath(serverPath);
552:                explorer.getTree().selectPath(serverSubNode);
553:
554:                // open context menu on the requested server node
555:                new QueueTool().waitEmpty(100);
556:
557:                explorer
558:                        .pushPopup(
559:                                tree,
560:                                serverPath,
561:                                Bundle
562:                                        .getStringTrimmed(
563:                                                "org.netbeans.modules.j2ee.deployment.impl.ui.actions.Bundle",
564:                                                "LBL_StartStopServer"));
565:                JDialogOperator serverStatusDialog = new JDialogOperator(
566:                        "Server Status");
567:                //  "Server Status - deployer:Sun:AppServer::localhost:14848");
568:                new JCheckBoxOperator(
569:                        serverStatusDialog,
570:                        Bundle
571:                                .getStringTrimmed(
572:                                        "org.netbeans.modules.j2ee.deployment.impl.ui.Bundle",
573:                                        "LBL_Close_When_Finished"))
574:                        .changeSelection(true);
575:                final JButtonOperator buttonStart = new JButtonOperator(
576:                        serverStatusDialog, "Start Server");
577:                final JButtonOperator buttonStop = new JButtonOperator(
578:                        serverStatusDialog, "Stop Server");
579:
580:                new Waiter(new Waitable() {
581:                    public Object actionProduced(Object obj) {
582:                        return (((buttonStart != null && buttonStart
583:                                .isEnabled()) || (buttonStop != null && buttonStop
584:                                .isEnabled())) ? this  : null);
585:                    }
586:
587:                    public String getDescription() {
588:                        return "One of Start/Stop buttons to enable";
589:                    }
590:                }).waitAction(null);
591:
592:                boolean started = !((buttonStart != null) && (buttonStart
593:                        .isEnabled()));
594:
595:                serverStatusDialog.close();
596:                serverStatusDialog.dispose();
597:
598:                new QueueTool().waitEmpty(100);
599:                return started;
600:            }
601:
602:            /** 
603:             * Starts an application server.
604:             * @param server a name of an application server (name of tree node)
605:             */
606:            public static void startServer(String server) throws Exception {
607:                // Select the Runtime and set the JTreeOperator
608:                new QueueTool().waitEmpty(100);
609:                ServerNavigatorOperator explorer = ServerNavigatorOperator
610:                        .showNavigatorOperator();
611:                TestUtils.wait(2000);
612:                JTreeOperator tree = explorer.getTree();
613:                TestUtils.wait(1000);
614:
615:                // Select the requested server node
616:                tree.selectPath(tree.findPath(STR_SERVERS_PATH + server));
617:                TestUtils.wait(5000);
618:                // open context menu on the requested server node
619:                new QueueTool().waitEmpty(100);
620:                tree.callPopupOnPath(tree.findPath(STR_SERVERS_PATH + server));
621:                TestUtils.wait(500);
622:                JPopupMenuOperator snpm = new JPopupMenuOperator();
623:                TestUtils.wait(1000);
624:                if (!(new JMenuItemOperator(snpm, STR_MENU_ITEM_START)
625:                        .isEnabled()))
626:                    tree.pushKey(KeyEvent.VK_ESCAPE);
627:                else {
628:                    JLabelOperator jlo = new JLabelOperator(Util
629:                            .getMainWindow(), 1);
630:                    new JMenuItemOperator(snpm, STR_MENU_ITEM_START).push();
631:                    while (jlo.getText() == null
632:                            || !jlo.getText().equals(STR_SERVER_START + server)) {
633:                        jlo = new JLabelOperator(Util.getMainWindow(), 1);
634:                        System.out.println("label in first cycle = "
635:                                + jlo.getText());
636:                        TestUtils.wait(1000);
637:                    }
638:                    while (jlo.getText() != null
639:                            && jlo.getText().equals(STR_SERVER_START + server)) {
640:                        jlo = new JLabelOperator(Util.getMainWindow(), 1);
641:                        TestUtils.wait(1000);
642:                    }
643:                    TestUtils.wait(1000);
644:                }
645:                new QueueTool().waitEmpty(100);
646:                TestUtils.wait(5000);
647:            }
648:
649:            /**
650:             * Adds a deployment target.
651:             * @param DTDescriptor object DeploymentTargetDescriptor, describing
652:             * properties of deployment target
653:             */
654:            public static void addDeploymentTarget(
655:                    DeploymentTargetDescriptor DTDescriptor) {
656:                Hashtable properties = (Hashtable) DTDescriptor.getProperties();
657:
658:                String serverType = properties.get(
659:                        DeploymentTargetDescriptor.SERVER_TYPE_KEY).toString();
660:
661:                //log("Open Server manager");
662:                ActionNoBlock srv = new ActionNoBlock(
663:                        STR_MENU_ITEM_SERVER_MANAGER, "", "");
664:                srv.performMenu();
665:                TestUtils.wait(500);
666:
667:                //log("Find Server manager dialog");
668:                NbDialogOperator serverManager = new NbDialogOperator(
669:                        STR_DIALOG_TITLE_SERVER_MANAGER);
670:
671:                // Is server in list?
672:                // We want to use here public API
673:                JTreeOperator jto = new JTreeOperator(serverManager);
674:                Object[] treeNodes = jto.getChildren(jto.getRoot());
675:                int length = treeNodes.length;
676:                String addServerName = properties.get(
677:                        DeploymentTargetDescriptor.NAME_KEY + serverType)
678:                        .toString();
679:                for (int i = 0; i < length; i++) {
680:                    String currentServerName = treeNodes[i].toString();
681:                    if (currentServerName.equals(addServerName)) {
682:                        //log("press close for server manager");
683:                        JButtonOperator close = new JButtonOperator(
684:                                serverManager, STR_BUTTON_TITLE_CLOSE);
685:                        close.pushNoBlock();
686:                        TestUtils.wait(500);
687:                        return;
688:                    }
689:                }
690:
691:                //log("Press add server button");
692:                JButtonOperator addServer = new JButtonOperator(serverManager,
693:                        STR_BUTTON_TITLE_ADD_SERVER);
694:                addServer.pushNoBlock();
695:                TestUtils.wait(500);
696:
697:                //log("locate server instance wizard");
698:                WizardOperator serverInstance = new WizardOperator(
699:                        STR_WIZARD_TITLE_ADD_SERVER);
700:
701:                //log("Chose Server");
702:                //JComboBoxOperator cbServerType = new JComboBoxOperator(serverInstance);
703:                //cbServerType.selectItem(serverType);
704:                JListOperator jlo = new JListOperator(serverInstance, 1);
705:                jlo.selectItem(serverType);
706:                TestUtils.wait(500);
707:
708:                //log("Enter Name");
709:                JTextFieldOperator tfName = new JTextFieldOperator(
710:                        serverInstance);
711:                tfName.setText(properties.get(
712:                        DeploymentTargetDescriptor.NAME_KEY + serverType)
713:                        .toString());
714:                TestUtils.wait(500);
715:
716:                //log("Go to next wizard page");
717:                serverInstance.next();
718:                TestUtils.wait(500);
719:
720:                //log("Set location");
721:                String projectPath = properties.get(
722:                        DeploymentTargetDescriptor.PATH_KEY + serverType)
723:                        .toString();
724:                JTextFieldOperator fileName;
725:                if (serverType.equals(STR_NAME_TOMCAT50)
726:                        || serverType.equals(STR_NAME_TOMCAT55)
727:                        || serverType.equals(STR_NAME_TOMCAT60))
728:                    fileName = new JTextFieldOperator(serverInstance, 1);
729:                else
730:                    fileName = new JTextFieldOperator(serverInstance, 0);
731:                fileName.setText(projectPath);
732:
733:                TestUtils.wait(5000);
734:
735:                if (serverType.equals(STR_NAME_WEBLOGIC))
736:                    addWebLogic(serverType, properties, serverInstance);
737:                if (serverType.equals(STR_NAME_JBOSS))
738:                    addJBoss(serverType, properties, serverInstance);
739:                if (serverType.equals(STR_NAME_APPSERVER)
740:                        || serverType.equals(STR_NAME_GLASSFISH_V1)
741:                        || serverType.equals(STR_NAME_GLASSFISH_V2))
742:                    addAppServer(serverType, properties, serverInstance);
743:                if (serverType.equals(STR_NAME_TOMCAT50)
744:                        || serverType.equals(STR_NAME_TOMCAT55)
745:                        || serverType.equals(STR_NAME_TOMCAT60))
746:                    addTomcat(serverType, properties, serverInstance);
747:
748:                //log("finish wizard");
749:                serverInstance.finish();
750:                TestUtils.wait(500);
751:
752:                //log("press close for server manager");
753:                JButtonOperator close = new JButtonOperator(serverManager,
754:                        STR_BUTTON_TITLE_CLOSE);
755:                close.pushNoBlock();
756:                TestUtils.wait(5000);
757:            }
758:
759:            private static void addWebLogic(String serverType,
760:                    Hashtable properties, WizardOperator serverInstance) {
761:                //workaround
762:                serverInstance.pushKey(KeyEvent.VK_LEFT);
763:
764:                //log("Go to next wizard page");
765:                serverInstance.next();
766:                TestUtils.wait(500);
767:
768:                //log("Choose Instance");
769:                JComboBoxOperator cbInstance = new JComboBoxOperator(
770:                        serverInstance);
771:                cbInstance.selectItem(properties.get(
772:                        DeploymentTargetDescriptor.DOMAIN_KEY + serverType)
773:                        .toString());
774:                TestUtils.wait(500);
775:
776:                //log("Enter Login");
777:                JTextFieldOperator tfLogin = new JTextFieldOperator(
778:                        serverInstance, 3);
779:                tfLogin.setText(properties.get(
780:                        DeploymentTargetDescriptor.LOGIN_KEY + serverType)
781:                        .toString());
782:                TestUtils.wait(500);
783:
784:                //log("Enter Password");
785:                JTextFieldOperator tfPassword = new JTextFieldOperator(
786:                        serverInstance, 4);
787:                tfPassword.setText(properties.get(
788:                        DeploymentTargetDescriptor.PASSWORD_KEY + serverType)
789:                        .toString());
790:                TestUtils.wait(500);
791:            }
792:
793:            private static void addJBoss(String serverType,
794:                    Hashtable properties, WizardOperator serverInstance) {
795:                //log("Go to next wizard page");
796:                serverInstance.next();
797:                TestUtils.wait(500);
798:                //log("Wizard step = " + serverInstance.stepsGetSelectedIndex() + ": " + serverInstance.stepsGetSelectedValue());
799:
800:                //log("Choose Instance");
801:                JComboBoxOperator cbInstance = new JComboBoxOperator(
802:                        serverInstance);
803:                cbInstance.selectItem(properties.get(
804:                        DeploymentTargetDescriptor.DOMAIN_KEY + serverType)
805:                        .toString());
806:                TestUtils.wait(500);
807:            }
808:
809:            private static void addAppServer(String serverType,
810:                    Hashtable properties, WizardOperator serverInstance) {
811:                //log("Choose Instance");
812:                JComboBoxOperator cbInstance = new JComboBoxOperator(
813:                        serverInstance);
814:                //        cbInstance.selectItem(properties.get(PROP_PREFIX_DOMAIN + serverType).toString());
815:                TestUtils.wait(500);
816:
817:                //log("Go to next wizard page");
818:                serverInstance.next();
819:                TestUtils.wait(2000);
820:
821:                //log("Enter Login");
822:                JTextFieldOperator tfLogin = new JTextFieldOperator(
823:                        serverInstance, 0);
824:                tfLogin.setText(properties.get(
825:                        DeploymentTargetDescriptor.LOGIN_KEY + serverType)
826:                        .toString());
827:                TestUtils.wait(500);
828:
829:                //log("Enter Password");
830:                JTextFieldOperator tfPassword = new JTextFieldOperator(
831:                        serverInstance, 1);
832:                tfPassword.setText(properties.get(
833:                        DeploymentTargetDescriptor.PASSWORD_KEY + serverType)
834:                        .toString());
835:                TestUtils.wait(500);
836:            }
837:
838:            private static void addTomcat(String serverType,
839:                    Hashtable properties, WizardOperator serverInstance) {
840:                //log("Enter Login");
841:                JTextFieldOperator tfLogin = new JTextFieldOperator(
842:                        serverInstance, 3);
843:                tfLogin.setText(properties.get(
844:                        DeploymentTargetDescriptor.LOGIN_KEY + serverType)
845:                        .toString());
846:                TestUtils.wait(500);
847:
848:                //log("Enter Password");
849:                JTextFieldOperator tfPassword = new JTextFieldOperator(
850:                        serverInstance, 2);
851:                tfPassword.setText(properties.get(
852:                        DeploymentTargetDescriptor.PASSWORD_KEY + serverType)
853:                        .toString());
854:                TestUtils.wait(500);
855:            }
856:
857:            /** 
858:             * Adds an URL of Web Service
859:             * @param url URL of a Web Service WSDL file
860:             * @return name of added Web Service
861:             */
862:            public String addWebServiceUrl(String url) {
863:                new WebServicesNode(this .getTree(), "Web Services")
864:                        .addWebService();
865:                AddWebServiceOperator addWs = new AddWebServiceOperator();
866:                //if (addWs.isProxySet()) addWs.clearProxy();
867:                String wsName = addWs.addWebService(url);
868:                addWs.btAdd().pushNoBlock();
869:                TestUtils.wait(1000);
870:                //new JButtonOperator(new JDialogOperator("Configure web servcie methods"), "OK").doClick();
871:                return wsName;
872:            }
873:
874:            /** 
875:             * Adds an URL of Web Service
876:             * @param url URL of a Web Service WSDL file
877:             * @param proxyHost a proxy server host
878:             * @param proxyPort a proxy server port
879:             * @return name of added Web Service
880:             */
881:            public String addWebServiceUrl(String url, String proxyHost,
882:                    String proxyPort) {
883:                new WebServicesNode(this .getTree(), "Web Services")
884:                        .addWebService();
885:                AddWebServiceOperator addWs = new AddWebServiceOperator();
886:                addWs.setProxy(proxyHost, proxyPort);
887:                String wsName = addWs.addWebService(url);
888:                addWs.btAdd().pushNoBlock();
889:                TestUtils.wait(1000);
890:                //new JButtonOperator(new JDialogOperator("Configure web servcie methods"), "OK").doClick();
891:                return wsName;
892:            }
893:
894:            /** 
895:             * Adds a Web Service by using a local file.
896:             * @param wsName a local WSDL file
897:             * @return name of added Web Service
898:             */
899:            public String addWebServiceLocal(String wsName) {
900:                new WebServicesNode(this .getTree(), "Web Services")
901:                        .addWebService();
902:                AddWebServiceOperator addWs = new AddWebServiceOperator();
903:                String wsDisplayName = addWs.addLocalWebService(wsName);
904:                addWs.btAdd().pushNoBlock();
905:                TestUtils.wait(1000);
906:                //new JButtonOperator(new JDialogOperator("Configure web servcie methods"), "OK").doClick();
907:                return wsDisplayName;
908:
909:            }
910:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.