1 19 20 28 29 package org.netbeans.test.cvsmodule; 30 31 import java.io.File ; 32 import java.io.InputStream ; 33 import junit.textui.TestRunner; 34 import org.netbeans.jellytools.JellyTestCase; 35 import org.netbeans.jellytools.NbDialogOperator; 36 import org.netbeans.jellytools.OutputOperator; 37 import org.netbeans.jellytools.OutputTabOperator; 38 import org.netbeans.jellytools.modules.javacvs.CVSRootStepOperator; 39 import org.netbeans.jellytools.modules.javacvs.CheckoutWizardOperator; 40 import org.netbeans.jellytools.modules.javacvs.ModuleToCheckoutStepOperator; 41 import org.netbeans.jellytools.modules.javacvs.VersioningOperator; 42 import org.netbeans.jellytools.nodes.Node; 43 import org.netbeans.jellytools.nodes.SourcePackagesNode; 44 import org.netbeans.jemmy.JemmyProperties; 45 import org.netbeans.jemmy.QueueTool; 46 import org.netbeans.jemmy.TimeoutExpiredException; 47 import org.netbeans.jemmy.operators.JButtonOperator; 48 import org.netbeans.jemmy.operators.JProgressBarOperator; 49 import org.netbeans.jemmy.operators.JTableOperator; 50 import org.netbeans.jemmy.operators.Operator; 51 import org.netbeans.jemmy.operators.Operator.DefaultStringComparator; 52 import org.netbeans.junit.NbTestSuite; 53 import org.netbeans.junit.ide.ProjectSupport; 54 55 59 public class VersioningButtonsTest extends JellyTestCase { 60 String os_name; 61 static String sessionCVSroot; 62 final String projectName = "ForImport"; 63 final String pathToMain = "forimport|Main.java"; 64 final String PROTOCOL_FOLDER = "protocol"; 65 static File cacheFolder; 66 Operator.DefaultStringComparator comOperator; 67 Operator.DefaultStringComparator oldOperator; 68 69 public VersioningButtonsTest(String name) { 70 super(name); 71 } 72 public static void main(String [] args) { 73 TestRunner.run(suite()); 75 } 76 77 protected void setUp() throws Exception { 78 os_name = System.getProperty("os.name"); 79 System.out.println("### " + getName() + " ###"); 81 } 82 83 public static NbTestSuite suite() { 84 NbTestSuite suite = new NbTestSuite(); 85 suite.addTest(new VersioningButtonsTest("testCheckOutProject")); 86 suite.addTest(new VersioningButtonsTest("testVersioningButtons")); 87 return suite; 89 } 90 public void testCheckOutProject() throws Exception { 91 TestKit.closeProject(projectName); 92 comOperator = new Operator.DefaultStringComparator(true, true); 93 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 94 Operator.setDefaultStringComparator(comOperator); 95 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 96 Operator.setDefaultStringComparator(oldOperator); 97 CVSRootStepOperator crso = new CVSRootStepOperator(); 98 crso.setCVSRoot(":pserver:anoncvs@localhost:/cvs"); 99 InputStream in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "authorized.in"); 101 PseudoCvsServer cvss = new PseudoCvsServer(in); 102 new Thread (cvss).start(); 103 cvss.ignoreProbe(); 104 String CVSroot = cvss.getCvsRoot(); 105 sessionCVSroot = CVSroot; 106 crso.setCVSRoot(CVSroot); 107 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 108 crso.next(); 109 try { 110 JProgressBarOperator progress = new JProgressBarOperator(crso); 111 JButtonOperator btnStop = new JButtonOperator(crso); 112 } catch (TimeoutExpiredException e) { 113 throw e; 114 } 115 File tmp = new File ("/tmp"); File work = new File (tmp, "" + File.separator + System.currentTimeMillis()); 118 cacheFolder = new File (work, projectName + File.separator + "src" + File.separator + "forimport" + File.separator + "CVS" + File.separator + "RevisionCache"); 119 tmp.mkdirs(); 120 work.mkdirs(); 121 tmp.deleteOnExit(); 122 ModuleToCheckoutStepOperator moduleCheck = new ModuleToCheckoutStepOperator(); 123 cvss.stop(); 124 in.close(); 125 moduleCheck.setModule("ForImport"); 126 moduleCheck.setLocalFolder(work.getAbsolutePath()); in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "checkout_finish_2.in"); 129 cvss = new PseudoCvsServer(in); 130 new Thread (cvss).start(); 131 CVSroot = cvss.getCvsRoot(); 132 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 133 cwo.finish(); 134 OutputOperator oo = OutputOperator.invoke(); 135 OutputTabOperator oto = oo.getOutputTab(sessionCVSroot); 136 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 137 oto.waitText("Checking out finished"); 138 cvss.stop(); 139 in.close(); 140 NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed"); 141 JButtonOperator open = new JButtonOperator(nbdialog, "Open Project"); 142 open.push(); 143 144 ProjectSupport.waitScanFinished(); 145 new QueueTool().waitEmpty(1000); 146 ProjectSupport.waitScanFinished(); 147 148 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 149 } 150 151 public void testVersioningButtons() throws Exception { 152 VersioningOperator vo; 153 OutputTabOperator oto; 155 InputStream in; 156 PseudoCvsServer cvss; 157 String CVSroot; 158 JTableOperator table; 159 org.openide.nodes.Node nodeIDE; 160 String color; 161 162 oto = new OutputTabOperator(sessionCVSroot); 163 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 164 165 Node nodeMain = new Node(new SourcePackagesNode(projectName), pathToMain); 167 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "versioning/show_changes_main.in"); 170 cvss = new PseudoCvsServer(in); 171 new Thread (cvss).start(); 172 CVSroot = cvss.getCvsRoot(); 173 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 174 nodeMain.performPopupAction("CVS|Show Changes"); 175 Thread.sleep(1000); 176 vo = VersioningOperator.invoke(); 177 table = vo.tabFiles(); 178 oto.waitText("Refreshing CVS Status finished"); 180 Thread.sleep(1000); 181 assertEquals("Table should be empty", 1, table.getRowCount()); 182 assertEquals("File should be [Remotely Modified]", "Remotely Modified", table.getValueAt(0, 1).toString()); 183 cvss.stop(); 184 186 oto = new OutputTabOperator(sessionCVSroot); 190 oto.clear(); 191 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "versioning/refresh_main.in"); 192 cvss = new PseudoCvsServer(in); 193 new Thread (cvss).start(); 194 CVSroot = cvss.getCvsRoot(); 195 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 196 vo.refresh(); 198 oto.waitText("Refreshing CVS Status finished"); 199 Thread.sleep(1000); 200 table = vo.tabFiles(); 201 assertEquals("Table should be empty", 0, table.getRowCount()); 202 cvss.stop(); 203 204 oto = new OutputTabOperator(sessionCVSroot); 207 oto.clear(); 208 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "versioning/refresh_main.in"); 209 cvss = new PseudoCvsServer(in); 210 new Thread (cvss).start(); 211 CVSroot = cvss.getCvsRoot(); 212 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 213 vo.update(); 215 oto.waitText("Updating Sources finished"); 216 Thread.sleep(1000); 217 cvss.stop(); 218 219 vo.commit(); 221 Thread.sleep(1000); 222 223 NbDialogOperator dialog = new NbDialogOperator("Comm"); 224 JButtonOperator btnOk = new JButtonOperator(dialog, "OK"); 225 btnOk.push(); 226 227 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 228 } 229 230 public void removeAllData() throws Exception { 231 TestKit.closeProject(projectName); 232 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 233 } 234 } 235 | Popular Tags |