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.JellyTestCase; 36 import org.netbeans.jellytools.NbDialogOperator; 37 import org.netbeans.jellytools.OutputOperator; 38 import org.netbeans.jellytools.OutputTabOperator; 39 import org.netbeans.jellytools.modules.javacvs.CVSRootStepOperator; 40 import org.netbeans.jellytools.modules.javacvs.CheckoutWizardOperator; 41 import org.netbeans.jellytools.modules.javacvs.ModuleToCheckoutStepOperator; 42 import org.netbeans.jellytools.modules.javacvs.VersioningOperator; 43 import org.netbeans.jellytools.nodes.Node; 44 import org.netbeans.jellytools.nodes.SourcePackagesNode; 45 import org.netbeans.jemmy.JemmyProperties; 46 import org.netbeans.jemmy.QueueTool; 47 import org.netbeans.jemmy.TimeoutExpiredException; 48 import org.netbeans.jemmy.operators.JButtonOperator; 49 import org.netbeans.jemmy.operators.JProgressBarOperator; 50 import org.netbeans.jemmy.operators.JTableOperator; 51 import org.netbeans.jemmy.operators.Operator; 52 import org.netbeans.jemmy.operators.Operator.DefaultStringComparator; 53 import org.netbeans.junit.NbTestSuite; 54 import org.netbeans.junit.ide.ProjectSupport; 55 56 57 61 public class IgnoreUnignoreTest extends JellyTestCase { 62 String os_name; 63 static String sessionCVSroot; 64 final String projectName = "ForImport"; 65 final String pathToMain = "forimport|Main.java"; 66 final String PROTOCOL_FOLDER = "protocol"; 67 static File cacheFolder; 68 Operator.DefaultStringComparator comOperator; 69 Operator.DefaultStringComparator oldOperator; 70 71 72 public IgnoreUnignoreTest(String name) { 73 super(name); 74 } 75 76 public static void main(String [] args) { 77 TestRunner.run(suite()); 79 } 80 81 protected void setUp() throws Exception { 82 os_name = System.getProperty("os.name"); 83 System.out.println("### " + getName() + " ###"); 85 } 86 87 public static NbTestSuite suite() { 88 NbTestSuite suite = new NbTestSuite(); 89 suite.addTest(new IgnoreUnignoreTest("testCheckOutProject")); 90 suite.addTest(new IgnoreUnignoreTest("testIgnoreUnignoreFile")); 91 suite.addTest(new IgnoreUnignoreTest("testIgnoreUnignoreGuiForm")); 92 suite.addTest(new IgnoreUnignoreTest("removeAllData")); 93 return suite; 94 } 95 96 public void testCheckOutProject() throws Exception { 97 TestKit.closeProject(projectName); 100 comOperator = new Operator.DefaultStringComparator(true, true); 101 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 102 Operator.setDefaultStringComparator(comOperator); 103 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 104 Operator.setDefaultStringComparator(oldOperator); 105 CVSRootStepOperator crso = new CVSRootStepOperator(); 106 crso.setCVSRoot(":pserver:anoncvs@localhost:/cvs"); 107 InputStream in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "authorized.in"); 109 PseudoCvsServer cvss = new PseudoCvsServer(in); 110 new Thread (cvss).start(); 111 cvss.ignoreProbe(); 112 String CVSroot = cvss.getCvsRoot(); 113 sessionCVSroot = CVSroot; 114 crso.setCVSRoot(CVSroot); 115 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 116 crso.next(); 117 try { 118 JProgressBarOperator progress = new JProgressBarOperator(crso); 119 JButtonOperator btnStop = new JButtonOperator(crso); 120 } catch (TimeoutExpiredException e) { 121 throw e; 122 } 123 File tmp = new File ("/tmp"); File work = new File (tmp, "" + File.separator + System.currentTimeMillis()); 127 cacheFolder = new File (work, projectName + File.separator + "src" + File.separator + "forimport" + File.separator + "CVS" + File.separator + "RevisionCache"); 128 tmp.mkdirs(); 129 work.mkdirs(); 130 tmp.deleteOnExit(); 131 ModuleToCheckoutStepOperator moduleCheck = new ModuleToCheckoutStepOperator(); 132 cvss.stop(); 133 in.close(); 134 moduleCheck.setModule("ForImport"); 135 moduleCheck.setLocalFolder(work.getAbsolutePath()); in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "checkout_finish_2.in"); 138 cvss = new PseudoCvsServer(in); 139 new Thread (cvss).start(); 140 CVSroot = cvss.getCvsRoot(); 141 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 142 cwo.finish(); 143 OutputOperator oo = OutputOperator.invoke(); 144 OutputTabOperator oto = oo.getOutputTab(sessionCVSroot); 145 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 146 oto.waitText("Checking out finished"); 147 cvss.stop(); 148 in.close(); 149 NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed"); 150 JButtonOperator open = new JButtonOperator(nbdialog, "Open Project"); 151 open.push(); 152 153 ProjectSupport.waitScanFinished(); 154 new QueueTool().waitEmpty(1000); 155 ProjectSupport.waitScanFinished(); 156 157 TestKit.createNewElements(projectName); 159 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 160 } 161 162 public void testIgnoreUnignoreFile() throws Exception { 163 VersioningOperator vo; 165 OutputTabOperator oto; 167 InputStream in; 168 PseudoCvsServer cvss; 169 String CVSroot; 170 JTableOperator table; 171 org.openide.nodes.Node nodeIDE; 172 String color; 173 174 Node nodeClass = new Node(new SourcePackagesNode(projectName), "xx|NewClass.java"); 175 nodeIDE = (org.openide.nodes.Node) nodeClass.getOpenideNode(); 176 color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 177 assertEquals("Wrong color for new file", TestKit.NEW_COLOR, color); 178 179 oto = new OutputTabOperator(sessionCVSroot); 180 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 181 oto.clear(); 182 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "show_changes_for_file"); 183 cvss = new PseudoCvsServer(in); 184 new Thread (cvss).start(); 185 CVSroot = cvss.getCvsRoot(); 186 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 187 nodeClass.performPopupAction("CVS|Show Changes"); 188 Thread.sleep(1000); 189 vo = VersioningOperator.invoke(); 190 table = vo.tabFiles(); 191 oto.waitText("Refreshing CVS Status finished"); 193 Thread.sleep(1000); 194 assertEquals("Wrong row count of table.", 1, table.getRowCount()); 195 assertEquals("Wrong file listed in table.", "NewClass.java", table.getValueAt(0, 0).toString()); 196 cvss.stop(); 197 198 oto = new OutputTabOperator(sessionCVSroot); 200 oto.clear(); 201 nodeClass.performPopupAction("CVS|Ignore"); 202 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "show_changes_for_file"); 203 cvss = new PseudoCvsServer(in); 204 new Thread (cvss).start(); 205 CVSroot = cvss.getCvsRoot(); 206 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 207 208 Thread.sleep(1000); 209 assertEquals("File should not be listed in table", 0, table.getRowCount()); 210 cvss.stop(); 211 212 nodeClass = new Node(new SourcePackagesNode(projectName), "xx|NewClass.java"); 213 nodeIDE = (org.openide.nodes.Node) nodeClass.getOpenideNode(); 214 color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 215 assertEquals("Wrong color for new file", TestKit.IGNORED_COLOR, color); 216 217 oto.clear(); 219 nodeClass.performPopupAction("CVS|Unignore"); 220 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "show_changes_for_file"); 221 cvss = new PseudoCvsServer(in); 222 new Thread (cvss).start(); 223 CVSroot = cvss.getCvsRoot(); 224 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 225 nodeClass.performPopupAction("CVS|Show Changes"); 226 oto.waitText("Refreshing CVS Status finished"); 227 Thread.sleep(1000); 228 assertEquals("File should not be listed in table", 1, table.getRowCount()); 229 cvss.stop(); 230 231 nodeIDE = (org.openide.nodes.Node) nodeClass.getOpenideNode(); 232 color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 233 assertEquals("Wrong color for new file", TestKit.NEW_COLOR, color); 234 235 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 236 } 237 238 public void testIgnoreUnignoreGuiForm() throws Exception { 239 VersioningOperator vo; 241 OutputTabOperator oto; 242 InputStream in; 243 PseudoCvsServer cvss; 244 String CVSroot; 245 JTableOperator table; 246 org.openide.nodes.Node nodeIDE; 247 String color; 248 Object [] expected; 249 Object [] actual; 250 251 Node nodeFrame = new Node(new SourcePackagesNode(projectName), "xx|NewJFrame.java"); 252 nodeIDE = (org.openide.nodes.Node) nodeFrame.getOpenideNode(); 253 color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 254 assertEquals("Wrong color for new file", TestKit.NEW_COLOR, color); 255 256 oto = new OutputTabOperator(sessionCVSroot); 258 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 259 oto.clear(); 260 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "show_changes_for_jframe"); 261 cvss = new PseudoCvsServer(in); 262 new Thread (cvss).start(); 263 CVSroot = cvss.getCvsRoot(); 264 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 265 nodeFrame.performPopupAction("CVS|Show Changes"); 266 Thread.sleep(1000); 267 vo = VersioningOperator.invoke(); 268 table = vo.tabFiles(); 269 oto.waitText("Refreshing CVS Status finished"); 270 Thread.sleep(1000); 271 cvss.stop(); 272 TableModel model = table.getModel(); 273 274 expected = new String [] {"NewJFrame.form", "NewJFrame.java"}; 275 actual = new String [model.getRowCount()]; 276 for (int i = 0; i < actual.length; i++) { 277 actual[i] = model.getValueAt(i, 0).toString(); 278 } 279 int result = TestKit.compareThem(expected, actual, false); 280 assertEquals("Wrong files in view", 2, result); 281 282 oto = new OutputTabOperator(sessionCVSroot); 284 oto.clear(); 285 nodeFrame.performPopupAction("CVS|Ignore"); 286 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "show_changes_for_jframe"); 287 cvss = new PseudoCvsServer(in); 288 new Thread (cvss).start(); 289 CVSroot = cvss.getCvsRoot(); 290 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 291 292 Thread.sleep(1000); 293 assertEquals("File should not be listed in table", 0, table.getRowCount()); 294 cvss.stop(); 295 296 nodeFrame = new Node(new SourcePackagesNode(projectName), "xx|NewJFrame.java"); 297 nodeIDE = (org.openide.nodes.Node) nodeFrame.getOpenideNode(); 298 color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 299 assertEquals("Wrong color for new file", TestKit.IGNORED_COLOR, color); 300 301 oto = new OutputTabOperator(sessionCVSroot); 303 oto.clear(); 304 nodeFrame.performPopupAction("CVS|Unignore"); 305 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "show_changes_for_jframe"); 306 cvss = new PseudoCvsServer(in); 307 new Thread (cvss).start(); 308 CVSroot = cvss.getCvsRoot(); 309 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 310 nodeFrame.performPopupAction("CVS|Show Changes"); 311 oto.waitText("Refreshing CVS Status finished"); 312 Thread.sleep(1000); 313 assertEquals("File should not be listed in table", 2, table.getRowCount()); 314 cvss.stop(); 315 316 nodeIDE = (org.openide.nodes.Node) nodeFrame.getOpenideNode(); 317 color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 318 assertEquals("Wrong color for new file", TestKit.NEW_COLOR, color); 319 320 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 321 } 322 323 public void removeAllData() throws Exception { 324 TestKit.closeProject(projectName); 325 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 326 } 327 } 328 | Popular Tags |