1 9 10 package org.netbeans.test.subversion.main.branches; 11 12 import java.io.File ; 13 import java.io.PrintStream ; 14 import junit.textui.TestRunner; 15 import org.netbeans.jellytools.JellyTestCase; 16 import org.netbeans.jellytools.NbDialogOperator; 17 import org.netbeans.jellytools.OutputTabOperator; 18 import org.netbeans.jellytools.ProjectsTabOperator; 19 import org.netbeans.jellytools.nodes.Node; 20 import org.netbeans.jellytools.nodes.SourcePackagesNode; 21 import org.netbeans.jemmy.JemmyProperties; 22 import org.netbeans.jemmy.QueueTool; 23 import org.netbeans.jemmy.operators.JButtonOperator; 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.CopyToOperator; 30 import org.netbeans.test.subversion.operators.RepositoryStepOperator; 31 import org.netbeans.test.subversion.operators.SwitchOperator; 32 import org.netbeans.test.subversion.operators.WorkDirStepOperator; 33 import org.netbeans.test.subversion.utils.RepositoryMaintenance; 34 import org.netbeans.test.subversion.utils.TestKit; 35 36 40 public class CopyTest extends JellyTestCase { 41 42 public static final String TMP_PATH = "/tmp"; 43 public static final String REPO_PATH = "repo"; 44 public static final String WORK_PATH = "work"; 45 public static final String PROJECT_NAME = "JavaApp"; 46 public File projectPath; 47 public PrintStream stream; 48 Operator.DefaultStringComparator comOperator; 49 Operator.DefaultStringComparator oldOperator; 50 51 String os_name; 52 53 54 public CopyTest(String name) { 55 super(name); 56 } 57 58 protected void setUp() throws Exception { 59 os_name = System.getProperty("os.name"); 60 System.out.println("### "+getName()+" ###"); 62 63 } 64 65 protected boolean isUnix() { 66 boolean unix = false; 67 if (os_name.indexOf("Windows") == -1) { 68 unix = true; 69 } 70 return unix; 71 } 72 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 CopyTest("testCreateNewCopySwitch")); 81 suite.addTest(new CopyTest("testCreateNewCopy")); 82 return suite; 83 } 84 85 public void testCreateNewCopySwitch() throws Exception { 86 try { 89 TestKit.closeProject(PROJECT_NAME); 90 91 stream = new PrintStream (new File (getWorkDir(), getName() + ".log")); 92 comOperator = new Operator.DefaultStringComparator(true, true); 93 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 94 Operator.setDefaultStringComparator(comOperator); 95 CheckoutWizardOperator co = CheckoutWizardOperator.invoke(); 96 Operator.setDefaultStringComparator(oldOperator); 97 RepositoryStepOperator rso = new RepositoryStepOperator(); 98 99 File work = new File (TMP_PATH + File.separator + WORK_PATH + File.separator + "w" + System.currentTimeMillis()); 101 new File (TMP_PATH).mkdirs(); 102 work.mkdirs(); 103 RepositoryMaintenance.deleteFolder(new File (TMP_PATH + File.separator + REPO_PATH)); 104 RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH); 106 RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump"); 107 rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false)); 108 109 rso.next(); 110 OutputTabOperator oto = new OutputTabOperator("file:///tmp/repo"); 111 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 112 oto.clear(); 113 WorkDirStepOperator wdso = new WorkDirStepOperator(); 114 wdso.setRepositoryFolder("trunk/" + PROJECT_NAME); 115 wdso.setLocalFolder(work.getCanonicalPath()); 116 wdso.checkCheckoutContentOnly(false); 117 wdso.finish(); 118 oto.waitText("Checking out... finished."); 120 NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed"); 121 JButtonOperator open = new JButtonOperator(nbdialog, "Open Project"); 122 open.push(); 123 124 ProjectSupport.waitScanFinished(); 125 new QueueTool().waitEmpty(1000); 126 ProjectSupport.waitScanFinished(); 127 128 oto = new OutputTabOperator("file:///tmp/repo"); 129 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 130 oto.clear(); 131 Node projNode = new Node(new ProjectsTabOperator().tree(), PROJECT_NAME); 132 CopyToOperator cto = CopyToOperator.invoke(projNode); 133 cto.setRepositoryFolder("branches/release01/" + PROJECT_NAME); 134 cto.setCopyPurpose("New branch for project."); 135 cto.checkSwitchToCopy(true); 136 cto.copy(); 137 Thread.sleep(2000); 138 oto.waitText("Copy"); 139 oto.waitText("finished."); 140 141 Node nodeFile = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp" + "|Main.java"); 142 org.openide.nodes.Node nodeIDE = (org.openide.nodes.Node) nodeFile.getOpenideNode(); 143 String status = TestKit.getStatus(nodeIDE.getHtmlDisplayName()); 145 assertEquals("Wrong annotation of node!!!", "[ release01]", status); 146 147 nodeFile = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp"); 148 nodeIDE = (org.openide.nodes.Node) nodeFile.getOpenideNode(); 149 status = TestKit.getStatus(nodeIDE.getHtmlDisplayName()); 151 assertEquals("Wrong annotation of node!!!", "[ release01]", status); 152 stream.flush(); 154 stream.close(); 155 } catch (Exception e) { 156 throw new Exception ("Test failed: " + e); 157 } finally { 158 TestKit.closeProject(PROJECT_NAME); 159 } 160 } 161 162 public void testCreateNewCopy() throws Exception { 163 try { 166 TestKit.closeProject(PROJECT_NAME); 167 168 stream = new PrintStream (new File (getWorkDir(), getName() + ".log")); 169 comOperator = new Operator.DefaultStringComparator(true, true); 170 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 171 Operator.setDefaultStringComparator(comOperator); 172 CheckoutWizardOperator co = CheckoutWizardOperator.invoke(); 173 Operator.setDefaultStringComparator(oldOperator); 174 RepositoryStepOperator rso = new RepositoryStepOperator(); 175 176 File work = new File (TMP_PATH + File.separator + WORK_PATH + File.separator + "w" + System.currentTimeMillis()); 178 new File (TMP_PATH).mkdirs(); 179 work.mkdirs(); 180 RepositoryMaintenance.deleteFolder(new File (TMP_PATH + File.separator + REPO_PATH)); 181 RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH); 183 RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump"); 184 rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false)); 185 186 rso.next(); 187 OutputTabOperator oto = new OutputTabOperator("file:///tmp/repo"); 188 oto.clear(); 189 WorkDirStepOperator wdso = new WorkDirStepOperator(); 190 wdso.setRepositoryFolder("trunk/" + PROJECT_NAME); 191 wdso.setLocalFolder(work.getCanonicalPath()); 192 wdso.checkCheckoutContentOnly(false); 193 wdso.finish(); 194 oto.waitText("Checking out... finished."); 196 NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed"); 197 JButtonOperator open = new JButtonOperator(nbdialog, "Open Project"); 198 open.push(); 199 200 ProjectSupport.waitScanFinished(); 201 new QueueTool().waitEmpty(1000); 202 ProjectSupport.waitScanFinished(); 203 204 oto = new OutputTabOperator("file:///tmp/repo"); 205 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 206 oto.clear(); 207 Node projNode = new Node(new ProjectsTabOperator().tree(), PROJECT_NAME); 208 CopyToOperator cto = CopyToOperator.invoke(projNode); 209 cto.setRepositoryFolder("branches/release01"); 210 cto.setCopyPurpose("New branch for project."); 211 cto.checkSwitchToCopy(false); 212 cto.copy(); 213 oto.waitText("Copy"); 214 oto.waitText("finished."); 215 216 Node nodeFile = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp" + "|Main.java"); 217 org.openide.nodes.Node nodeIDE = (org.openide.nodes.Node) nodeFile.getOpenideNode(); 218 String status = TestKit.getStatus(nodeIDE.getHtmlDisplayName()); 220 assertEquals("Wrong annotation of node!!!", TestKit.UPTODATE_STATUS, status); 221 222 nodeFile = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp"); 223 nodeIDE = (org.openide.nodes.Node) nodeFile.getOpenideNode(); 224 status = TestKit.getStatus(nodeIDE.getHtmlDisplayName()); 226 assertEquals("Wrong annotation of node!!!", TestKit.UPTODATE_STATUS, status); 227 229 oto = new OutputTabOperator("file:///tmp/repo"); 231 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 232 oto.clear(); 233 projNode = new Node(new ProjectsTabOperator().tree(), PROJECT_NAME); 234 SwitchOperator so = SwitchOperator.invoke(projNode); 235 so.setRepositoryFolder("branches/release01/" + PROJECT_NAME); 236 so.switchBt(); 237 oto.waitText("Switch"); 238 oto.waitText("finished."); 239 240 nodeFile = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp" + "|Main.java"); 241 nodeIDE = (org.openide.nodes.Node) nodeFile.getOpenideNode(); 242 status = TestKit.getStatus(nodeIDE.getHtmlDisplayName()); 244 assertEquals("Wrong annotation of node!!!", "[ release01]", status); 245 246 nodeFile = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp"); 247 nodeIDE = (org.openide.nodes.Node) nodeFile.getOpenideNode(); 248 status = TestKit.getStatus(nodeIDE.getHtmlDisplayName()); 250 assertEquals("Wrong annotation of node!!!", "[ release01]", status); 251 252 oto = new OutputTabOperator("file:///tmp/repo"); 253 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 254 oto.clear(); 255 projNode = new Node(new ProjectsTabOperator().tree(), PROJECT_NAME); 256 so = SwitchOperator.invoke(projNode); 257 so.setRepositoryFolder("trunk/" + PROJECT_NAME); 258 so.switchBt(); 259 oto.waitText("Switch"); 260 oto.waitText("finished."); 261 Thread.sleep(2000); 262 263 nodeFile = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp" + "|Main.java"); 264 nodeIDE = (org.openide.nodes.Node) nodeFile.getOpenideNode(); 265 status = TestKit.getStatus(nodeIDE.getHtmlDisplayName()); 267 assertEquals("Wrong annotation of node!!!", TestKit.UPTODATE_STATUS, status); 268 269 nodeFile = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp"); 270 nodeIDE = (org.openide.nodes.Node) nodeFile.getOpenideNode(); 271 status = TestKit.getStatus(nodeIDE.getHtmlDisplayName()); 273 assertEquals("Wrong annotation of node!!!", TestKit.UPTODATE_STATUS, status); 274 275 stream.flush(); 276 stream.close(); 277 } catch (Exception e) { 278 throw new Exception ("Test failed: " + e); 279 } finally { 280 TestKit.closeProject(PROJECT_NAME); 281 } 282 } 283 } 284 | Popular Tags |