1 9 10 package org.netbeans.test.subversion.main.delete; 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.nodes.Node; 19 import org.netbeans.jellytools.nodes.SourcePackagesNode; 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.JTableOperator; 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.CommitOperator; 30 import org.netbeans.test.subversion.operators.RepositoryStepOperator; 31 import org.netbeans.test.subversion.operators.RevertModificationsOperator; 32 import org.netbeans.test.subversion.operators.VersioningOperator; 33 import org.netbeans.test.subversion.operators.WorkDirStepOperator; 34 import org.netbeans.test.subversion.utils.RepositoryMaintenance; 35 import org.netbeans.test.subversion.utils.TestKit; 36 37 41 public class DeleteTest extends JellyTestCase { 42 43 public static final String TMP_PATH = "/tmp"; 44 public static final String REPO_PATH = "repo"; 45 public static final String WORK_PATH = "work"; 46 public static final String PROJECT_NAME = "JavaApp"; 47 public File projectPath; 48 public PrintStream stream; 49 String os_name; 50 Operator.DefaultStringComparator comOperator; 51 Operator.DefaultStringComparator oldOperator; 52 53 54 public DeleteTest(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 DeleteTest("testDeleteRevert")); 81 suite.addTest(new DeleteTest("testDeleteCommit")); 82 return suite; 83 } 84 85 public void testDeleteRevert() throws Exception { 86 try { 89 TestKit.closeProject(PROJECT_NAME); 90 91 stream = new PrintStream (new File (getWorkDir(), getName() + ".log")); 92 VersioningOperator vo = VersioningOperator.invoke(); 93 comOperator = new Operator.DefaultStringComparator(true, true); 94 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 95 Operator.setDefaultStringComparator(comOperator); 96 CheckoutWizardOperator co = CheckoutWizardOperator.invoke(); 97 Operator.setDefaultStringComparator(oldOperator); 98 RepositoryStepOperator rso = new RepositoryStepOperator(); 99 100 File work = new File (TMP_PATH + File.separator + WORK_PATH + File.separator + "w" + System.currentTimeMillis()); 102 new File (TMP_PATH).mkdirs(); 103 work.mkdirs(); 104 RepositoryMaintenance.deleteFolder(new File (TMP_PATH + File.separator + REPO_PATH)); 105 RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH); 107 RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump"); 108 rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false)); 109 110 rso.next(); 111 WorkDirStepOperator wdso = new WorkDirStepOperator(); 112 wdso.setRepositoryFolder("trunk/" + PROJECT_NAME); 113 wdso.setLocalFolder(work.getCanonicalPath()); 114 wdso.checkCheckoutContentOnly(false); 115 OutputTabOperator oto = new OutputTabOperator("file:///tmp/repo"); 116 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 117 oto.clear(); 118 wdso.finish(); 119 oto.waitText("Checking out... finished."); 121 NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed"); 122 JButtonOperator open = new JButtonOperator(nbdialog, "Open Project"); 123 open.push(); 124 125 ProjectSupport.waitScanFinished(); 126 new QueueTool().waitEmpty(1000); 127 ProjectSupport.waitScanFinished(); 128 129 oto = new OutputTabOperator("file:///tmp/repo"); 130 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 131 oto.clear(); 132 Node node = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp"); 133 node.performPopupAction("Subversion|Show Changes"); 134 oto.waitText("Refreshing... finished."); 135 node.performPopupActionNoBlock("Delete"); 136 NbDialogOperator dialog = new NbDialogOperator("Confirm Object Deletion"); 137 dialog.yes(); 138 139 Thread.sleep(1000); 140 vo = VersioningOperator.invoke(); 141 JTableOperator table; 142 Exception e = null; 143 try { 144 table = vo.tabFiles(); 145 assertEquals("Files should have been [Locally Deleted]", "Locally Deleted", table.getValueAt(0, 1).toString()); 146 } catch (Exception ex) { 147 e = ex; 148 } 149 assertNull("Unexpected behavior - file should appear in Versioning view!!!", e); 150 151 e = null; 152 try { 153 node = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp|Main.java"); 154 } catch (Exception ex) { 155 e = ex; 156 } 157 assertNotNull("TimeoutExpiredException should have been thrown. Deleted file can't be visible!!!", e); 158 159 161 oto = new OutputTabOperator("file:///tmp/repo"); 162 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 163 oto.clear(); 164 node = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp"); 165 RevertModificationsOperator rmo = RevertModificationsOperator.invoke(node); 166 rmo.rbLocalChanges().push(); 167 rmo.revert(); 168 oto.waitText("Modifications finished."); 169 170 e = null; 171 try { 172 vo = VersioningOperator.invoke(); 173 table = vo.tabFiles(); 174 } catch (Exception ex) { 175 e = ex; 176 } 177 assertNotNull("Unexpected behavior - file should disappear in Versioning view!!!", e); 178 179 e = null; 180 try { 181 node = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp|Main.java"); 182 } catch (Exception ex) { 183 e = ex; 184 } 185 assertNull("Reverted file should be visible!!!", e); 186 187 } catch (Exception e) { 188 throw new Exception ("Test failed: " + e); 189 } finally { 190 TestKit.closeProject(PROJECT_NAME); 191 } 192 } 193 194 public void testDeleteCommit() throws Exception { 195 try { 198 TestKit.closeProject(PROJECT_NAME); 199 200 stream = new PrintStream (new File (getWorkDir(), getName() + ".log")); 201 VersioningOperator vo = VersioningOperator.invoke(); 202 CheckoutWizardOperator co = CheckoutWizardOperator.invoke(); 203 RepositoryStepOperator rso = new RepositoryStepOperator(); 204 205 File work = new File (TMP_PATH + File.separator + WORK_PATH + File.separator + "w" + System.currentTimeMillis()); 207 new File (TMP_PATH).mkdirs(); 208 work.mkdirs(); 209 RepositoryMaintenance.deleteFolder(new File (TMP_PATH + File.separator + REPO_PATH)); 210 RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH); 212 RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump"); 213 rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false)); 214 215 rso.next(); 216 WorkDirStepOperator wdso = new WorkDirStepOperator(); 217 wdso.setRepositoryFolder("trunk/" + PROJECT_NAME); 218 wdso.setLocalFolder(work.getCanonicalPath()); 219 wdso.checkCheckoutContentOnly(false); 220 OutputTabOperator oto = new OutputTabOperator("file:///tmp/repo"); 221 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 222 oto.clear(); 223 wdso.finish(); 224 oto.waitText("Checking out... finished."); 226 NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed"); 227 JButtonOperator open = new JButtonOperator(nbdialog, "Open Project"); 228 open.push(); 229 230 ProjectSupport.waitScanFinished(); 231 new QueueTool().waitEmpty(1000); 232 ProjectSupport.waitScanFinished(); 233 234 oto = new OutputTabOperator("file:///tmp/repo"); 235 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 236 oto.clear(); 237 Node node = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp"); 238 node.performPopupAction("Subversion|Show Changes"); 239 oto.waitText("Refreshing... finished."); 240 node.performPopupActionNoBlock("Delete"); 241 NbDialogOperator dialog = new NbDialogOperator("Confirm Object Deletion"); 242 dialog.yes(); 243 244 Thread.sleep(1000); 245 vo = VersioningOperator.invoke(); 246 JTableOperator table; 247 Exception e = null; 248 try { 249 table = vo.tabFiles(); 250 assertEquals("Files should have been [Locally Deleted]", "Locally Deleted", table.getValueAt(0, 1).toString()); 251 } catch (Exception ex) { 252 e = ex; 253 } 254 assertNull("Unexpected behavior - file should appear in Versioning view!!!", e); 255 256 e = null; 257 try { 258 node = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp|Main.java"); 259 } catch (Exception ex) { 260 e = ex; 261 } 262 assertNotNull("TimeoutExpiredException should have been thrown. Deleted file can't be visible!!!", e); 263 264 oto = new OutputTabOperator("file:///tmp/repo"); 266 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 267 oto.clear(); 268 node = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp"); 269 CommitOperator cmo = CommitOperator.invoke(node); 270 assertEquals("There should be \"Main.java\" file in Commit dialog!!!", cmo.tabFiles().getValueAt(0, 0), "Main.java"); 271 cmo.commit(); 272 oto.waitText("finished."); 273 274 e = null; 275 try { 276 vo = VersioningOperator.invoke(); 277 table = vo.tabFiles(); 278 } catch (Exception ex) { 279 e = ex; 280 } 281 assertNotNull("Unexpected behavior - file should disappear in Versioning view!!!", e); 282 283 e = null; 284 try { 285 node = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp|Main.java"); 286 } catch (Exception ex) { 287 e = ex; 288 } 289 assertNotNull("Deleteted file should be visible!!!", e); 290 291 } catch (Exception e) { 292 throw new Exception ("Test failed: " + e); 293 } finally { 294 TestKit.closeProject(PROJECT_NAME); 295 } 296 } 297 } 298 | Popular Tags |