1 19 20 package org.netbeans.test.cvsmodule; 21 22 import java.io.File ; 23 import java.io.InputStream ; 24 import java.util.Random ; 25 import junit.textui.TestRunner; 26 import org.netbeans.jellytools.JellyTestCase; 27 import org.netbeans.jellytools.NbDialogOperator; 28 import org.netbeans.jellytools.OutputOperator; 29 import org.netbeans.jellytools.OutputTabOperator; 30 import org.netbeans.jellytools.modules.javacvs.BrowseCVSModuleOperator; 31 import org.netbeans.jellytools.modules.javacvs.BrowseTagsOperator; 32 import org.netbeans.jellytools.modules.javacvs.CVSRootStepOperator; 33 import org.netbeans.jellytools.modules.javacvs.CheckoutWizardOperator; 34 import org.netbeans.jellytools.modules.javacvs.EditCVSRootOperator; 35 import org.netbeans.jellytools.modules.javacvs.ModuleToCheckoutStepOperator; 36 import org.netbeans.jemmy.JemmyProperties; 37 import org.netbeans.jemmy.QueueTool; 38 import org.netbeans.jemmy.TimeoutExpiredException; 39 import org.netbeans.jemmy.operators.JButtonOperator; 40 import org.netbeans.jemmy.operators.JCheckBoxOperator; 41 import org.netbeans.jemmy.operators.JComboBoxOperator; 42 import org.netbeans.jemmy.operators.JFileChooserOperator; 43 import org.netbeans.jemmy.operators.JLabelOperator; 44 import org.netbeans.jemmy.operators.JPasswordFieldOperator; 45 import org.netbeans.jemmy.operators.JProgressBarOperator; 46 import org.netbeans.jemmy.operators.JRadioButtonOperator; 47 import org.netbeans.jemmy.operators.JTextFieldOperator; 48 import org.netbeans.jemmy.operators.Operator; 49 import org.netbeans.jemmy.operators.Operator.DefaultStringComparator; 50 import org.netbeans.junit.NbTestSuite; 51 import org.netbeans.junit.ide.ProjectSupport; 52 56 public class CheckOutWizardTest extends JellyTestCase { 57 58 String os_name; 59 final String projectName = "ForImport"; 60 final String pathToMain = "forimport|Main.java"; 61 final String PROTOCOL_FOLDER = "protocol"; 62 Operator.DefaultStringComparator comOperator; 63 Operator.DefaultStringComparator oldOperator; 64 65 68 public CheckOutWizardTest(String name) { 69 super(name); 70 } 71 72 75 public static void main(String [] args) { 76 TestRunner.run(suite()); 78 } 79 80 public static NbTestSuite suite() { 81 NbTestSuite suite = new NbTestSuite(); 82 suite.addTest(new CheckOutWizardTest("testInvokeCheckoutWizard")); 83 suite.addTest(new CheckOutWizardTest("testCancelCheckoutWizard")); 84 suite.addTest(new CheckOutWizardTest("testCheckoutWizardLocal")); 85 suite.addTest(new CheckOutWizardTest("testCheckoutWizardFork")); 86 suite.addTest(new CheckOutWizardTest("testCheckoutWizardPserver")); 87 suite.addTest(new CheckOutWizardTest("testCheckoutWizardExt")); 88 suite.addTest(new CheckOutWizardTest("testRandomChange")); 89 suite.addTest(new CheckOutWizardTest("testLocalUI")); 90 suite.addTest(new CheckOutWizardTest("testForkUI")); 91 suite.addTest(new CheckOutWizardTest("testPserverUI")); 92 suite.addTest(new CheckOutWizardTest("testExtUI")); 93 suite.addTest(new CheckOutWizardTest("testEditCVSRootDialogUI")); 94 suite.addTest(new CheckOutWizardTest("testPserverLoginSuccess")); 95 suite.addTest(new CheckOutWizardTest("testCheckWizardSecondStepUI")); 96 suite.addTest(new CheckOutWizardTest("testPserverLoginFailed")); 97 suite.addTest(new CheckOutWizardTest("testRepositoryBrowsing")); 98 suite.addTest(new CheckOutWizardTest("testAliasBrowsing")); 99 suite.addTest(new CheckOutWizardTest("testBranchBrowsing")); 100 suite.addTest(new CheckOutWizardTest("testTagBrowsing")); 101 suite.addTest(new CheckOutWizardTest("testCheckWizardFinish")); 102 105 return suite; 107 } 108 protected void setUp() throws Exception { 109 110 os_name = System.getProperty("os.name"); 111 System.out.println("### "+getName()+" ###"); 113 114 } 115 116 protected boolean isUnix() { 117 boolean unix = false; 118 if (os_name.indexOf("Windows") == -1) { 119 unix = true; 120 } 121 return unix; 122 } 123 124 public void testInvokeCheckoutWizard() { 125 CheckoutWizardOperator.invoke(); 126 } 127 128 public void testCancelCheckoutWizard() { 129 new CheckoutWizardOperator().cancel(); 130 } 131 132 public void testCheckoutWizardLocal() { 133 comOperator = new Operator.DefaultStringComparator(true, true); 134 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 135 Operator.setDefaultStringComparator(comOperator); 136 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 137 Operator.setDefaultStringComparator(oldOperator); 138 CVSRootStepOperator crso = new CVSRootStepOperator(); 139 crso.setCVSRoot(":local:/cvs"); 140 141 EditCVSRootOperator editOperator = crso.edit(); 142 assertEquals("Wrong access method in Edit CVSRoot dialog", "local", editOperator.getAccessMethod()); 143 assertEquals("Wrong repository path in Edit CVSRoot dialog", "/cvs", editOperator.getRepositoryPath()); 144 145 editOperator.setRepositoryPath("/cvs/repo"); 147 editOperator.cancel(); 148 assertEquals("Values are propagated, but Cancel was push", ":local:/cvs", crso.getCVSRoot()); 149 150 editOperator = crso.edit(); 152 editOperator.setRepositoryPath("/cvs/repo"); 153 editOperator.ok(); 154 assertEquals("Values are propagated, but Cancel was push", ":local:/cvs/repo", crso.getCVSRoot()); 155 crso.cancel(); 156 } 157 158 public void testCheckoutWizardFork() { 159 comOperator = new Operator.DefaultStringComparator(true, true); 160 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 161 Operator.setDefaultStringComparator(comOperator); 162 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 163 Operator.setDefaultStringComparator(oldOperator); 164 CVSRootStepOperator crso = new CVSRootStepOperator(); 165 crso.setCVSRoot(":fork:/cvs"); 166 167 EditCVSRootOperator editOperator = crso.edit(); 168 assertEquals("Wrong access method in Edit CVSRoot dialog", "fork", editOperator.getAccessMethod()); 169 assertEquals("Wrong repository path in Edit CVSRoot dialog", "/cvs", editOperator.getRepositoryPath()); 170 171 editOperator.setRepositoryPath("/cvs/repo"); 173 editOperator.cancel(); 174 assertEquals("Values are propagated, but Cancel was push", ":fork:/cvs", crso.getCVSRoot()); 175 176 editOperator = crso.edit(); 178 editOperator.setRepositoryPath("/cvs/repo"); 179 editOperator.ok(); 180 assertEquals("Values are propagated, but Cancel was push", ":fork:/cvs/repo", crso.getCVSRoot()); 181 crso.cancel(); 182 } 183 184 public void testCheckoutWizardPserver() { 185 comOperator = new Operator.DefaultStringComparator(true, true); 186 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 187 Operator.setDefaultStringComparator(comOperator); 188 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 189 Operator.setDefaultStringComparator(oldOperator); 190 CVSRootStepOperator crso = new CVSRootStepOperator(); 191 192 crso.setCVSRoot(":pserver:test@localhost:2401/cvs"); 193 crso.setPassword("test"); 194 195 EditCVSRootOperator editOperator = crso.edit(); 198 assertEquals("Wrong access method in Edit CVSRoot dialog", "pserver", editOperator.getAccessMethod()); 199 assertEquals("Wrong username Edit CVSRoot dialog", "test", editOperator.getUser()); 200 assertEquals("Wrong hostname in Edit CVSRoot dialog", "localhost", editOperator.getHost()); 201 assertEquals("Wrong port Edit CVSRoot dialog", "2401", editOperator.getPort()); 202 assertEquals("Wrong repository path Edit CVSRoot dialog", "/cvs", editOperator.getRepositoryPath()); 203 204 editOperator.selectAccessMethod(editOperator.ITEM_PSERVER); 206 editOperator.setRepositoryPath("/cvs/repo"); 207 editOperator.setHost("127.0.0.1"); 208 editOperator.setUser("user"); 209 editOperator.setPort("8080"); 210 editOperator.cancel(); 211 assertEquals("Values are propagated, but Cancel was push", ":pserver:test@localhost:2401/cvs", crso.getCVSRoot()); 212 213 editOperator = crso.edit(); 215 editOperator.selectAccessMethod(editOperator.ITEM_PSERVER); 216 editOperator.setRepositoryPath("/cvs/repo"); 217 editOperator.setHost("127.0.0.1"); 218 editOperator.setUser("user"); 219 editOperator.setPort("8080"); 220 editOperator.ok(); 221 assertEquals("Values are not propagated correctly", ":pserver:user@127.0.0.1:8080/cvs/repo", crso.getCVSRoot()); 222 crso.cancel(); 223 } 224 225 public void testCheckoutWizardExt() { 226 comOperator = new Operator.DefaultStringComparator(true, true); 227 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 228 Operator.setDefaultStringComparator(comOperator); 229 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 230 Operator.setDefaultStringComparator(oldOperator); 231 CVSRootStepOperator crso = new CVSRootStepOperator(); 232 crso.setCVSRoot(":ext:test@localhost:2401/cvs"); 233 crso.rbUseInternalSSH().push(); 234 235 crso.setPassword("test"); 236 crso.cbRememberPassword().push(); 237 crso.cbRememberPassword().push(); 238 crso.rbUseExternalShell().push(); 239 240 crso.setSSHCommand("plink.exe -l user -i private_key.ppk"); 241 EditCVSRootOperator editOperator = crso.edit(); 242 assertEquals("Wrong access method in Edit CVSRoot dialog", "ext", editOperator.getAccessMethod()); 243 assertEquals("Wrong username Edit CVSRoot dialog", "test", editOperator.getUser()); 244 assertEquals("Wrong hostname in Edit CVSRoot dialog", "localhost", editOperator.getHost()); 245 assertEquals("Wrong port Edit CVSRoot dialog", "2401", editOperator.getPort()); 246 assertEquals("Wrong repository path Edit CVSRoot dialog", "/cvs", editOperator.getRepositoryPath()); 247 248 editOperator.selectAccessMethod(editOperator.ITEM_EXT); 250 editOperator.setRepositoryPath("/cvs/repo"); 251 editOperator.setHost("127.0.0.1"); 252 editOperator.setUser("user"); 253 editOperator.setPort("8080"); 254 editOperator.cancel(); 255 assertEquals("Values are propagated, but Cancel was push", ":ext:test@localhost:2401/cvs", crso.getCVSRoot()); 256 257 editOperator = crso.edit(); 259 editOperator.selectAccessMethod(editOperator.ITEM_EXT); 260 editOperator.setRepositoryPath("/cvs/repo"); 261 editOperator.setHost("127.0.0.1"); 262 editOperator.setUser("user"); 263 editOperator.setPort("8080"); 264 editOperator.ok(); 265 assertEquals("Values are not propagated correctly", ":ext:user@127.0.0.1:8080/cvs/repo", crso.getCVSRoot()); 266 crso.cancel(); 267 } 268 269 public void testRandomChange() { 270 Random rand = new Random (); 271 int am; 272 String [] cvsRoots = new String [] {":local:/cvs", ":fork:/cvs", ":pserver:test@localhost:2401/cvs", ":ext:test@localhost:2401/cvs"}; 273 String [] accessMethods = new String [] {"local", "fork", "pserver", "ext"}; 274 comOperator = new Operator.DefaultStringComparator(true, true); 275 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 276 Operator.setDefaultStringComparator(comOperator); 277 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 278 Operator.setDefaultStringComparator(oldOperator); 279 CVSRootStepOperator crso = new CVSRootStepOperator(); 280 EditCVSRootOperator ecro; 281 for (int i = 0; i < 10; i++) { 282 int index = rand.nextInt(4); 283 switch (index) { 284 case 0: crso.setCVSRoot(cvsRoots[0]); 286 ecro = crso.edit(); 287 am = rand.nextInt(4); 288 ecro.selectAccessMethod(accessMethods[am]); 289 assertEquals("Wrong access method", accessMethods[am], ecro.getAccessMethod()); 290 ecro.cancel(); 291 break; 292 case 1: crso.setCVSRoot(cvsRoots[1]); 294 ecro = crso.edit(); 295 am = rand.nextInt(4); 296 ecro.selectAccessMethod(accessMethods[am]); 297 assertEquals("Wrong access method", accessMethods[am], ecro.getAccessMethod()); 298 ecro.cancel(); 299 break; 300 case 2: crso.setCVSRoot(cvsRoots[2]); 302 ecro = crso.edit(); 303 am = rand.nextInt(4); 304 ecro.selectAccessMethod(accessMethods[am]); 305 assertEquals("Wrong access method", accessMethods[am], ecro.getAccessMethod()); 306 ecro.cancel(); 307 break; 308 case 3: crso.setCVSRoot(cvsRoots[3]); 310 ecro = crso.edit(); 311 am = rand.nextInt(4); 312 ecro.selectAccessMethod(accessMethods[am]); 313 assertEquals("Wrong access method", accessMethods[am], ecro.getAccessMethod()); 314 ecro.cancel(); 315 break; 316 } 317 } 318 cwo.cancel(); 319 } 320 321 public void testPserverUI() { 322 comOperator = new Operator.DefaultStringComparator(true, true); 324 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 325 Operator.setDefaultStringComparator(comOperator); 326 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 327 Operator.setDefaultStringComparator(oldOperator); 328 CVSRootStepOperator crso = new CVSRootStepOperator(); 329 330 crso.setCVSRoot(":pserver:test"); 332 try { 333 JLabelOperator inv = new JLabelOperator(crso, "Invalid CVS Root"); 334 } catch (TimeoutExpiredException e) { 335 throw e; 336 } 337 338 crso.setCVSRoot(":pserver:test@localhost:2401/cvs"); 339 341 try { 343 JComboBoxOperator combo = new JComboBoxOperator(crso); 344 JPasswordFieldOperator passwd = new JPasswordFieldOperator(crso); 345 JButtonOperator btnEdit = new JButtonOperator(crso, "Edit..."); 346 JButtonOperator btnProxy = new JButtonOperator(crso, "Proxy Configuration..."); 347 JButtonOperator btnBack = new JButtonOperator(crso, "< Back"); 348 JButtonOperator btnNext = new JButtonOperator(crso, "Next >"); 349 JButtonOperator btnFinish = new JButtonOperator(crso, "Finish"); 350 JButtonOperator btnCancel = new JButtonOperator(crso, "Cancel"); 351 JButtonOperator btnHelp = new JButtonOperator(crso, "Help"); 352 } catch (TimeoutExpiredException e) { 353 throw e; 354 } 355 cwo.cancel(); 357 } 358 359 public void testLocalUI() { 360 comOperator = new Operator.DefaultStringComparator(true, true); 362 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 363 Operator.setDefaultStringComparator(comOperator); 364 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 365 Operator.setDefaultStringComparator(oldOperator); 366 CVSRootStepOperator crso = new CVSRootStepOperator(); 367 368 crso.setCVSRoot(":loca:"); 370 try { 371 JLabelOperator inv = new JLabelOperator(crso, "Only :pserver:, :local:, :ext: and :fork: connection methods supported"); 372 } catch (TimeoutExpiredException e) { 373 throw e; 374 } 375 crso.setCVSRoot(":local:/cvs"); 376 Exception ex; 377 try { 380 JComboBoxOperator combo = new JComboBoxOperator(crso); 381 JButtonOperator btnEdit = new JButtonOperator(crso, "Edit..."); 383 JButtonOperator btnBack = new JButtonOperator(crso, "< Back"); 384 JButtonOperator btnNext = new JButtonOperator(crso, "Next >"); 385 JButtonOperator btnFinish = new JButtonOperator(crso, "Finish"); 386 JButtonOperator btnCancel = new JButtonOperator(crso, "Cancel"); 387 JButtonOperator btnHelp = new JButtonOperator(crso, "Help"); 388 } catch (TimeoutExpiredException e) { 389 throw e; 390 } 391 393 cwo.cancel(); 394 } 395 396 397 public void testForkUI() { 398 comOperator = new Operator.DefaultStringComparator(true, true); 400 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 401 Operator.setDefaultStringComparator(comOperator); 402 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 403 Operator.setDefaultStringComparator(oldOperator); 404 CVSRootStepOperator crso = new CVSRootStepOperator(); 405 406 crso.setCVSRoot(":for:"); 408 try { 409 JLabelOperator inv = new JLabelOperator(crso, "Only :pserver:, :local:, :ext: and :fork: connection methods supported"); 410 } catch (TimeoutExpiredException e) { 411 throw e; 412 } 413 414 crso.setCVSRoot(":fork:/cvs"); 415 417 try { 418 JComboBoxOperator combo = new JComboBoxOperator(crso); 419 JButtonOperator btnEdit = new JButtonOperator(crso, "Edit..."); 421 JButtonOperator btnBack = new JButtonOperator(crso, "< Back"); 422 JButtonOperator btnNext = new JButtonOperator(crso, "Next >"); 423 JButtonOperator btnFinish = new JButtonOperator(crso, "Finish"); 424 JButtonOperator btnCancel = new JButtonOperator(crso, "Cancel"); 425 JButtonOperator btnHelp = new JButtonOperator(crso, "Help"); 426 } catch (TimeoutExpiredException e) { 427 throw e; 428 } 429 431 cwo.cancel(); 432 } 433 434 public void testExtUI() { 435 comOperator = new Operator.DefaultStringComparator(true, true); 437 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 438 Operator.setDefaultStringComparator(comOperator); 439 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 440 Operator.setDefaultStringComparator(oldOperator); 441 CVSRootStepOperator crso = new CVSRootStepOperator(); 442 crso.setCVSRoot(":ext:test@localhost:2401/cvs"); 443 crso.setCVSRoot(":ext:test"); 445 try { 446 JLabelOperator inv = new JLabelOperator(crso, "Invalid CVS Root"); 447 } catch (TimeoutExpiredException e) { 448 throw e; 449 } 450 451 crso.setCVSRoot(":ext:test@localhost:2401/cvs"); 452 try { 454 JComboBoxOperator combo = new JComboBoxOperator(crso); 455 JPasswordFieldOperator passwd = new JPasswordFieldOperator(crso); 456 JButtonOperator btnEdit = new JButtonOperator(crso, "Edit..."); 457 JButtonOperator btnProxy = new JButtonOperator(crso, "Proxy Configuration..."); 458 JRadioButtonOperator internal = new JRadioButtonOperator(crso, "Use Internal SSH"); 459 JRadioButtonOperator external = new JRadioButtonOperator(crso, "Use External Shell"); 460 JCheckBoxOperator remeber = new JCheckBoxOperator(crso, "Remember Password"); 461 JTextFieldOperator sshCommand = new JTextFieldOperator(crso); 462 JButtonOperator btnBack = new JButtonOperator(crso, "< Back"); 463 JButtonOperator btnNext = new JButtonOperator(crso, "Next >"); 464 JButtonOperator btnFinish = new JButtonOperator(crso, "Finish"); 465 JButtonOperator btnCancel = new JButtonOperator(crso, "Cancel"); 466 JButtonOperator btnHelp = new JButtonOperator(crso, "Help"); 467 } catch (TimeoutExpiredException e) { 468 throw e; 469 } 470 472 cwo.cancel(); 473 } 474 475 public void testEditCVSRootDialogUI() { 476 comOperator = new Operator.DefaultStringComparator(true, true); 478 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 479 Operator.setDefaultStringComparator(comOperator); 480 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 481 Operator.setDefaultStringComparator(oldOperator); 482 CVSRootStepOperator crso = new CVSRootStepOperator(); 483 EditCVSRootOperator ecro = crso.edit(); 484 try { 485 JComboBoxOperator combo = new JComboBoxOperator(ecro); 486 combo.selectItem("pserver"); 487 combo.selectItem("local"); 488 combo.selectItem("fork"); 489 combo.selectItem("ext"); 490 } catch (TimeoutExpiredException e) { 491 throw e; 492 } 493 494 try { 496 JTextFieldOperator user = new JTextFieldOperator(ecro, 0); 497 user.getFocus(); 498 JTextFieldOperator host = new JTextFieldOperator(ecro, 1); 499 host.getFocus(); 500 JTextFieldOperator repository = new JTextFieldOperator(ecro, 2); 501 repository.getFocus(); 502 JTextFieldOperator port = new JTextFieldOperator(ecro, 3); 503 port.getFocus(); 504 JButtonOperator btnOK = new JButtonOperator(ecro, "OK"); 505 JButtonOperator btnCancel = new JButtonOperator(ecro, "Cancel"); 506 JButtonOperator btnHelp = new JButtonOperator(ecro, "Help"); 507 } catch (TimeoutExpiredException e) { 508 throw e; 509 } 510 511 ecro.cancel(); 512 cwo.cancel(); 513 } 514 515 516 public void testPserverLoginFailed() throws Exception { 517 comOperator = new Operator.DefaultStringComparator(true, true); 520 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 521 Operator.setDefaultStringComparator(comOperator); 522 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 523 Operator.setDefaultStringComparator(oldOperator); 524 final CVSRootStepOperator crso = new CVSRootStepOperator(); 525 crso.setCVSRoot(":pserver:test@localhost:/cvs"); 526 527 InputStream in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "nonauthorized.in"); 529 if (in == null) { 530 System.err.println(getClass().getProtectionDomain().getCodeSource().getLocation().toExternalForm()); 531 in.markSupported(); 532 } 533 534 PseudoCvsServer cvss = new PseudoCvsServer(in); 535 new Thread (cvss).start(); 536 cvss.ignoreProbe(); 537 crso.setCVSRoot(cvss.getCvsRoot()); 538 539 crso.next(); 540 541 try { 542 JProgressBarOperator progress = new JProgressBarOperator(crso); 543 JButtonOperator btnStop = new JButtonOperator(crso); 544 } catch (TimeoutExpiredException e) { 545 throw e; 546 } 547 548 try { 550 JLabelOperator message = new JLabelOperator(crso, "Please check username, password and repository."); 551 } catch (TimeoutExpiredException e) { 552 throw e; 553 } 554 cvss.stop(); 555 in.close(); 556 cwo.cancel(); 557 } 558 559 public void testPserverLoginSuccess() throws Exception { 560 comOperator = new Operator.DefaultStringComparator(true, true); 563 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 564 Operator.setDefaultStringComparator(comOperator); 565 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 566 Operator.setDefaultStringComparator(oldOperator); 567 final CVSRootStepOperator crso = new CVSRootStepOperator(); 568 570 InputStream in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "authorized.in"); 572 if (in == null) { 573 System.err.println(getClass().getProtectionDomain().getCodeSource().getLocation().toExternalForm()); 574 in.markSupported(); 575 } 576 577 PseudoCvsServer cvss = new PseudoCvsServer(in); 578 new Thread (cvss).start(); 579 cvss.ignoreProbe(); 580 crso.setCVSRoot(cvss.getCvsRoot()); 581 crso.next(); 582 583 JProgressBarOperator progress = new JProgressBarOperator(crso); 584 JButtonOperator btnStop = new JButtonOperator(crso); 585 586 ModuleToCheckoutStepOperator moduleCheck = new ModuleToCheckoutStepOperator(); 588 cvss.stop(); 589 in.close(); 590 BrowseCVSModuleOperator bcmo = moduleCheck.browseModule(); 591 bcmo.cancel(); 592 cwo.cancel(); 594 } 595 596 597 public void testRepositoryBrowsing() throws Exception { 598 String CVSroot = ""; 599 comOperator = new Operator.DefaultStringComparator(true, true); 601 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 602 Operator.setDefaultStringComparator(comOperator); 603 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 604 Operator.setDefaultStringComparator(oldOperator); 605 CVSRootStepOperator crso = new CVSRootStepOperator(); 606 607 JComboBoxOperator combo = new JComboBoxOperator(crso, 0); 608 crso.setCVSRoot(":pserver:anoncvs@localhost:/cvs"); 609 crso.setPassword(""); 610 611 InputStream in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "authorized.in"); 612 if (in == null) { 613 System.err.println(getClass().getProtectionDomain().getCodeSource().getLocation().toExternalForm()); 614 in.markSupported(); 615 } 616 617 PseudoCvsServer cvss = new PseudoCvsServer(in); 618 new Thread (cvss).start(); 619 cvss.ignoreProbe(); 620 crso.setCVSRoot(cvss.getCvsRoot()); 621 622 crso.next(); 623 624 JProgressBarOperator progress = new JProgressBarOperator(crso); 625 JButtonOperator btnStop = new JButtonOperator(crso); 626 627 ModuleToCheckoutStepOperator moduleCheck = new ModuleToCheckoutStepOperator(); 628 cvss.stop(); 629 in.close(); 630 631 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "repository_browsing.in"); 632 cvss = new PseudoCvsServer(in); 633 new Thread (cvss).start(); 634 CVSroot = cvss.getCvsRoot(); 635 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 636 637 BrowseCVSModuleOperator browseCVSModule = moduleCheck.browseModule(); 638 browseCVSModule.selectModule("/cvs|CVSROOT"); 639 browseCVSModule.selectModule("/cvs|ForImport"); 640 browseCVSModule.ok(); 641 assertEquals("Folder in repository was not found", "ForImport", moduleCheck.getModule()); 642 643 cvss.stop(); 644 in.close(); 645 cwo.cancel(); 646 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 647 } 650 651 public void testAliasBrowsing() throws Exception { 652 String CVSroot = ""; 653 comOperator = new Operator.DefaultStringComparator(true, true); 655 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 656 Operator.setDefaultStringComparator(comOperator); 657 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 658 Operator.setDefaultStringComparator(oldOperator); 659 CVSRootStepOperator crso = new CVSRootStepOperator(); 660 661 JComboBoxOperator combo = new JComboBoxOperator(crso, 0); 662 crso.setCVSRoot(":pserver:anoncvs@localhost:/cvs"); 663 crso.setPassword(""); 664 665 InputStream in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "authorized.in"); 666 if (in == null) { 667 System.err.println(getClass().getProtectionDomain().getCodeSource().getLocation().toExternalForm()); 668 in.markSupported(); 669 } 670 671 PseudoCvsServer cvss = new PseudoCvsServer(in); 672 new Thread (cvss).start(); 673 cvss.ignoreProbe(); 674 crso.setCVSRoot(cvss.getCvsRoot()); 675 676 crso.next(); 677 678 JProgressBarOperator progress = new JProgressBarOperator(crso); 679 JButtonOperator btnStop = new JButtonOperator(crso); 680 681 ModuleToCheckoutStepOperator moduleCheck = new ModuleToCheckoutStepOperator(); 682 cvss.stop(); 683 in.close(); 684 685 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "alias_browsing.in"); 686 cvss = new PseudoCvsServer(in); 687 new Thread (cvss).start(); 688 CVSroot = cvss.getCvsRoot(); 689 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 690 691 BrowseCVSModuleOperator browseCVSModule = moduleCheck.browseModule(); 692 browseCVSModule.selectModule("Alias|ForImport"); 693 browseCVSModule.ok(); 694 assertEquals("Alias was not found", "ForImport", moduleCheck.getModule()); 695 696 cvss.stop(); 697 in.close(); 698 cwo.cancel(); 699 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 700 } 703 704 public void testBranchBrowsing() throws Exception { 705 String CVSroot; 706 comOperator = new Operator.DefaultStringComparator(true, true); 708 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 709 Operator.setDefaultStringComparator(comOperator); 710 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 711 Operator.setDefaultStringComparator(oldOperator); 712 CVSRootStepOperator crso = new CVSRootStepOperator(); 713 714 crso.setCVSRoot(":pserver:anoncvs@localhost:/cvs"); 715 crso.setPassword(""); 716 717 InputStream in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "authorized.in"); 718 if (in == null) { 719 System.err.println(getClass().getProtectionDomain().getCodeSource().getLocation().toExternalForm()); 720 in.markSupported(); 721 } 722 723 PseudoCvsServer cvss = new PseudoCvsServer(in); 724 new Thread (cvss).start(); 725 cvss.ignoreProbe(); 726 crso.setCVSRoot(cvss.getCvsRoot()); 727 728 crso.next(); 729 730 JProgressBarOperator progress = new JProgressBarOperator(crso); 731 JButtonOperator btnStop = new JButtonOperator(crso); 732 733 ModuleToCheckoutStepOperator moduleCheck = new ModuleToCheckoutStepOperator(); 734 cvss.stop(); 735 in.close(); 736 737 moduleCheck.setModule("ForImport"); 738 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "branch_check_browsing_1.in"); 739 cvss = new PseudoCvsServer(in); 740 new Thread (cvss).start(); 741 CVSroot = cvss.getCvsRoot() + ","; 742 743 InputStream in2 = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "branch_browsing.in"); 744 PseudoCvsServer cvss2 = new PseudoCvsServer(in2); 745 new Thread (cvss2).start(); 746 CVSroot = CVSroot + cvss2.getCvsRoot(); 747 748 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 749 750 BrowseTagsOperator browseTags = moduleCheck.browseBranch(); 751 browseTags.selectBranch("MyBranch"); 752 browseTags.ok(); 753 assertEquals("Branch was not found", "MyBranch", moduleCheck.getBranch()); 754 cvss.stop(); 755 in.close(); 756 cvss2.stop(); 757 in2.close(); 758 759 cwo.cancel(); 760 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 763 } 764 765 public void testTagBrowsing() throws Exception { 766 String CVSroot; 767 comOperator = new Operator.DefaultStringComparator(true, true); 769 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 770 Operator.setDefaultStringComparator(comOperator); 771 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 772 Operator.setDefaultStringComparator(oldOperator); 773 CVSRootStepOperator crso = new CVSRootStepOperator(); 774 775 crso.setCVSRoot(":pserver:anoncvs@localhost:/cvs"); 776 crso.setPassword(""); 777 InputStream in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "authorized.in"); 778 if (in == null) { 779 System.err.println(getClass().getProtectionDomain().getCodeSource().getLocation().toExternalForm()); 780 in.markSupported(); 781 } 782 783 PseudoCvsServer cvss = new PseudoCvsServer(in); 784 new Thread (cvss).start(); 785 cvss.ignoreProbe(); 786 crso.setCVSRoot(cvss.getCvsRoot()); 787 788 crso.next(); 789 790 JProgressBarOperator progress = new JProgressBarOperator(crso); 791 JButtonOperator btnStop = new JButtonOperator(crso); 792 793 ModuleToCheckoutStepOperator moduleCheck = new ModuleToCheckoutStepOperator(); 794 cvss.stop(); 795 in.close(); 796 797 moduleCheck.setModule("ForImport"); 798 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "branch_check_browsing_1.in"); 799 cvss = new PseudoCvsServer(in); 800 new Thread (cvss).start(); 801 CVSroot = cvss.getCvsRoot() + ","; 802 803 InputStream in2 = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "branch_browsing.in"); 804 PseudoCvsServer cvss2 = new PseudoCvsServer(in2); 805 new Thread (cvss2).start(); 806 CVSroot = CVSroot + cvss2.getCvsRoot(); 807 808 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 809 810 BrowseTagsOperator browseTags = moduleCheck.browseBranch(); 811 812 browseTags.selectTag("MyBranch_root"); 813 814 try { 815 JButtonOperator btnOk = new JButtonOperator(browseTags, "OK"); 816 JButtonOperator btnHelp = new JButtonOperator(browseTags, "Help"); 817 JButtonOperator btnCancel = new JButtonOperator(browseTags, "Cancel"); 818 } catch(TimeoutExpiredException e) { 819 throw e; 820 } 821 823 browseTags.ok(); 824 assertEquals("Branch was not found", "MyBranch_root", moduleCheck.getBranch()); 825 cvss.stop(); 826 in.close(); 827 cvss2.stop(); 828 in2.close(); 829 830 cwo.cancel(); 831 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 834 } 835 836 public void testCheckWizardSecondStepUI() throws Exception { 837 comOperator = new Operator.DefaultStringComparator(true, true); 839 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 840 Operator.setDefaultStringComparator(comOperator); 841 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 842 Operator.setDefaultStringComparator(oldOperator); 843 final CVSRootStepOperator crso = new CVSRootStepOperator(); 844 crso.setCVSRoot(":pserver:anoncvs@localhost:/cvs"); 845 crso.setPassword(""); 846 848 InputStream in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "authorized.in"); 850 if (in == null) { 851 System.err.println(getClass().getProtectionDomain().getCodeSource().getLocation().toExternalForm()); 852 in.markSupported(); 853 } 854 855 PseudoCvsServer cvss = new PseudoCvsServer(in); 856 new Thread (cvss).start(); 857 cvss.ignoreProbe(); 858 crso.setCVSRoot(cvss.getCvsRoot()); 859 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", cvss.getCvsRoot()); 860 861 crso.next(); 862 863 JProgressBarOperator progress = new JProgressBarOperator(crso); 864 JButtonOperator btnStop = new JButtonOperator(crso); 865 866 File file = new File ("/tmp"); file.mkdir(); 870 file.deleteOnExit(); 871 ModuleToCheckoutStepOperator moduleCheck = new ModuleToCheckoutStepOperator(); 872 cvss.stop(); 873 in.close(); 874 BrowseCVSModuleOperator browseCVSModule = moduleCheck.browseModule(); 875 browseCVSModule.selectModule("Aliases"); 877 browseCVSModule.selectModule("/cvs"); 879 try { 882 JButtonOperator btnCancel = new JButtonOperator(browseCVSModule, "Cancel"); 883 JButtonOperator btnHelp = new JButtonOperator(browseCVSModule, "Help"); 884 JButtonOperator btnOk = new JButtonOperator(browseCVSModule, "Ok"); 885 btnOk.push(); 886 } catch(TimeoutExpiredException e) { 887 throw e; 888 } 889 890 moduleCheck.setLocalFolder("/tmp"); JFileChooserOperator browseFolder = moduleCheck.browseLocalFolder(); 892 assertEquals("Directory set in wizard not propagated to file chooser:", true, browseFolder.getCurrentDirectory().getAbsolutePath().endsWith("tmp")); browseFolder.cancel(); 894 try { 897 JButtonOperator btn1 = new JButtonOperator(crso, 0); 898 JButtonOperator btn2 = new JButtonOperator(crso, 1); 899 JButtonOperator btn3 = new JButtonOperator(crso, 2); 900 JTextFieldOperator txt1 = new JTextFieldOperator(crso, 0); 901 JTextFieldOperator txt2 = new JTextFieldOperator(crso, 1); 902 JTextFieldOperator txt3 = new JTextFieldOperator(crso, 2); 903 JButtonOperator btnBack = new JButtonOperator(crso, "< Back"); 904 JButtonOperator btnNext = new JButtonOperator(crso, "Next >"); 905 JButtonOperator btnFinish = new JButtonOperator(crso, "Finish"); 906 JButtonOperator btnCancel = new JButtonOperator(crso, "Cancel"); 907 JButtonOperator btnHelp = new JButtonOperator(crso, "Help"); 908 } catch (TimeoutExpiredException ex) { 909 throw ex; 910 } 911 cwo.cancel(); 912 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 913 } 914 915 public void testCheckWizardFinish() throws Exception { 916 TestKit.closeProject(projectName); 919 String sessionCVSroot; 920 OutputOperator oo = OutputOperator.invoke(); 921 comOperator = new Operator.DefaultStringComparator(true, true); 922 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 923 Operator.setDefaultStringComparator(comOperator); 924 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 925 Operator.setDefaultStringComparator(oldOperator); 926 CVSRootStepOperator crso = new CVSRootStepOperator(); 927 928 crso.setCVSRoot(":pserver:anoncvs@localhost:/cvs"); 929 932 InputStream in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "authorized.in"); 934 if (in == null) { 935 System.err.println(getClass().getProtectionDomain().getCodeSource().getLocation().toExternalForm()); 936 in.markSupported(); 937 } 938 939 PseudoCvsServer cvss = new PseudoCvsServer(in); 940 new Thread (cvss).start(); 941 cvss.ignoreProbe(); 942 String CVSroot = cvss.getCvsRoot(); 943 crso.setCVSRoot(CVSroot); 944 sessionCVSroot = CVSroot; 945 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 946 crso.next(); 947 948 try { 949 JProgressBarOperator progress = new JProgressBarOperator(crso); 950 JButtonOperator btnStop = new JButtonOperator(crso); 951 } catch (TimeoutExpiredException e) { 952 throw e; 953 } 954 955 958 File tmp = new File ("/tmp"); File work = new File (tmp, "" + File.separator + System.currentTimeMillis()); 960 tmp.mkdirs(); 961 work.mkdirs(); 962 tmp.deleteOnExit(); 963 ModuleToCheckoutStepOperator moduleCheck = new ModuleToCheckoutStepOperator(); 964 cvss.stop(); 965 in.close(); 966 moduleCheck.setModule("ForImport"); 967 moduleCheck.setLocalFolder(work.getAbsolutePath()); 969 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "checkout_finish_2.in"); 971 cvss = new PseudoCvsServer(in); 972 new Thread (cvss).start(); 973 CVSroot = cvss.getCvsRoot(); 974 976 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 978 cwo.finish(); 979 980 981 OutputTabOperator oto = new OutputTabOperator(sessionCVSroot); 983 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 984 oto.waitText("Checking out finished"); 985 cvss.stop(); 986 in.close(); 987 NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed"); 988 JButtonOperator open = new JButtonOperator(nbdialog, "Open Project"); 989 open.push(); 990 991 ProjectSupport.waitScanFinished(); 992 new QueueTool().waitEmpty(1000); 993 ProjectSupport.waitScanFinished(); 994 995 TestKit.closeProject(projectName); 996 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 997 } 998 } 999 | Popular Tags |