1 2 20 21 package complete; 22 23 import complete.GenericStub.GenericNode; 24 import java.io.File ; 25 import java.text.SimpleDateFormat ; 26 import java.util.Date ; 27 import java.util.Enumeration ; 28 import junit.framework.AssertionFailedError; 29 import org.netbeans.jellytools.NbDialogOperator; 30 import org.netbeans.jellytools.NewWizardOperator; 31 import org.netbeans.jellytools.actions.Action; 32 import org.netbeans.jellytools.actions.CustomizeAction; 33 import org.netbeans.jellytools.modules.javacvs.CVSClientCustomizerDialogOperator; 34 import org.netbeans.jellytools.modules.javacvs.actions.JCVSMountAction; 35 import org.netbeans.jellytools.modules.javacvs.wizard.*; 36 import org.netbeans.jellytools.nodes.Node; 37 import org.netbeans.jellytools.properties.ComboBoxProperty; 38 import org.netbeans.jellytools.properties.PropertySheetOperator; 39 import org.netbeans.jemmy.operators.JCheckBoxOperator; 40 import org.netbeans.jemmy.operators.JTableOperator; 41 import org.netbeans.test.oo.gui.jelly.javacvs.AddDialog; 42 import org.netbeans.test.oo.gui.jelly.javacvs.CheckoutDialog; 43 import org.netbeans.test.oo.gui.jelly.javacvs.CommitDialog; 44 import org.netbeans.test.oo.gui.jelly.javacvs.TagDialog; 45 import org.openide.filesystems.FileSystem; 46 import org.openide.filesystems.Repository; 47 import util.History; 48 49 public abstract class JCVSStub extends GenericStub { 50 51 public JCVSStub(String testName) { 52 super(testName); 53 nRootPrefix = "CVS "; 54 } 55 56 static FileSystem sfs = null; 57 58 protected FileSystem getFileSystem () { 59 return sfs; 60 } 61 62 protected void setFileSystem (FileSystem fs) { 63 sfs = fs; 64 } 65 66 protected void prepareServer (String dir) { 67 } 68 69 protected static String roothistoryshort = null; 70 71 protected void setUp() throws Exception { 72 super.setUp (); 73 if (!"configure".equals (getName ())) { 74 history.switchToJCVS(); 75 history.setTimeout(30); 76 root.setHistoryShort(roothistoryshort); 77 } 78 } 79 80 protected void findFS () { 81 if (!GenericStub.DEBUG) { 82 super.findFS (); 83 return; 84 } 85 String normalizedClient = (nRootPrefix + clientDirectory.replace ('\\', '/')).toLowerCase (); 86 Enumeration e = Repository.getDefault().getFileSystems(); 87 while (e.hasMoreElements()) { 88 FileSystem f = (FileSystem) e.nextElement(); 89 info.println("Is it?: " + f.getDisplayName()); 90 String path = f.getDisplayName ().replace ('\\', '/').toLowerCase(); 91 if (path.indexOf (normalizedClient) >= 0) { 92 info.println("Yes"); 93 setFileSystem(f); 94 roothistoryshort = f.getDisplayName ().substring(f.getDisplayName ().lastIndexOf ('/') + 1); 95 return; 96 } 97 } 98 new AssertionFailedError ("Filesystem not found: Filesystem: " + normalizedClient); 99 } 100 101 protected void mountVCSFileSystem () { 102 new Action ("Versioning|Mount Version Control", null).performMenu (); new Action ("Tools", null).performMenu (); sleep (10000); 105 new Action ("Versioning|Mount Version Control", null).performMenu (); new Action ("Tools", null).performMenu (); new JCVSMountAction().perform(); 108 109 WorkingDirectoryStepOperator wdso = new WorkingDirectoryStepOperator (); 110 wdso.verify (); 111 txtSetTypeText (wdso.cboWorkingDirectory().getTextField(), clientDirectory); 112 wdso.next (); 113 114 CVSConnectionMethodStepOperator ccmsto = new CVSConnectionMethodStepOperator (); 115 ccmsto.verify (); 116 ccmsto.passwordServer(); 117 ccmsto.setServerName("mercury"); 122 ccmsto.setUserName("test"); 123 txtSetTypeText (ccmsto.txtRepository(), "/cvsroot"); 124 ccmsto.txtCVSROOT().waitText(":pserver:test@mercury:/cvsroot"); 125 ccmsto.next (); 126 127 CVSClientStepOperator ccso = new CVSClientStepOperator (); 128 ccso.verify (); 129 ccso.useBuiltInCVSClient(); 130 ccso.next (); 131 132 CVSLoginStepOperator clso = new CVSLoginStepOperator (); 133 clso.verify (); 134 clso.txtPassword().clearText (); 135 clso.txtPassword().typeText ("test"); 136 clso.login(); 137 clso.txtLogin().waitText ("Login successful."); 138 clso.next (); 139 140 InitialCheckoutStepOperator icso = new InitialCheckoutStepOperator (); 141 icso.checkCheckOutACopyOfTheRepositoryFilesToYourWorkingDirectory (false); 142 icso.finish (); 143 } 144 145 protected void prepareClient () { 146 history = new History (getFileSystem(), info); 147 history.switchToJCVS(); 148 history.setTimeout(30); 149 root.setHistoryShort ("client"); 150 151 closeAllVCSWindows(); 152 closeAllProperties(); 153 154 root.jcvsNode().properties(); 155 PropertySheetOperator pso = new PropertySheetOperator (root.node ()); 156 ComboBoxProperty cbp = new ComboBoxProperty (pso, "User Interface Mode"); 157 cbp.setValue("GUI Style"); 158 sleep (1000); 159 info.println ("User Interface Mode property value 1: " + cbp.getValue ()); 160 closeAllProperties(); 161 162 root.jcvsNode().properties(); 164 pso = new PropertySheetOperator (root.node ()); 165 cbp = new ComboBoxProperty (pso, "User Interface Mode"); 166 info.println ("User Interface Mode property value 2: " + cbp.getValue ()); 167 cbp.setValue("GUI Style"); 168 sleep (1000); 169 info.println ("User Interface Mode property value 3: " + cbp.getValue ()); 170 closeAllProperties(); 171 172 history.setTimeout(120); 173 checkout(root, "test/jcvs"); 174 history.setTimeout(30); 175 GenericNode test = new GenericNode (root, "test"); 176 GenericNode jcvs = new GenericNode (test, "jcvs"); 177 jcvs.waitStatus (null); 178 jcvs.jcvsNode().select (); 179 180 roothistoryshort = new SimpleDateFormat ("yyMMddHHmmssSS").format (new Date (System.currentTimeMillis())); 181 GenericNode cur = new GenericNode (jcvs, roothistoryshort); 182 cur.mkdirs(); 183 refresh (jcvs); 184 cur.waitStatus("Local"); 185 addDirectory (cur); 186 187 new CustomizeAction ().performPopup(root.jcvsNode()); 188 CVSClientCustomizerDialogOperator cus = new CVSClientCustomizerDialogOperator (); 189 new Node (cus.treeSelectRelativeMountPoint(), "test|jcvs|" + roothistoryshort).select (); 190 cus.txtRelativeMountPoint().waitText ("test" + File.separator + "jcvs" + File.separator + roothistoryshort); 191 cus.ok (); 192 cus.waitClosed(); 193 closeAllVCSWindows(); 194 for (int a = 0; a < 30; a ++) { 195 if (getFileSystem().getDisplayName().endsWith(roothistoryshort)) { 196 root = new GenericNode (null, getFileSystem ().getDisplayName ().substring(nRootPrefix.length())); 197 root.setHistoryShort(roothistoryshort); 198 root.jcvsNode ().select (); 199 return; 200 } 201 sleep (1000); 202 } 203 throw new AssertionFailedError ("New root not found: Root: " + roothistoryshort); 204 } 205 206 protected void refresh (GenericNode node) { 207 node.jcvsNode ().expand (); node.jcvsNode().jCVSRefresh(); 209 node.waitHistoryShort ("status -l"); 210 } 211 212 protected void refreshRecursively (GenericNode node) { 213 node.jcvsNode ().expand (); node.jcvsNode ().jCVSRefreshRecursively(); 215 node.waitHistoryShort ("status"); 216 } 217 218 protected void addDirectory (GenericNode node) { 219 node.jcvsNode ().expand (); node.jcvsNode ().jCVSAdd(); 221 AddDialog add = new AddDialog (); 222 add.runCommand (); 223 add.waitClosed(); 224 node.waitHistoryShort ("add"); 225 node.waitStatus (null); 226 } 227 228 protected void checkout (GenericNode node, String what) { 229 node.jcvsNode ().expand (); node.jcvsNode ().jCVSCheckOut(); 231 CheckoutDialog cod = new CheckoutDialog (); 232 cod.txtCheckout().clearText(); 233 cod.txtCheckout().typeText(what); 234 cod.runCommand(); 235 cod.waitClosed(); 236 node.waitHistoryShort ("checkout " + what); 237 } 238 239 protected void addFile (GenericNode node, String desc) { 240 node.cvsNode ().cVSAdd(); 241 AddDialog add = new AddDialog (); 242 if (desc != null) { 243 add.txtMessage().setCaretPosition(0); 244 add.txtMessage().typeText(desc); 245 } 246 add.runCommand (); 247 add.waitClosed(); 248 if (desc != null) { 249 if (desc.length () > 9) 250 desc = desc.substring(0, 5) + "..."; 251 node.waitHistoryShort("add -m \"" + desc + "\""); 252 } else 253 node.waitHistoryShort("add"); 254 node.waitStatus ("LAdded; New"); 255 } 256 257 protected void commitFile (GenericNode node, String branch, String desc) { 258 node.cvsNode ().cVSCommit(); 259 CommitDialog com = new CommitDialog (); 260 if (branch != null) { 261 checkCheckBox (com.cbRevisionBranch()); 262 com.txtRevisionBranch().clearText(); 263 com.txtRevisionBranch().typeText(branch); 264 } 265 if (desc != null) { 266 com.txtMessage().setCaretPosition(0); 267 com.txtMessage().typeText(desc); 268 } 269 com.runCommand (); 270 com.waitClosed(); 271 String cmd = "commit"; 272 if (branch != null) 273 cmd += " -r " + branch; 274 if (desc != null) { 275 if (desc.length () > 9) 276 desc = desc.substring (0, 5) + "..."; 277 cmd += " -m \"" + desc + "\""; 278 } else 279 cmd += " -m \"\""; 280 node.waitHistoryShort (cmd); 281 node.jcvsNode().jCVSRefresh(); node.waitHistoryShort ("status -l"); node.waitStatus ("Up-to-date", false); 284 } 285 286 public void createAddCommitFile (GenericNode node, String template) { 287 NewWizardOperator.create(template, node.parent ().node (), node.name ()); 288 node.waitStatus ("Local"); 289 addFile (node, "Initial"); 290 commitFile (node, null, "Initial state"); 291 node.waitStatus ("Up-to-date; 1.1"); 292 } 293 294 public void dumpTable (JTableOperator table) { 295 out.println ("==== Table Dump ===="); 296 int rows = table.getRowCount(); 297 out.println ("Rows: " + rows); 298 int columns = table.getColumnCount(); 299 out.println ("Columns: " + columns); 300 for (int a = 0; a < rows; a ++) { 301 out.print ("" + (a + 1) + "."); 302 for (int b = 0; b < columns; b ++) 303 out.print (" - " + table.getValueAt(a, b)); 304 out.println (); 305 } 306 } 307 308 protected void addTagFile (GenericNode node, String name, boolean branch) { 309 node.jcvsNode().jCVSTag(); 310 TagDialog tag = new TagDialog (); 311 checkCheckBox (tag.cbBranch(), branch); 312 tag.txtTag().clearText (); 313 tag.txtTag().typeText (name); 314 tag.runCommand (); 315 tag.waitClosed (); 316 if (branch) 317 node.waitHistoryShort("tag -b " + name); 318 else 319 node.waitHistoryShort("tag " + name); 320 } 321 322 protected void checkCheckBox (JCheckBoxOperator cb) { 323 checkCheckBox (cb, true); 324 } 325 326 protected void checkCheckBox (JCheckBoxOperator cb, boolean state) { 327 if (cb.isSelected() != state) 328 cb.push (); 329 } 330 331 protected void assertCVSErrorDialog () { 332 NbDialogOperator dia = new NbDialogOperator ("CVS Error"); 333 dia.close(); 334 dia.waitClosed (); 335 } 336 } 337 | Popular Tags |