Source Code Cross Referenced for AcceptanceTest.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » modules » visualweb » test » components » selection » radiobuttongroup » 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.selection.radiobuttongroup 
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.selection.radiobuttongroup;
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.jellytools.EditorOperator;
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.modules.visualweb.test.components.util.ComponentUtils;
059:        import org.netbeans.jellytools.OutputOperator;
060:        import org.netbeans.jemmy.Waitable;
061:        import org.netbeans.jemmy.Waiter;
062:        import org.netbeans.jemmy.QueueTool;
063:        import org.netbeans.jemmy.operators.JTreeOperator;
064:        import org.netbeans.modules.visualweb.gravy.Bundle;
065:        import org.netbeans.modules.visualweb.gravy.RaveTestCase;
066:        import org.netbeans.modules.visualweb.gravy.RaveWindowOperator;
067:        import org.netbeans.modules.visualweb.gravy.TestUtils;
068:        import org.netbeans.modules.visualweb.gravy.Util;
069:
070:        /**
071:         * @author Sherry Zhou (sherry.zhou@sun.com)
072:         */
073:        public class AcceptanceTest extends RaveTestCase {
074:
075:            public String _bundle = ComponentUtils.getBundle();
076:            public String _projectName = "RadioButtonGroupAcceptanceTest";
077:            public String _projectServer = Bundle.getStringTrimmed(_bundle,
078:                    "projectServer");
079:            public String _logFileLocation = Bundle.getStringTrimmed(_bundle,
080:                    "logFile");
081:            public String _logFile = System.getProperty("xtest.workdir")
082:                    + File.separator + _logFileLocation;
083:            public String _exception = Bundle.getStringTrimmed(_bundle,
084:                    "Exception");
085:            public String _close = Bundle.getStringTrimmed(_bundle, "close");
086:            public String _run = Bundle.getStringTrimmed(_bundle, "Run");
087:            public String _buildSuccess = Bundle.getStringTrimmed(_bundle,
088:                    "buildSuccess");
089:            public String _true = Bundle.getStringTrimmed(_bundle, "true");
090:
091:            //undeployment
092:            public String _undeploy = Bundle.getStringTrimmed(_bundle,
093:                    "undeploy");
094:            public String _refresh = Bundle
095:                    .getStringTrimmed(_bundle, "refresh");
096:            public String _serverPath = Bundle.getStringTrimmed(_bundle,
097:                    "serverPath");
098:            public String _deploymentPath = Bundle.getStringTrimmed(_bundle,
099:                    "deploymentPathGlassfish");
100:            public String _separator = Bundle.getStringTrimmed(_bundle,
101:                    "separator");
102:
103:            public static int xRadioButtonGroup = 50;
104:            public static int yRadioButtonGroup = 50;
105:            public static int xStaticText = 80;
106:            public static int yStaticText = 200;
107:            public static int xButton = 150;
108:            public static int yButton = 150;
109:            public static DesignerPaneOperator designer;
110:            public static SheetTableOperator sheet;
111:            public static ServerNavigatorOperator explorer;
112:            public String imageDir = ComponentUtils.getDataDir() + "selection"
113:                    + File.separator;
114:            String image1 = imageDir + "solarisLogo.jpg";
115:            String image2 = imageDir + "windowXPLogo.jpg";
116:            String image3 = imageDir + "rhLogo.png";
117:            String image4 = imageDir + "macLogo.jpg";
118:            String radioButtonGroupID = "radioButtonGroup1";
119:
120:            //    String importStatement="import " + Bundle.getStringTrimmed(_bundle, "optionType")+";";
121:            //    String[] javaCode =  {importStatement};
122:            //    String[] javaCode1={ "platforms = new Option[4]; ",
123:            //    "String selectionData[][ ] = { ",
124:            //    "    {\"1\", \"/resources/solarisLogo.jpg\", \"Solaris 10\", \"Solaris 10 Image\"}, ",
125:            //    "     {\"2\", \"/resources/windowXPLogo.jpg\", \"Window XP\", \"WindowXP Image\"}, ",
126:            //    "     {\"3\", \"/resources/rhLogo.png\", \"Lunix\", \"Linux Image\"}, ",
127:            //    "     {\"4\", \"/resources/macLogo.jpg\", \"MacOS\", \"MacOS Image\"}}  ; ",
128:            //    "    for (int i = 0; i<4; ++i) {  ",
129:            //    "        platforms[i] = new Option();  ",
130:            //    "        platforms[i].setValue(selectionData[i][0]);  ",
131:            //    "        platforms[i].setImage(selectionData[i][1]);  ",
132:            //    "        platforms[i].setLabel(selectionData[i][2]);   ",
133:            //    "        platforms[i].setImageAlt(selectionData[i][3]);  " };
134:            //    String[] javaCode2 = {"String selectedPlatform=\"Selected platform is \" ;",
135:            //    "if (radioButtonGroup1.getSelected()!=null) ",
136:            //    "staticText1.setText(\" You have selected \" + radioButtonGroup1.getSelected().toString()); ",
137:            //    "else ",
138:            //    "staticText1.setText(\"You don't select OS yet\"); "};
139:            //    
140:
141:            public AcceptanceTest(String testName) {
142:                super (testName);
143:            }
144:
145:            public static Test suite() {
146:                TestSuite suite = new TestSuite();
147:                suite.addTest(new AcceptanceTest("testCreateProject"));
148:                suite.addTest(new AcceptanceTest("testAddRadioButtonGroup"));
149:                //   suite.addTest(new AcceptanceTest("testAddPageBeanProperty"));
150:                //        suite.addTest(new AcceptanceTest("testLoadImageFiles"));
151:                //        suite.addTest(new AcceptanceTest("testAddButtonActionEvent"));
152:                suite.addTest(new AcceptanceTest("testDeploy"));
153:                suite.addTest(new AcceptanceTest("testCloseProject"));
154:                suite.addTest(new AcceptanceTest("testUndeploy"));
155:                suite.addTest(new AcceptanceTest("testCheckIDELog"));
156:
157:                return suite;
158:            }
159:
160:            /** method called before each testcase
161:             */
162:            protected void setUp() {
163:                System.out.println("########  " + getName() + "  #######");
164:            }
165:
166:            /** method called after each testcase
167:             */
168:            protected void tearDown() {
169:                System.out.println("########  " + getName()
170:                        + " Finished #######");
171:            }
172:
173:            /*
174:             * Start PE. Delete PointBase travel resource
175:             */
176:            private void testStartup() {
177:                //Start PE is it is not started yet
178:                ServerNavigatorOperator se = new ServerNavigatorOperator();
179:                // Skip next 2 steps if running on Mac as Jemmy's call popup issue
180:                if (!System.getProperty("os.name").equals("Mac OS X")) {
181:                    //Start PE is it is not started yet
182:                    try {
183:                        se.startServer("J2EE");
184:                    } catch (Exception e) {
185:                    }
186:                    // Delete pb travel resource if it exists
187:                    se.deleteResource("jdbc/Travel");
188:                }
189:            }
190:
191:            /*
192:             *   Create new project
193:             *   And add property val to SessionBean1.java
194:             */
195:            public void testCreateProject() {
196:                startTest();
197:                log("**Creating Project");
198:                //Create Project
199:                try {
200:                    ComponentUtils.createNewProject(_projectName);
201:                    Util.wait(10000);
202:                } catch (Exception e) {
203:                    log(">> Project Creation Failed");
204:                    e.printStackTrace();
205:                    log(e.toString());
206:                    fail();
207:                }
208:                log("**Done");
209:                endTest();
210:            }
211:
212:            /*
213:             *   Add a RadioButton Group component . Set id, label, and imageURL properties
214:             */
215:
216:            public void testAddRadioButtonGroup() {
217:                startTest();
218:                designer = new DesignerPaneOperator(RaveWindowOperator
219:                        .getDefaultRave());
220:                String basicPalette = Bundle.getStringTrimmed(_bundle,
221:                        "basicPalette");
222:                PaletteContainerOperator palette = new PaletteContainerOperator(
223:                        basicPalette);
224:                Util.wait(2000);
225:
226:                // Add a  RadioButtonGroup component, set its label and columns property
227:                Point dropPoint = new Point(xRadioButtonGroup,
228:                        yRadioButtonGroup);
229:                palette.addComponent(Bundle.getStringTrimmed(_bundle,
230:                        "basicRadioButtonGroup"), designer, dropPoint);
231:                sheet = new SheetTableOperator();
232:                Util.wait(2000);
233:                ComponentUtils.setProperty(sheet, Bundle.getStringTrimmed(
234:                        _bundle, "propertyLabel"), "Select an OS");
235:                ComponentUtils.setProperty(sheet, Bundle.getStringTrimmed(
236:                        _bundle, "propertyColumns"), "2");
237:                Util.wait(2000);
238:
239:                log(" Add a button");
240:                palette = new PaletteContainerOperator(basicPalette);
241:                palette.addComponent(Bundle.getStringTrimmed(_bundle,
242:                        "basicButton"), designer, new Point(xButton, yButton));
243:                Util.wait(2000);
244:
245:                log(" Add a static text");
246:                palette = new PaletteContainerOperator(basicPalette);
247:                palette.addComponent(Bundle.getStringTrimmed(_bundle,
248:                        "basicStaticText"), designer, new Point(xStaticText,
249:                        yStaticText));
250:                Util.wait(2000);
251:
252:                Util.saveAllAPICall();
253:                Util.wait(2000);
254:                endTest();
255:            }
256:
257:            public void testAddPageBeanProperty() {
258:                startTest();
259:                log("Add SessionBean property - platforms, type is Option[]");
260:                String path = _projectName + "|" + "Source Packages|"
261:                        + _projectName + "|Page1.java|Page1|Bean Patterns";
262:                String type = Bundle.getStringTrimmed(_bundle, "optionType")
263:                        + "[]";
264:                ComponentUtils.addObjectProperty(path, "platforms", type,
265:                        Bundle.getStringTrimmed(_bundle,
266:                                "BeanPattern_Mode_ReadWrite"));
267:
268:                log("Open Java editor, initiaize platforms property");
269:                designer = new DesignerPaneOperator(RaveWindowOperator
270:                        .getDefaultRave());
271:                designer.makeComponentVisible();
272:                // Double click at button to open Jave Editor
273:                designer.clickMouse(20, 20, 2);
274:                TestUtils.wait(1000);
275:                EditorOperator editor = new EditorOperator(
276:                        Util.getMainWindow(), "Page1.java");
277:                editor.setVerification(false);
278:
279:                TestUtils.wait(2000);
280:                editor.requestFocus();
281:                TestUtils.wait(2000);
282:                editor.pushKey(KeyEvent.VK_ENTER);
283:                editor.insert("log(\"Action Performed.\");\n");
284:                TestUtils.wait(500);
285:
286:                Util.saveAllAPICall();
287:                Util.wait(2000);
288:
289:                //        log("Reformat code");
290:                //        editor.clickForPopup();
291:                //        new JPopupMenuOperator().pushMenu("Reformat Code");
292:                //        TestUtils.wait(200);
293:                //        
294:                log("Switch to design panel");
295:                designer.makeComponentVisible();
296:                TestUtils.wait(10000);
297:
298:                log("Bind platforms to radiobuttongroup's item property");
299:                // ComponentUtils.bindToObject(xRadioButtonGroup, yRadioButtonGroup, "Page1|page1|platforms");
300:                designer = new DesignerPaneOperator(RaveWindowOperator
301:                        .getDefaultRave());
302:                designer.clickMouse(radioButtonGroupID, 1);
303:                TestUtils.wait(1000);
304:
305:                ComponentUtils.setPropertyBinding(designer, xRadioButtonGroup,
306:                        yRadioButtonGroup, "item", "#{Page1.platforms}");
307:
308:                //        sheet = new SheetTableOperator();
309:                //        TestUtils.wait(2000);
310:                //        ComponentUtils.setProperty(sheet, Bundle.getStringTrimmed(_bundle, "propertyItems"), "#{Page1.platforms}");
311:                //        TestUtils.wait(2000);
312:                Util.wait(500);
313:                endTest();
314:            }
315:
316:            public void testLoadImageFiles() {
317:                startTest();
318:                log("load first image" + image1);
319:                ComponentUtils.loadImageFile(image1);
320:                TestUtils.wait(1000);
321:
322:                log("load second image" + image2);
323:                ComponentUtils.loadImageFile(image2);
324:                TestUtils.wait(1000);
325:
326:                log("load third image" + image3);
327:                ComponentUtils.loadImageFile(image3);
328:                TestUtils.wait(1000);
329:
330:                log("load fourth image" + image4);
331:                ComponentUtils.loadImageFile(image4);
332:                TestUtils.wait(1000);
333:
334:                endTest();
335:
336:            }
337:
338:            public void testAddButtonActionEvent() {
339:                startTest();
340:                designer = new DesignerPaneOperator(RaveWindowOperator
341:                        .getDefaultRave());
342:                designer.makeComponentVisible();
343:                // Double click at button to open Jave Editor
344:                designer.clickMouse(xButton + 1, yButton + 1, 2);
345:                TestUtils.wait(1000);
346:                EditorOperator editor = new EditorOperator(
347:                        Util.getMainWindow(), "Page1.java");
348:
349:                editor.setVerification(false);
350:                TestUtils.wait(2000);
351:                editor.requestFocus();
352:                TestUtils.wait(2000);
353:                editor.pushKey(KeyEvent.VK_ENTER);
354:                editor.insert("log(\"Action Performed.\");\n");
355:                TestUtils.wait(200);
356:                // Switch to design panel
357:                designer.makeComponentVisible();
358:                TestUtils.wait(10000);
359:                endTest();
360:            }
361:
362:            /*
363:             * Deploy application
364:             */
365:            public void testDeploy() {
366:                startTest();
367:                //need to wait responce
368:                Waiter deploymentWaiter = new Waiter(new Waitable() {
369:                    public Object actionProduced(Object output) {
370:                        String text = ((OutputOperator) output).getText();
371:                        if (text.indexOf(_buildSuccess) != -1)
372:                            return _true;
373:                        return null;
374:
375:                    }
376:
377:                    public String getDescription() {
378:                        return ("Waiting Project Deployed");
379:                    }
380:                });
381:                log("Deploy from menu");
382:                ProjectNavigatorOperator.pressPopupItemOnNode(_projectName,
383:                        _run);
384:                TestUtils.wait(2000);
385:                OutputOperator outputWindow = new OutputOperator();
386:                deploymentWaiter.getTimeouts().setTimeout("Waiter.WaitingTime",
387:                        240000);
388:                log("wait until " + _buildSuccess);
389:                try {
390:                    deploymentWaiter.waitAction(outputWindow);
391:                } catch (InterruptedException e) {
392:                    log(outputWindow.getText());
393:                    e.printStackTrace();
394:                    fail("Deployment error: " + e);
395:                }
396:                log("Deployment complete");
397:                endTest();
398:            }
399:
400:            public void testCloseProject() {
401:                startTest();
402:                Util.saveAllAPICall();
403:                new ProjectNavigatorOperator().pressPopupItemOnNode(
404:                        _projectName, Bundle.getStringTrimmed(_bundle,
405:                                "CloseProjectPopupItem"));
406:                //TestUtils.closeCurrentProject();
407:                TestUtils.wait(5000);
408:                endTest();
409:            }
410:
411:            /* Need to undeploy project to finish tests correctly */
412:            public void testUndeploy() {
413:                startTest();
414:                log("Initialize");
415:                explorer = ServerNavigatorOperator.showNavigatorOperator();
416:                String serverPath = _serverPath + _projectServer; //Current deployment server
417:                String deploymentPath = serverPath + _deploymentPath; //glassfish specific
418:                String applicationPath = deploymentPath + _separator
419:                        + _projectName; //project name
420:
421:                // Select the Server Navigator and set the JTreeOperator
422:                log("get explorer");
423:                new QueueTool().waitEmpty(100); //??
424:                explorer.requestFocus();
425:                JTreeOperator tree = explorer.getTree();
426:                try {
427:                    Thread.sleep(4000);
428:                } catch (Exception e) {
429:                } // Sleep 4 secs to make sure Server Navigator is in focus
430:
431:                // Need to refresh J2EE AppServer node
432:                log("refresh");
433:                explorer.pushPopup(tree, serverPath, _refresh);
434:                TestUtils.wait(1000);
435:
436:                log("refresh deployment path: " + deploymentPath);
437:                TestUtils.wait(1000);
438:                explorer.selectPath(deploymentPath);
439:                explorer.getTree().expandPath(
440:                        explorer.getTree().findPath(deploymentPath));
441:                explorer.pushPopup(tree, deploymentPath, _refresh);
442:                TestUtils.wait(1000);
443:
444:                log("undeploy Path: " + applicationPath);
445:                explorer.selectPath(applicationPath);
446:                TestUtils.wait(1000);
447:
448:                log("Push Menu Undeploy...");
449:                explorer.pushPopup(explorer.getTree(), applicationPath,
450:                        _undeploy);
451:                TestUtils.wait(5000);
452:                endTest();
453:            }
454:
455:            public void testCheckIDELog() {
456:                startTest();
457:                try {
458:                    String err = ComponentUtils.hasUnexpectedException();
459:                    String str = "";
460:                    if (!(err.equals(""))) {
461:                        assertTrue(
462:                                "Unexpected  exceptions found in message.log: "
463:                                        + err, str.equals(""));
464:                    }
465:                } catch (IOException ioe) {
466:                    ioe.printStackTrace();
467:                    fail("Failed to open message.log : " + ioe);
468:                }
469:                endTest();
470:            }
471:        }
w__w_w.ja___va___2s.___c__o___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.