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.OutputOperator; 17 import org.netbeans.jellytools.OutputTabOperator; 18 import org.netbeans.jellytools.ProjectsTabOperator; 19 import org.netbeans.jellytools.nodes.Node; 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.Operator; 24 import org.netbeans.jemmy.operators.Operator.DefaultStringComparator; 25 import org.netbeans.junit.NbTestSuite; 26 import org.netbeans.junit.ide.ProjectSupport; 27 import org.netbeans.test.subversion.operators.CheckoutWizardOperator; 28 import org.netbeans.test.subversion.operators.RepositoryStepOperator; 29 import org.netbeans.test.subversion.operators.WorkDirStepOperator; 30 import org.netbeans.test.subversion.utils.RepositoryMaintenance; 31 import org.netbeans.test.subversion.utils.TestKit; 32 33 37 public class CheckoutContentTest extends JellyTestCase { 38 39 public static final String TMP_PATH = "/tmp"; 40 public static final String REPO_PATH = "repo"; 41 public static final String WORK_PATH = "work"; 42 public static final String PROJECT_NAME = "JavaApp"; 43 public File projectPath; 44 String os_name; 45 Operator.DefaultStringComparator comOperator; 46 Operator.DefaultStringComparator oldOperator; 47 48 51 public CheckoutContentTest(String name) { 52 super(name); 53 } 54 55 protected void setUp() throws Exception { 56 os_name = System.getProperty("os.name"); 57 System.out.println("### "+getName()+" ###"); 59 60 } 61 62 protected boolean isUnix() { 63 boolean unix = false; 64 if (os_name.indexOf("Windows") == -1) { 65 unix = true; 66 } 67 return unix; 68 } 69 70 public static void main(String [] args) { 71 TestRunner.run(suite()); 73 } 74 75 public static NbTestSuite suite() { 76 NbTestSuite suite = new NbTestSuite(); 77 suite.addTest(new CheckoutContentTest("testCheckoutProject")); 78 suite.addTest(new CheckoutContentTest("testCheckoutContent")); 79 return suite; 80 } 81 82 public void testCheckoutProject() throws Exception { 83 try { 86 TestKit.closeProject(PROJECT_NAME); 87 OutputTabOperator oto; 88 OutputOperator oo = OutputOperator.invoke(); 89 90 comOperator = new Operator.DefaultStringComparator(true, true); 91 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 92 Operator.setDefaultStringComparator(comOperator); 93 CheckoutWizardOperator co = CheckoutWizardOperator.invoke(); 94 Operator.setDefaultStringComparator(oldOperator); 95 RepositoryStepOperator rso = new RepositoryStepOperator(); 96 97 File work = new File (TMP_PATH + File.separator + WORK_PATH + File.separator + "w" + System.currentTimeMillis()); 99 new File (TMP_PATH).mkdirs(); 100 work.mkdirs(); 101 RepositoryMaintenance.deleteFolder(new File (TMP_PATH + File.separator + REPO_PATH)); 102 RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH); 104 RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump"); 105 rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false)); 106 107 rso.next(); 108 oto = new OutputTabOperator("file:///tmp/repo"); 109 oto.clear(); 110 WorkDirStepOperator wdso = new WorkDirStepOperator(); 111 wdso.setRepositoryFolder("trunk/" + PROJECT_NAME); 112 wdso.setLocalFolder(work.getCanonicalPath()); 113 wdso.checkCheckoutContentOnly(false); 114 wdso.finish(); 115 oto.waitText("Checking out... finished."); 117 NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed"); 118 JButtonOperator open = new JButtonOperator(nbdialog, "Open Project"); 119 open.push(); 120 121 ProjectSupport.waitScanFinished(); 122 new QueueTool().waitEmpty(1000); 123 ProjectSupport.waitScanFinished(); 124 125 Node projNode = new Node(new ProjectsTabOperator().tree(), PROJECT_NAME); 126 127 } catch (Exception e) { 128 throw new Exception ("Test failed: " + e); 129 } finally { 130 TestKit.closeProject(PROJECT_NAME); 131 } 132 } 133 134 public void testCheckoutContent() throws Exception { 135 try { 138 TestKit.closeProject(PROJECT_NAME); 139 140 comOperator = new Operator.DefaultStringComparator(true, true); 141 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 142 Operator.setDefaultStringComparator(comOperator); 143 CheckoutWizardOperator co = CheckoutWizardOperator.invoke(); 144 Operator.setDefaultStringComparator(oldOperator); 145 RepositoryStepOperator rso = new RepositoryStepOperator(); 146 147 File work = new File (TMP_PATH + File.separator + WORK_PATH + File.separator + "w" + System.currentTimeMillis()); 149 new File (TMP_PATH).mkdirs(); 150 work.mkdirs(); 151 RepositoryMaintenance.deleteFolder(new File (TMP_PATH + File.separator + REPO_PATH)); 152 RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH); 154 RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump"); 155 rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false)); 156 157 rso.next(); 158 OutputTabOperator oto = new OutputTabOperator("file:///tmp/repo"); 159 oto.clear(); 160 WorkDirStepOperator wdso = new WorkDirStepOperator(); 161 wdso.setRepositoryFolder("trunk/JavaApp/src"); 162 wdso.checkCheckoutContentOnly(true); 163 wdso.setLocalFolder(work.getCanonicalPath()); 164 wdso.finish(); 165 oto.waitText("Checking out... finished."); 167 NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed"); 168 JButtonOperator create = new JButtonOperator(nbdialog, "Create Project..."); 169 JButtonOperator close = new JButtonOperator(nbdialog, "Close"); 170 close.push(); 171 172 } catch (Exception e) { 173 throw new Exception ("Test failed: " + e); 174 } finally { 175 TestKit.closeProject(PROJECT_NAME); 176 } 177 } 178 } 179 | Popular Tags |