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.nodes.Node; 42 import org.netbeans.jellytools.nodes.SourcePackagesNode; 43 import org.netbeans.jemmy.JemmyProperties; 44 import org.netbeans.jemmy.QueueTool; 45 import org.netbeans.jemmy.TimeoutExpiredException; 46 import org.netbeans.jemmy.operators.JButtonOperator; 47 import org.netbeans.jemmy.operators.JProgressBarOperator; 48 import org.netbeans.jemmy.operators.Operator; 49 import org.netbeans.jemmy.operators.Operator; 50 import org.netbeans.jemmy.operators.Operator.DefaultStringComparator; 51 import org.netbeans.junit.NbTestSuite; 52 import org.netbeans.junit.ide.ProjectSupport; 53 54 58 public class ResolveConflictsAndRevertTest extends JellyTestCase { 59 String os_name; 60 static String sessionCVSroot; 61 final String projectName = "ForImport"; 62 final String pathToMain = "forimport|Main.java"; 63 final String PROTOCOL_FOLDER = "protocol"; 64 static File cacheFolder; 65 Operator.DefaultStringComparator comOperator; 66 Operator.DefaultStringComparator oldOperator; 67 68 69 public ResolveConflictsAndRevertTest(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 ResolveConflictsAndRevertTest("testCheckOutProject")); 86 suite.addTest(new ResolveConflictsAndRevertTest("testResolveConflicts")); 87 suite.addTest(new ResolveConflictsAndRevertTest("testRevertModifications")); 88 return suite; 90 } 91 92 public void testCheckOutProject() throws Exception { 93 TestKit.closeProject(projectName); 96 comOperator = new Operator.DefaultStringComparator(true, true); 97 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 98 Operator.setDefaultStringComparator(comOperator); 99 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 100 Operator.setDefaultStringComparator(oldOperator); 101 CVSRootStepOperator crso = new CVSRootStepOperator(); 102 crso.setCVSRoot(":pserver:anoncvs@localhost:/cvs"); 103 InputStream in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "authorized.in"); 105 PseudoCvsServer cvss = new PseudoCvsServer(in); 106 new Thread (cvss).start(); 107 cvss.ignoreProbe(); 108 String CVSroot = cvss.getCvsRoot(); 109 sessionCVSroot = CVSroot; 110 crso.setCVSRoot(CVSroot); 111 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 112 crso.next(); 113 try { 114 JProgressBarOperator progress = new JProgressBarOperator(crso); 115 JButtonOperator btnStop = new JButtonOperator(crso); 116 } catch (TimeoutExpiredException e) { 117 throw e; 118 } 119 File tmp = new File ("/tmp"); File work = new File (tmp, "" + File.separator + System.currentTimeMillis()); 122 cacheFolder = new File (work, projectName + File.separator + "src" + File.separator + "forimport" + File.separator + "CVS" + File.separator + "RevisionCache"); 123 tmp.mkdirs(); 124 work.mkdirs(); 125 tmp.deleteOnExit(); 126 ModuleToCheckoutStepOperator moduleCheck = new ModuleToCheckoutStepOperator(); 127 cvss.stop(); 128 in.close(); 129 moduleCheck.setModule("ForImport"); 130 moduleCheck.setLocalFolder(work.getAbsolutePath()); in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "checkout_finish_2.in"); 133 cvss = new PseudoCvsServer(in); 134 new Thread (cvss).start(); 135 CVSroot = cvss.getCvsRoot(); 136 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 137 cwo.finish(); 138 OutputOperator oo = OutputOperator.invoke(); 139 OutputTabOperator oto = oo.getOutputTab(sessionCVSroot); 140 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 141 oto.waitText("Checking out finished"); 142 cvss.stop(); 143 in.close(); 144 NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed"); 145 JButtonOperator open = new JButtonOperator(nbdialog, "Open Project"); 146 open.push(); 147 148 ProjectSupport.waitScanFinished(); 149 new QueueTool().waitEmpty(1000); 150 ProjectSupport.waitScanFinished(); 151 152 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 153 } 154 155 public void testResolveConflicts() throws Exception { 156 PseudoCvsServer cvss; 158 InputStream in; 159 OutputTabOperator oto; 160 org.openide.nodes.Node nodeIDE; 161 String color; 162 163 oto = new OutputTabOperator(sessionCVSroot); 164 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 165 oto.clear(); 166 167 Node nodeClass = new Node(new SourcePackagesNode(projectName), pathToMain); 168 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "diff/create_conflict.in"); 169 cvss = new PseudoCvsServer(in); 170 new Thread (cvss).start(); 171 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", cvss.getCvsRoot()); 172 nodeClass.performPopupActionNoBlock("CVS|Update"); 173 NbDialogOperator dialog = new NbDialogOperator("Warning"); 174 dialog.ok(); 175 oto.waitText("cvs server: conflicts found in Main.java"); 176 oto.waitText("Updating \"Main.java\" finished"); 177 Thread.sleep(1000); 178 cvss.stop(); 179 180 nodeClass = new Node(new SourcePackagesNode(projectName), pathToMain); 181 nodeIDE = (org.openide.nodes.Node) nodeClass.getOpenideNode(); 182 color = TestKit.getColor(nodeIDE.getHtmlDisplayName()); 183 assertEquals("Wrong color for file in conflict", TestKit.CONFLICT_COLOR, color); 184 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 188 } 189 190 public void testRevertModifications() throws Exception { 191 PseudoCvsServer cvss; 193 InputStream in; 194 OutputTabOperator oto; 195 org.openide.nodes.Node nodeIDE; 196 oto = new OutputTabOperator(sessionCVSroot); 197 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 198 oto.clear(); 199 TestKit.deleteRecursively(cacheFolder); 201 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "revert_modifications.in"); 202 cvss = new PseudoCvsServer(in); 203 new Thread (cvss).start(); 204 Node nodeMain = new Node(new SourcePackagesNode("ForImport"), "forimport|Main.java"); 205 nodeMain.performPopupActionNoBlock("CVS|Revert Modifications"); 206 NbDialogOperator nbDialog = new NbDialogOperator("Confirm overwrite"); 207 JButtonOperator btnYes = new JButtonOperator(nbDialog, "Yes"); 208 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", cvss.getCvsRoot()); 209 btnYes.push(); 210 Thread.sleep(1000); 211 oto = new OutputTabOperator(sessionCVSroot); 212 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 213 oto.waitText("Reverting finished"); 214 cvss.stop(); 215 nodeIDE = (org.openide.nodes.Node) nodeMain.getOpenideNode(); 216 assertNull("No color for node expected", nodeIDE.getHtmlDisplayName()); 217 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 218 } 219 220 public void removeAllData() throws Exception { 221 TestKit.closeProject(projectName); 222 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 223 } 224 } 225 | Popular Tags |