Source Code Cross Referenced for AcceptanceTest.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » modules » visualweb » test » components » action » hyperlink » 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.hyperlink 
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-2008 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.hyperlink;
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.toolbox.PaletteContainerOperator;
055:        import org.netbeans.modules.visualweb.gravy.designer.DesignerPaneOperator;
056:        import org.netbeans.modules.visualweb.gravy.properties.SheetTableOperator;
057:        import org.netbeans.modules.visualweb.gravy.dataconnectivity.ServerNavigatorOperator;
058:        import org.netbeans.jemmy.operators.*;
059:        import org.netbeans.modules.visualweb.test.components.util.ComponentUtils;
060:        import org.netbeans.jellytools.OutputOperator;
061:        import org.netbeans.jemmy.Waitable;
062:        import org.netbeans.jemmy.Waiter;
063:        import org.netbeans.jemmy.QueueTool;
064:        import org.netbeans.jemmy.operators.JTreeOperator;
065:
066:        /**
067:         * @author Sherry Zhou (sherry.zhou@sun.com)
068:         */
069:        public class AcceptanceTest extends RaveTestCase {
070:
071:            public String _bundle = "org.netbeans.modules.visualweb.test.components.Component";
072:            public String _projectServer = Bundle.getStringTrimmed(_bundle,
073:                    "projectServer");
074:            public String _logFileLocation = Bundle.getStringTrimmed(_bundle,
075:                    "logFile");
076:            public String _logFile = System.getProperty("xtest.workdir")
077:                    + File.separator + _logFileLocation;
078:            public String _exception = Bundle.getStringTrimmed(_bundle,
079:                    "Exception");
080:            public String _close = Bundle.getStringTrimmed(_bundle, "close");
081:
082:            public String _projectName = "HyperlinkAcceptanceTest";
083:
084:            public String _page1 = "Page1";
085:            public String _page2 = "Page2";
086:
087:            //Menu variables
088:            public String _separator = Bundle.getStringTrimmed(_bundle,
089:                    "separator");
090:            public String _propertySheet = Bundle.getStringTrimmed(_bundle,
091:                    "propertySheet");
092:            public String _reformatCode = Bundle.getStringTrimmed(_bundle,
093:                    "reformatCode");
094:
095:            public static int xHyperlink = 50;
096:            public static int yHyperlink1 = 50;
097:            public static int yHyperlink2 = 125;
098:            public static int yHyperlink3 = 200;
099:
100:            //undeployment
101:            public String _undeploy = Bundle.getStringTrimmed(_bundle,
102:                    "undeploy");
103:            public String _refresh = Bundle
104:                    .getStringTrimmed(_bundle, "refresh");
105:            public String _serverPath = Bundle.getStringTrimmed(_bundle,
106:                    "serverPath");
107:            public String _deploymentPath = Bundle.getStringTrimmed(_bundle,
108:                    "deploymentPathGlassfish");
109:
110:            public static DesignerPaneOperator designer;
111:            public static SheetTableOperator sheet;
112:            public static ProjectNavigatorOperator prjNav = ProjectNavigatorOperator
113:                    .showProjectNavigator();
114:            public static ServerNavigatorOperator explorer;
115:
116:            public String _run = Bundle.getStringTrimmed(_bundle, "Run");
117:            public String _buildSuccess = Bundle.getStringTrimmed(_bundle,
118:                    "buildSuccess");
119:            public String _true = Bundle.getStringTrimmed(_bundle, "true");
120:
121:            public AcceptanceTest(String testName) {
122:                super (testName);
123:            }
124:
125:            public static Test suite() {
126:                TestSuite suite = new TestSuite();
127:                suite.addTest(new AcceptanceTest("testCreateProject"));
128:                suite.addTest(new AcceptanceTest("testAddHyperlink1"));
129:                suite.addTest(new AcceptanceTest("testAddHyperlink2"));
130:                suite.addTest(new AcceptanceTest("testAddHyperlink3"));
131:                suite.addTest(new AcceptanceTest("testDeploy"));
132:                suite.addTest(new AcceptanceTest("testCloseProject"));
133:                suite.addTest(new AcceptanceTest("testUndeploy"));
134:                suite.addTest(new AcceptanceTest("testCheckIDELog"));
135:                return suite;
136:            }
137:
138:            /** method called before each testcase
139:             */
140:            protected void setUp() {
141:                System.out.println("########  " + getName() + "  #######");
142:            }
143:
144:            /** method called after each testcase
145:             */
146:            protected void tearDown() {
147:                System.out.println("########  " + getName()
148:                        + " Finished #######");
149:            }
150:
151:            /*
152:             * Start PE. Delete PointBase travel resource
153:             */
154:            private void testStartup() {
155:                //Start PE is it is not started yet
156:                ServerNavigatorOperator se = new ServerNavigatorOperator();
157:                // Skip next 2 steps if running on Mac as Jemmy's call popup issue
158:                if (!System.getProperty("os.name").equals("Mac OS X")) {
159:                    //Start PE is it is not started yet
160:                    try {
161:                        se.startServer("J2EE");
162:                    } catch (Exception e) {
163:                        fail(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 hyperlink component. Change its text  property sheet as "Go to Google".
192:             *  . Change its text color via style property.
193:             *  . Set its tooltip property to " Launch 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://www.google.com");
196:             */
197:
198:            public void testAddHyperlink1() {
199:                startTest();
200:                designer = new DesignerPaneOperator(RaveWindowOperator
201:                        .getDefaultRave());
202:                log("Add first hyperlink component");
203:                PaletteContainerOperator palette = new PaletteContainerOperator(
204:                        Bundle.getStringTrimmed(_bundle, "basicPalette"));
205:                Util.wait(5000);
206:                palette.dndPaletteComponent(Bundle.getStringTrimmed(_bundle,
207:                        "basicHyperlink"), designer, new Point(xHyperlink,
208:                        yHyperlink1));
209:
210:                log("Set text, toolTip, target properties");
211:                sheet = new SheetTableOperator();
212:                String GO_TO_GOOGLE = "Go to Google";
213:                ComponentUtils.setProperty(sheet, Bundle.getStringTrimmed(
214:                        _bundle, "propertyText"), GO_TO_GOOGLE);
215:                ComponentUtils.setProperty(sheet, Bundle.getStringTrimmed(
216:                        _bundle, "propertyToolTip"),
217:                        "Launch browser in a new window ");
218:                sheet.setComboBoxValue(Bundle.getStringTrimmed(_bundle,
219:                        "propertyTarget"), Bundle.getStringTrimmed(_bundle,
220:                        "propertyTargetNewWindow"));
221:                Util.wait(1000);
222:
223:                log("Set style property");
224:                setFontStyle("hyperlink1", GO_TO_GOOGLE, "serif", "36",
225:                        "fuchsia");
226:                Util.wait(5000); //setFontStyle is not blocking so need to give time to finish.
227:
228:                log("Add code to processValueChange");
229:                designer.clickMouse(xHyperlink, yHyperlink1, 2);
230:                TestUtils.wait(3000);
231:                JEditorPaneOperator editor = new JEditorPaneOperator(
232:                        RaveWindowOperator.getDefaultRave(), "public class "
233:                                + _page1);
234:
235:                editor.setVerification(false);
236:                TestUtils.wait(2000);
237:                editor.requestFocus();
238:                TestUtils.wait(2000);
239:                editor.pushKey(KeyEvent.VK_ENTER);
240:                editor
241:                        .typeText("//hyperlink1.setUrl(\"http://www.google.com\");");
242:                editor.pushKey(KeyEvent.VK_ENTER);
243:
244:                TestUtils.wait(200);
245:                editor.clickForPopup();
246:                new JPopupMenuOperator().pushMenu(_reformatCode);
247:                TestUtils.wait(200);
248:                // Switch to design panel
249:                designer.makeComponentVisible();
250:                TestUtils.wait(10000);
251:                endTest();
252:            }
253:
254:            /*
255:             *  Add 2nd Hyperlink component.
256:             *  Set its text, url properties
257:             */
258:            public void testAddHyperlink2() {
259:                startTest();
260:                designer = new DesignerPaneOperator(RaveWindowOperator
261:                        .getDefaultRave());
262:
263:                log("Add second hyperlink component");
264:                PaletteContainerOperator palette = new PaletteContainerOperator(
265:                        Bundle.getStringTrimmed(_bundle, "basicPalette"));
266:                Util.wait(1000);
267:                palette.dndPaletteComponent(Bundle.getStringTrimmed(_bundle,
268:                        "basicHyperlink"), designer, new Point(xHyperlink,
269:                        yHyperlink2));
270:
271:                log("make sure property sheet is visible"); //or it will set previous component values.
272:                Util.getMainMenu().pushMenu(_propertySheet, _separator);
273:                try {
274:                    Thread.sleep(2000);
275:                } catch (Exception e) {
276:                }
277:
278:                log("Set its text and url property");
279:                sheet = new SheetTableOperator();
280:                ComponentUtils.setProperty(sheet, Bundle.getStringTrimmed(
281:                        _bundle, "propertyText"), "Sun Java Studio Creator");
282:                // sheet.setButtonValue(Bundle.getStringTrimmed(_bundle, "propertyText"), "Sun Java Studio Creator");
283:                ComponentUtils
284:                        .setProperty(sheet, Bundle.getStringTrimmed(_bundle,
285:                                "propertyUrl"),
286:                                "http://developers.sun.com/prodtech/javatools/jscreator/");
287:                Util.wait(2000);
288:
289:                Util.saveAllAPICall();
290:                Util.wait(2000);
291:                endTest();
292:            }
293:
294:            /*
295:             *  . Add 3rd hyperlink component.
296:             *  . Change its  text to Page2.
297:             *  . Create  Page2.jsp.
298:             *  . Link this Hyperlink to Page2.jsp
299:             */
300:            public void testAddHyperlink3() {
301:                startTest();
302:                designer = new DesignerPaneOperator(RaveWindowOperator
303:                        .getDefaultRave());
304:
305:                log("Add 3rd hyperlink component");
306:                PaletteContainerOperator palette = new PaletteContainerOperator(
307:                        Bundle.getStringTrimmed(_bundle, "basicPalette"));
308:                Util.wait(2000);
309:                palette.dndPaletteComponent(Bundle.getStringTrimmed(_bundle,
310:                        "basicHyperlink"), designer, new Point(xHyperlink,
311:                        yHyperlink3));
312:
313:                log("make sure property sheet is visible"); //or it will set previous component values.
314:                Util.getMainMenu().pushMenu(_propertySheet, _separator);
315:                try {
316:                    Thread.sleep(2000);
317:                } catch (Exception e) {
318:                }
319:
320:                log("Set its text property");
321:                sheet = new SheetTableOperator();
322:                ComponentUtils.setProperty(sheet, Bundle.getStringTrimmed(
323:                        _bundle, "propertyText"), "Page 2");
324:                Util.wait(2000);
325:
326:                log("Create second page Page2.jsp");
327:                Util.saveAllAPICall();//adding page fails - takes too long, so save first.
328:                Util.wait(5000);
329:                prjNav.addWebPage(_projectName, _page2);
330:                Util.wait(8000);
331:                Util.wait(8000);
332:                Util.wait(8000);
333:                /*        
334:                 log("add label to page");
335:                 palette = new PaletteContainerOperator(Bundle.getStringTrimmed(_bundle, "basicPalette"));
336:                 palette.dndPaletteComponent(Bundle.getStringTrimmed(_bundle, "basicLabel"), designer, new Point(50, 50));
337:
338:                 log("Set its text property");
339:                 sheet = new SheetTableOperator();
340:                 ComponentUtils.setProperty(sheet, Bundle.getStringTrimmed(_bundle, "propertyText"), "Page 2");
341:                 Util.wait(2000); 
342:                 */
343:                log("Go back to first page");
344:                prjNav.openWebPage(_projectName, _page1);
345:                //TODO fix the org.netbeans.modules.visualweb.gravy.navigation.NavigatorOperator.NavigatorChooser class, then uncomment the next line
346:                //ComponentUtils.linkWebPages(designer, _page1, _page2, "next");
347:
348:                Util.saveAllAPICall();
349:                Util.wait(2000);
350:                endTest();
351:            }
352:
353:            /*
354:             * Deploy application
355:             */
356:            public void testDeploy() {
357:                startTest();
358:                //need to wait responce
359:                Waiter deploymentWaiter = new Waiter(new Waitable() {
360:                    public Object actionProduced(Object output) {
361:                        String text = ((OutputOperator) output).getText();
362:                        if (text.indexOf(_buildSuccess) != -1)
363:                            return _true;
364:                        return null;
365:
366:                    }
367:
368:                    public String getDescription() {
369:                        return ("Waiting Project Deployed");
370:                    }
371:                });
372:                log("Deploy from menu");
373:                ProjectNavigatorOperator.pressPopupItemOnNode(_projectName,
374:                        _run);
375:                TestUtils.wait(2000);
376:                OutputOperator outputWindow = new OutputOperator();
377:                deploymentWaiter.getTimeouts().setTimeout("Waiter.WaitingTime",
378:                        240000);
379:                log("wait until " + _buildSuccess);
380:                try {
381:                    deploymentWaiter.waitAction(outputWindow);
382:                } catch (InterruptedException e) {
383:                    log(outputWindow.getText());
384:                    e.printStackTrace();
385:                    fail("Deployment error: " + e);
386:                }
387:                log("Deployment complete");
388:                endTest();
389:            }
390:
391:            public void testCloseProject() {
392:                startTest();
393:                Util.saveAllAPICall();
394:                new ProjectNavigatorOperator().pressPopupItemOnNode(
395:                        _projectName, Bundle.getStringTrimmed(_bundle,
396:                                "CloseProjectPopupItem"));
397:                //TestUtils.closeCurrentProject();
398:                TestUtils.wait(5000);
399:                endTest();
400:            }
401:
402:            public void setFontStyle(String componentID, String ComponentName,
403:                    String style, String size, String color) {
404:                sheet = new SheetTableOperator();
405:                sheet.pushDotted(Bundle.getStringTrimmed(_bundle,
406:                        "propertyStyle"));
407:                String title = componentID + ":" + ComponentName + " - "
408:                        + Bundle.getStringTrimmed(_bundle, "propertyStyle");
409:                JDialogOperator dialog = new JDialogOperator(title);
410:                (new JListOperator(dialog, 0)).selectItem(Bundle
411:                        .getStringTrimmed(_bundle, "style_font"));
412:                if (!style.equals("")) {
413:                    (new JListOperator(dialog, 1)).selectItem(style);
414:                }
415:                if (!size.equals("")) {
416:                    (new JListOperator(dialog, 2)).selectItem(size);
417:                }
418:                if (!color.equals("")) {
419:                    (new JComboBoxOperator(dialog, 4)).selectItem(color);
420:                }
421:                TestUtils.wait(1000);
422:                (new JButtonOperator(dialog, "OK")).pushNoBlock();
423:            }
424:
425:            /* Need to undeploy project to finish tests correctly */
426:            public void testUndeploy() {
427:                startTest();
428:                log("Initialize");
429:                explorer = ServerNavigatorOperator.showNavigatorOperator();
430:                String serverPath = _serverPath + _projectServer; //Current deployment server
431:                String deploymentPath = serverPath + _deploymentPath; //glassfish specific
432:                String applicationPath = deploymentPath + _separator
433:                        + _projectName; //project name
434:
435:                // Select the Server Navigator and set the JTreeOperator
436:                log("get explorer");
437:                new QueueTool().waitEmpty(100); //??
438:                explorer.requestFocus();
439:                JTreeOperator tree = explorer.getTree();
440:                try {
441:                    Thread.sleep(4000);
442:                } catch (Exception e) {
443:                } // Sleep 4 secs to make sure Server Navigator is in focus
444:
445:                // Need to refresh J2EE AppServer node
446:                log("refresh");
447:                explorer.pushPopup(tree, serverPath, _refresh);
448:                TestUtils.wait(1000);
449:
450:                log("refresh deployment path: " + deploymentPath);
451:                TestUtils.wait(1000);
452:                explorer.selectPath(deploymentPath);
453:                explorer.getTree().expandPath(
454:                        explorer.getTree().findPath(deploymentPath));
455:                explorer.pushPopup(tree, deploymentPath, _refresh);
456:                TestUtils.wait(1000);
457:
458:                log("undeploy Path: " + applicationPath);
459:                explorer.selectPath(applicationPath);
460:                TestUtils.wait(1000);
461:
462:                log("Push Menu Undeploy...");
463:                explorer.pushPopup(explorer.getTree(), applicationPath,
464:                        _undeploy);
465:                TestUtils.wait(5000);
466:                endTest();
467:            }
468:
469:            public void testCheckIDELog() {
470:                startTest();
471:                try {
472:                    String err = ComponentUtils.hasUnexpectedException();
473:                    String str = "";
474:                    if (!(err.equals(""))) {
475:                        assertTrue(
476:                                "Unexpected  exceptions found in message.log: "
477:                                        + err, str.equals(""));
478:                    }
479:                } catch (IOException ioe) {
480:                    ioe.printStackTrace();
481:                    fail("Failed to open message.log : " + ioe);
482:                }
483:                endTest();
484:            }
485:        }
ww_w___.j__a_v_a2__s_.com___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.