1 19 20 28 29 package org.netbeans.test.cvsmodule; 30 31 import java.io.File ; 32 import java.io.InputStream ; 33 import javax.swing.table.TableModel ; 34 import junit.textui.TestRunner; 35 import org.netbeans.jellytools.EditorOperator; 36 import org.netbeans.jellytools.JellyTestCase; 37 import org.netbeans.jellytools.NbDialogOperator; 38 import org.netbeans.jellytools.OutputOperator; 39 import org.netbeans.jellytools.OutputTabOperator; 40 import org.netbeans.jellytools.modules.javacvs.CVSRootStepOperator; 41 import org.netbeans.jellytools.modules.javacvs.CheckoutWizardOperator; 42 import org.netbeans.jellytools.modules.javacvs.CommitOperator; 43 import org.netbeans.jellytools.modules.javacvs.ModuleToCheckoutStepOperator; 44 import org.netbeans.jellytools.modules.javacvs.VersioningOperator; 45 import org.netbeans.jellytools.nodes.Node; 46 import org.netbeans.jellytools.nodes.SourcePackagesNode; 47 import org.netbeans.jemmy.JemmyProperties; 48 import org.netbeans.jemmy.QueueTool; 49 import org.netbeans.jemmy.TimeoutExpiredException; 50 import org.netbeans.jemmy.operators.JButtonOperator; 51 import org.netbeans.jemmy.operators.JProgressBarOperator; 52 import org.netbeans.jemmy.operators.JTableOperator; 53 import org.netbeans.jemmy.operators.Operator; 54 import org.netbeans.jemmy.operators.Operator.DefaultStringComparator; 55 import org.netbeans.junit.NbTestSuite; 56 import org.netbeans.junit.ide.ProjectSupport; 57 61 public class CommittingCvs11Test extends JellyTestCase { 62 63 String os_name; 64 static String sessionCVSroot; 65 final String projectName = "ForImport"; 66 final String pathToMain = "forimport|Main.java"; 67 static File cacheFolder; 68 String PROTOCOL_FOLDER = "protocol"; 69 Operator.DefaultStringComparator comOperator; 70 Operator.DefaultStringComparator oldOperator; 71 72 75 public CommittingCvs11Test(String name) { 76 super(name); 77 } 78 79 public static void main(String [] args) { 80 TestRunner.run(suite()); 82 } 83 84 protected void setUp() throws Exception { 85 os_name = System.getProperty("os.name"); 86 System.out.println("### " + getName() + " ###"); 88 } 89 90 public static NbTestSuite suite() { 91 NbTestSuite suite = new NbTestSuite(); 92 suite.addTest(new CommittingCvs11Test("testCheckOutProject")); 93 suite.addTest(new CommittingCvs11Test("testCommitModified")); 94 suite.addTest(new CommittingCvs11Test("removeAllData")); 95 return suite; 96 } 97 98 public void testCheckOutProject() throws Exception { 99 PROTOCOL_FOLDER = "protocol"; 100 TestKit.closeProject(projectName); 103 comOperator = new Operator.DefaultStringComparator(true, true); 104 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 105 Operator.setDefaultStringComparator(comOperator); 106 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 107 Operator.setDefaultStringComparator(oldOperator); 108 CVSRootStepOperator crso = new CVSRootStepOperator(); 109 crso.setCVSRoot(":pserver:anoncvs@localhost:/cvs"); 111 114 InputStream in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "authorized.in"); 116 PseudoCvsServer cvss = new PseudoCvsServer(in); 117 new Thread (cvss).start(); 118 cvss.ignoreProbe(); 119 String CVSroot = cvss.getCvsRoot(); 120 sessionCVSroot = CVSroot; 121 crso.setCVSRoot(CVSroot); 123 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 124 crso.next(); 125 126 try { 127 JProgressBarOperator progress = new JProgressBarOperator(crso); 128 JButtonOperator btnStop = new JButtonOperator(crso); 129 } catch (TimeoutExpiredException e) { 130 throw e; 131 } 132 133 136 File tmp = new File ("/tmp"); File work = new File (tmp, "" + File.separator + System.currentTimeMillis()); 138 cacheFolder = new File (work, projectName + File.separator + "src" + File.separator + "forimport" + File.separator + "CVS" + File.separator + "RevisionCache"); 139 tmp.mkdirs(); 140 work.mkdirs(); 141 tmp.deleteOnExit(); 142 ModuleToCheckoutStepOperator moduleCheck = new ModuleToCheckoutStepOperator(); 143 cvss.stop(); 144 in.close(); 145 moduleCheck.setModule("ForImport"); 146 moduleCheck.setLocalFolder(work.getAbsolutePath()); 148 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "checkout_finish_2.in"); 150 cvss = new PseudoCvsServer(in); 151 new Thread (cvss).start(); 152 CVSroot = cvss.getCvsRoot(); 153 155 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 158 cwo.finish(); 159 160 OutputOperator oo = OutputOperator.invoke(); 161 163 OutputTabOperator oto = oo.getOutputTab(sessionCVSroot); 164 oto.waitText("Checking out finished"); 165 cvss.stop(); 166 in.close(); 167 NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed"); 168 JButtonOperator open = new JButtonOperator(nbdialog, "Open Project"); 169 open.push(); 170 171 ProjectSupport.waitScanFinished(); 172 new QueueTool().waitEmpty(1000); 173 ProjectSupport.waitScanFinished(); 174 175 TestKit.createNewElementsCommitCvs11(projectName); 177 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 178 } 179 180 public void testCommitModified() throws Exception { 181 PseudoCvsServer cvss, cvss2, cvss3, cvss4; 183 InputStream in, in2, in3, in4; 184 CommitOperator co; 185 String CVSroot, color; 186 JTableOperator table; 187 OutputOperator oo; 188 OutputTabOperator oto; 189 VersioningOperator vo; 190 String [] expected; 191 String [] actual; 192 String allCVSRoots; 193 org.openide.nodes.Node nodeIDE; 194 PROTOCOL_FOLDER = "protocol" + File.separator + "cvs_committing_cvs11"; 195 196 Node packNode = new Node(new SourcePackagesNode("ForImport"), "xx"); 197 198 co = CommitOperator.invoke(packNode); 199 Thread.sleep(1000); 200 table = co.tabFiles(); 201 TableModel model = table.getModel(); 202 203 expected = new String [] {"NewClass.java", "NewClass2.java", "NewClass3.java", "NewClass4.java"}; 204 actual = new String [model.getRowCount()]; 205 for (int i = 0; i < actual.length; i++) { 206 actual[i] = model.getValueAt(i, 0).toString(); 207 } 208 int result = TestKit.compareThem(expected, actual, false); 209 assertEquals("Wrong records displayed in dialog", 4, result); 210 co.setCommitMessage("Initial commit message"); 211 212 oo = OutputOperator.invoke(); 213 oto = oo.getOutputTab(sessionCVSroot); 214 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 215 oto.clear(); 216 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "commit_invoke.in"); 217 cvss = new PseudoCvsServer(in); 218 new Thread (cvss).start(); 219 allCVSRoots = cvss.getCvsRoot() + ","; 220 221 in2 = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "commit_invoke_add_4.in"); 222 cvss2 = new PseudoCvsServer(in2); 223 new Thread (cvss2).start(); 224 allCVSRoots = allCVSRoots + cvss2.getCvsRoot() + ","; 225 226 in3 = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "commit_invoke_commit_4.in"); 227 cvss3 = new PseudoCvsServer(in3); 228 new Thread (cvss3).start(); 229 allCVSRoots = allCVSRoots + cvss3.getCvsRoot()+ ","; 230 231 in4 = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "checkout_final.in"); 232 cvss4 = new PseudoCvsServer(in4); 233 new Thread (cvss4).start(); 234 allCVSRoots = allCVSRoots + cvss4.getCvsRoot(); 235 236 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", allCVSRoots); 237 co.commit(); 238 oto.waitText("Committing"); 239 oto.waitText("finished"); 240 241 cvss.stop(); 242 cvss2.stop(); 243 cvss3.stop(); 244 cvss4.stop(); 245 Node node = new Node(new SourcePackagesNode(projectName), "xx|NewClass.java"); 247 node.performPopupAction("Open"); 248 EditorOperator eo = new EditorOperator("NewClass.java"); 249 eo.deleteLine(2); 250 eo.insert(" a", 3, 4); 251 eo.save(); 252 node = new Node(new SourcePackagesNode(projectName), "xx|NewClass2.java"); 253 node.performPopupAction("Open"); 254 eo = new EditorOperator("NewClass2.java"); 255 eo.deleteLine(2); 256 eo.insert(" a", 3, 4); 257 eo.save(); 258 node = new Node(new SourcePackagesNode(projectName), "xx|NewClass3.java"); 259 node.performPopupAction("Open"); 260 eo = new EditorOperator("NewClass3.java"); 261 eo.deleteLine(2); 262 eo.insert(" a", 3, 4); 263 eo.save(); 264 node = new Node(new SourcePackagesNode(projectName), "xx|NewClass4.java"); 265 node.performPopupAction("Open"); 266 eo = new EditorOperator("NewClass4.java"); 267 eo.deleteLine(2); 268 eo.insert(" a", 3, 4); 269 eo.save(); 270 272 oto = new OutputTabOperator(sessionCVSroot); 274 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 275 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "commit_invoke_commit_4_modified_show_changes.in"); 276 cvss = new PseudoCvsServer(in); 277 new Thread (cvss).start(); 278 CVSroot = cvss.getCvsRoot(); 279 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 280 packNode.performPopupAction("CVS|Show Changes"); 281 Thread.sleep(1000); 282 oto.waitText("Refreshing"); 283 oto.waitText("finished"); 284 cvss.stop(); 285 286 oto = new OutputTabOperator(sessionCVSroot); 288 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 289 oto.clear(); 290 co = CommitOperator.invoke(packNode); 291 Thread.sleep(1000); 293 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "commit_invoke_commit_4_modified_wrong.in"); 294 cvss = new PseudoCvsServer(in); 295 new Thread (cvss).start(); 296 297 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", cvss.getCvsRoot()); 298 co.commit(); 299 300 oto.waitText("Committing"); 301 oto.waitText("finished"); 302 cvss.stop(); 303 cvss2.stop(); 304 305 Node nodeClass = new Node(new SourcePackagesNode("ForImport"), "xx|NewClass.java"); 307 nodeIDE = (org.openide.nodes.Node) nodeClass.getOpenideNode(); 308 assertNull("Wrong color of node!!!", nodeIDE.getHtmlDisplayName()); 310 311 nodeClass = new Node(new SourcePackagesNode("ForImport"), "xx|NewClass2.java"); 312 nodeIDE = (org.openide.nodes.Node) nodeClass.getOpenideNode(); 313 assertNull("Wrong color of node!!!", nodeIDE.getHtmlDisplayName()); 315 316 nodeClass = new Node(new SourcePackagesNode("ForImport"), "xx|NewClass3.java"); 317 nodeIDE = (org.openide.nodes.Node) nodeClass.getOpenideNode(); 318 color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 319 assertEquals("Wrong color of node!!!", TestKit.MODIFIED_COLOR, color); 320 321 nodeClass = new Node(new SourcePackagesNode("ForImport"), "xx|NewClass4.java"); 322 nodeIDE = (org.openide.nodes.Node) nodeClass.getOpenideNode(); 323 assertNull("Wrong color of node!!!", nodeIDE.getHtmlDisplayName()); 325 326 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 327 } 328 329 public void removeAllData() throws Exception { 330 TestKit.closeProject(projectName); 331 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 332 } 333 } 334 | Popular Tags |