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 complete;
043:
044: import org.netbeans.jellytools.EditorOperator;
045: import org.netbeans.jellytools.NbDialogOperator;
046: import org.netbeans.jellytools.NewWizardOperator;
047: import org.netbeans.jellytools.TopComponentOperator;
048: import org.netbeans.jellytools.actions.OpenAction;
049: import org.netbeans.jellytools.modules.javacvs.output.AnnotateOutputOperator;
050: import org.netbeans.jellytools.modules.javacvs.output.LogOutputOperator;
051: import org.netbeans.jellytools.modules.javacvs.output.StatusOutputOperator;
052: import org.netbeans.jellytools.modules.vcscore.VCSCommandsOutputOperator;
053: import org.netbeans.jellytools.nodes.FilesystemNode;
054: import org.netbeans.jellytools.nodes.Node;
055: import org.netbeans.jellytools.util.StringFilter;
056: import org.netbeans.jemmy.operators.JTextFieldOperator;
057: import org.netbeans.test.oo.gui.jelly.javacvs.AddDialog;
058: import org.netbeans.test.oo.gui.jelly.javacvs.AnnotateDialog;
059: import org.netbeans.test.oo.gui.jelly.javacvs.CommitDialog;
060: import org.netbeans.test.oo.gui.jelly.javacvs.DiffDialog;
061: import org.netbeans.test.oo.gui.jelly.javacvs.LogDialog;
062: import org.netbeans.test.oo.gui.jelly.javacvs.RemoveDialog;
063: import org.netbeans.test.oo.gui.jelly.javacvs.StatusDialog;
064: import org.netbeans.test.oo.gui.jelly.javacvs.TagDialog;
065: import org.netbeans.test.oo.gui.jelly.vcscore.OutputOfVCSCommandsFrame;
066:
067: public class BasicCommands extends JCVSStub {
068:
069: public BasicCommands(String testName) {
070: super (testName);
071: }
072:
073: public static junit.framework.Test suite() {
074: // DEBUG = true;
075: junit.framework.TestSuite suite = new org.netbeans.junit.NbTestSuite();
076: suite.addTest(new BasicCommands("configure"));
077: suite.addTest(new BasicCommands("testAddDirectoryRecursive"));
078: suite
079: .addTest(new BasicCommands(
080: "testAddNoKeywordSubstitution"));
081: suite.addTest(new BasicCommands("testAddKeywordSubstitution"));
082: suite.addTest(new BasicCommands("testTagInit"));
083: suite.addTest(new BasicCommands("testTagDirectory"));
084: suite.addTest(new BasicCommands("testTagAdd"));
085: suite.addTest(new BasicCommands("testTagModified"));
086: suite.addTest(new BasicCommands("testTagByRevision"));
087: suite.addTest(new BasicCommands("testTagForce"));
088: suite.addTest(new BasicCommands("testTagDelete"));
089: suite.addTest(new BasicCommands("testUnmount"));
090: return suite;
091: }
092:
093: public static void main(java.lang.String[] args) {
094: junit.textui.TestRunner.run(suite());
095: }
096:
097: GenericNode pac1, subpac1;
098: GenericNode add1, add2, add3;
099:
100: GenericNode pac2, subpac2, subpac22;
101: GenericNode tag1, tag2, tag3, tag4, tag51, tag52, tag6;
102:
103: protected void createStructure() {
104: pac1 = new GenericNode(root, "pac1");
105: subpac1 = new GenericNode(pac1, "subpac1");
106: add1 = new GenericNode(subpac1, "add1");
107: add2 = new GenericNode(pac1, "add2");
108: add3 = new GenericNode(pac1, "add3");
109:
110: pac2 = new GenericNode(root, "pac2");
111: subpac2 = new GenericNode(pac2, "subpac2");
112: tag1 = new GenericNode(subpac2, "tag1", ".java");
113: tag2 = new GenericNode(pac2, "tag2", ".java");
114: tag3 = new GenericNode(pac2, "tag3", ".java");
115: tag4 = new GenericNode(pac2, "tag4", ".java");
116:
117: subpac22 = new GenericNode(pac2, "subpa22");
118: tag51 = new GenericNode(subpac22, "tag51");
119: tag52 = new GenericNode(subpac22, "tag52");
120:
121: tag6 = new GenericNode(pac2, "tag6", ".java");
122: }
123:
124: public void configure() {
125: super .configure();
126: }
127:
128: public void dumpStatus(GenericNode node, boolean directory) {
129: closeAllVCSWindows();
130: node.jcvsNode().jCVSStatus();
131: StatusDialog stat = new StatusDialog();
132: checkCheckBox(stat.cbIncludeTagInfo());
133: stat.runCommand();
134: stat.waitClosed();
135: node.waitHistoryShort("status -v");
136: StatusOutputOperator soo = new StatusOutputOperator(directory);
137: if (directory)
138: soo.dumpAll(out, "/cvsroot/test/jcvs/" + roothis toryshort);
139: else
140: soo.dumpFile(out, "/cvsroot/test/jcvs/" + roothis toryshort);
141: }
142:
143: public void testAddDirectoryRecursive() {
144: subpac1.mkdirs();
145: add1.save("Adding 1");
146: refresh(root);
147:
148: pac1.jcvsNode().jCVSAdd();
149: AddDialog add = new AddDialog();
150: add.txtMessage().setText("Adding Desc 1");
151: checkCheckBox(add.cbRecursively());
152: add.runCommand();
153: add.waitClosed();
154: pac1.waitHistoryShort("add -m \"Addin...\"");
155:
156: add1.waitStatus("LAdded; New", true);
157: dumpStatus(add1, false);
158:
159: compareReferenceFiles();
160: }
161:
162: public void assertKeywordSubstitution(AddDialog add, String value,
163: String switches) {
164: switches = "add "
165: + ((switches != null) ? (switches + " ") : "");
166: add.cboSubstitution().selectItem(value);
167: add.compareSwitches(switches);
168: JTextFieldOperator tfo = new JTextFieldOperator(add, switches);
169: assertEquals("Keyword Substitution assertion failed", switches,
170: tfo.getText());
171: }
172:
173: public void testAddNoKeywordSubstitution() {
174: add2.save("$Revision$\n");
175: refresh(pac1);
176:
177: add2.jcvsNode().jCVSAdd();
178: AddDialog add = new AddDialog();
179: assertKeywordSubstitution(add, "Reuse Old Value (-ko)", "-ko");
180: add.txtMessage().setText("Adding Desc 2");
181: add.runCommand();
182: add.waitClosed();
183: add2.waitHistoryShort("add -m \"Addin...\" -ko");
184: add2.waitStatus("LAdded; New", true);
185:
186: commitFile(add2, null, null);
187: add2.waitStatus("Up-to-date; 1.1", true);
188: out.println("Corrected file:");
189: out.println(loadFile(add2.file()));
190:
191: compareReferenceFiles();
192: }
193:
194: public void testAddKeywordSubstitution() {
195: add3.save("$Revision$\n");
196: refresh(pac1);
197:
198: add3.jcvsNode().jCVSAdd();
199: AddDialog add = new AddDialog();
200: assertKeywordSubstitution(add, "<NONE>", null);
201: assertKeywordSubstitution(add, "Binary (-kb)", "-kb");
202: assertKeywordSubstitution(add, "Keyword and Value (-kkv)",
203: "-kkv");
204: assertKeywordSubstitution(add,
205: "Keyword, Value, Locker (-kkvl)", "-kkvl");
206: assertKeywordSubstitution(add, "Keyword Only (-kk)", "-kk");
207: assertKeywordSubstitution(add, "Value Only (-kv)", "-kv");
208: assertKeywordSubstitution(add, "Reuse Old Value (-ko)", "-ko");
209:
210: assertKeywordSubstitution(add, "Keyword and Value (-kkv)",
211: "-kkv");
212: add.txtMessage().setText("Adding Desc 3");
213: add.runCommand();
214: add.waitClosed();
215: add3.waitHistoryShort("add -m \"Addin...\" -kkv");
216: add3.waitStatus("LAdded; New", true);
217:
218: commitFile(add3, null, null);
219: add3.waitStatus("Up-to-date; 1.1", true);
220: out.println("Corrected file:");
221: out.println(loadFile(add3.file()));
222:
223: compareReferenceFiles();
224: }
225:
226: public void testTagInit() {
227: subpac2.mkdirs();
228: refresh(root);
229: addDirectory(pac2);
230: refresh(pac2);
231: addDirectory(subpac2);
232: createAddCommitFile(tag1, "Java Classes|Empty");
233: createAddCommitFile(tag2, "Java Classes|Empty");
234: }
235:
236: public void testTagDirectory() {
237: TagDialog tag;
238:
239: pac2.jcvsNode().jCVSTag();
240: tag = new TagDialog();
241: tag.txtTag().typeText("DirectoryRecursiveTag");
242: checkCheckBox(tag.cbBranch());
243: tag.runCommand();
244: tag.waitClosed();
245: pac2.waitHistoryShort("tag -b DirectoryRecursiveTag");
246:
247: pac2.jcvsNode().jCVSTag();
248: tag = new TagDialog();
249: tag.txtTag().typeText("DirectoryTag");
250: checkCheckBox(tag.cbNotRecursively());
251: tag.runCommand();
252: tag.waitClosed();
253: pac2.waitHistoryShort("tag -l DirectoryTag");
254:
255: dumpStatus(pac2, true);
256:
257: compareReferenceFiles();
258: }
259:
260: public void testTagAdd() {
261: createAddCommitFile(tag3, "Java Classes|Empty");
262: TagDialog tag;
263:
264: tag3.jcvsNode().jCVSTag();
265: tag = new TagDialog();
266: tag.txtTag().typeText("AddTagName");
267: tag.runCommand();
268: tag.waitClosed();
269: tag3.waitHistoryShort("tag AddTagName");
270:
271: tag3.jcvsNode().jCVSTag();
272: tag = new TagDialog();
273: tag.txtTag().typeText("AddBranchTagName");
274: checkCheckBox(tag.cbBranch());
275: tag.runCommand();
276: tag.waitClosed();
277: tag3.waitHistoryShort("tag -b AddBranchTagName");
278:
279: dumpStatus(tag3, false);
280:
281: compareReferenceFiles();
282: }
283:
284: public void testTagModified() {
285: createAddCommitFile(tag4, "Java Classes|Empty");
286: tag4.save("");
287: refresh(tag4.parent());
288:
289: closeAllVCSWindows();
290: tag4.jcvsNode().jCVSTag();
291: TagDialog tag = new TagDialog();
292: tag.txtTag().typeText("ModifiedAddTagName");
293: checkCheckBox(tag.cbCheckModifiedFiles());
294: tag.runCommand();
295: tag.waitClosed();
296: assertCVSErrorDialog();
297: }
298:
299: public void testTagByRevision() {
300: commitFile(tag4, null, "Desc 1.2");
301: tag4.waitStatus("Up-to-date; 1.2");
302:
303: closeAllVCSWindows();
304: tag4.jcvsNode().jCVSTag();
305: TagDialog tag = new TagDialog();
306: tag.txtTag().typeText("AddTagToRevisionName");
307: checkCheckBox(tag.cbByRevision());
308: tag.txtByRevision().typeText("1.1");
309: tag.runCommand();
310: tag.waitClosed();
311:
312: dumpStatus(tag4, false);
313:
314: compareReferenceFiles();
315: }
316:
317: public void testTagForce() {
318: subpac22.mkdirs();
319: refresh(subpac22.parent());
320: addDirectory(subpac22);
321:
322: tag51.save("Tag51");
323: tag52.save("Tag52");
324: refresh(subpac22);
325: addFile(tag51, null);
326: commitFile(tag51, null, null);
327: tag51.waitStatus("Up-to-date; 1.1");
328: addTagFile(tag51, "NoForceTag", false);
329: tag51.save("Tag51a");
330: commitFile(tag51, null, null);
331: tag51.waitStatus("Up-to-date; 1.2");
332: addFile(tag52, null);
333: commitFile(tag52, null, null);
334: tag52.waitStatus("Up-to-date; 1.1");
335: addTagFile(tag52, "ForceTag", false);
336: tag52.save("Tag52a");
337: commitFile(tag52, null, null);
338: tag52.waitStatus("Up-to-date; 1.2");
339:
340: dumpStatus(subpac22, true);
341:
342: subpac22.jcvsNode().jCVSTag();
343: TagDialog tag = new TagDialog();
344: tag.txtTag().typeText("ForceTag");
345: checkCheckBox(tag.cbForceReassignement());
346: tag.runCommand();
347: tag.waitClosed();
348: subpac22.waitHistoryShort("tag -F ForceTag");
349:
350: dumpStatus(subpac22, true);
351:
352: compareReferenceFiles();
353: }
354:
355: public void testTagDelete() {
356: createAddCommitFile(tag6, "Java Classes|Empty");
357: addTagFile(tag6, "TagToDelete", false);
358:
359: dumpStatus(tag6, false);
360:
361: tag6.jcvsNode().jCVSTag();
362: TagDialog tag = new TagDialog();
363: tag.txtTag().typeText("TagToDelete");
364: checkCheckBox(tag.cbDelete());
365: tag.runCommand();
366: tag.waitClosed();
367: tag6.waitHistoryShort("tag -d TagToDelete");
368:
369: dumpStatus(tag6, false);
370:
371: compareReferenceFiles();
372: }
373:
374: public void testUnmount() {
375: new FilesystemNode(exp.repositoryTab().tree(), root.node())
376: .unmount();
377: new Node(exp.repositoryTab().tree(), "")
378: .waitChildNotPresent(root.node());
379: }
380:
381: }
|