1 9 package org.netbeans.test.cvsmodule; 10 11 import java.io.BufferedReader ; 12 import java.io.File ; 13 import java.io.FileReader ; 14 import java.io.InputStream ; 15 import javax.swing.ListModel ; 16 import javax.swing.table.TableModel ; 17 import junit.textui.TestRunner; 18 import org.netbeans.jellytools.EditorOperator; 19 import org.netbeans.jellytools.JellyTestCase; 20 import org.netbeans.jellytools.NbDialogOperator; 21 import org.netbeans.jellytools.OutputOperator; 22 import org.netbeans.jellytools.OutputTabOperator; 23 import org.netbeans.jellytools.ProjectsTabOperator; 24 import org.netbeans.jellytools.modules.javacvs.BranchOperator; 25 import org.netbeans.jellytools.modules.javacvs.CVSRootStepOperator; 26 import org.netbeans.jellytools.modules.javacvs.CheckoutWizardOperator; 27 import org.netbeans.jellytools.modules.javacvs.CommitOperator; 28 import org.netbeans.jellytools.modules.javacvs.DiffOperator; 29 import org.netbeans.jellytools.modules.javacvs.ModuleToCheckoutStepOperator; 30 import org.netbeans.jellytools.modules.javacvs.SearchHistoryOperator; 31 import org.netbeans.jellytools.modules.javacvs.SwitchToBranchOperator; 32 import org.netbeans.jellytools.modules.javacvs.VersioningOperator; 33 import org.netbeans.jellytools.nodes.Node; 34 import org.netbeans.jellytools.nodes.SourcePackagesNode; 35 import org.netbeans.jemmy.JemmyProperties; 36 import org.netbeans.jemmy.QueueTool; 37 import org.netbeans.jemmy.TimeoutExpiredException; 38 import org.netbeans.jemmy.operators.JButtonOperator; 39 import org.netbeans.jemmy.operators.JListOperator; 40 import org.netbeans.jemmy.operators.JProgressBarOperator; 41 import org.netbeans.jemmy.operators.JTableOperator; 42 import org.netbeans.jemmy.operators.JTextFieldOperator; 43 import org.netbeans.jemmy.operators.Operator; 44 import org.netbeans.jemmy.operators.Operator.DefaultStringComparator; 45 import org.netbeans.junit.NbTestSuite; 46 import org.netbeans.junit.ide.ProjectSupport; 47 48 52 public class StandardWorkFlow extends JellyTestCase { 53 54 String os_name; 55 static String sessionCVSroot; 56 final String projectName = "ForImport"; 57 final String pathToMain = "forimport|Main.java"; 58 final String PROTOCOL_FOLDER = "protocol"; 59 static File cacheFolder; 60 Operator.DefaultStringComparator comOperator; 61 Operator.DefaultStringComparator oldOperator; 62 63 66 public StandardWorkFlow(String name) { 67 super(name); 68 } 69 70 73 public static void main(String [] args) { 74 TestRunner.run(suite()); 76 } 77 78 public static NbTestSuite suite() { 79 NbTestSuite suite = new NbTestSuite(); 80 suite.addTest(new StandardWorkFlow("testCheckOutProject")); 81 suite.addTest(new StandardWorkFlow("testIgnoreUnignoreFile")); 82 suite.addTest(new StandardWorkFlow("testIgnoreUnignoreGuiForm")); 83 suite.addTest(new StandardWorkFlow("testCommit")); 84 suite.addTest(new StandardWorkFlow("testCreateBranchForProject")); 85 suite.addTest(new StandardWorkFlow("testSwitchProjectToBranch")); 86 suite.addTest(new StandardWorkFlow("testDiffFile")); 87 suite.addTest(new StandardWorkFlow("testExportDiffPatch")); 88 suite.addTest(new StandardWorkFlow("testResolveConflicts")); 89 suite.addTest(new StandardWorkFlow("testRevertModifications")); 90 suite.addTest(new StandardWorkFlow("testShowAnnotations")); 91 suite.addTest(new StandardWorkFlow("testSearchHistory")); 92 suite.addTest(new StandardWorkFlow("testVersioningButtons")); 93 suite.addTest(new StandardWorkFlow("testRemoveFileGetBack")); 94 suite.addTest(new StandardWorkFlow("testRemoveFileCommit")); 95 suite.addTest(new StandardWorkFlow("removeAllData")); 96 return suite; 97 } 98 99 protected void setUp() throws Exception { 100 101 os_name = System.getProperty("os.name"); 102 System.out.println("### "+getName()+" ###"); 104 105 } 106 107 protected boolean isUnix() { 108 boolean unix = false; 109 if (os_name.indexOf("Windows") == -1) { 110 unix = true; 111 } 112 return unix; 113 } 114 115 public void testCheckOutProject() throws Exception { 116 OutputOperator oo = OutputOperator.invoke(); 119 comOperator = new Operator.DefaultStringComparator(true, true); 120 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 121 Operator.setDefaultStringComparator(comOperator); 122 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 123 Operator.setDefaultStringComparator(oldOperator); 124 CVSRootStepOperator crso = new CVSRootStepOperator(); 125 crso.setCVSRoot(":pserver:anoncvs@localhost:/cvs"); 127 130 InputStream in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "authorized.in"); 132 PseudoCvsServer cvss = new PseudoCvsServer(in); 133 new Thread (cvss).start(); 134 cvss.ignoreProbe(); 135 String CVSroot = cvss.getCvsRoot(); 136 sessionCVSroot = CVSroot; 137 crso.setCVSRoot(CVSroot); 139 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 140 crso.next(); 141 142 try { 143 JProgressBarOperator progress = new JProgressBarOperator(crso); 144 JButtonOperator btnStop = new JButtonOperator(crso); 145 } catch (TimeoutExpiredException e) { 146 throw e; 147 } 148 149 152 File tmp = new File ("/tmp"); File work = new File (tmp, "" + File.separator + System.currentTimeMillis()); 154 cacheFolder = new File (work, projectName + File.separator + "src" + File.separator + "forimport" + File.separator + "CVS" + File.separator + "RevisionCache"); 155 tmp.mkdirs(); 156 work.mkdirs(); 157 tmp.deleteOnExit(); 158 ModuleToCheckoutStepOperator moduleCheck = new ModuleToCheckoutStepOperator(); 159 cvss.stop(); 160 in.close(); 161 moduleCheck.setModule("ForImport"); 162 moduleCheck.setLocalFolder(work.getAbsolutePath()); 164 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "checkout_finish_2.in"); 166 cvss = new PseudoCvsServer(in); 167 new Thread (cvss).start(); 168 CVSroot = cvss.getCvsRoot(); 169 171 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 174 cwo.finish(); 175 176 178 OutputTabOperator oto = new OutputTabOperator(sessionCVSroot); 179 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 180 oto.waitText("Checking out finished"); 181 cvss.stop(); 182 in.close(); 183 NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed"); 184 JButtonOperator open = new JButtonOperator(nbdialog, "Open Project"); 185 open.push(); 186 187 ProjectSupport.waitScanFinished(); 188 new QueueTool().waitEmpty(1000); 189 ProjectSupport.waitScanFinished(); 190 191 TestKit.createNewElements(projectName); 193 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 194 } 195 196 public void testIgnoreUnignoreFile() throws Exception { 197 VersioningOperator vo; 199 OutputTabOperator oto; 201 InputStream in; 202 PseudoCvsServer cvss; 203 String CVSroot; 204 JTableOperator table; 205 org.openide.nodes.Node nodeIDE; 206 String color; 207 208 Node nodeClass = new Node(new SourcePackagesNode(projectName), "xx|NewClass.java"); 209 nodeIDE = (org.openide.nodes.Node) nodeClass.getOpenideNode(); 210 color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 211 assertEquals("Wrong color for new file", TestKit.NEW_COLOR, color); 212 213 oto = new OutputTabOperator(sessionCVSroot); 217 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 218 oto.clear(); 219 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "show_changes_for_file"); 220 cvss = new PseudoCvsServer(in); 221 new Thread (cvss).start(); 222 CVSroot = cvss.getCvsRoot(); 223 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 224 nodeClass.performPopupAction("CVS|Show Changes"); 225 Thread.sleep(1000); 226 vo = VersioningOperator.invoke(); 227 table = vo.tabFiles(); 228 oto.waitText("Refreshing CVS Status finished"); 230 Thread.sleep(1000); 231 assertEquals("Wrong row count of table.", 1, table.getRowCount()); 232 assertEquals("Wrong file listed in table.", "NewClass.java", table.getValueAt(0, 0).toString()); 233 cvss.stop(); 234 235 oto = new OutputTabOperator(sessionCVSroot); 238 oto.clear(); 239 nodeClass.performPopupAction("CVS|Ignore"); 240 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "show_changes_for_file"); 241 cvss = new PseudoCvsServer(in); 242 new Thread (cvss).start(); 243 CVSroot = cvss.getCvsRoot(); 244 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 245 247 Thread.sleep(1000); 248 assertEquals("File should not be listed in table", 0, table.getRowCount()); 249 cvss.stop(); 250 251 nodeClass = new Node(new SourcePackagesNode(projectName), "xx|NewClass.java"); 252 nodeIDE = (org.openide.nodes.Node) nodeClass.getOpenideNode(); 253 color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 254 assertEquals("Wrong color for new file", TestKit.IGNORED_COLOR, color); 255 256 oto.clear(); 260 nodeClass.performPopupAction("CVS|Unignore"); 261 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "show_changes_for_file"); 262 cvss = new PseudoCvsServer(in); 263 new Thread (cvss).start(); 264 CVSroot = cvss.getCvsRoot(); 265 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 266 nodeClass.performPopupAction("CVS|Show Changes"); 267 oto.waitText("Refreshing CVS Status finished"); 268 Thread.sleep(1000); 269 assertEquals("File should not be listed in table", 1, table.getRowCount()); 270 cvss.stop(); 271 272 nodeIDE = (org.openide.nodes.Node) nodeClass.getOpenideNode(); 273 color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 274 assertEquals("Wrong color for new file", TestKit.NEW_COLOR, color); 275 276 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 277 } 278 279 public void testIgnoreUnignoreGuiForm() throws Exception { 280 VersioningOperator vo; 282 OutputTabOperator oto; 284 InputStream in; 285 PseudoCvsServer cvss; 286 String CVSroot; 287 JTableOperator table; 288 org.openide.nodes.Node nodeIDE; 289 String color; 290 Object [] expected; 291 Object [] actual; 292 293 Node nodeFrame = new Node(new SourcePackagesNode(projectName), "xx|NewJFrame.java"); 294 nodeIDE = (org.openide.nodes.Node) nodeFrame.getOpenideNode(); 295 color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 296 assertEquals("Wrong color for new file", TestKit.NEW_COLOR, color); 297 298 oto = new OutputTabOperator(sessionCVSroot); 302 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 303 oto.clear(); 304 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "show_changes_for_jframe"); 305 cvss = new PseudoCvsServer(in); 306 new Thread (cvss).start(); 307 CVSroot = cvss.getCvsRoot(); 308 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 309 nodeFrame.performPopupAction("CVS|Show Changes"); 310 Thread.sleep(1000); 311 vo = VersioningOperator.invoke(); 312 table = vo.tabFiles(); 313 oto.waitText("Refreshing CVS Status finished"); 315 Thread.sleep(1000); 316 cvss.stop(); 319 TableModel model = table.getModel(); 320 321 expected = new String [] {"NewJFrame.form", "NewJFrame.java"}; 322 actual = new String [model.getRowCount()]; 323 for (int i = 0; i < actual.length; i++) { 324 actual[i] = model.getValueAt(i, 0).toString(); 325 } 326 int result = TestKit.compareThem(expected, actual, false); 327 assertEquals("Wrong files in view", 2, result); 328 329 oto = new OutputTabOperator(sessionCVSroot); 333 oto.clear(); 334 nodeFrame.performPopupAction("CVS|Ignore"); 335 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "show_changes_for_jframe"); 336 cvss = new PseudoCvsServer(in); 337 new Thread (cvss).start(); 338 CVSroot = cvss.getCvsRoot(); 339 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 340 342 Thread.sleep(1000); 343 assertEquals("File should not be listed in table", 0, table.getRowCount()); 344 cvss.stop(); 345 346 nodeFrame = new Node(new SourcePackagesNode(projectName), "xx|NewJFrame.java"); 347 nodeIDE = (org.openide.nodes.Node) nodeFrame.getOpenideNode(); 348 color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 349 assertEquals("Wrong color for new file", TestKit.IGNORED_COLOR, color); 350 351 oto = new OutputTabOperator(sessionCVSroot); 355 oto.clear(); 356 nodeFrame.performPopupAction("CVS|Unignore"); 357 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "show_changes_for_jframe"); 358 cvss = new PseudoCvsServer(in); 359 new Thread (cvss).start(); 360 CVSroot = cvss.getCvsRoot(); 361 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 362 nodeFrame.performPopupAction("CVS|Show Changes"); 363 oto.waitText("Refreshing CVS Status finished"); 364 Thread.sleep(1000); 365 assertEquals("File should not be listed in table", 2, table.getRowCount()); 366 cvss.stop(); 367 368 nodeIDE = (org.openide.nodes.Node) nodeFrame.getOpenideNode(); 369 color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 370 assertEquals("Wrong color for new file", TestKit.NEW_COLOR, color); 371 372 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 373 } 374 375 public void testCommit() throws Exception { 376 PseudoCvsServer cvss, cvss2, cvss3, cvss4; 379 InputStream in, in2, in3, in4; 380 CommitOperator co; 381 String CVSroot, color; 382 JTableOperator table; 383 OutputTabOperator oto; 385 VersioningOperator vo; 386 String [] expected; 387 String [] actual; 388 String allCVSRoots; 389 org.openide.nodes.Node nodeIDE; 390 391 oto = new OutputTabOperator(sessionCVSroot); 392 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 393 394 Node packNode = new Node(new SourcePackagesNode("ForImport"), "xx"); 395 Node nodeClass = new Node(new SourcePackagesNode("ForImport"), "xx|NewClass.java"); 397 nodeIDE = (org.openide.nodes.Node) nodeClass.getOpenideNode(); 398 color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 399 assertEquals("Wrong color for new file", TestKit.NEW_COLOR, color); 400 402 Node nodeFrame = new Node(new SourcePackagesNode("ForImport"), "xx|NewJFrame.java"); 403 nodeIDE = (org.openide.nodes.Node) nodeFrame.getOpenideNode(); 404 color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 405 assertEquals("Wrong color for new file", TestKit.NEW_COLOR, color); 406 408 co = CommitOperator.invoke(packNode); 409 Thread.sleep(1000); 410 table = co.tabFiles(); 411 TableModel model = table.getModel(); 412 413 expected = new String [] {"NewClass.java", "NewJFrame.form", "NewJFrame.java"}; 414 actual = new String [model.getRowCount()]; 415 for (int i = 0; i < actual.length; i++) { 416 actual[i] = model.getValueAt(i, 0).toString(); 417 } 418 int result = TestKit.compareThem(expected, actual, false); 419 assertEquals("Wrong records displayed in dialog", 3, result); 420 co.setCommitMessage("Initial commit message"); 421 422 424 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "commit_invoke.in"); 426 cvss = new PseudoCvsServer(in); 427 new Thread (cvss).start(); 428 allCVSRoots = cvss.getCvsRoot() + ","; 429 430 in2 = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "commit_invoke_add.in"); 431 cvss2 = new PseudoCvsServer(in2); 432 new Thread (cvss2).start(); 433 allCVSRoots = allCVSRoots + cvss2.getCvsRoot() + ","; 434 435 in3 = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "commit_invoke_commit.in"); 436 cvss3 = new PseudoCvsServer(in3); 437 new Thread (cvss3).start(); 438 allCVSRoots = allCVSRoots + cvss3.getCvsRoot() + ","; 439 440 in4 = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "checkout_final.in"); 441 cvss4 = new PseudoCvsServer(in4); 442 new Thread (cvss4).start(); 443 allCVSRoots = allCVSRoots + cvss4.getCvsRoot(); 444 445 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", allCVSRoots); 446 co.commit(); 447 oto.waitText("Committing \"xx\" finished"); 448 449 cvss.stop(); 450 cvss2.stop(); 451 cvss3.stop(); 452 cvss4.stop(); 453 454 nodeIDE = (org.openide.nodes.Node) nodeClass.getOpenideNode(); 455 assertNull("Wrong color of node!!!", nodeIDE.getHtmlDisplayName()); 457 458 nodeIDE = (org.openide.nodes.Node) nodeFrame.getOpenideNode(); 459 assertNull("Wrong color of node!!!", nodeIDE.getHtmlDisplayName()); 460 461 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 462 } 463 464 public void testDiffFile() throws Exception { 465 PseudoCvsServer cvss; 467 InputStream in; 468 OutputTabOperator oto; 470 org.openide.nodes.Node nodeIDE; 471 String color; 472 473 oto = new OutputTabOperator(sessionCVSroot); 474 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 475 476 Node node = new Node(new SourcePackagesNode(projectName), pathToMain); 477 node.performPopupAction("Open"); 478 EditorOperator eo = new EditorOperator("Main.java"); 479 eo.deleteLine(2); 480 eo.insert(" insert", 5, 1); 481 eo.insert("\tSystem.out.println(\"\");\n", 19, 1); 482 eo.save(); 483 484 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "diff_class.in"); 485 cvss = new PseudoCvsServer(in); 486 new Thread (cvss).start(); 487 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", cvss.getCvsRoot()); 488 node.performPopupAction("CVS|Diff..."); 489 491 oto.waitText("Diffing \"Main.java\" finished"); 492 Thread.sleep(1000); 493 cvss.stop(); 494 495 Node nodeClass = new Node(new SourcePackagesNode(projectName), pathToMain); 496 nodeIDE = (org.openide.nodes.Node) nodeClass.getOpenideNode(); 497 color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 498 assertEquals("Wrong color for modified file", TestKit.MODIFIED_COLOR, color); 499 500 DiffOperator diffOp = new DiffOperator("Main.java"); 502 try { 504 TimeoutExpiredException afee = null; 505 diffOp.next(); 506 diffOp.next(); 507 try { 508 diffOp.next(); 509 } catch (TimeoutExpiredException e) { 510 afee = e; 511 } 512 assertNotNull("TimeoutExpiredException was expected.", afee); 513 514 afee = null; 516 diffOp.previous(); 517 diffOp.previous(); 518 try { 519 diffOp.previous(); 520 } catch (TimeoutExpiredException e) { 521 afee = e; 522 } 523 assertNotNull("TimeoutExpiredException was expected.", afee); 524 } catch (Exception e) { 525 System.out.println("Problem with buttons of differences"); 526 } 527 528 oto = new OutputTabOperator(sessionCVSroot); 532 oto.clear(); 533 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "diff/refresh.in"); 534 cvss = new PseudoCvsServer(in); 535 new Thread (cvss).start(); 536 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", cvss.getCvsRoot()); 537 diffOp.refresh(); 538 oto.waitText("Refreshing CVS Status finished"); 539 cvss.stop(); 540 Thread.sleep(1000); 541 542 oto = new OutputTabOperator(sessionCVSroot); 546 oto.clear(); 547 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "diff/refresh.in"); 548 cvss = new PseudoCvsServer(in); 549 new Thread (cvss).start(); 550 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", cvss.getCvsRoot()); 551 diffOp.update(); 552 oto.waitText("Updating Sources finished"); 553 cvss.stop(); 554 Thread.sleep(1000); 555 556 CommitOperator co = diffOp.commit(); 558 JTableOperator table = co.tabFiles(); 559 assertEquals("There should be only one file!", 1, table.getRowCount()); 560 assertEquals("There should be Main.java file only!", "Main.java", table.getValueAt(0, 0)); 561 co.cancel(); 562 563 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 564 eo.closeAllDocuments(); 565 TestKit.deleteRecursively(cacheFolder); 566 } 567 568 public void testExportDiffPatch() throws Exception { 569 PseudoCvsServer cvss, cvss2, cvss3; 572 InputStream in, in2, in3; 573 OutputTabOperator oto; 575 org.openide.nodes.Node nodeIDE; 576 String color, CVSroot; 577 578 oto = new OutputTabOperator(sessionCVSroot); 579 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 580 581 Node nodeClass = new Node(new SourcePackagesNode(projectName), pathToMain); 582 584 comOperator = new Operator.DefaultStringComparator(true, true); 585 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 586 Operator.setDefaultStringComparator(comOperator); 587 nodeClass.performMenuActionNoBlock("Versioning|CVS|Export"); 588 Operator.setDefaultStringComparator(oldOperator); 589 NbDialogOperator dialog = new NbDialogOperator("Export"); 590 JTextFieldOperator tf = new JTextFieldOperator(dialog, 0); 591 String patchFile = "/tmp/patch" + System.currentTimeMillis() + ".patch"; 592 File file = new File (patchFile); 593 tf.setText(file.getCanonicalFile().toString()); 595 JButtonOperator btnExport = new JButtonOperator(dialog, "export"); 596 598 oto = new OutputTabOperator(sessionCVSroot); 599 oto.clear(); 600 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "diff/export_diff.in"); 601 cvss = new PseudoCvsServer(in); 602 new Thread (cvss).start(); 603 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", cvss.getCvsRoot()); 604 btnExport.push(); 605 oto.waitText("Diff Patch finished"); 606 cvss.stop(); 607 Thread.sleep(1000); 608 assertTrue("Diff Patch file wasn't created!", file.isFile()); 610 BufferedReader br = new BufferedReader (new FileReader (file)); 611 String line = br.readLine(); 612 boolean generated = false; 613 if (line != null) { 614 generated = line.indexOf("# This patch file was generated by NetBeans IDE") != -1 ? true : false; 615 } 616 617 br.close(); 618 assertTrue("Diff Patch file is empty!", generated); 619 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 620 } 621 622 public void testResolveConflicts() throws Exception { 623 PseudoCvsServer cvss, cvss2, cvss3; 625 InputStream in, in2, in3; 626 OutputTabOperator oto; 628 org.openide.nodes.Node nodeIDE; 629 String color, CVSroot; 630 631 oto = new OutputTabOperator(sessionCVSroot); 632 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 633 oto.clear(); 634 635 Node nodeClass = new Node(new SourcePackagesNode(projectName), pathToMain); 636 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "diff/create_conflict.in"); 637 cvss = new PseudoCvsServer(in); 638 new Thread (cvss).start(); 639 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", cvss.getCvsRoot()); 640 nodeClass.performPopupActionNoBlock("CVS|Update"); 641 NbDialogOperator dialog = new NbDialogOperator("Warning"); 642 dialog.ok(); 643 oto.waitText("cvs server: conflicts found in Main.java"); 644 oto.waitText("Updating \"Main.java\" finished"); 645 Thread.sleep(1000); 646 cvss.stop(); 647 648 nodeClass = new Node(new SourcePackagesNode(projectName), pathToMain); 649 nodeIDE = (org.openide.nodes.Node) nodeClass.getOpenideNode(); 650 color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 651 assertEquals("Wrong color for file in conflict", TestKit.CONFLICT_COLOR, color); 652 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 653 } 654 655 public void testCreateBranchForProject() throws Exception { 656 PseudoCvsServer cvss, cvss2, cvss3; 658 InputStream in, in2, in3; 659 OutputTabOperator oto; 661 org.openide.nodes.Node nodeIDE; 662 String color, CVSroot; 663 664 oto = new OutputTabOperator(sessionCVSroot); 665 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 666 667 Node rootNode = new ProjectsTabOperator().getProjectRootNode(projectName); 668 669 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "create_new_branch_switch.in"); 670 cvss = new PseudoCvsServer(in); 671 new Thread (cvss).start(); 672 CVSroot = cvss.getCvsRoot(); 673 674 in2 = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "create_new_branch_switch_1.in"); 675 cvss2 = new PseudoCvsServer(in2); 676 new Thread (cvss2).start(); 677 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 679 680 BranchOperator bo = BranchOperator.invoke(rootNode); 681 bo.setBranchName("MyNewBranch"); 682 bo.checkSwitchToThisBranchAftewards(false); 683 bo.checkTagBeforeBranching(false); 684 oto = new OutputTabOperator(sessionCVSroot); 685 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 686 bo.branch(); 687 Thread.sleep(1000); 688 oto.waitText("Branch"); 691 oto.waitText("ForImport"); 692 oto.waitText("finished"); 693 cvss.stop(); 694 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 695 } 696 697 public void testSwitchProjectToBranch() throws Exception { 698 PseudoCvsServer cvss; 700 InputStream in; 701 OutputTabOperator oto; 703 org.openide.nodes.Node nodeIDE; 704 String color, cvsRoot; 705 706 oto = new OutputTabOperator(sessionCVSroot); 707 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 708 709 Node rootNode = new ProjectsTabOperator().getProjectRootNode(projectName); 710 711 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "create_new_branch_switch_1.in"); 712 cvss = new PseudoCvsServer(in); 713 new Thread (cvss).start(); 714 cvsRoot = cvss.getCvsRoot(); 715 716 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", cvsRoot); 717 oto = new OutputTabOperator(sessionCVSroot); 718 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 719 SwitchToBranchOperator sbo = SwitchToBranchOperator.invoke(rootNode); 720 sbo.switchToBranch(); 721 sbo.setBranch("MyNewBranch"); 722 sbo.pushSwitch(); 723 Thread.sleep(1000); 724 oto.waitText(" to Branch finished"); 726 727 cvss.stop(); 728 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 729 730 } 731 732 public void testRevertModifications() throws Exception { 733 PseudoCvsServer cvss; 735 InputStream in; 736 OutputTabOperator oto; 738 org.openide.nodes.Node nodeIDE; 739 String color, cvsRoot; 740 741 oto = new OutputTabOperator(sessionCVSroot); 743 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 744 oto.clear(); 745 746 TestKit.deleteRecursively(cacheFolder); 748 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "revert_modifications.in"); 749 cvss = new PseudoCvsServer(in); 750 new Thread (cvss).start(); 751 Node nodeMain = new Node(new SourcePackagesNode("ForImport"), "forimport|Main.java"); 752 nodeMain.performPopupActionNoBlock("CVS|Revert Modifications"); 753 NbDialogOperator nbDialog = new NbDialogOperator("Confirm overwrite"); 754 JButtonOperator btnYes = new JButtonOperator(nbDialog, "Yes"); 755 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", cvss.getCvsRoot()); 756 btnYes.push(); 757 Thread.sleep(1000); 758 oto = new OutputTabOperator(sessionCVSroot); 759 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 760 oto.waitText("Reverting finished"); 761 cvss.stop(); 762 763 764 nodeIDE = (org.openide.nodes.Node) nodeMain.getOpenideNode(); 765 assertNull("No color for node expected", nodeIDE.getHtmlDisplayName()); 766 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 767 } 768 769 public void testShowAnnotations() throws Exception { 770 PseudoCvsServer cvss, cvss2; 772 InputStream in, in2; 773 OutputTabOperator oto; 775 org.openide.nodes.Node nodeIDE; 776 String color, cvsRoot; 777 778 TestKit.deleteRecursively(cacheFolder); 779 780 oto = new OutputTabOperator(sessionCVSroot); 782 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 783 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "show_annotation.in"); 784 cvss = new PseudoCvsServer(in); 785 new Thread (cvss).start(); 786 787 in2 = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "show_annotation_1.in"); 788 cvss2 = new PseudoCvsServer(in2); 789 new Thread (cvss2).start(); 790 791 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", cvss.getCvsRoot() + "," + cvss2.getCvsRoot()); 792 Node nodeMain = new Node(new SourcePackagesNode("ForImport"), "forimport|Main.java"); 793 oto = new OutputTabOperator(sessionCVSroot); 794 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 795 nodeMain.performPopupAction("CVS|Show Annotations"); 796 Thread.sleep(1000); 797 oto.waitText("Loading Annotations finished"); 798 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 799 cvss.stop(); 800 cvss2.stop(); 801 } 802 803 public void testSearchHistory() throws Exception { 804 PseudoCvsServer cvss, cvss2; 806 InputStream in, in2; 807 OutputTabOperator oto; 809 org.openide.nodes.Node nodeIDE; 810 String color, cvsRoot; 811 812 TestKit.deleteRecursively(cacheFolder); 813 814 oto = new OutputTabOperator(sessionCVSroot); 816 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 817 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "search_history.in"); 818 cvss = new PseudoCvsServer(in); 819 new Thread (cvss).start(); 820 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", cvss.getCvsRoot()); 821 Node nodeMain = new Node(new SourcePackagesNode("ForImport"), "forimport|Main.java"); 822 SearchHistoryOperator sho = SearchHistoryOperator.invoke(nodeMain); 824 oto.waitText("Searching History finished"); 825 Thread.sleep(1000); 826 cvss.stop(); 827 828 oto.clear(); 829 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "search_history_1.in"); 830 cvss = new PseudoCvsServer(in); 831 new Thread (cvss).start(); 832 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", cvss.getCvsRoot()); 833 sho.setUsername("test"); 834 sho.setFrom("1.1"); 835 sho.setTo("1.1"); 836 sho.btSearch().push(); 837 oto.waitText("Searching History started"); 838 Thread.sleep(1000); 839 cvss.stop(); 840 JListOperator list = sho.lstHistory(); 841 842 ListModel model = list.getModel(); 843 assertEquals("Wrong result count", 2, model.getSize()); 844 assertTrue("Revision \"1.1\" is missing", model.getElementAt(1).toString().indexOf("1.1") > 0); 845 846 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 847 } 848 849 public void testVersioningButtons() throws Exception { 850 VersioningOperator vo; 852 OutputTabOperator oto; 854 InputStream in; 855 PseudoCvsServer cvss; 856 String CVSroot; 857 JTableOperator table; 858 org.openide.nodes.Node nodeIDE; 859 String color; 860 861 oto = new OutputTabOperator(sessionCVSroot); 862 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 863 864 Node nodeMain = new Node(new SourcePackagesNode(projectName), pathToMain); 866 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "versioning/show_changes_main.in"); 869 cvss = new PseudoCvsServer(in); 870 new Thread (cvss).start(); 871 CVSroot = cvss.getCvsRoot(); 872 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 873 nodeMain.performPopupAction("CVS|Show Changes"); 874 Thread.sleep(1000); 875 vo = VersioningOperator.invoke(); 876 table = vo.tabFiles(); 877 oto.waitText("Refreshing CVS Status finished"); 879 Thread.sleep(1000); 880 assertEquals("Table should be empty", 1, table.getRowCount()); 881 assertEquals("File should be [Remotely Modified]", "Remotely Modified", table.getValueAt(0, 1).toString()); 882 cvss.stop(); 883 885 oto = new OutputTabOperator(sessionCVSroot); 889 oto.clear(); 890 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "versioning/refresh_main.in"); 891 cvss = new PseudoCvsServer(in); 892 new Thread (cvss).start(); 893 CVSroot = cvss.getCvsRoot(); 894 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 895 vo.refresh(); 897 oto.waitText("Refreshing CVS Status finished"); 898 Thread.sleep(1000); 899 table = vo.tabFiles(); 900 assertEquals("Table should be empty", 0, table.getRowCount()); 901 cvss.stop(); 902 903 oto = new OutputTabOperator(sessionCVSroot); 906 oto.clear(); 907 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "versioning/refresh_main.in"); 908 cvss = new PseudoCvsServer(in); 909 new Thread (cvss).start(); 910 CVSroot = cvss.getCvsRoot(); 911 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 912 vo.update(); 914 oto.waitText("Updating Sources finished"); 915 Thread.sleep(1000); 916 cvss.stop(); 917 918 vo.commit(); 920 Thread.sleep(1000); 921 922 NbDialogOperator dialog = new NbDialogOperator("Comm"); 923 JButtonOperator btnOk = new JButtonOperator(dialog, "OK"); 924 btnOk.push(); 925 926 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 927 } 928 929 public void testRemoveFileGetBack() throws Exception { 930 PseudoCvsServer cvss, cvss2, cvss3; 932 InputStream in, in2, in3; 933 OutputTabOperator oto; 935 org.openide.nodes.Node nodeIDE; 936 String color, CVSroot; 937 VersioningOperator vo; 938 JTableOperator table; 939 940 oto = new OutputTabOperator(sessionCVSroot); 941 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 942 943 TestKit.deleteRecursively(cacheFolder); 944 Node nodeMain = new Node(new SourcePackagesNode(projectName), pathToMain); 945 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "versioning/refresh_main.in"); 946 cvss = new PseudoCvsServer(in); 947 new Thread (cvss).start(); 948 CVSroot = cvss.getCvsRoot(); 949 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 950 nodeMain.performPopupAction("CVS|Show Changes"); 951 Thread.sleep(1000); 952 vo = VersioningOperator.invoke(); 953 cvss.stop(); 954 955 nodeMain.performPopupActionNoBlock("Delete"); 956 NbDialogOperator dialog = new NbDialogOperator("Confirm Object Deletion"); 957 dialog.yes(); 958 Thread.sleep(1000); 959 table = vo.tabFiles(); 960 assertEquals("Files should have been [Locally Deleted]", "Locally Deleted", table.getValueAt(0, 1).toString()); 961 TimeoutExpiredException tee = null; 963 try { 964 nodeMain = new Node(new SourcePackagesNode(projectName), pathToMain); 965 } catch (Exception e) { 966 tee = (TimeoutExpiredException) e; 967 } 968 assertNotNull(tee); 969 970 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "revert_modifications.in"); 971 cvss = new PseudoCvsServer(in); 972 new Thread (cvss).start(); 973 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", cvss.getCvsRoot()); 974 975 new Thread (new Runnable () { 977 public void run() { 978 VersioningOperator vo = VersioningOperator.invoke(); 979 vo.performPopup("Main.java", "Revert Delete"); 980 } 981 }).start(); 982 dialog = new NbDialogOperator("Confirm overwrite"); 983 dialog.yes(); 984 oto.waitText("Reverting finished"); 985 Thread.sleep(1000); 986 cvss.stop(); 987 nodeMain = new Node(new SourcePackagesNode(projectName), pathToMain); 989 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 990 } 991 992 public void testRemoveFileCommit() throws Exception { 993 PseudoCvsServer cvss, cvss2, cvss3; 995 InputStream in, in2, in3; 996 OutputTabOperator oto; 998 org.openide.nodes.Node nodeIDE; 999 String color, CVSroot; 1000 VersioningOperator vo; 1001 JTableOperator table; 1002 1003 oto = new OutputTabOperator(sessionCVSroot); 1004 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 1005 1006 TestKit.deleteRecursively(cacheFolder); 1007 Node nodeMain = new Node(new SourcePackagesNode(projectName), pathToMain); 1008 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "versioning/refresh_main.in"); 1009 cvss = new PseudoCvsServer(in); 1010 new Thread (cvss).start(); 1011 CVSroot = cvss.getCvsRoot(); 1012 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 1013 nodeMain.performPopupAction("CVS|Show Changes"); 1014 Thread.sleep(1000); 1015 vo = VersioningOperator.invoke(); 1016 cvss.stop(); 1017 1018 nodeMain = new Node(new SourcePackagesNode(projectName), pathToMain); 1020 nodeMain.performPopupActionNoBlock("Delete"); 1021 NbDialogOperator dialog = new NbDialogOperator("Confirm Object Deletion"); 1022 dialog.yes(); 1023 Thread.sleep(1000); 1024 table = vo.tabFiles(); 1025 assertEquals("Files should have been [Locally Deleted]", "Locally Deleted", table.getValueAt(0, 1).toString()); 1026 1027 TimeoutExpiredException tee = null; 1028 try { 1029 nodeMain = new Node(new SourcePackagesNode(projectName), pathToMain); 1030 } catch (Exception e) { 1031 tee = (TimeoutExpiredException) e; 1032 } 1033 assertNotNull(tee); 1034 1035 1036 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "commit_locally_deleted_main.in"); 1037 cvss = new PseudoCvsServer(in); 1038 new Thread (cvss).start(); 1039 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", cvss.getCvsRoot()); 1040 1041 CommitOperator co = vo.commit(); 1043 table = co.tabFiles(); 1044 assertEquals("There should be one file only", 1, table.getRowCount()); 1045 assertEquals("There should Main.java file", "Main.java", table.getValueAt(0, 0)); 1046 assertEquals("File Main.java should be [Locally Deleted]", "Locally Deleted", table.getValueAt(0, 1)); 1047 co.commit(); 1048 1049 Thread.sleep(1000); 1050 cvss.stop(); 1051 oto.waitText("Committing finished"); 1052 1053 tee = null; 1054 try { 1055 nodeMain = new Node(new SourcePackagesNode(projectName), pathToMain); 1056 } catch (Exception e) { 1057 tee = (TimeoutExpiredException) e; 1058 } 1059 assertNotNull(tee); 1060 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 1061 } 1062 1063 public void removeAllData() { 1064 TestKit.removeAllData(projectName); 1065 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 1066 } 1067} 1068 | Popular Tags |