1 9 10 package org.netbeans.test.subversion.main.checkout; 11 12 import java.io.File ; 13 import junit.textui.TestRunner; 14 import org.netbeans.jellytools.JellyTestCase; 15 import org.netbeans.jellytools.NbDialogOperator; 16 import org.netbeans.jellytools.NewProjectNameLocationStepOperator; 17 import org.netbeans.jellytools.NewProjectWizardOperator; 18 import org.netbeans.jellytools.OutputOperator; 19 import org.netbeans.jellytools.OutputTabOperator; 20 import org.netbeans.jemmy.JemmyProperties; 21 import org.netbeans.jemmy.QueueTool; 22 import org.netbeans.jemmy.operators.JButtonOperator; 23 import org.netbeans.jemmy.operators.JTextFieldOperator; 24 import org.netbeans.jemmy.operators.Operator; 25 import org.netbeans.jemmy.operators.Operator.DefaultStringComparator; 26 import org.netbeans.junit.NbTestSuite; 27 import org.netbeans.junit.ide.ProjectSupport; 28 import org.netbeans.test.subversion.operators.CheckoutWizardOperator; 29 import org.netbeans.test.subversion.operators.RepositoryStepOperator; 30 import org.netbeans.test.subversion.operators.WorkDirStepOperator; 31 import org.netbeans.test.subversion.utils.RepositoryMaintenance; 32 import org.netbeans.test.subversion.utils.TestKit; 33 34 38 public class CreateProjectVersionedDirTest extends JellyTestCase { 39 40 public static final String TMP_PATH = "/tmp"; 41 public static final String REPO_PATH = "repo"; 42 public static final String WORK_PATH = "work"; 43 public static final String PROJECT_NAME = "JavaApp"; 44 public File projectPath; 45 String os_name; 46 Operator.DefaultStringComparator comOperator; 47 Operator.DefaultStringComparator oldOperator; 48 49 50 public CreateProjectVersionedDirTest(String name) { 51 super(name); 52 } 53 54 protected void setUp() throws Exception { 55 os_name = System.getProperty("os.name"); 56 System.out.println("### "+getName()+" ###"); 58 59 } 60 61 protected boolean isUnix() { 62 boolean unix = false; 63 if (os_name.indexOf("Windows") == -1) { 64 unix = true; 65 } 66 return unix; 67 } 68 69 public static void main(String [] args) { 70 TestRunner.run(suite()); 72 } 73 74 public static NbTestSuite suite() { 75 NbTestSuite suite = new NbTestSuite(); 76 suite.addTest(new CreateProjectVersionedDirTest("testCreateNewProject")); 77 return suite; 78 } 79 80 public void testCreateNewProject() throws Exception { 81 try { 84 TestKit.closeProject(PROJECT_NAME); 85 OutputTabOperator oto; 86 OutputOperator oo = OutputOperator.invoke(); 87 comOperator = new Operator.DefaultStringComparator(true, true); 88 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 89 Operator.setDefaultStringComparator(comOperator); 90 CheckoutWizardOperator co = CheckoutWizardOperator.invoke(); 91 Operator.setDefaultStringComparator(oldOperator); 92 RepositoryStepOperator rso = new RepositoryStepOperator(); 93 94 File work = new File (TMP_PATH + File.separator + WORK_PATH + File.separator + "w" + System.currentTimeMillis()); 96 new File (TMP_PATH).mkdirs(); 97 work.mkdirs(); 98 RepositoryMaintenance.deleteFolder(new File (TMP_PATH + File.separator + REPO_PATH)); 99 RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH); 101 RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump"); 102 rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false)); 103 104 rso.next(); 105 oto = new OutputTabOperator("file:///tmp/repo"); 106 oto.clear(); 107 WorkDirStepOperator wdso = new WorkDirStepOperator(); 108 wdso.setRepositoryFolder("trunk/" + PROJECT_NAME); 109 wdso.setLocalFolder(work.getCanonicalPath()); 110 wdso.checkCheckoutContentOnly(false); 111 wdso.finish(); 112 oto.waitText("Checking out... finished."); 114 NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed"); 115 JButtonOperator open = new JButtonOperator(nbdialog, "Open Project"); 116 open.push(); 117 118 ProjectSupport.waitScanFinished(); 119 new QueueTool().waitEmpty(1000); 120 ProjectSupport.waitScanFinished(); 121 122 NewProjectWizardOperator npwo = NewProjectWizardOperator.invoke(); 123 npwo.selectCategory("General"); 124 npwo.selectProject("Java Application"); 125 npwo.next(); 126 NewProjectNameLocationStepOperator npnlso = new NewProjectNameLocationStepOperator(); 127 new JTextFieldOperator(npnlso, 1).setText(work.getAbsolutePath() + File.separator + PROJECT_NAME + File.separator+ "src"); new JTextFieldOperator(npnlso, 0).setText(PROJECT_NAME); new NewProjectWizardOperator().finish(); 131 ProjectSupport.waitScanFinished(); 133 134 } catch (Exception e) { 135 throw new Exception ("Test failed: " + e); 136 } finally { 137 TestKit.closeProject(PROJECT_NAME); 138 } 139 } 140 } 141 | Popular Tags |