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 CommittingCvs12Test 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 CommittingCvs12Test(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 CommittingCvs12Test("testCheckOutProject")); 93 suite.addTest(new CommittingCvs12Test("testCommitModifiedCvs12")); 94 suite.addTest(new CommittingCvs12Test("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.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 165 oto.waitText("Checking out finished"); 166 cvss.stop(); 167 in.close(); 168 NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed"); 169 JButtonOperator open = new JButtonOperator(nbdialog, "Open Project"); 170 open.push(); 171 172 ProjectSupport.waitScanFinished(); 173 new QueueTool().waitEmpty(1000); 174 ProjectSupport.waitScanFinished(); 175 176 TestKit.createNewElementsCommitCvs12(projectName); 178 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 179 } 180 181 public void testCommitModifiedCvs12() throws Exception { 182 PseudoCvsServer cvss, cvss2, cvss3, cvss4; 184 InputStream in, in2, in3, in4; 185 CommitOperator co; 186 String CVSroot, color; 187 JTableOperator table; 188 OutputOperator oo; 189 OutputTabOperator oto; 190 VersioningOperator vo; 191 String [] expected; 192 String [] actual; 193 String allCVSRoots; 194 org.openide.nodes.Node nodeIDE; 195 PROTOCOL_FOLDER = "protocol" + File.separator + "cvs_committing_cvs12"; 196 197 Node packNode = new SourcePackagesNode("ForImport"); 198 199 co = CommitOperator.invoke(packNode); 200 Thread.sleep(1000); 201 table = co.tabFiles(); 202 TableModel model = table.getModel(); 203 204 expected = new String [] {"NewClass.java", "NewClass2.java", "NewClass.java", "NewClass2.java"}; 205 table = co.tabFiles(); 206 model = table.getModel(); 207 actual = new String [model.getRowCount()]; 208 for (int i = 0; i < actual.length; i++) { 209 actual[i] = model.getValueAt(i, 0).toString(); 210 } 211 int result = TestKit.compareThem(expected, actual, false); 212 assertEquals("Wrong records displayed in dialog", 4, result); 213 co.setCommitMessage("Initial commit message"); 214 215 oo = OutputOperator.invoke(); 216 oto = oo.getOutputTab(sessionCVSroot); 217 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 218 oto.clear(); 219 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "commit_invoke.in"); 220 cvss = new PseudoCvsServer(in); 221 new Thread (cvss).start(); 222 allCVSRoots = cvss.getCvsRoot() + ","; 223 224 in2 = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "commit_invoke_add_4.in"); 225 cvss2 = new PseudoCvsServer(in2); 226 new Thread (cvss2).start(); 227 allCVSRoots = allCVSRoots + cvss2.getCvsRoot() + ","; 228 229 in3 = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "commit_invoke_commit_4.in"); 230 cvss3 = new PseudoCvsServer(in3); 231 new Thread (cvss3).start(); 232 allCVSRoots = allCVSRoots + cvss3.getCvsRoot() + ","; 233 234 in4 = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "checkout_final.in"); 235 cvss4 = new PseudoCvsServer(in4); 236 new Thread (cvss4).start(); 237 allCVSRoots = allCVSRoots + cvss4.getCvsRoot(); 238 239 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", allCVSRoots); 240 co.commit(); 241 oto.waitText("Committing \"src\" finished"); 242 243 cvss.stop(); 244 cvss2.stop(); 245 cvss3.stop(); 246 cvss4.stop(); 247 248 Node node = new Node(new SourcePackagesNode(projectName), "aa|NewClass.java"); 250 node.performPopupAction("Open"); 251 EditorOperator eo = new EditorOperator("NewClass.java"); 252 eo.deleteLine(2); 253 eo.insert(" a", 3, 4); 254 eo.save(); 255 node = new Node(new SourcePackagesNode(projectName), "aa|NewClass2.java"); 256 node.performPopupAction("Open"); 257 eo = new EditorOperator("NewClass2.java"); 258 eo.deleteLine(2); 259 eo.insert(" a", 3, 4); 260 eo.save(); 261 node = new Node(new SourcePackagesNode(projectName), "bb|NewClass.java"); 262 node.performPopupAction("Open"); 263 eo = new EditorOperator("NewClass.java"); 264 eo.deleteLine(2); 265 eo.insert(" a", 3, 4); 266 eo.save(); 267 node = new Node(new SourcePackagesNode(projectName), "bb|NewClass2.java"); 268 node.performPopupAction("Open"); 269 eo = new EditorOperator("NewClass2.java"); 270 eo.deleteLine(2); 271 eo.insert(" a", 3, 4); 272 eo.save(); 273 274 oto = new OutputTabOperator(sessionCVSroot); 276 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 277 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "commit_invoke_commit_4_modified_show_changes.in"); 278 cvss = new PseudoCvsServer(in); 279 new Thread (cvss).start(); 280 CVSroot = cvss.getCvsRoot(); 281 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 282 packNode.performPopupAction("CVS|Show Changes"); 283 Thread.sleep(1000); 284 oto.waitText("Refreshing"); 285 oto.waitText("finished"); 286 cvss.stop(); 287 288 oo = OutputOperator.invoke(); 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 \"src\" finished"); 301 cvss.stop(); 302 cvss2.stop(); 303 304 Node nodeClass = new Node(new SourcePackagesNode("ForImport"), "aa|NewClass.java"); 306 nodeIDE = (org.openide.nodes.Node) nodeClass.getOpenideNode(); 307 assertNull("Wrong color of node!!!", nodeIDE.getHtmlDisplayName()); 309 310 nodeClass = new Node(new SourcePackagesNode("ForImport"), "aa|NewClass2.java"); 311 nodeIDE = (org.openide.nodes.Node) nodeClass.getOpenideNode(); 312 assertNull("Wrong color of node!!!", nodeIDE.getHtmlDisplayName()); 314 315 nodeClass = new Node(new SourcePackagesNode("ForImport"), "bb|NewClass.java"); 316 nodeIDE = (org.openide.nodes.Node) nodeClass.getOpenideNode(); 317 color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 318 assertEquals("Wrong color of node!!!", TestKit.MODIFIED_COLOR, color); 319 320 nodeClass = new Node(new SourcePackagesNode("ForImport"), "bb|NewClass2.java"); 321 nodeIDE = (org.openide.nodes.Node) nodeClass.getOpenideNode(); 322 assertNull("Wrong color of node!!!", nodeIDE.getHtmlDisplayName()); 324 325 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 326 } 327 328 public void removeAllData() throws Exception { 329 TestKit.closeProject(projectName); 330 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 331 } 332 } 333 | Popular Tags |