Source Code Cross Referenced for CustomEditorOperatorsTest.java in  » IDE-Netbeans » jellytools » org » netbeans » jellytools » properties » editors » 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 » jellytools » org.netbeans.jellytools.properties.editors 
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-2006 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.jellytools.properties.editors;
043:
044:        import java.io.File;
045:        import org.netbeans.jellytools.Bundle;
046:        import org.netbeans.jellytools.NbDialogOperator;
047:        import org.netbeans.jellytools.properties.Property;
048:        import org.netbeans.jellytools.properties.PropertySheetOperator;
049:        import org.netbeans.jellytools.properties.TestNode;
050:
051:        /** Tests of all custom editors which reside in package org.netbeans.jellytools.properties.editors.
052:         *
053:         * @author <a href="mailto:adam.sotona@sun.com">Adam Sotona</a>
054:         * @author Jiri.Skrivanek@sun.com
055:         */
056:        public class CustomEditorOperatorsTest extends
057:                org.netbeans.jellytools.JellyTestCase {
058:
059:            /** Node with all customizable properties */
060:            private static TestNode testNode;
061:
062:            /** constructor required by JUnit
063:             * @param testName method name to be used as testcase
064:             */
065:            public CustomEditorOperatorsTest(String testName) {
066:                super (testName);
067:            }
068:
069:            /** method used for explicit testsuite definition
070:             */
071:            public static junit.framework.Test suite() {
072:                junit.framework.TestSuite suite = new org.netbeans.junit.NbTestSuite();
073:                suite.addTest(new CustomEditorOperatorsTest(
074:                        "testStringCustomEditorOperator"));
075:                suite.addTest(new CustomEditorOperatorsTest(
076:                        "testStringArrayCustomEditorOperator"));
077:                suite.addTest(new CustomEditorOperatorsTest(
078:                        "testPointCustomEditorOperator"));
079:                suite.addTest(new CustomEditorOperatorsTest(
080:                        "testDimensionCustomEditorOperator"));
081:                suite.addTest(new CustomEditorOperatorsTest(
082:                        "testRectangleCustomEditorOperator"));
083:                suite.addTest(new CustomEditorOperatorsTest(
084:                        "testColorCustomEditorOperator"));
085:                suite.addTest(new CustomEditorOperatorsTest(
086:                        "testFontCustomEditorOperator"));
087:                suite.addTest(new CustomEditorOperatorsTest(
088:                        "testFileCustomEditorOperator"));
089:                suite.addTest(new CustomEditorOperatorsTest(
090:                        "testClasspathCustomEditorOperator"));
091:                suite.addTest(new CustomEditorOperatorsTest(
092:                        "testProcessDescriptorCustomEditorOperator"));
093:                suite.addTest(new CustomEditorOperatorsTest(
094:                        "testServiceTypeCustomEditorOperator"));
095:                // don't know how to show filesystem editor
096:                //suite.addTest(new CustomEditorOperatorsTest("testFilesystemCustomEditorOperator"));
097:                // don't know how to show icon editor
098:                //suite.addTest(new CustomEditorOperatorsTest("testIconCustomEditorOperator"));
099:                suite.addTest(new CustomEditorOperatorsTest("testClose"));
100:                return suite;
101:            }
102:
103:            /** Method called before each testcase. */
104:            protected void setUp() {
105:                System.out.println("### " + getName() + " ###"); // NOI18N
106:                if (testNode == null) {
107:                    testNode = new TestNode();
108:                    testNode.showProperties();
109:                }
110:            }
111:
112:            /** Use for internal test execution inside IDE
113:             * @param args command line arguments
114:             */
115:            public static void main(java.lang.String[] args) {
116:                junit.textui.TestRunner.run(suite());
117:            }
118:
119:            /** Test of org.netbeans.jellytools.properties.editors.StringCustomEditorOperator. */
120:            public void testStringCustomEditorOperator() {
121:                StringCustomEditorOperator editor = null;
122:                Property p = new Property(new PropertySheetOperator(
123:                        TestNode.NODE_NAME), "String");
124:                p.openEditor();
125:                editor = new StringCustomEditorOperator("String");
126:                editor.setStringValue("tested text");
127:                assertEquals("tested text", editor.getStringValue());
128:                editor.ok();
129:                assertEquals("tested text", p.getValue());
130:            }
131:
132:            /** Test of org.netbeans.jellytools.properties.editors.StringArrayCustomEditorOperator. */
133:            public void testStringArrayCustomEditorOperator() {
134:                StringArrayCustomEditorOperator editor = null;
135:                Property p = new Property(new PropertySheetOperator(
136:                        TestNode.NODE_NAME), "String []");
137:                p.openEditor();
138:                editor = new StringArrayCustomEditorOperator("String []");
139:                editor.setItemText("tested text 1");
140:                assertEquals("tested text 1", editor.getItemText());
141:                editor.add();
142:                editor.setItemText("tested text 2");
143:                editor.add();
144:                editor.lstItemList().selectItem("tested text 1");
145:                assertEquals(0, editor.lstItemList().getSelectedIndex());
146:                editor.down();
147:                assertEquals(1, editor.lstItemList().getSelectedIndex());
148:                editor.up();
149:                assertEquals(0, editor.lstItemList().getSelectedIndex());
150:                editor.down("tested text 1");
151:                assertEquals("down(String) failed.", 1, editor.lstItemList()
152:                        .getSelectedIndex());
153:                editor.up("tested text 1");
154:                assertEquals("up(String) failed.", 0, editor.lstItemList()
155:                        .getSelectedIndex());
156:                editor.setItemText("tested text 3");
157:                editor.edit();
158:                editor.remove("tested text 3");
159:                assertEquals(1, editor.lstItemList().getModel().getSize());
160:                editor.edit("tested text 2", "tested text 4");
161:                assertEquals("edit(String, String) failed.", "tested text 4",
162:                        editor.getItemText());
163:                String s[] = new String[] { "aa", "bb", "cc" };
164:                editor.setStringArrayValue(s);
165:                String s2[] = editor.getStringArrayValue();
166:                assertEquals(s[0], s2[0]);
167:                assertEquals(s[1], s2[1]);
168:                assertEquals(s[2], s2[2]);
169:                editor.ok();
170:                assertEquals("aa, bb, cc", p.getValue());
171:            }
172:
173:            /** Test of org.netbeans.jellytools.properties.editors.PointCustomEditorOperator. */
174:            public void testPointCustomEditorOperator() {
175:                PointCustomEditorOperator editor = null;
176:                Property p = new Property(new PropertySheetOperator(
177:                        TestNode.NODE_NAME), "Point");
178:                p.openEditor();
179:                editor = new PointCustomEditorOperator("Point");
180:                editor.setPointValue("10", "20");
181:                assertEquals("10", editor.getXValue());
182:                assertEquals("20", editor.getYValue());
183:                editor.setXValue("30");
184:                assertEquals("30", editor.getXValue());
185:                editor.setYValue("40");
186:                assertEquals("40", editor.getYValue());
187:                editor.ok();
188:                assertEquals("[30, 40]", p.getValue());
189:            }
190:
191:            /** Test of org.netbeans.jellytools.properties.editors.RectangleCustomEditorOperator. */
192:            public void testRectangleCustomEditorOperator() {
193:                RectangleCustomEditorOperator editor = null;
194:                Property p = new Property(new PropertySheetOperator(
195:                        TestNode.NODE_NAME), "Rectangle");
196:                p.openEditor();
197:                editor = new RectangleCustomEditorOperator("Rectangle");
198:                editor.setRectangleValue("10", "20", "30", "40");
199:                assertEquals("10", editor.getXValue());
200:                assertEquals("20", editor.getYValue());
201:                assertEquals("30", editor.getWidthValue());
202:                assertEquals("40", editor.getHeightValue());
203:                editor.setXValue("50");
204:                assertEquals("50", editor.getXValue());
205:                editor.setYValue("60");
206:                assertEquals("60", editor.getYValue());
207:                editor.setWidthValue("70");
208:                assertEquals("70", editor.getWidthValue());
209:                editor.setHeightValue("80");
210:                assertEquals("80", editor.getHeightValue());
211:                editor.ok();
212:                assertEquals("[50, 60, 70, 80]", p.getValue());
213:            }
214:
215:            /** Test of org.netbeans.jellytools.properties.editors.DimensionCustomEditorOperator. */
216:            public void testDimensionCustomEditorOperator() {
217:                DimensionCustomEditorOperator editor = null;
218:                Property p = new Property(new PropertySheetOperator(
219:                        TestNode.NODE_NAME), "Dimension");
220:                p.openEditor();
221:                editor = new DimensionCustomEditorOperator("Dimension");
222:                editor.setDimensionValue("10", "20");
223:                assertEquals("10", editor.getWidthValue());
224:                assertEquals("20", editor.getHeightValue());
225:                editor.setWidthValue("30");
226:                assertEquals("30", editor.getWidthValue());
227:                editor.setHeightValue("40");
228:                assertEquals("40", editor.getHeightValue());
229:                editor.ok();
230:                assertEquals("[30, 40]", p.getValue());
231:            }
232:
233:            /** Test of org.netbeans.jellytools.properties.editors.ColorCustomEditorOperator. */
234:            public void testColorCustomEditorOperator() {
235:                ColorCustomEditorOperator editor = null;
236:                Property p = new Property(new PropertySheetOperator(
237:                        TestNode.NODE_NAME), "Color");
238:                p.openEditor();
239:                editor = new ColorCustomEditorOperator("Color");
240:                editor.setRGBValue(10, 20, 30);
241:                assertEquals(new java.awt.Color(10, 20, 30), editor
242:                        .getColorValue());
243:                java.awt.Color c = new java.awt.Color(40, 50, 60);
244:                editor.setColorValue(c);
245:                assertEquals(c, editor.getColorValue());
246:                editor.ok();
247:            }
248:
249:            /** Test of org.netbeans.jellytools.properties.editors.FontCustomEditorOperator. */
250:            public void testFontCustomEditorOperator() {
251:                FontCustomEditorOperator editor = null;
252:                PropertySheetOperator pso = new PropertySheetOperator(
253:                        TestNode.NODE_NAME);
254:                Property p = new Property(pso, "Font");
255:                p.openEditor();
256:                editor = new FontCustomEditorOperator("Font");
257:                editor.setFontName("Serif");
258:                assertTrue(editor.getFontName().indexOf("Serif") >= 0);
259:                editor.setFontStyle(editor.STYLE_BOLDITALIC);
260:                assertEquals(editor.STYLE_BOLDITALIC, editor.getFontStyle());
261:                editor.setFontSize("14");
262:                assertEquals("14", editor.getFontSize());
263:                editor.ok();
264:                // need to change selection because it gets editable otherwise
265:                pso.tblSheet().selectCell(0, 0);
266:            }
267:
268:            /** Test of org.netbeans.jellytools.properties.editors.FileCustomEditorOperator. */
269:            public void testFileCustomEditorOperator() throws Exception {
270:                FileCustomEditorOperator editor = null;
271:                Property p = new Property(new PropertySheetOperator(
272:                        TestNode.NODE_NAME), "File");
273:                p.openEditor();
274:                editor = new FileCustomEditorOperator("File");
275:                editor.setFileValue(getWorkDir().getAbsolutePath());
276:                assertEquals(getWorkDir(), editor.getFileValue());
277:                editor.ok();
278:                assertEquals(getWorkDir().getAbsolutePath(), p.getValue());
279:            }
280:
281:            /** Test of org.netbeans.jellytools.properties.editors.ClasspathCustomEditorOperator. */
282:            public void testClasspathCustomEditorOperator() throws Exception {
283:                ClasspathCustomEditorOperator editor = null;
284:                Property p = new Property(new PropertySheetOperator(
285:                        TestNode.NODE_NAME), "NbClassPath");
286:                p.openEditor();
287:                editor = new ClasspathCustomEditorOperator("NbClassPath");
288:                editor.addJARZIP().close();
289:                editor.addDirectory(getWorkDir());
290:                assertEquals(1, editor.getClasspathValue().length);
291:                assertEquals(getWorkDir().getAbsolutePath().toLowerCase(),
292:                        editor.getClasspathValue()[0].toLowerCase());
293:                File parent = getWorkDir().getParentFile();
294:                editor.addDirectory(parent);
295:                assertEquals(2, editor.getClasspathValue().length);
296:                assertEquals(parent.getAbsolutePath().toLowerCase(), editor
297:                        .getClasspathValue()[1].toLowerCase());
298:                editor.lstClasspath().selectItem(0);
299:                editor.moveDown();
300:                assertEquals(getWorkDir().getAbsolutePath().toLowerCase(),
301:                        editor.getClasspathValue()[1].toLowerCase());
302:                editor.lstClasspath().selectItem(1);
303:                editor.moveUp();
304:                assertEquals(getWorkDir().getAbsolutePath().toLowerCase(),
305:                        editor.getClasspathValue()[0].toLowerCase());
306:                editor.remove(parent.getAbsolutePath());
307:                assertEquals(1, editor.getClasspathValue().length);
308:                String s[] = new String[] { getWorkDir().getAbsolutePath(),
309:                        parent.getAbsolutePath() };
310:                editor.setClasspathValue(s);
311:                String s2[] = editor.getClasspathValue();
312:                assertEquals(s[0].toLowerCase(), s2[0].toLowerCase());
313:                assertEquals(s[1].toLowerCase(), s2[1].toLowerCase());
314:                editor.ok();
315:                assertTrue(p.getValue().toLowerCase().indexOf(
316:                        s[0].toLowerCase() + File.pathSeparator
317:                                + s[1].toLowerCase()) >= 0);
318:            }
319:
320:            /** Test of org.netbeans.jellytools.properties.editors.ProcessDescriptorCustomEditorOperator. */
321:            public void testProcessDescriptorCustomEditorOperator() {
322:                ProcessDescriptorCustomEditorOperator editor = null;
323:                Property p = new Property(new PropertySheetOperator(
324:                        TestNode.NODE_NAME), "NbProcessDescriptor");
325:                p.openEditor();
326:                editor = new ProcessDescriptorCustomEditorOperator(
327:                        "NbProcessDescriptor");
328:                editor.selectProcessExecutable().close();
329:                editor.setProcess("test process");
330:                assertEquals("test process", editor.getProcess());
331:                editor.setArguments("test arguments");
332:                assertEquals("test arguments", editor.getArguments());
333:                assertEquals("", editor.getArgumentKey());
334:                editor.ok();
335:                assertEquals("test process test arguments", p.getValue());
336:            }
337:
338:            /** Test of org.netbeans.jellytools.properties.editors.ServiceTypeCustomEditorOperator. */
339:            public void testServiceTypeCustomEditorOperator() {
340:                ServiceTypeCustomEditorOperator editor = null;
341:                Property p = new Property(new PropertySheetOperator(
342:                        TestNode.NODE_NAME), "Service Type");
343:                p.openEditor();
344:                editor = new ServiceTypeCustomEditorOperator("Service Type");
345:                // "No Indentation"
346:                String noIndentationLabel = Bundle.getString(
347:                        "org.netbeans.beaninfo.Bundle",
348:                        "LAB_IndentEngineDefault"); // NOI18N
349:                editor.setServiceTypeValue(noIndentationLabel);
350:                assertEquals(noIndentationLabel, editor.getServiceTypeValue());
351:                editor.ok();
352:                assertEquals(noIndentationLabel, p.getValue());
353:            }
354:
355:            /** Tests FilesystemCustomEditorOperator. */
356:            public void testFilesystemCustomEditorOperator() {
357:                Property p = new Property(new PropertySheetOperator(
358:                        TestNode.NODE_NAME), "Filesystem");
359:                p.openEditor();
360:                FilesystemCustomEditorOperator editor = new FilesystemCustomEditorOperator(
361:                        "Filesystem");
362:                editor.addLocalDirectory();
363:                assertTrue("Add Local Directory radio button not pushed.",
364:                        editor.rbAddLocalDirectory().isSelected());
365:                editor.setDirectory("localDirectory");
366:                assertEquals("Wrong value in Directory text field.",
367:                        "localDirectory", editor.getDirectory());
368:                editor.browse();
369:                String userdir = System.getProperty("netbeans.user");
370:                org.netbeans.jemmy.operators.JFileChooserOperator fileChooserOper = new org.netbeans.jemmy.operators.JFileChooserOperator();
371:                fileChooserOper.setSelectedFile(new File(userdir));
372:                fileChooserOper.approve();
373:                assertEquals(
374:                        "Wrong value in Directory text field from file chooser.",
375:                        userdir, editor.getDirectory());
376:                // test JAR File
377:                editor.addJARFile();
378:                assertTrue("Add JAR File radio button not pushed.", editor
379:                        .rbAddJARFile().isSelected());
380:                editor.setJARFile("jarFile");
381:                assertEquals("Wrong value in Directory text field.", "jarFile",
382:                        editor.getJARFile());
383:                editor.browse2();
384:                fileChooserOper = new org.netbeans.jemmy.operators.JFileChooserOperator();
385:                String nbhome = System.getProperty("netbeans.home");
386:                String jarPath = nbhome + File.separator + "lib"
387:                        + File.separator + "core.jar";
388:                fileChooserOper.setSelectedFile(new File(jarPath));
389:                fileChooserOper.approve();
390:                assertEquals(
391:                        "Wrong value in JAR File text field from file chooser.",
392:                        jarPath, editor.getJARFile());
393:                editor.ok();
394:                assertTrue("Editor doesn't save value after OK.", p.getValue()
395:                        .indexOf("core.jar") > -1);
396:            }
397:
398:            /** Test of org.netbeans.jellytools.properties.editors.IconCustomEditorOperator. */
399:            public void testIconCustomEditorOperator() {
400:                Property p = new Property(new PropertySheetOperator(
401:                        TestNode.NODE_NAME), "Icon");
402:                p.openEditor();
403:                IconCustomEditorOperator editor = new IconCustomEditorOperator(
404:                        "Icon");
405:                editor.uRL();
406:                assertTrue("URL radio button not pushed.", editor.rbURL()
407:                        .isSelected());
408:                editor.noPicture();
409:                assertTrue("No picture radio button not pushed.", editor
410:                        .rbNoPicture().isSelected());
411:                editor.classpath();
412:                assertTrue("Classpath radio button not pushed.", editor
413:                        .rbClasspath().isSelected());
414:                editor.file();
415:                assertTrue("File radio button not pushed.", editor.rbFile()
416:                        .isSelected());
417:                editor.selectFile();
418:                new NbDialogOperator(org.netbeans.jellytools.Bundle.getString(
419:                        "org.openide.explorer.propertysheet.editors.Bundle",
420:                        "CTL_OpenDialogName")).cancel();
421:                editor.setName("iconFile");
422:                assertEquals("Wrong value in Name text field", "iconFile",
423:                        editor.getName());
424:                editor.ok();
425:                assertTrue("Editor doesn't save value after OK.", p.getValue()
426:                        .indexOf("iconFile") > -1);
427:            }
428:
429:            /** Close property sheet. */
430:            public void testClose() {
431:                new PropertySheetOperator(TestNode.NODE_NAME).close();
432:            }
433:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.