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.EditorOperator; 16 import org.netbeans.jellytools.JellyTestCase; 17 import org.netbeans.jellytools.NbDialogOperator; 18 import org.netbeans.jellytools.OutputOperator; 19 import org.netbeans.jellytools.OutputTabOperator; 20 import org.netbeans.jellytools.ProjectsTabOperator; 21 import org.netbeans.jellytools.modules.javacvs.CVSRootStepOperator; 22 import org.netbeans.jellytools.modules.javacvs.CheckoutWizardOperator; 23 import org.netbeans.jellytools.modules.javacvs.CommitOperator; 24 import org.netbeans.jellytools.modules.javacvs.ModuleToCheckoutStepOperator; 25 import org.netbeans.jellytools.modules.javacvs.VersioningOperator; 26 import org.netbeans.jellytools.nodes.Node; 27 import org.netbeans.jellytools.nodes.SourcePackagesNode; 28 import org.netbeans.jemmy.JemmyProperties; 29 import org.netbeans.jemmy.QueueTool; 30 import org.netbeans.jemmy.TimeoutExpiredException; 31 import org.netbeans.jemmy.operators.JButtonOperator; 32 import org.netbeans.jemmy.operators.JProgressBarOperator; 33 import org.netbeans.jemmy.operators.JTableOperator; 34 import org.netbeans.jemmy.operators.Operator; 35 import org.netbeans.jemmy.operators.Operator.DefaultStringComparator; 36 import org.netbeans.junit.NbTestSuite; 37 import org.netbeans.junit.ide.ProjectSupport; 38 39 43 public class UpdateErrorTest extends JellyTestCase { 44 45 String os_name; 46 static String sessionCVSroot; 47 final String projectName = "ForImport"; 48 final String pathToMain = "forimport|Main.java"; 49 static File cacheFolder; 50 String PROTOCOL_FOLDER = "protocol"; 51 Operator.DefaultStringComparator comOperator; 52 Operator.DefaultStringComparator oldOperator; 53 54 57 public UpdateErrorTest(String name) { 58 super(name); 59 } 60 61 public static void main(String [] args) { 62 TestRunner.run(suite()); 64 } 65 66 protected void setUp() throws Exception { 67 os_name = System.getProperty("os.name"); 68 System.out.println("### " + getName() + " ###"); 70 } 71 72 public static NbTestSuite suite() { 73 NbTestSuite suite = new NbTestSuite(); 74 suite.addTest(new UpdateErrorTest("testCheckOutProject")); 75 suite.addTest(new UpdateErrorTest("testUpdate")); 76 suite.addTest(new UpdateErrorTest("removeAllData")); 77 return suite; 78 } 79 80 public void testCheckOutProject() throws Exception { 81 PROTOCOL_FOLDER = "protocol"; 82 TestKit.closeProject(projectName); 85 comOperator = new Operator.DefaultStringComparator(true, true); 86 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 87 Operator.setDefaultStringComparator(comOperator); 88 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 89 Operator.setDefaultStringComparator(oldOperator); 90 CVSRootStepOperator crso = new CVSRootStepOperator(); 91 crso.setCVSRoot(":pserver:anoncvs@localhost:/cvs"); 93 96 InputStream in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "authorized.in"); 98 PseudoCvsServer cvss = new PseudoCvsServer(in); 99 new Thread (cvss).start(); 100 cvss.ignoreProbe(); 101 String CVSroot = cvss.getCvsRoot(); 102 sessionCVSroot = CVSroot; 103 crso.setCVSRoot(CVSroot); 105 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 106 crso.next(); 107 108 try { 109 JProgressBarOperator progress = new JProgressBarOperator(crso); 110 JButtonOperator btnStop = new JButtonOperator(crso); 111 } catch (TimeoutExpiredException e) { 112 throw e; 113 } 114 115 118 File tmp = new File ("/tmp"); File work = new File (tmp, "" + File.separator + System.currentTimeMillis()); 120 cacheFolder = new File (work, projectName + File.separator + "src" + File.separator + "forimport" + File.separator + "CVS" + File.separator + "RevisionCache"); 121 tmp.mkdirs(); 122 work.mkdirs(); 123 tmp.deleteOnExit(); 124 ModuleToCheckoutStepOperator moduleCheck = new ModuleToCheckoutStepOperator(); 125 cvss.stop(); 126 in.close(); 127 moduleCheck.setModule("ForImport"); 128 moduleCheck.setLocalFolder(work.getAbsolutePath()); 130 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "checkout_finish_2.in"); 132 cvss = new PseudoCvsServer(in); 133 new Thread (cvss).start(); 134 CVSroot = cvss.getCvsRoot(); 135 137 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 140 cwo.finish(); 141 142 OutputOperator oo = OutputOperator.invoke(); 143 145 OutputTabOperator oto = oo.getOutputTab(sessionCVSroot); 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 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 158 } 159 160 public void testUpdate() throws Exception { 161 PseudoCvsServer cvss, cvss2, cvss3; 163 InputStream in, in2, in3; 164 CommitOperator co; 165 String CVSroot, color; 166 JTableOperator table; 167 OutputOperator oo; 168 OutputTabOperator oto; 169 VersioningOperator vo; 170 String [] expected; 171 String [] actual; 172 String allCVSRoots; 173 org.openide.nodes.Node nodeIDE; 174 PROTOCOL_FOLDER = "protocol" + File.separator + "update_access_denied"; 175 176 vo = VersioningOperator.invoke(); 177 oo = OutputOperator.invoke(); 178 oto = oo.getOutputTab(sessionCVSroot); 179 180 Node node = new Node(new SourcePackagesNode("ForImport"), "forimport|Main.java"); 181 node.performPopupAction("Open"); 182 EditorOperator eo = new EditorOperator("Main.java"); 183 eo.deleteLine(2); 184 eo.insert(" a", 3, 4); 185 eo.save(); 186 oto = oo.getOutputTab(sessionCVSroot); 188 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 189 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "show_changes_package.in"); 190 cvss = new PseudoCvsServer(in); 191 new Thread (cvss).start(); 192 CVSroot = cvss.getCvsRoot(); 193 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 194 node = new Node(new SourcePackagesNode("ForImport"), "forimport"); 195 node.performPopupAction("CVS|Show Changes"); 196 Thread.sleep(1000); 197 oto.waitText("Refreshing"); 198 oto.waitText("finished"); 199 cvss.stop(); 200 201 assertEquals("File should be listed in Versioning view", "Main.java", vo.tabFiles().getValueAt(0, 0).toString()); 202 203 node = new Node(new SourcePackagesNode("ForImport"), "forimport|Main.java"); 204 nodeIDE = (org.openide.nodes.Node) node.getOpenideNode(); 205 color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 206 assertEquals("Wrong color of node!!!", TestKit.MODIFIED_COLOR, color); 207 208 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "update_access_denied.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 node = ProjectsTabOperator.invoke().getProjectRootNode("ForImport"); 214 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 216 node.performPopupAction("CVS|Update"); 217 Thread.sleep(1000); 218 cvss.stop(); 219 oto.waitText("Updating"); 220 oto.waitText("finished"); 221 222 NbDialogOperator dialog = new NbDialogOperator("Command"); 223 JButtonOperator btn = new JButtonOperator(dialog, "Ok"); 224 btn.push(); 225 226 Thread.sleep(1000); 227 node = new Node(new SourcePackagesNode("ForImport"), "forimport|Main.java"); 228 nodeIDE = (org.openide.nodes.Node) node.getOpenideNode(); 229 color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 230 assertEquals("Wrong color of node. Modified file can't be changed to up-to-date. See issue http://www.netbeans.org/issues/show_bug.cgi?id=83476!!!", TestKit.MODIFIED_COLOR, color); 231 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 232 233 } 234 235 public void removeAllData() throws Exception { 236 TestKit.closeProject(projectName); 237 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 238 } 239 240 } 241 | Popular Tags |