Source Code Cross Referenced for AcceptanceTest.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » modules » visualweb » test » components » action » imagehyperlink » 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.test.components.action.imagehyperlink 
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.test.components.action.imagehyperlink;
043:
044:        import junit.framework.Test;
045:        import junit.framework.TestSuite;
046:
047:        import java.io.File;
048:        import java.awt.*;
049:        import java.awt.event.KeyEvent;
050:        import java.io.IOException;
051:
052:        import org.netbeans.modules.visualweb.gravy.*;
053:        import org.netbeans.modules.visualweb.gravy.ProjectNavigatorOperator;
054:        import org.netbeans.modules.visualweb.gravy.dataconnectivity.ServerNavigatorOperator;
055:        import org.netbeans.modules.visualweb.gravy.toolbox.PaletteContainerOperator;
056:        import org.netbeans.modules.visualweb.gravy.designer.DesignerPaneOperator;
057:        import org.netbeans.modules.visualweb.gravy.properties.SheetTableOperator;
058:        import org.netbeans.modules.visualweb.gravy.navigation.*;
059:        import org.netbeans.modules.visualweb.gravy.dataconnectivity.ServerNavigatorOperator;
060:        import org.netbeans.jemmy.operators.*;
061:        import org.netbeans.modules.visualweb.test.components.util.ComponentUtils;
062:        import org.netbeans.jellytools.OutputOperator;
063:        import org.netbeans.jemmy.Waitable;
064:        import org.netbeans.jemmy.Waiter;
065:        import org.netbeans.jemmy.QueueTool;
066:        import org.netbeans.jemmy.operators.JTreeOperator;
067:
068:        /**
069:         * @author Sherry Zhou (sherry.zhou@sun.com)
070:         */
071:        public class AcceptanceTest extends RaveTestCase {
072:
073:            public String _bundle = "org.netbeans.modules.visualweb.test.components.Component";
074:            public String _projectServer = Bundle.getStringTrimmed(_bundle,
075:                    "projectServer");
076:            public String _logFileLocation = Bundle.getStringTrimmed(_bundle,
077:                    "logFile");
078:            public String _logFile = System.getProperty("xtest.workdir")
079:                    + File.separator + _logFileLocation;
080:            public String _exception = Bundle.getStringTrimmed(_bundle,
081:                    "Exception");
082:            public String _close = Bundle.getStringTrimmed(_bundle, "close");
083:            public String _run = Bundle.getStringTrimmed(_bundle, "Run");
084:            public String _buildSuccess = Bundle.getStringTrimmed(_bundle,
085:                    "buildSuccess");
086:            public String _true = Bundle.getStringTrimmed(_bundle, "true");
087:
088:            public String _projectName = "ImageHyperlinkAcceptanceTest";
089:
090:            public String imageDir = ComponentUtils.getDataDir()
091:                    + File.separator + "action" + File.separator;
092:            String image1 = imageDir + "imagehyperlink_component.png";
093:            String image2 = imageDir + "orchid1.JPG";
094:            public String _requestPrefix = "";
095:            public static int xImageHyperlink = 50;
096:            public static int yImageHyperlink1 = 50;
097:            public static int yImageHyperlink2 = 125;
098:            public static int yImageHyperlink3 = 225;
099:            public String _page1 = "Page1";
100:            public String _page2 = "Page2";
101:
102:            //undeployment
103:            public String _undeploy = Bundle.getStringTrimmed(_bundle,
104:                    "undeploy");
105:            public String _refresh = Bundle
106:                    .getStringTrimmed(_bundle, "refresh");
107:            public String _serverPath = Bundle.getStringTrimmed(_bundle,
108:                    "serverPath");
109:            public String _deploymentPath = Bundle.getStringTrimmed(_bundle,
110:                    "deploymentPathGlassfish");
111:            public String _separator = Bundle.getStringTrimmed(_bundle,
112:                    "separator");
113:            public String _reformatCode = Bundle.getStringTrimmed(_bundle,
114:                    "reformatCode");
115:
116:            public static DesignerPaneOperator designer;
117:            public static SheetTableOperator sheet;
118:            public static ProjectNavigatorOperator prjNav = ProjectNavigatorOperator
119:                    .showProjectNavigator();
120:            public static ServerNavigatorOperator explorer;
121:
122:            public AcceptanceTest(String testName) {
123:                super (testName);
124:            }
125:
126:            public static Test suite() {
127:                TestSuite suite = new TestSuite();
128:                suite.addTest(new AcceptanceTest("testCreateProject"));
129:                suite.addTest(new AcceptanceTest("testAddImageHyperlink3"));
130:                suite.addTest(new AcceptanceTest("testAddImageHyperlink1"));
131:                suite.addTest(new AcceptanceTest("testAddImageHyperlink2"));
132:                suite.addTest(new AcceptanceTest("testDeploy"));
133:                suite.addTest(new AcceptanceTest("testCloseProject"));
134:                suite.addTest(new AcceptanceTest("testUndeploy"));
135:                suite.addTest(new AcceptanceTest("testCheckIDELog"));
136:                return suite;
137:            }
138:
139:            /** method called before each testcase
140:             */
141:            protected void setUp() {
142:                System.out.println("########  " + getName() + "  #######");
143:            }
144:
145:            /** method called after each testcase
146:             */
147:            protected void tearDown() {
148:                System.out.println("########  " + getName()
149:                        + " Finished #######");
150:            }
151:
152:            /*
153:             * Start PE. Delete PointBase travel resource
154:             */
155:            private void testStartup() {
156:                //Start PE is it is not started yet
157:                ServerNavigatorOperator se = new ServerNavigatorOperator();
158:                // Skip next 2 steps if running on Mac as Jemmy's call popup issue
159:                if (!System.getProperty("os.name").equals("Mac OS X")) {
160:                    //Start PE is it is not started yet
161:                    try {
162:                        se.startServer("J2EE");
163:                    } catch (Exception e) {
164:                    }
165:                    // Delete pb travel resource if it exists
166:                    se.deleteResource("jdbc/Travel");
167:                }
168:            }
169:
170:            /*
171:             *   Create new project
172:             *   And add property val to SessionBean1.java
173:             */
174:            public void testCreateProject() {
175:                startTest();
176:                log("**Creating Project");
177:                //Create Project
178:                try {
179:                    ComponentUtils.createNewProject(_projectName);
180:                } catch (Exception e) {
181:                    log(">> Project Creation Failed");
182:                    e.printStackTrace();
183:                    log(e.toString());
184:                    fail();
185:                }
186:                log("**Done");
187:                endTest();
188:            }
189:
190:            /*
191:             *  . Add 1st image hyperlink component. Change its text  property sheet as "Scheduler".
192:             *  . Clcik ... button of its icon property. Choose SCHEDULAR_POPUP from the list.
193:             *  . Set its tooltip property to " Launch Machine Scheduler  in a new window", and set New Window for target property
194:             *  . Double click the image hyperlink in designer, add code in hyperlink1_action() :
195:             *   hyperlink1.setUrl("http://bsqe-giant.sfbay.sun.com/RaveHWScheduler/index.cgi");
196:             */
197:
198:            public void testAddImageHyperlink1() {
199:                startTest();
200:                designer = new DesignerPaneOperator(RaveWindowOperator
201:                        .getDefaultRave());
202:
203:                log("Add first ImageHyperlink component");
204:                PaletteContainerOperator palette = new PaletteContainerOperator(
205:                        Bundle.getStringTrimmed(_bundle, "basicPalette"));
206:                Util.wait(5000);
207:                //      palette.addComponent(Bundle.getStringTrimmed(_bundle, "basicImageHyperlink"), designer, new Point(xImageHyperlink, yImageHyperlink1));
208:                palette.dndPaletteComponent(Bundle.getStringTrimmed(_bundle,
209:                        "basicImageHyperlink"), designer, new Point(
210:                        xImageHyperlink, yImageHyperlink1));
211:
212:                log("Set text, url, toolTips, ans target properties ");
213:                sheet = new SheetTableOperator();
214:                ComponentUtils.setProperty(sheet, Bundle.getStringTrimmed(
215:                        _bundle, "propertyText"), "Scheduler");
216:                sheet
217:                        .setButtonValue(Bundle.getStringTrimmed(_bundle,
218:                                "propertyUrl"),
219:                                "http://bsqe-giant.sfbay.sun.com/RaveHWScheduler/index.cgi");
220:                ComponentUtils.setProperty(sheet, Bundle.getStringTrimmed(
221:                        _bundle, "propertyToolTip"),
222:                        "Launch Machine Scheduler  in a new window ");
223:                sheet.setComboBoxValue(Bundle.getStringTrimmed(_bundle,
224:                        "propertyTarget"), Bundle.getStringTrimmed(_bundle,
225:                        "propertyTargetNewWindow"));
226:
227:                // setIcon(); Not working so far
228:                Util.wait(1000);
229:
230:                log(" Add code in init()");
231:                designer.clickMouse(1, 1);
232:                TestUtils.wait(3000);
233:                designer.clickMouse(1, 1, 2);
234:                TestUtils.wait(3000);
235:
236:                JEditorPaneOperator editor = new JEditorPaneOperator(
237:                        RaveWindowOperator.getDefaultRave(), "public class "
238:                                + _page1);
239:                editor.requestFocus();
240:                editor.setText("log(\"Button action performed\");\n");
241:
242:                // Open context menuitem, Reformat code
243:                Util.wait(1000);
244:                editor.clickForPopup(300, 300);
245:                new JPopupMenuOperator().pushMenu(_reformatCode);
246:                TestUtils.wait(1000);
247:                log("Java Editor Dump:");
248:                log(editor.getText());
249:                // Switch to design panel
250:                designer.makeComponentVisible();
251:
252:                Util.wait(2000);
253:                Util.saveAllAPICall();
254:                Util.wait(2000);
255:                endTest();
256:            }
257:
258:            /*
259:             *  Add 2nd imagehyperlink component.
260:             *  Set its text, url and imageURL properties
261:             */
262:            public void testAddImageHyperlink2() {
263:                startTest();
264:                designer = new DesignerPaneOperator(RaveWindowOperator
265:                        .getDefaultRave());
266:                log("Add second imagehyperlink property");
267:                PaletteContainerOperator palette = new PaletteContainerOperator(
268:                        Bundle.getStringTrimmed(_bundle, "basicPalette"));
269:                Util.wait(5000);
270:                //        palette.addComponent(Bundle.getStringTrimmed(_bundle, "basicImageHyperlink"), designer, new Point(xImageHyperlink, yImageHyperlink2));
271:                palette.dndPaletteComponent(Bundle.getStringTrimmed(_bundle,
272:                        "basicImageHyperlink"), designer, new Point(
273:                        xImageHyperlink, yImageHyperlink2));
274:                Util.wait(1000);
275:
276:                log("Set text, url properties");
277:                sheet = new SheetTableOperator();
278:                Util.wait(1000);
279:                ComponentUtils.setProperty(sheet, Bundle.getStringTrimmed(
280:                        _bundle, "propertyText"), "");
281:                sheet.setButtonValue(Bundle.getStringTrimmed(_bundle,
282:                        "propertyUrl"), "http://www.yahoo.com"); // setProperty("url", "http://www.yahoo.com");
283:                Util.wait(2000);
284:                log(image1);
285:                sheet.setImage("imageHyperlink3:Image Hyperlink", Bundle
286:                        .getStringTrimmed(_bundle, "propertyImageURL"), image1);
287:                Util.wait(2000);
288:
289:                Util.saveAllAPICall();
290:                Util.wait(2000);
291:                endTest();
292:            }
293:
294:            /*
295:             *  . Add 3rd image hyperlink component. Set its image from designer. Change its width/length 50/40.
296:             *  . Change its  text to Page2. Set the border property to 2 . Set its text position to left.
297:             *  . Create  Page2.jsp.
298:             *  . Link this ImageHyperlink to Page2.jsp
299:             */
300:            public void testAddImageHyperlink3() {
301:
302:                startTest();
303:                designer = new DesignerPaneOperator(RaveWindowOperator
304:                        .getDefaultRave());
305:                Util.wait(5000);
306:                log("Add third imagehyperlink component");
307:                PaletteContainerOperator palette = new PaletteContainerOperator(
308:                        Bundle.getStringTrimmed(_bundle, "basicPalette"));
309:                Util.wait(5000);
310:                //        palette.addComponent(Bundle.getStringTrimmed(_bundle, "basicImageHyperlink"), designer, new Point(xImageHyperlink, yImageHyperlink3));
311:                palette.dndPaletteComponent(Bundle.getStringTrimmed(_bundle,
312:                        "basicImageHyperlink"), designer, new Point(
313:                        xImageHyperlink, yImageHyperlink3));
314:                Util.wait(5000);
315:
316:                log("Set its width, height, border, text properties");
317:                sheet = new SheetTableOperator();
318:                Util.wait(5000);
319:                ComponentUtils.setProperty(sheet, Bundle.getStringTrimmed(
320:                        _bundle, "propertyText"), "Page 2");
321:                Util.wait(2000);
322:                log(image2);
323:                designer.setImage(xImageHyperlink + 5, yImageHyperlink3 + 5,
324:                        image2);
325:                ComponentUtils.setProperty(sheet, Bundle.getStringTrimmed(
326:                        _bundle, "propertyWidth"), "50");
327:                ComponentUtils.setProperty(sheet, Bundle.getStringTrimmed(
328:                        _bundle, "propertyHeight"), "40");
329:                ComponentUtils.setProperty(sheet, Bundle.getStringTrimmed(
330:                        _bundle, "propertyBorder"), "2");
331:                sheet.setComboBoxValue(Bundle.getStringTrimmed(_bundle,
332:                        "propertyTextPosition"), Bundle.getStringTrimmed(
333:                        _bundle, "propertyTextPositionLeft"));
334:                Util.wait(2000);
335:
336:                //        
337:                //        log("Create second page Page2.jsp");
338:                //        prjNav.addWebPage(_projectName, _page2);
339:                //        log("Open first page");
340:                //        prjNav.openWebPage(_projectName, _page1);
341:                //        ComponentUtils.linkWebPages(designer, _page1, _page2, "next");
342:                //        
343:                Util.saveAllAPICall();
344:                Util.wait(2000);
345:                endTest();
346:            }
347:
348:            /*
349:             * Deploy application
350:             */
351:            public void testDeploy() {
352:                startTest();
353:                //need to wait responce
354:                Waiter deploymentWaiter = new Waiter(new Waitable() {
355:                    public Object actionProduced(Object output) {
356:                        String text = ((OutputOperator) output).getText();
357:                        if (text.indexOf(_buildSuccess) != -1)
358:                            return _true;
359:                        return null;
360:
361:                    }
362:
363:                    public String getDescription() {
364:                        return ("Waiting Project Deployed");
365:                    }
366:                });
367:                log("Deploy from menu");
368:                ProjectNavigatorOperator.pressPopupItemOnNode(_projectName,
369:                        _run);
370:                TestUtils.wait(2000);
371:                OutputOperator outputWindow = new OutputOperator();
372:                deploymentWaiter.getTimeouts().setTimeout("Waiter.WaitingTime",
373:                        240000);
374:                log("wait until " + _buildSuccess);
375:                try {
376:                    deploymentWaiter.waitAction(outputWindow);
377:                } catch (InterruptedException e) {
378:                    log(outputWindow.getText());
379:                    e.printStackTrace();
380:                    fail("Deployment error: " + e);
381:                }
382:                log("Deployment complete");
383:                endTest();
384:            }
385:
386:            public void testCloseProject() {
387:                startTest();
388:                Util.saveAllAPICall();
389:                new ProjectNavigatorOperator().pressPopupItemOnNode(
390:                        _projectName, Bundle.getStringTrimmed(_bundle,
391:                                "CloseProjectPopupItem"));
392:                //TestUtils.closeCurrentProject();
393:                TestUtils.wait(5000);
394:                endTest();
395:            }
396:
397:            public void linkWebPages() {
398:                designer.clickForPopup(10, 10);
399:                Util.wait(500);
400:                new JPopupMenuOperator().pushMenuNoBlock(Bundle
401:                        .getStringTrimmed(_bundle,
402:                                "Designer_Menu_PageNavigation"));
403:
404:                NavigatorOperator navigation = new NavigatorOperator();
405:                Util.wait(500);
406:                //queueTool.waitEmpty();
407:
408:                // navigation.staticLink(_page1, _page2, _page2);
409:                Util.wait(1000);
410:                //queueTool.waitEmpty();
411:
412:            }
413:
414:            /* Need to undeploy project to finish tests correctly */
415:            public void testUndeploy() {
416:                startTest();
417:                log("Initialize");
418:                explorer = ServerNavigatorOperator.showNavigatorOperator();
419:                String serverPath = _serverPath + _projectServer; //Current deployment server
420:                String deploymentPath = serverPath + _deploymentPath; //glassfish specific
421:                String applicationPath = deploymentPath + _separator
422:                        + _projectName; //project name
423:
424:                // Select the Server Navigator and set the JTreeOperator
425:                log("get explorer");
426:                new QueueTool().waitEmpty(100); //??
427:                explorer.requestFocus();
428:                JTreeOperator tree = explorer.getTree();
429:                try {
430:                    Thread.sleep(4000);
431:                } catch (Exception e) {
432:                } // Sleep 4 secs to make sure Server Navigator is in focus
433:
434:                // Need to refresh J2EE AppServer node
435:                log("refresh");
436:                explorer.pushPopup(tree, serverPath, _refresh);
437:                TestUtils.wait(1000);
438:
439:                log("refresh deployment path: " + deploymentPath);
440:                TestUtils.wait(1000);
441:                explorer.selectPath(deploymentPath);
442:                explorer.getTree().expandPath(
443:                        explorer.getTree().findPath(deploymentPath));
444:                explorer.pushPopup(tree, deploymentPath, _refresh);
445:                TestUtils.wait(1000);
446:
447:                log("undeploy Path: " + applicationPath);
448:                explorer.selectPath(applicationPath);
449:                TestUtils.wait(1000);
450:
451:                log("Push Menu Undeploy...");
452:                explorer.pushPopup(explorer.getTree(), applicationPath,
453:                        _undeploy);
454:                TestUtils.wait(5000);
455:                endTest();
456:            }
457:
458:            public void testCheckIDELog() {
459:                startTest();
460:                try {
461:                    String err = ComponentUtils.hasUnexpectedException();
462:                    String str = "";
463:                    if (!(err.equals(""))) {
464:                        assertTrue(
465:                                "Unexpected  exceptions found in message.log: "
466:                                        + err, str.equals(""));
467:                    }
468:                } catch (IOException ioe) {
469:                    ioe.printStackTrace();
470:                    fail("Failed to open message.log : " + ioe);
471:                }
472:                endTest();
473:            }
474:        }
w__w___w_.__j___a__v___a_2_s._co___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.