1 19 20 28 package org.netbeans.test.subversion.main.checkout; 29 30 import java.io.File ; 31 import junit.textui.TestRunner; 32 import org.netbeans.jellytools.JellyTestCase; 33 import org.netbeans.jellytools.OutputOperator; 34 import org.netbeans.jemmy.JemmyProperties; 35 import org.netbeans.jemmy.TimeoutExpiredException; 36 import org.netbeans.jemmy.operators.JButtonOperator; 37 import org.netbeans.jemmy.operators.JFileChooserOperator; 38 import org.netbeans.jemmy.operators.JLabelOperator; 39 import org.netbeans.jemmy.operators.JTextFieldOperator; 40 import org.netbeans.jemmy.operators.Operator; 41 import org.netbeans.jemmy.operators.Operator.DefaultStringComparator; 42 import org.netbeans.junit.NbTestSuite; 43 import org.netbeans.test.subversion.operators.CheckoutWizardOperator; 44 import org.netbeans.test.subversion.operators.RepositoryBrowserOperator; 45 import org.netbeans.test.subversion.operators.RepositoryStepOperator; 46 import org.netbeans.test.subversion.operators.WorkDirStepOperator; 47 import org.netbeans.test.subversion.utils.RepositoryMaintenance; 48 import org.netbeans.test.subversion.utils.TestKit; 49 50 54 public class CheckoutUITest extends JellyTestCase{ 55 56 public static final String TMP_PATH = "/tmp"; 57 public static final String REPO_PATH = "repo"; 58 public static final String WORK_PATH = "work"; 59 public static final String PROJECT_NAME = "SVNApplication"; 60 public File projectPath; 61 String os_name; 62 Operator.DefaultStringComparator comOperator; 63 Operator.DefaultStringComparator oldOperator; 64 65 66 public CheckoutUITest(String name) { 67 super(name); 68 } 69 70 protected void setUp() throws Exception { 71 os_name = System.getProperty("os.name"); 72 System.out.println("### "+getName()+" ###"); 74 75 } 76 77 protected boolean isUnix() { 78 boolean unix = false; 79 if (os_name.indexOf("Windows") == -1) { 80 unix = true; 81 } 82 return unix; 83 } 84 85 public static void main(String [] args) { 86 TestRunner.run(suite()); 88 } 89 90 public static NbTestSuite suite() { 91 NbTestSuite suite = new NbTestSuite(); 92 suite.addTest(new CheckoutUITest("testInvokeClose")); 93 suite.addTest(new CheckoutUITest("testChangeAccessTypes")); 94 suite.addTest(new CheckoutUITest("testIncorrentUrl")); 95 suite.addTest(new CheckoutUITest("testAvailableFields")); 96 suite.addTest(new CheckoutUITest("testRepositoryFolder")); 97 return suite; 98 } 99 100 public void testInvokeClose() throws Exception { 101 TestKit.showStatusLabels(); 102 OutputOperator oo = OutputOperator.invoke(); 103 CheckoutWizardOperator co = CheckoutWizardOperator.invoke(); 104 co.btCancel().pushNoBlock(); 105 } 106 107 public void testChangeAccessTypes() throws Exception { 108 111 comOperator = new Operator.DefaultStringComparator(true, true); 112 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 113 Operator.setDefaultStringComparator(comOperator); 114 CheckoutWizardOperator co = CheckoutWizardOperator.invoke(); 115 Operator.setDefaultStringComparator(oldOperator); 116 RepositoryStepOperator rso = new RepositoryStepOperator(); 117 rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE); 118 Thread.sleep(1000); 119 rso.setRepositoryURL(RepositoryStepOperator.ITEM_SVN); 121 rso.txtUser().setText(RepositoryStepOperator.ITEM_SVN); 122 rso.txtPassword().setText(RepositoryStepOperator.ITEM_SVN); 123 Thread.sleep(1000); 124 rso.setRepositoryURL(RepositoryStepOperator.ITEM_SVNSSH); 126 rso.txtUser().setText(RepositoryStepOperator.ITEM_SVNSSH); 127 Thread.sleep(1000); 129 rso.setRepositoryURL(RepositoryStepOperator.ITEM_HTTP); 131 rso.txtUser().setText(RepositoryStepOperator.ITEM_HTTP); 132 rso.txtPassword().setText(RepositoryStepOperator.ITEM_HTTP); 133 Thread.sleep(1000); 134 rso.setRepositoryURL(RepositoryStepOperator.ITEM_HTTPS); 136 rso.txtUser().setText(RepositoryStepOperator.ITEM_HTTPS); 137 rso.txtPassword().setText(RepositoryStepOperator.ITEM_HTTPS); 138 Thread.sleep(1000); 139 co.btCancel().pushNoBlock(); 140 } 141 142 public void testIncorrentUrl() throws Exception { 143 comOperator = new Operator.DefaultStringComparator(true, true); 146 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 147 Operator.setDefaultStringComparator(comOperator); 148 CheckoutWizardOperator co = CheckoutWizardOperator.invoke(); 149 Operator.setDefaultStringComparator(oldOperator); 150 RepositoryStepOperator rso = new RepositoryStepOperator(); 151 rso.setRepositoryURL("dfile:///"); 153 assertEquals("This should be wrong url string!!!", "Invalid svn url :dfile:///", rso.lblWarning().getText()); 154 rso.setRepositoryURL("dsvn://"); 156 assertEquals("This should be wrong url string!!!", "Invalid svn url :dsvn://", rso.lblWarning().getText()); 157 rso.setRepositoryURL("file :///"); 159 assertEquals("This should be wrong url string!!!", "Invalid svn url :file :///", rso.lblWarning().getText()); 160 rso.setRepositoryURL("svn ://"); 162 assertEquals("This should be wrong url string!!!", "Invalid svn url :svn ://", rso.lblWarning().getText()); 163 rso.setRepositoryURL("http ://"); 165 assertEquals("This should be wrong url string!!!", "Invalid svn url :http ://", rso.lblWarning().getText()); 166 rso.setRepositoryURL("https ://"); 168 assertEquals("This should be wrong url string!!!", "Invalid svn url :https ://", rso.lblWarning().getText()); 169 rso.setRepositoryURL("svn+ssh ://"); 171 assertEquals("This should be wrong url string!!!", "Invalid svn url :svn+ssh ://", rso.lblWarning().getText()); 172 173 co.btCancel().pushNoBlock(); 174 } 175 176 public void testAvailableFields() throws Exception { 177 180 comOperator = new Operator.DefaultStringComparator(true, true); 181 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 182 Operator.setDefaultStringComparator(comOperator); 183 CheckoutWizardOperator co = CheckoutWizardOperator.invoke(); 184 Operator.setDefaultStringComparator(oldOperator); 185 RepositoryStepOperator rso = new RepositoryStepOperator(); 186 rso.selectRepositoryURL(RepositoryStepOperator.ITEM_FILE); 188 TimeoutExpiredException tee = null; 189 try { 190 JLabelOperator lbl = rso.lblUser(); 191 } catch (Exception e) { 192 tee = (TimeoutExpiredException) e; 193 } 194 assertNotNull("User name should not be accessible for file:///!!!" ,tee); 195 196 tee = null; 197 try { 198 JLabelOperator lbl = rso.lblPassword(); 199 } catch (Exception e) { 200 tee = (TimeoutExpiredException) e; 201 } 202 assertNotNull("Password should not be accessible for file:///!!!" ,tee); 203 204 rso = new RepositoryStepOperator(); 206 rso.setRepositoryURL(RepositoryStepOperator.ITEM_HTTP); 207 JLabelOperator lblU = rso.lblUser(); 208 JLabelOperator lblP = rso.lblPassword(); 209 JButtonOperator btnProxy = rso.btProxyConfiguration(); 210 211 rso = new RepositoryStepOperator(); 213 rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE); 214 tee = null; 215 try { 216 JLabelOperator lbl = rso.lblUser(); 217 } catch (Exception e) { 218 tee = (TimeoutExpiredException) e; 219 } 220 assertNotNull("User name should not be accessible for file:///!!!" ,tee); 221 222 tee = null; 223 try { 224 JLabelOperator lbl = rso.lblPassword(); 225 } catch (Exception e) { 226 tee = (TimeoutExpiredException) e; 227 } 228 assertNotNull("Password should not be accessible for file:///!!!" ,tee); 229 230 rso = new RepositoryStepOperator(); 232 rso.setRepositoryURL(RepositoryStepOperator.ITEM_HTTPS); 233 lblU = rso.lblUser(); 234 lblP = rso.lblPassword(); 235 btnProxy = rso.btProxyConfiguration(); 236 237 rso = new RepositoryStepOperator(); 239 rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE); 240 tee = null; 241 try { 242 JLabelOperator lbl = rso.lblUser(); 243 } catch (Exception e) { 244 tee = (TimeoutExpiredException) e; 245 } 246 assertNotNull("User name should not be accessible for file:///!!!" ,tee); 247 248 tee = null; 249 try { 250 JLabelOperator lbl = rso.lblPassword(); 251 } catch (Exception e) { 252 tee = (TimeoutExpiredException) e; 253 } 254 assertNotNull("Password should not be accessible for file:///!!!" ,tee); 255 256 rso = new RepositoryStepOperator(); 258 rso.setRepositoryURL(RepositoryStepOperator.ITEM_SVN); 259 lblU = rso.lblUser(); 260 lblP = rso.lblPassword(); 261 btnProxy = rso.btProxyConfiguration(); 262 263 rso = new RepositoryStepOperator(); 265 rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE); 266 tee = null; 267 try { 268 JLabelOperator lbl = rso.lblUser(); 269 } catch (Exception e) { 270 tee = (TimeoutExpiredException) e; 271 } 272 assertNotNull("User name should not be accessible for file:///!!!" ,tee); 273 274 tee = null; 275 try { 276 JLabelOperator lbl = rso.lblPassword(); 277 } catch (Exception e) { 278 tee = (TimeoutExpiredException) e; 279 } 280 assertNotNull("Password should not be accessible for file:///!!!" ,tee); 281 282 rso = new RepositoryStepOperator(); 284 rso.setRepositoryURL(RepositoryStepOperator.ITEM_SVNSSH); 285 lblU = rso.lblUseExternal(); 286 lblU = rso.lblTunnelCommand(); 287 JTextFieldOperator txt = rso.txtTunnelCommand(); 288 txt.typeText("plink"); 289 Thread.sleep(2000); 290 294 rso = new RepositoryStepOperator(); 296 rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE); 297 tee = null; 298 try { 299 JLabelOperator lbl = rso.lblUser(); 300 } catch (Exception e) { 301 tee = (TimeoutExpiredException) e; 302 } 303 assertNotNull("User name should not be accessible for file:///!!!" ,tee); 304 305 tee = null; 306 try { 307 JLabelOperator lbl = rso.lblPassword(); 308 } catch (Exception e) { 309 tee = (TimeoutExpiredException) e; 310 } 311 assertNotNull("Password should not be accessible for file:///!!!" ,tee); 312 313 co.btCancel().pushNoBlock(); 314 } 315 316 public void testRepositoryFolder() throws Exception { 317 320 comOperator = new Operator.DefaultStringComparator(true, true); 321 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 322 Operator.setDefaultStringComparator(comOperator); 323 CheckoutWizardOperator co = CheckoutWizardOperator.invoke(); 324 Operator.setDefaultStringComparator(oldOperator); 325 RepositoryStepOperator rso = new RepositoryStepOperator(); 326 327 new File (TMP_PATH).mkdirs(); 329 RepositoryMaintenance.deleteFolder(new File (TMP_PATH + File.separator + REPO_PATH)); 330 RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH); 331 RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump"); 332 rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false)); 333 334 rso.next(); 336 Thread.sleep(2000); 337 338 WorkDirStepOperator wdso = new WorkDirStepOperator(); 339 wdso.verify(); 340 RepositoryBrowserOperator rbo = wdso.browseRepository(); 341 rbo.verify(); 342 rbo.selectFolder("branches"); 344 rbo.selectFolder("tags"); 345 rbo.selectFolder("trunk"); 346 rbo.selectFolder("trunk|JavaApp|src|javaapp"); 347 rbo.ok(); 348 349 assertEquals("Wrong folder selection!!!", "trunk/JavaApp/src/javaapp", wdso.getRepositoryFolder()); 350 rbo = wdso.browseRepository(); 351 rbo.selectFolder("trunk|JavaApp"); 352 rbo.ok(); 353 assertEquals("Wrong folder selection!!!", "trunk/JavaApp", wdso.getRepositoryFolder()); 354 wdso.setLocalFolder("/tmp"); 355 JFileChooserOperator jfc = wdso.browseLocalFolder(); 356 assertEquals("Directory set in wizard not propagated to file chooser:", true, jfc.getCurrentDirectory().getAbsolutePath().endsWith("tmp")); 357 jfc.cancel(); 358 wdso.setRepositoryRevision("10"); 359 wdso.checkCheckoutContentOnly(true); 360 co.btCancel().pushNoBlock(); 361 } 362 363 public void testStopProcess() throws Exception { 364 367 comOperator = new Operator.DefaultStringComparator(true, true); 368 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 369 Operator.setDefaultStringComparator(comOperator); 370 CheckoutWizardOperator co = CheckoutWizardOperator.invoke(); 371 Operator.setDefaultStringComparator(oldOperator); 372 RepositoryStepOperator rso = new RepositoryStepOperator(); 373 374 new File (TMP_PATH).mkdirs(); 376 RepositoryMaintenance.deleteFolder(new File (TMP_PATH + File.separator + REPO_PATH)); 377 RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH); 378 RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump"); 379 rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false)); 380 381 rso.next(); 383 rso.btStop().push(); 385 assertEquals("Warning message - process was cancelled by user", "Action canceled by user", rso.lblWarning().getText()); 386 co.btCancel().pushNoBlock(); 387 } 388 } 389 | Popular Tags |