1 9 10 package org.netbeans.test.cvsmodule; 11 12 import java.io.File ; 13 import java.io.InputStream ; 14 import junit.textui.TestRunner; 15 import org.netbeans.jellytools.JellyTestCase; 16 import org.netbeans.jellytools.NbDialogOperator; 17 import org.netbeans.jellytools.OutputOperator; 18 import org.netbeans.jellytools.OutputTabOperator; 19 import org.netbeans.jellytools.modules.javacvs.CVSRootStepOperator; 20 import org.netbeans.jellytools.modules.javacvs.CheckoutWizardOperator; 21 import org.netbeans.jellytools.modules.javacvs.ModuleToCheckoutStepOperator; 22 import org.netbeans.jellytools.modules.javacvs.VersioningOperator; 23 import org.netbeans.jellytools.nodes.Node; 24 import org.netbeans.jellytools.nodes.SourcePackagesNode; 25 import org.netbeans.jemmy.JemmyProperties; 26 import org.netbeans.jemmy.QueueTool; 27 import org.netbeans.jemmy.TimeoutExpiredException; 28 import org.netbeans.jemmy.operators.JButtonOperator; 29 import org.netbeans.jemmy.operators.JProgressBarOperator; 30 import org.netbeans.jemmy.operators.JTableOperator; 31 import org.netbeans.jemmy.operators.Operator; 32 import org.netbeans.jemmy.operators.Operator.DefaultStringComparator; 33 import org.netbeans.junit.NbTestSuite; 34 import org.netbeans.junit.ide.ProjectSupport; 35 36 40 public class DeleteTest extends JellyTestCase { 41 42 String os_name; 43 static String sessionCVSroot; 44 final String projectName = "ForImport"; 45 final String pathToMain = "forimport|Main.java"; 46 final String PROTOCOL_FOLDER = "protocol"; 47 static File cacheFolder; 48 Operator.DefaultStringComparator comOperator; 49 Operator.DefaultStringComparator oldOperator; 50 51 52 public DeleteTest(String name) { 53 super(name); 54 } 55 56 59 public static void main(String [] args) { 60 TestRunner.run(suite()); 62 } 63 64 public static NbTestSuite suite() { 65 NbTestSuite suite = new NbTestSuite(); 66 suite.addTest(new DeleteTest("testCheckOutProject")); 67 suite.addTest(new DeleteTest("testDeleteFile")); 68 suite.addTest(new DeleteTest("removeAllData")); 69 return suite; 70 } 71 72 protected void setUp() throws Exception { 73 74 os_name = System.getProperty("os.name"); 75 System.out.println("### "+getName()+" ###"); 77 78 } 79 80 protected boolean isUnix() { 81 boolean unix = false; 82 if (os_name.indexOf("Windows") == -1) { 83 unix = true; 84 } 85 return unix; 86 } 87 88 public void testCheckOutProject() throws Exception { 89 TestKit.closeProject(projectName); 92 OutputOperator oo = OutputOperator.invoke(); 93 comOperator = new Operator.DefaultStringComparator(true, true); 94 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 95 Operator.setDefaultStringComparator(comOperator); 96 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 97 Operator.setDefaultStringComparator(oldOperator); 98 CVSRootStepOperator crso = new CVSRootStepOperator(); 99 crso.setCVSRoot(":pserver:anoncvs@localhost:/cvs"); 101 104 InputStream in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "authorized.in"); 106 PseudoCvsServer cvss = new PseudoCvsServer(in); 107 new Thread (cvss).start(); 108 cvss.ignoreProbe(); 109 String CVSroot = cvss.getCvsRoot(); 110 sessionCVSroot = CVSroot; 111 crso.setCVSRoot(CVSroot); 113 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 114 crso.next(); 115 116 try { 117 JProgressBarOperator progress = new JProgressBarOperator(crso); 118 JButtonOperator btnStop = new JButtonOperator(crso); 119 } catch (TimeoutExpiredException e) { 120 throw e; 121 } 122 123 126 File tmp = new File ("/tmp"); File work = new File (tmp, "" + File.separator + System.currentTimeMillis()); 128 cacheFolder = new File (work, projectName + File.separator + "src" + File.separator + "forimport" + File.separator + "CVS" + File.separator + "RevisionCache"); 129 tmp.mkdirs(); 130 work.mkdirs(); 131 tmp.deleteOnExit(); 132 ModuleToCheckoutStepOperator moduleCheck = new ModuleToCheckoutStepOperator(); 133 cvss.stop(); 134 in.close(); 135 moduleCheck.setModule("ForImport"); 136 moduleCheck.setLocalFolder(work.getAbsolutePath()); 138 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "checkout_finish_2.in"); 140 cvss = new PseudoCvsServer(in); 141 new Thread (cvss).start(); 142 CVSroot = cvss.getCvsRoot(); 143 145 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 148 cwo.finish(); 149 150 152 OutputTabOperator oto = new OutputTabOperator(sessionCVSroot); 153 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 154 oto.waitText("Checking out finished"); 155 cvss.stop(); 156 in.close(); 157 NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed"); 158 JButtonOperator open = new JButtonOperator(nbdialog, "Open Project"); 159 open.push(); 160 161 ProjectSupport.waitScanFinished(); 162 new QueueTool().waitEmpty(1000); 163 ProjectSupport.waitScanFinished(); 164 165 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 168 } 169 170 public void testDeleteFile() throws Exception { 171 PseudoCvsServer cvss, cvss2, cvss3; 173 InputStream in, in2, in3; 174 OutputTabOperator oto; 176 org.openide.nodes.Node nodeIDE; 177 String color, CVSroot; 178 VersioningOperator vo; 179 JTableOperator table; 180 181 oto = new OutputTabOperator(sessionCVSroot); 182 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 183 184 TestKit.deleteRecursively(cacheFolder); 185 Node nodeMain = new Node(new SourcePackagesNode(projectName), "forimport"); 186 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "show_changes_package_1.in"); 187 cvss = new PseudoCvsServer(in); 188 new Thread (cvss).start(); 189 CVSroot = cvss.getCvsRoot(); 190 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 191 nodeMain.performPopupAction("CVS|Show Changes"); 192 Thread.sleep(1000); 193 vo = VersioningOperator.invoke(); 194 cvss.stop(); 195 196 nodeMain = new Node(new SourcePackagesNode(projectName), pathToMain); 198 nodeMain.performPopupActionNoBlock("Delete"); 199 NbDialogOperator dialog = new NbDialogOperator("Confirm Object Deletion"); 200 dialog.yes(); 201 Thread.sleep(1000); 202 Exception e = null; 203 try { 204 table = vo.tabFiles(); 205 assertEquals("Files should have been [Locally Deleted]", "Locally Deleted", table.getValueAt(0, 1).toString()); 206 } 207 catch (Exception ex) { 208 e = ex; 209 } 210 assertNull("Unexpected behavior - file should appear in Versioning view!!!", e); 211 } 212 213 public void removeAllData() { 214 TestKit.closeProject(projectName); 215 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 216 } 217 } 218 219 | Popular Tags |