1 19 package org.netbeans.test.cvsmodule; 20 21 25 26 import java.io.File ; 27 import java.io.InputStream ; 28 import junit.textui.TestRunner; 29 import org.netbeans.jellytools.JellyTestCase; 30 import org.netbeans.jellytools.NbDialogOperator; 31 import org.netbeans.jellytools.OutputOperator; 32 import org.netbeans.jellytools.OutputTabOperator; 33 import org.netbeans.jellytools.ProjectsTabOperator; 34 import org.netbeans.jellytools.modules.javacvs.BranchOperator; 35 import org.netbeans.jellytools.modules.javacvs.CVSRootStepOperator; 36 import org.netbeans.jellytools.modules.javacvs.CheckoutWizardOperator; 37 import org.netbeans.jellytools.modules.javacvs.ModuleToCheckoutStepOperator; 38 import org.netbeans.jellytools.modules.javacvs.SwitchToBranchOperator; 39 import org.netbeans.jellytools.nodes.Node; 40 import org.netbeans.jellytools.nodes.SourcePackagesNode; 41 import org.netbeans.jemmy.JemmyProperties; 42 import org.netbeans.jemmy.QueueTool; 43 import org.netbeans.jemmy.TimeoutExpiredException; 44 import org.netbeans.jemmy.operators.JButtonOperator; 45 import org.netbeans.jemmy.operators.JProgressBarOperator; 46 import org.netbeans.jemmy.operators.Operator; 47 import org.netbeans.jemmy.operators.Operator.DefaultStringComparator; 48 import org.netbeans.junit.NbTestSuite; 49 import org.netbeans.junit.ide.ProjectSupport; 50 51 52 56 public class BranchCreationAndSwitchTest extends JellyTestCase { 57 58 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 BranchCreationAndSwitchTest(String name) { 70 super(name); 71 } 72 73 public static void main(String [] args) { 74 TestRunner.run(suite()); 76 } 77 78 protected void setUp() throws Exception { 79 os_name = System.getProperty("os.name"); 80 System.out.println("### " + getName() + " ###"); 82 } 83 84 public static NbTestSuite suite() { 85 NbTestSuite suite = new NbTestSuite(); 86 suite.addTest(new BranchCreationAndSwitchTest("testCheckOutProject")); 87 suite.addTest(new BranchCreationAndSwitchTest("testCreateBranchForProject")); 88 suite.addTest(new BranchCreationAndSwitchTest("testSwitchProjectToBranch")); 89 suite.addTest(new BranchCreationAndSwitchTest("removeAllData")); 90 return suite; 91 } 92 93 public void testCheckOutProject() throws Exception { 94 97 TestKit.closeProject(projectName); 98 comOperator = new Operator.DefaultStringComparator(true, true); 99 oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator(); 100 Operator.setDefaultStringComparator(comOperator); 101 CheckoutWizardOperator cwo = CheckoutWizardOperator.invoke(); 102 Operator.setDefaultStringComparator(oldOperator); 103 CVSRootStepOperator crso = new CVSRootStepOperator(); 104 crso.setCVSRoot(":pserver:anoncvs@localhost:/cvs"); 105 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 158 public void testCreateBranchForProject() throws Exception { 159 PseudoCvsServer cvss; 161 InputStream in; 162 OutputTabOperator oto; 163 String CVSroot; 164 oto = new OutputTabOperator(sessionCVSroot); 165 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 166 Node rootNode = new ProjectsTabOperator().getProjectRootNode(projectName); 167 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "cvs_60_create_branch.in"); 168 cvss = new PseudoCvsServer(in); 169 new Thread (cvss).start(); 170 CVSroot = cvss.getCvsRoot(); 171 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", CVSroot); 172 BranchOperator bo = BranchOperator.invoke(rootNode); 173 bo.setBranchName("MyNewBranch"); 174 bo.checkSwitchToThisBranchAftewards(false); 175 bo.checkTagBeforeBranching(false); 176 oto = new OutputTabOperator(sessionCVSroot); 177 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 178 bo.branch(); 179 Thread.sleep(1000); 180 oto.waitText("Branch"); 181 oto.waitText("ForImport"); 182 oto.waitText("finished"); 183 cvss.stop(); 184 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 185 } 186 public void testSwitchProjectToBranch() throws Exception { 187 PseudoCvsServer cvss; 189 InputStream in; 190 OutputTabOperator oto; 191 org.openide.nodes.Node nodeIDE; 192 String cvsRoot; 193 oto = new OutputTabOperator(sessionCVSroot); 194 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 195 Node rootNode = new ProjectsTabOperator().getProjectRootNode(projectName); 196 in = TestKit.getStream(getDataDir().getCanonicalFile().toString() + File.separator + PROTOCOL_FOLDER, "cvs_60_switch_branch.in"); 197 cvss = new PseudoCvsServer(in); 198 new Thread (cvss).start(); 199 cvsRoot = cvss.getCvsRoot(); 200 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", cvsRoot); 201 oto = new OutputTabOperator(sessionCVSroot); 202 oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000); 203 SwitchToBranchOperator sbo = SwitchToBranchOperator.invoke(rootNode); 204 sbo.switchToBranch(); 205 sbo.setBranch("MyNewBranch"); 206 sbo.pushSwitch(); 207 Thread.sleep(1000); 208 oto.waitText(" to Branch finished"); 209 cvss.stop(); 210 TestKit.showStatusLabels(); 212 Node nodeFile = new Node(new SourcePackagesNode(projectName), "ForImport" + "|Main.java"); 213 nodeIDE = (org.openide.nodes.Node) nodeFile.getOpenideNode(); 214 String status = TestKit.getStatus(nodeIDE.getHtmlDisplayName()); 215 boolean comparison = status.equals("[; MyNewBranch]"); 216 assertEquals("Wrong annotation of node!!!", true, comparison); 217 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 218 } 219 220 221 public void removeAllData() throws Exception { 222 TestKit.closeProject(projectName); 223 System.setProperty("netbeans.t9y.cvs.connection.CVSROOT", ""); 224 } 225 } | Popular Tags |