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.ListModel ; 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.SearchHistoryOperator; 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.JListOperator; 50 import org.netbeans.jemmy.operators.JProgressBarOperator; 51 import org.netbeans.jemmy.operators.Operator; 52 import org.netbeans.jemmy.operators.Operator; 53 import org.netbeans.jemmy.operators.Operator.DefaultStringComparator; 54 import org.netbeans.junit.NbTestSuite; 55 import org.netbeans.junit.ide.ProjectSupport; 56 57 61 public class ShowAnnotationsAndSearchHistoryTest 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 public ShowAnnotationsAndSearchHistoryTest(String name) { 72 super(name); 73 } 74 75 public static void main(String [] args) { 76 TestRunner.run(suite()); 78 } 79 80 protected void setUp() throws Exception { 81 os_name = System.getProperty("os.name"); 82 System.out.println("### " + getName() + " ###"); 84 } 85 86 public static NbTestSuite suite() { 87 NbTestSuite suite = new NbTestSuite(); 88 suite.addTest(new ShowAnnotationsAndSearchHistoryTest("testCheckOutProject")); 89 suite.addTest(new ShowAnnotationsAndSearchHistoryTest("testShowAnnotations")); 91 suite.addTest(new ShowAnnotationsAndSearchHistoryTest("removeAllData")); 92 return suite; 93 } 94 95 public void testCheckOutProject() throws Exception { 96 TestKit.closeProject(projectName); 99 comOperator = new Operator.DefaultStringComparator(true, true); 100 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 101 Operator.setDefaultStringComparator(comOperator); 102 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 103 Operator.setDefaultStringComparator(oldOperator); 104 CVSRootStepOperator crso = new CVSRootStepOperator(); 105 crso.setCVSRoot(":pserver:anoncvs@localhost:/cvs"); 106 InputStream in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "authorized.in"); 108 PseudoCvsServer cvss = new PseudoCvsServer(in); 109 new Thread (cvss).start(); 110 cvss.ignoreProbe(); 111 String CVSroot = cvss.getCvsRoot(); 112 sessionCVSroot = CVSroot; 113 crso.setCVSRoot(CVSroot); 114 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 115 crso.next(); 116 try { 117 JProgressBarOperator progress = new JProgressBarOperator(crso); 118 JButtonOperator btnStop = new JButtonOperator(crso); 119 } catch (TimeoutExpiredException e) { 120 throw e; 121 } 122 File tmp = new File ("/tmp"); File work = new File (tmp, "" + File.separator + System.currentTimeMillis()); 125 cacheFolder = new File (work, projectName + File.separator + "src" + File.separator + "forimport" + File.separator + "CVS" + File.separator + "RevisionCache"); 126 tmp.mkdirs(); 127 work.mkdirs(); 128 tmp.deleteOnExit(); 129 ModuleToCheckoutStepOperator moduleCheck = new ModuleToCheckoutStepOperator(); 130 cvss.stop(); 131 in.close(); 132 moduleCheck.setModule("ForImport"); 133 moduleCheck.setLocalFolder(work.getAbsolutePath()); in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "checkout_finish_2.in"); 136 cvss = new PseudoCvsServer(in); 137 new Thread (cvss).start(); 138 CVSroot = cvss.getCvsRoot(); 139 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 140 cwo.finish(); 141 OutputOperator oo = OutputOperator.invoke(); 142 OutputTabOperator oto = oo.getOutputTab(sessionCVSroot); 143 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 144 oto.waitText("Checking out finished"); 145 cvss.stop(); 146 in.close(); 147 NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed"); 148 JButtonOperator open = new JButtonOperator(nbdialog, "Open Project"); 149 open.push(); 150 151 ProjectSupport.waitScanFinished(); 152 new QueueTool().waitEmpty(1000); 153 ProjectSupport.waitScanFinished(); 154 155 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 156 } 157 public void testShowAnnotations() throws Exception { 158 PseudoCvsServer cvss, cvss2; 160 InputStream in, in2; 161 OutputTabOperator oto; 163 org.openide.nodes.Node nodeIDE; 164 String color, cvsRoot; 165 166 TestKit.deleteRecursively(cacheFolder); 167 168 oto = new OutputTabOperator(sessionCVSroot); 170 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 171 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "show_annotation.in"); 172 cvss = new PseudoCvsServer(in); 173 new Thread (cvss).start(); 174 175 in2 = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "show_annotation_1.in"); 176 cvss2 = new PseudoCvsServer(in2); 177 new Thread (cvss2).start(); 178 179 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", cvss.getCvsRoot() + "," + cvss2.getCvsRoot()); 180 Node nodeMain = new Node(new SourcePackagesNode("ForImport"), "forimport|Main.java"); 181 oto = new OutputTabOperator(sessionCVSroot); 182 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 183 nodeMain.performPopupAction("CVS|Show Annotations"); 184 Thread.sleep(1000); 185 oto.waitText("Loading Annotations finished"); 186 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 187 cvss.stop(); 188 cvss2.stop(); 189 } 190 191 public void testSearchHistory() throws Exception { 192 PseudoCvsServer cvss, cvss2; 194 InputStream in, in2; 195 OutputTabOperator oto; 197 org.openide.nodes.Node nodeIDE; 198 String color, cvsRoot; 199 TestKit.deleteRecursively(cacheFolder); 200 oto = new OutputTabOperator(sessionCVSroot); 201 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 202 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "search_history.in"); 203 cvss = new PseudoCvsServer(in); 204 new Thread (cvss).start(); 205 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", cvss.getCvsRoot()); 206 Node nodeMain = new Node(new SourcePackagesNode("ForImport"), "forimport|Main.java"); 207 SearchHistoryOperator sho = SearchHistoryOperator.invoke(nodeMain); 209 oto.waitText("Searching History finished"); 210 Thread.sleep(1000); 211 cvss.stop(); 212 oto.clear(); 213 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "search_history_1.in"); 214 cvss = new PseudoCvsServer(in); 215 new Thread (cvss).start(); 216 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", cvss.getCvsRoot()); 217 sho.setUsername("test"); 218 sho.setFrom("1.1"); 219 sho.setTo("1.1"); 220 sho.btSearch().push(); 221 oto.waitText("Searching History started"); 222 Thread.sleep(1000); 223 cvss.stop(); 224 JListOperator list = sho.lstHistory(); 225 ListModel model = list.getModel(); 226 assertEquals("Wrong result count", 2, model.getSize()); 227 assertTrue("Revision \"1.1\" is missing", model.getElementAt(1).toString().indexOf("1.1") > 0); 228 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 229 } 230 231 public void removeAllData() throws Exception { 232 TestKit.closeProject(projectName); 233 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 234 } 235 } 236 | Popular Tags |