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: * Portions Copyrighted 2007 Sun Microsystems, Inc.
027: */
028: package org.netbeans.test.java.editor.codegeneration;
029:
030: import junit.textui.TestRunner;
031: import org.netbeans.jellytools.EditorOperator;
032: import org.netbeans.jellytools.MainWindowOperator;
033: import org.netbeans.jellytools.actions.Action;
034: import org.netbeans.jemmy.operators.JTreeOperator;
035: import org.netbeans.test.java.editor.jelly.GenerateCodeOperator;
036: import org.netbeans.test.java.editor.jelly.GenerateConstructorOperator;
037: import org.netbeans.test.java.editor.jelly.ImplementMethodsOperator;
038:
039: /**
040: *
041: * @author Jiri Prox
042: */
043: public class ImplementMethod extends GenerateCode {
044:
045: /** Creates a new instance of CreateConstructor */
046: public ImplementMethod(String name) {
047: super (name);
048: }
049:
050: public void testIssue112613() {
051: openSourceFile(
052: "org.netbeans.test.java.editor.codegeneration.ImplementMethod",
053: "test112613");
054: editor = new EditorOperator("test112613");
055: txtOper = editor.txtEditorPane();
056: try {
057: editor.requestFocus();
058: editor.setCaretPosition(18, 5);
059: assert (GenerateCodeOperator.containsItems(editor,
060: GenerateCodeOperator.GENERATE_CONSTRUCTOR,
061: GenerateCodeOperator.OVERRIDE_METHOD));
062: } finally {
063: editor.close(false);
064: }
065: openSourceFile(
066: "org.netbeans.test.java.editor.codegeneration.ImplementMethod",
067: "test112613b");
068: editor = new EditorOperator("test112613b");
069: txtOper = editor.txtEditorPane();
070: try {
071: editor.requestFocus();
072: editor.setCaretPosition(17, 1);
073: GenerateCodeOperator.openDialog(
074: GenerateCodeOperator.IMPLEMENT_METHOD, editor);
075: ImplementMethodsOperator imo = new ImplementMethodsOperator();
076: JTreeOperator jto = imo.treeTreeView$ExplorerTree();
077: jto.selectRow(1);
078: imo.btGenerate().push();
079: String expected = ""
080: + " public void m() {\n"
081: + " throw new UnsupportedOperationException(\"Not supported yet.\");\n"
082: + " }\n";
083: waitAndCompare(expected);
084: } finally {
085: editor.close(false);
086: }
087: }
088:
089: public void testMoreIfaces() {
090: openSourceFile(
091: "org.netbeans.test.java.editor.codegeneration.ImplementMethod",
092: "testMoreIfaces");
093: editor = new EditorOperator("testMoreIfaces");
094: txtOper = editor.txtEditorPane();
095: try {
096: editor.requestFocus();
097: editor.setCaretPosition(7, 5);
098: GenerateCodeOperator.openDialog(
099: GenerateCodeOperator.IMPLEMENT_METHOD, editor);
100: ImplementMethodsOperator imo = new ImplementMethodsOperator();
101: JTreeOperator jto = imo.treeTreeView$ExplorerTree();
102: jto.expandRow(4);
103: jto.selectRow(1);
104: jto.selectRow(5);
105: imo.btGenerate().push();
106: String expected = ""
107: + " @Override\n"
108: + " public int getColumnCount() {\n"
109: + " throw new UnsupportedOperationException(\"Not supported yet.\");\n"
110: + " }\n"
111: + "\n"
112: + " @Override\n"
113: + " public void run() {\n"
114: + " throw new UnsupportedOperationException(\"Not supported yet.\");\n"
115: + " }\n";
116: waitAndCompare(expected);
117: } finally {
118: editor.close(false);
119: }
120:
121: }
122:
123: public static void main(String[] args) {
124: TestRunner.run(ImplementMethod.class);
125: }
126: }
|