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 gui;
043:
044: import java.io.File;
045: import java.io.IOException;
046: import junit.textui.TestRunner;
047: import org.netbeans.jellytools.Bundle;
048: import org.netbeans.jellytools.EditorOperator;
049: import org.netbeans.jellytools.JellyTestCase;
050: import org.netbeans.jellytools.NbDialogOperator;
051: import org.netbeans.jellytools.OptionsOperator;
052: import org.netbeans.jellytools.RepositoryTabOperator;
053: import org.netbeans.jellytools.actions.PropertiesAction;
054: import org.netbeans.jellytools.nodes.JavaNode;
055: import org.netbeans.jellytools.nodes.Node;
056: import org.netbeans.jellytools.properties.Property;
057: import org.netbeans.jellytools.properties.PropertySheetOperator;
058: import org.netbeans.jemmy.EventTool;
059: import org.netbeans.jemmy.operators.JCheckBoxOperator;
060: import org.netbeans.jemmy.operators.JComboBoxOperator;
061: import org.netbeans.jemmy.operators.JTextFieldOperator;
062: import org.netbeans.junit.NbTestSuite;
063: import org.openide.actions.SaveAllAction;
064: import org.openide.filesystems.FileObject;
065: import org.openide.filesystems.Repository;
066: import org.openide.loaders.DataFolder;
067: import org.openide.loaders.DataObject;
068:
069: public class CreateNewNonIndexedProperty extends JellyTestCase {
070:
071: private static final String NAME_TEST_FILE = "TestFile";
072: private static final String NAME_NON_INDEX_PROPERTY = "nonIndexProperty";
073: private static final String NAME_WRONG = "123";
074: private static final String TYPE_WRONG = "+++";
075:
076: private static final String sampleDir = Utilities.findFileSystem(
077: "src").getDisplayName();
078:
079: /** Need to be defined because of JUnit */
080: public CreateNewNonIndexedProperty(String name) {
081: super (name);
082: }
083:
084: public static NbTestSuite suite() {
085: NbTestSuite suite = new NbTestSuite();
086: suite.addTest(new CreateNewNonIndexedProperty("testName"));
087: suite.addTest(new CreateNewNonIndexedProperty("testType"));
088: suite.addTest(new CreateNewNonIndexedProperty("testMode"));
089: suite.addTest(new CreateNewNonIndexedProperty("testBound"));
090: suite
091: .addTest(new CreateNewNonIndexedProperty(
092: "testConstrained"));
093: suite.addTest(new CreateNewNonIndexedProperty(
094: "testGenerateField"));
095: suite.addTest(new CreateNewNonIndexedProperty(
096: "testGenerateReturnStatement"));
097: suite.addTest(new CreateNewNonIndexedProperty(
098: "testGenerateSetStatement"));
099: suite.addTest(new CreateNewNonIndexedProperty(
100: "testGeneratePropertyChangeSupport"));
101: return suite;
102: }
103:
104: /** Use for execution inside IDE */
105: public static void main(java.lang.String[] args) {
106: // run whole suite
107: TestRunner.run(suite());
108: // run only selected test case
109: //junit.textui.TestRunner.run(new BeansTemplates("testJavaBean"));
110: }
111:
112: /** setUp method */
113: public void setUp() {
114: System.out.println("######## " + getName() + " #######");
115:
116: OptionsOperator optionsOperator = OptionsOperator.invoke();
117: optionsOperator.selectOption(Bundle.getString(
118: "org.netbeans.core.Bundle", "UI/Services/Editing")
119: + "|"
120: + Bundle.getString("org.netbeans.modules.beans.Bundle",
121: "PROP_Option_Menu"));
122: PropertySheetOperator propertySheetTabOperator = new PropertySheetOperator(
123: optionsOperator);
124: new Property(propertySheetTabOperator, Bundle.getString(
125: "org.netbeans.modules.beans.Bundle",
126: "PROP_Option_Prop_Style")).setValue(Bundle.getString(
127: "org.netbeans.modules.beans.Bundle",
128: "MSG_Option_Gen_This"));
129:
130: FileObject testFile = Repository.getDefault().findResource(
131: "gui/data/" + NAME_TEST_FILE + ".java");
132: FileObject destination = Repository.getDefault()
133: .findFileSystem(sampleDir.replace('\\', '/')).getRoot();
134: optionsOperator.close();
135: try {
136: DataObject.find(testFile).copy(
137: DataFolder.findFolder(destination));
138: } catch (IOException e) {
139: fail(e);
140: }
141: new PropertiesAction().perform();
142: }
143:
144: /** tearDown method */
145: public void tearDown() {
146: ((SaveAllAction) SaveAllAction.findObject(SaveAllAction.class,
147: true)).performAction();
148:
149: Utilities.delete(NAME_TEST_FILE + ".java");
150: }
151:
152: /** testName method */
153: public void testName() {
154: RepositoryTabOperator explorerOperator = new RepositoryTabOperator();
155:
156: Node repositoryRootNode = explorerOperator.getRootNode();
157: Node patternsNode = new Node(repositoryRootNode, sampleDir
158: + "|"
159: + NAME_TEST_FILE
160: + "|"
161: + "class "
162: + NAME_TEST_FILE
163: + "|"
164: + Bundle.getString("org.netbeans.modules.beans.Bundle",
165: "Patterns"));
166: patternsNode.select();
167: patternsNode.performPopupActionNoBlock(Bundle.getString(
168: "org.openide.src.nodes.Bundle", "LAB_Add")
169: + "|"
170: + Bundle.getString("org.netbeans.modules.beans.Bundle",
171: "MENU_CREATE_PROPERTY"));
172: String dialogTitle = Bundle.getString(
173: "org.netbeans.modules.beans.Bundle",
174: "CTL_TITLE_NewProperty");
175: NbDialogOperator nbDialogOperator = new NbDialogOperator(
176: dialogTitle);
177:
178: JTextFieldOperator jTextFieldOperator = new JTextFieldOperator(
179: nbDialogOperator, 0);
180: jTextFieldOperator.typeText(NAME_WRONG);
181:
182: JComboBoxOperator jComboBoxOperator = new JComboBoxOperator(
183: nbDialogOperator, 0);
184: jComboBoxOperator.setSelectedItem("String");
185:
186: nbDialogOperator.ok();
187:
188: new EventTool().waitNoEvent(3000);
189:
190: new NbDialogOperator("Error").ok();
191:
192: jTextFieldOperator.clearText();
193: jTextFieldOperator.typeText(NAME_NON_INDEX_PROPERTY);
194:
195: jComboBoxOperator.setSelectedItem("String");
196:
197: nbDialogOperator.ok();
198:
199: new JavaNode(repositoryRootNode, sampleDir + "|"
200: + NAME_TEST_FILE).open();
201:
202: EditorOperator eo = new EditorOperator(NAME_TEST_FILE);
203: ref(eo.getText());
204: compareReferenceFiles();
205: }
206:
207: /** testType method */
208: public void testType() {
209:
210: RepositoryTabOperator explorerOperator = new RepositoryTabOperator();
211:
212: Node repositoryRootNode = explorerOperator.getRootNode();
213: Node patternsNode = new Node(repositoryRootNode, sampleDir
214: + "|"
215: + NAME_TEST_FILE
216: + "|"
217: + "class "
218: + NAME_TEST_FILE
219: + "|"
220: + Bundle.getString("org.netbeans.modules.beans.Bundle",
221: "Patterns"));
222: patternsNode.select();
223: patternsNode.performPopupActionNoBlock(Bundle.getString(
224: "org.openide.src.nodes.Bundle", "LAB_Add")
225: + "|"
226: + Bundle.getString("org.netbeans.modules.beans.Bundle",
227: "MENU_CREATE_PROPERTY"));
228: String dialogTitle = Bundle.getString(
229: "org.netbeans.modules.beans.Bundle",
230: "CTL_TITLE_NewProperty");
231: NbDialogOperator nbDialogOperator = new NbDialogOperator(
232: dialogTitle);
233:
234: JTextFieldOperator jTextFieldOperator = new JTextFieldOperator(
235: nbDialogOperator, 0);
236: jTextFieldOperator.typeText(NAME_NON_INDEX_PROPERTY);
237:
238: JComboBoxOperator jComboBoxOperator = new JComboBoxOperator(
239: nbDialogOperator, 0);
240: jComboBoxOperator.typeText(TYPE_WRONG);
241: nbDialogOperator.ok();
242:
243: new EventTool().waitNoEvent(3000);
244: new NbDialogOperator("Error").ok();
245:
246: jTextFieldOperator.clearText();
247: jTextFieldOperator.typeText(NAME_NON_INDEX_PROPERTY);
248: jComboBoxOperator.clearText();
249: jComboBoxOperator.setSelectedItem("Double");
250:
251: nbDialogOperator.ok();
252: new JavaNode(repositoryRootNode, sampleDir + "|"
253: + NAME_TEST_FILE).open();
254:
255: EditorOperator eo = new EditorOperator(NAME_TEST_FILE);
256: ref(eo.getText());
257: compareReferenceFiles();
258:
259: }
260:
261: /** testMode method */
262: public void testMode() {
263:
264: RepositoryTabOperator explorerOperator = new RepositoryTabOperator();
265:
266: Node repositoryRootNode = explorerOperator.getRootNode();
267: Node patternsNode = new Node(repositoryRootNode, sampleDir
268: + "|"
269: + NAME_TEST_FILE
270: + "|"
271: + "class "
272: + NAME_TEST_FILE
273: + "|"
274: + Bundle.getString("org.netbeans.modules.beans.Bundle",
275: "Patterns"));
276: patternsNode.select();
277: patternsNode.performPopupActionNoBlock(Bundle.getString(
278: "org.openide.src.nodes.Bundle", "LAB_Add")
279: + "|"
280: + Bundle.getString("org.netbeans.modules.beans.Bundle",
281: "MENU_CREATE_PROPERTY"));
282: String dialogTitle = Bundle.getString(
283: "org.netbeans.modules.beans.Bundle",
284: "CTL_TITLE_NewProperty");
285: NbDialogOperator nbDialogOperator = new NbDialogOperator(
286: dialogTitle);
287:
288: JTextFieldOperator jTextFieldOperator = new JTextFieldOperator(
289: nbDialogOperator, 0);
290: jTextFieldOperator.typeText("first");
291: JComboBoxOperator jComboBoxOperator = new JComboBoxOperator(
292: nbDialogOperator, 0);
293: jComboBoxOperator.typeText("int");
294: jComboBoxOperator = new JComboBoxOperator(nbDialogOperator, 1);
295: jComboBoxOperator.setSelectedItem(Bundle
296: .getString("org.netbeans.modules.beans.Bundle",
297: "LAB_ReadOnlyMODE"));
298: nbDialogOperator.ok();
299:
300: new EventTool().waitNoEvent(1000);
301:
302: patternsNode.performPopupActionNoBlock(Bundle.getString(
303: "org.openide.src.nodes.Bundle", "LAB_Add")
304: + "|"
305: + Bundle.getString("org.netbeans.modules.beans.Bundle",
306: "MENU_CREATE_PROPERTY"));
307: dialogTitle = Bundle.getString(
308: "org.netbeans.modules.beans.Bundle",
309: "CTL_TITLE_NewProperty");
310: nbDialogOperator = new NbDialogOperator(dialogTitle);
311:
312: jTextFieldOperator = new JTextFieldOperator(nbDialogOperator, 0);
313: jTextFieldOperator.typeText("second");
314: jComboBoxOperator = new JComboBoxOperator(nbDialogOperator, 0);
315: jComboBoxOperator.typeText("double");
316: jComboBoxOperator = new JComboBoxOperator(nbDialogOperator, 1);
317: jComboBoxOperator.setSelectedItem(Bundle.getString(
318: "org.netbeans.modules.beans.Bundle",
319: "LAB_WriteOnlyMODE"));
320: nbDialogOperator.ok();
321:
322: patternsNode.performPopupActionNoBlock(Bundle.getString(
323: "org.openide.src.nodes.Bundle", "LAB_Add")
324: + "|"
325: + Bundle.getString("org.netbeans.modules.beans.Bundle",
326: "MENU_CREATE_PROPERTY"));
327: dialogTitle = Bundle.getString(
328: "org.netbeans.modules.beans.Bundle",
329: "CTL_TITLE_NewProperty");
330: nbDialogOperator = new NbDialogOperator(dialogTitle);
331:
332: jTextFieldOperator = new JTextFieldOperator(nbDialogOperator, 0);
333: jTextFieldOperator.typeText("third");
334: jComboBoxOperator = new JComboBoxOperator(nbDialogOperator, 0);
335: jComboBoxOperator.typeText("long");
336: jComboBoxOperator = new JComboBoxOperator(nbDialogOperator, 1);
337: jComboBoxOperator.setSelectedItem(Bundle.getString(
338: "org.netbeans.modules.beans.Bundle",
339: "LAB_ReadWriteMODE"));
340: nbDialogOperator.ok();
341:
342: new JavaNode(repositoryRootNode, sampleDir + "|"
343: + NAME_TEST_FILE).open();
344:
345: EditorOperator eo = new EditorOperator(NAME_TEST_FILE);
346: ref(eo.getText());
347: compareReferenceFiles();
348:
349: }
350:
351: /** testBound method */
352: public void testBound() {
353:
354: RepositoryTabOperator explorerOperator = new RepositoryTabOperator();
355:
356: Node repositoryRootNode = explorerOperator.getRootNode();
357: Node patternsNode = new Node(repositoryRootNode, sampleDir
358: + "|"
359: + NAME_TEST_FILE
360: + "|"
361: + "class "
362: + NAME_TEST_FILE
363: + "|"
364: + Bundle.getString("org.netbeans.modules.beans.Bundle",
365: "Patterns"));
366: patternsNode.select();
367: patternsNode.performPopupActionNoBlock(Bundle.getString(
368: "org.openide.src.nodes.Bundle", "LAB_Add")
369: + "|"
370: + Bundle.getString("org.netbeans.modules.beans.Bundle",
371: "MENU_CREATE_PROPERTY"));
372: String dialogTitle = Bundle.getString(
373: "org.netbeans.modules.beans.Bundle",
374: "CTL_TITLE_NewProperty");
375: NbDialogOperator nbDialogOperator = new NbDialogOperator(
376: dialogTitle);
377:
378: JTextFieldOperator jTextFieldOperator = new JTextFieldOperator(
379: nbDialogOperator, 0);
380: jTextFieldOperator.typeText(NAME_NON_INDEX_PROPERTY);
381: JComboBoxOperator jComboBoxOperator = new JComboBoxOperator(
382: nbDialogOperator, 0);
383: jComboBoxOperator.typeText("MyType");
384: jComboBoxOperator = new JComboBoxOperator(nbDialogOperator, 1);
385: jComboBoxOperator.setSelectedItem(Bundle.getString(
386: "org.netbeans.modules.beans.Bundle",
387: "LAB_ReadWriteMODE"));
388: JCheckBoxOperator jCheckBoxOperator = new JCheckBoxOperator(
389: nbDialogOperator, Bundle.getString(
390: "org.netbeans.modules.beans.Bundle",
391: "CTL_PropertyPanel_boundCheckBox"));
392: jCheckBoxOperator.push();
393: nbDialogOperator.ok();
394:
395: new JavaNode(repositoryRootNode, sampleDir + "|"
396: + NAME_TEST_FILE).open();
397:
398: EditorOperator eo = new EditorOperator(NAME_TEST_FILE);
399: ref(eo.getText());
400: compareReferenceFiles();
401:
402: }
403:
404: /** testConstrained method */
405: public void testConstrained() {
406:
407: RepositoryTabOperator explorerOperator = new RepositoryTabOperator();
408:
409: Node repositoryRootNode = explorerOperator.getRootNode();
410: Node patternsNode = new Node(repositoryRootNode, sampleDir
411: + "|"
412: + NAME_TEST_FILE
413: + "|"
414: + "class "
415: + NAME_TEST_FILE
416: + "|"
417: + Bundle.getString("org.netbeans.modules.beans.Bundle",
418: "Patterns"));
419: patternsNode.select();
420: patternsNode.performPopupActionNoBlock(Bundle.getString(
421: "org.openide.src.nodes.Bundle", "LAB_Add")
422: + "|"
423: + Bundle.getString("org.netbeans.modules.beans.Bundle",
424: "MENU_CREATE_PROPERTY"));
425: String dialogTitle = Bundle.getString(
426: "org.netbeans.modules.beans.Bundle",
427: "CTL_TITLE_NewProperty");
428: NbDialogOperator nbDialogOperator = new NbDialogOperator(
429: dialogTitle);
430:
431: JTextFieldOperator jTextFieldOperator = new JTextFieldOperator(
432: nbDialogOperator, 0);
433: jTextFieldOperator.typeText(NAME_NON_INDEX_PROPERTY);
434: JComboBoxOperator jComboBoxOperator = new JComboBoxOperator(
435: nbDialogOperator, 0);
436: jComboBoxOperator.typeText("MyType");
437: jComboBoxOperator = new JComboBoxOperator(nbDialogOperator, 1);
438: jComboBoxOperator.setSelectedItem(Bundle.getString(
439: "org.netbeans.modules.beans.Bundle",
440: "LAB_ReadWriteMODE"));
441: JCheckBoxOperator jCheckBoxOperator = new JCheckBoxOperator(
442: nbDialogOperator, Bundle.getString(
443: "org.netbeans.modules.beans.Bundle",
444: "CTL_PropertyPanel_constrainedCheckBox"));
445: jCheckBoxOperator.push();
446:
447: new EventTool().waitNoEvent(2000);
448:
449: nbDialogOperator.ok();
450:
451: new JavaNode(repositoryRootNode, sampleDir + "|"
452: + NAME_TEST_FILE).open();
453:
454: EditorOperator eo = new EditorOperator(NAME_TEST_FILE);
455: ref(eo.getText());
456: compareReferenceFiles();
457:
458: }
459:
460: /** testGenerateField method */
461: public void testGenerateField() {
462:
463: RepositoryTabOperator explorerOperator = new RepositoryTabOperator();
464:
465: Node repositoryRootNode = explorerOperator.getRootNode();
466: Node patternsNode = new Node(repositoryRootNode, sampleDir
467: + "|"
468: + NAME_TEST_FILE
469: + "|"
470: + "class "
471: + NAME_TEST_FILE
472: + "|"
473: + Bundle.getString("org.netbeans.modules.beans.Bundle",
474: "Patterns"));
475: patternsNode.select();
476: patternsNode.performPopupActionNoBlock(Bundle.getString(
477: "org.openide.src.nodes.Bundle", "LAB_Add")
478: + "|"
479: + Bundle.getString("org.netbeans.modules.beans.Bundle",
480: "MENU_CREATE_PROPERTY"));
481: String dialogTitle = Bundle.getString(
482: "org.netbeans.modules.beans.Bundle",
483: "CTL_TITLE_NewProperty");
484: NbDialogOperator nbDialogOperator = new NbDialogOperator(
485: dialogTitle);
486:
487: JTextFieldOperator jTextFieldOperator = new JTextFieldOperator(
488: nbDialogOperator, 0);
489: jTextFieldOperator.typeText(NAME_NON_INDEX_PROPERTY);
490: JComboBoxOperator jComboBoxOperator = new JComboBoxOperator(
491: nbDialogOperator, 0);
492: jComboBoxOperator.typeText("MyType");
493: jComboBoxOperator = new JComboBoxOperator(nbDialogOperator, 1);
494: jComboBoxOperator.setSelectedItem(Bundle.getString(
495: "org.netbeans.modules.beans.Bundle",
496: "LAB_ReadWriteMODE"));
497: JCheckBoxOperator jCheckBoxOperator = new JCheckBoxOperator(
498: nbDialogOperator, Bundle.getString(
499: "org.netbeans.modules.beans.Bundle",
500: "CTL_PropertyPanel_fieldCheckBox"));
501: jCheckBoxOperator.push();
502:
503: new EventTool().waitNoEvent(2000);
504:
505: nbDialogOperator.ok();
506:
507: new JavaNode(repositoryRootNode, sampleDir + "|"
508: + NAME_TEST_FILE).open();
509:
510: EditorOperator eo = new EditorOperator(NAME_TEST_FILE);
511: ref(eo.getText());
512: compareReferenceFiles();
513:
514: }
515:
516: /** testGenerateReturnStatement method */
517: public void testGenerateReturnStatement() {
518:
519: RepositoryTabOperator explorerOperator = new RepositoryTabOperator();
520:
521: Node repositoryRootNode = explorerOperator.getRootNode();
522: Node patternsNode = new Node(repositoryRootNode, sampleDir
523: + "|"
524: + NAME_TEST_FILE
525: + "|"
526: + "class "
527: + NAME_TEST_FILE
528: + "|"
529: + Bundle.getString("org.netbeans.modules.beans.Bundle",
530: "Patterns"));
531: patternsNode.select();
532: patternsNode.performPopupActionNoBlock(Bundle.getString(
533: "org.openide.src.nodes.Bundle", "LAB_Add")
534: + "|"
535: + Bundle.getString("org.netbeans.modules.beans.Bundle",
536: "MENU_CREATE_PROPERTY"));
537: String dialogTitle = Bundle.getString(
538: "org.netbeans.modules.beans.Bundle",
539: "CTL_TITLE_NewProperty");
540: NbDialogOperator nbDialogOperator = new NbDialogOperator(
541: dialogTitle);
542:
543: JTextFieldOperator jTextFieldOperator = new JTextFieldOperator(
544: nbDialogOperator, 0);
545: jTextFieldOperator.typeText(NAME_NON_INDEX_PROPERTY);
546: JComboBoxOperator jComboBoxOperator = new JComboBoxOperator(
547: nbDialogOperator, 0);
548: jComboBoxOperator.typeText("MyType");
549: jComboBoxOperator = new JComboBoxOperator(nbDialogOperator, 1);
550: jComboBoxOperator.setSelectedItem(Bundle.getString(
551: "org.netbeans.modules.beans.Bundle",
552: "LAB_ReadWriteMODE"));
553: JCheckBoxOperator jCheckBoxOperator = new JCheckBoxOperator(
554: nbDialogOperator, Bundle.getString(
555: "org.netbeans.modules.beans.Bundle",
556: "CTL_PropertyPanel_fieldCheckBox"));
557: jCheckBoxOperator.push();
558: jCheckBoxOperator = new JCheckBoxOperator(nbDialogOperator,
559: Bundle.getString("org.netbeans.modules.beans.Bundle",
560: "CTL_PropertyPanel_returnCheckBox"));
561: jCheckBoxOperator.push();
562:
563: new EventTool().waitNoEvent(2000);
564:
565: nbDialogOperator.ok();
566:
567: new JavaNode(repositoryRootNode, sampleDir + "|"
568: + NAME_TEST_FILE).open();
569:
570: EditorOperator eo = new EditorOperator(NAME_TEST_FILE);
571: ref(eo.getText());
572: compareReferenceFiles();
573:
574: }
575:
576: /** testGenerateSetStatement method */
577: public void testGenerateSetStatement() {
578:
579: RepositoryTabOperator explorerOperator = new RepositoryTabOperator();
580:
581: Node repositoryRootNode = explorerOperator.getRootNode();
582: Node patternsNode = new Node(repositoryRootNode, sampleDir
583: + "|"
584: + NAME_TEST_FILE
585: + "|"
586: + "class "
587: + NAME_TEST_FILE
588: + "|"
589: + Bundle.getString("org.netbeans.modules.beans.Bundle",
590: "Patterns"));
591: patternsNode.select();
592: patternsNode.performPopupActionNoBlock(Bundle.getString(
593: "org.openide.src.nodes.Bundle", "LAB_Add")
594: + "|"
595: + Bundle.getString("org.netbeans.modules.beans.Bundle",
596: "MENU_CREATE_PROPERTY"));
597: String dialogTitle = Bundle.getString(
598: "org.netbeans.modules.beans.Bundle",
599: "CTL_TITLE_NewProperty");
600: NbDialogOperator nbDialogOperator = new NbDialogOperator(
601: dialogTitle);
602:
603: JTextFieldOperator jTextFieldOperator = new JTextFieldOperator(
604: nbDialogOperator, 0);
605: jTextFieldOperator.typeText(NAME_NON_INDEX_PROPERTY);
606: JComboBoxOperator jComboBoxOperator = new JComboBoxOperator(
607: nbDialogOperator, 0);
608: jComboBoxOperator.typeText("MyType");
609: jComboBoxOperator = new JComboBoxOperator(nbDialogOperator, 1);
610: jComboBoxOperator.setSelectedItem(Bundle.getString(
611: "org.netbeans.modules.beans.Bundle",
612: "LAB_ReadWriteMODE"));
613: JCheckBoxOperator jCheckBoxOperator = new JCheckBoxOperator(
614: nbDialogOperator, Bundle.getString(
615: "org.netbeans.modules.beans.Bundle",
616: "CTL_PropertyPanel_fieldCheckBox"));
617: jCheckBoxOperator.push();
618: jCheckBoxOperator = new JCheckBoxOperator(nbDialogOperator,
619: Bundle.getString("org.netbeans.modules.beans.Bundle",
620: "CTL_PropertyPanel_setCheckBox"));
621: jCheckBoxOperator.push();
622:
623: new EventTool().waitNoEvent(2000);
624:
625: nbDialogOperator.ok();
626:
627: new JavaNode(repositoryRootNode, sampleDir + "|"
628: + NAME_TEST_FILE).open();
629:
630: EditorOperator eo = new EditorOperator(NAME_TEST_FILE);
631: ref(eo.getText());
632: compareReferenceFiles();
633:
634: }
635:
636: /** testGeneratePropertyChangeSupport method */
637: public void testGeneratePropertyChangeSupport() {
638:
639: RepositoryTabOperator explorerOperator = new RepositoryTabOperator();
640:
641: Node repositoryRootNode = explorerOperator.getRootNode();
642: Node patternsNode = new Node(repositoryRootNode, sampleDir
643: + "|"
644: + NAME_TEST_FILE
645: + "|"
646: + "class "
647: + NAME_TEST_FILE
648: + "|"
649: + Bundle.getString("org.netbeans.modules.beans.Bundle",
650: "Patterns"));
651: patternsNode.select();
652: patternsNode.performPopupActionNoBlock(Bundle.getString(
653: "org.openide.src.nodes.Bundle", "LAB_Add")
654: + "|"
655: + Bundle.getString("org.netbeans.modules.beans.Bundle",
656: "MENU_CREATE_PROPERTY"));
657: String dialogTitle = Bundle.getString(
658: "org.netbeans.modules.beans.Bundle",
659: "CTL_TITLE_NewProperty");
660: NbDialogOperator nbDialogOperator = new NbDialogOperator(
661: dialogTitle);
662:
663: JTextFieldOperator jTextFieldOperator = new JTextFieldOperator(
664: nbDialogOperator, 0);
665: jTextFieldOperator.typeText(NAME_NON_INDEX_PROPERTY);
666: JComboBoxOperator jComboBoxOperator = new JComboBoxOperator(
667: nbDialogOperator, 0);
668: jComboBoxOperator.typeText("MyType");
669: jComboBoxOperator = new JComboBoxOperator(nbDialogOperator, 1);
670: jComboBoxOperator.setSelectedItem(Bundle.getString(
671: "org.netbeans.modules.beans.Bundle",
672: "LAB_ReadWriteMODE"));
673: JCheckBoxOperator jCheckBoxOperator = new JCheckBoxOperator(
674: nbDialogOperator, Bundle.getString(
675: "org.netbeans.modules.beans.Bundle",
676: "CTL_PropertyPanel_fieldCheckBox"));
677: jCheckBoxOperator.push();
678: jCheckBoxOperator = new JCheckBoxOperator(nbDialogOperator,
679: Bundle.getString("org.netbeans.modules.beans.Bundle",
680: "CTL_PropertyPanel_setCheckBox"));
681: jCheckBoxOperator.push();
682: jCheckBoxOperator = new JCheckBoxOperator(nbDialogOperator,
683: Bundle.getString("org.netbeans.modules.beans.Bundle",
684: "CTL_PropertyPanel_constrainedCheckBox"));
685: jCheckBoxOperator.push();
686: jCheckBoxOperator = new JCheckBoxOperator(nbDialogOperator,
687: Bundle.getString("org.netbeans.modules.beans.Bundle",
688: "CTL_PropertyPanel_boundCheckBox"));
689: jCheckBoxOperator.push();
690: jCheckBoxOperator = new JCheckBoxOperator(nbDialogOperator,
691: Bundle.getString("org.netbeans.modules.beans.Bundle",
692: "CTL_PropertyPanel_supportCheckBox"));
693: jCheckBoxOperator.push();
694:
695: new EventTool().waitNoEvent(2000);
696:
697: nbDialogOperator.ok();
698: new JavaNode(repositoryRootNode, sampleDir + "|"
699: + NAME_TEST_FILE).open();
700:
701: EditorOperator eo = new EditorOperator(NAME_TEST_FILE);
702: ref(eo.getText());
703: compareReferenceFiles();
704:
705: }
706:
707: }
|