KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > subversion > main > checkout > CheckoutUITest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * CheckoutUITest.java
22  *
23  * Created on 19 April 2006, 13:34
24  *
25  * To change this template, choose Tools | Template Manager
26  * and open the template in the editor.
27  */

28 package org.netbeans.test.subversion.main.checkout;
29
30 import java.io.File JavaDoc;
31 import junit.textui.TestRunner;
32 import org.netbeans.jellytools.JellyTestCase;
33 import org.netbeans.jellytools.OutputOperator;
34 import org.netbeans.jemmy.JemmyProperties;
35 import org.netbeans.jemmy.TimeoutExpiredException;
36 import org.netbeans.jemmy.operators.JButtonOperator;
37 import org.netbeans.jemmy.operators.JFileChooserOperator;
38 import org.netbeans.jemmy.operators.JLabelOperator;
39 import org.netbeans.jemmy.operators.JTextFieldOperator;
40 import org.netbeans.jemmy.operators.Operator;
41 import org.netbeans.jemmy.operators.Operator.DefaultStringComparator;
42 import org.netbeans.junit.NbTestSuite;
43 import org.netbeans.test.subversion.operators.CheckoutWizardOperator;
44 import org.netbeans.test.subversion.operators.RepositoryBrowserOperator;
45 import org.netbeans.test.subversion.operators.RepositoryStepOperator;
46 import org.netbeans.test.subversion.operators.WorkDirStepOperator;
47 import org.netbeans.test.subversion.utils.RepositoryMaintenance;
48 import org.netbeans.test.subversion.utils.TestKit;
49
50 /**
51  *
52  * @author peter
53  */

54 public class CheckoutUITest extends JellyTestCase{
55     
56     public static final String JavaDoc TMP_PATH = "/tmp";
57     public static final String JavaDoc REPO_PATH = "repo";
58     public static final String JavaDoc WORK_PATH = "work";
59     public static final String JavaDoc PROJECT_NAME = "SVNApplication";
60     public File JavaDoc projectPath;
61     String JavaDoc os_name;
62     Operator.DefaultStringComparator comOperator;
63     Operator.DefaultStringComparator oldOperator;
64     
65     /** Creates a new instance of CheckoutUITest */
66     public CheckoutUITest(String JavaDoc name) {
67         super(name);
68     }
69     
70     protected void setUp() throws Exception JavaDoc {
71         os_name = System.getProperty("os.name");
72         //System.out.println(os_name);
73
System.out.println("### "+getName()+" ###");
74         
75     }
76     
77     protected boolean isUnix() {
78         boolean unix = false;
79         if (os_name.indexOf("Windows") == -1) {
80             unix = true;
81         }
82         return unix;
83     }
84     
85     public static void main(String JavaDoc[] args) {
86         // TODO code application logic here
87
TestRunner.run(suite());
88     }
89     
90     public static NbTestSuite suite() {
91         NbTestSuite suite = new NbTestSuite();
92         suite.addTest(new CheckoutUITest("testInvokeClose"));
93         suite.addTest(new CheckoutUITest("testChangeAccessTypes"));
94         suite.addTest(new CheckoutUITest("testIncorrentUrl"));
95         suite.addTest(new CheckoutUITest("testAvailableFields"));
96         suite.addTest(new CheckoutUITest("testRepositoryFolder"));
97         return suite;
98     }
99     
100     public void testInvokeClose() throws Exception JavaDoc {
101         TestKit.showStatusLabels();
102         OutputOperator oo = OutputOperator.invoke();
103         CheckoutWizardOperator co = CheckoutWizardOperator.invoke();
104         co.btCancel().pushNoBlock();
105     }
106     
107     public void testChangeAccessTypes() throws Exception JavaDoc {
108         //JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 3000);
109
//JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", 3000);
110

111         comOperator = new Operator.DefaultStringComparator(true, true);
112         oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator();
113         Operator.setDefaultStringComparator(comOperator);
114         CheckoutWizardOperator co = CheckoutWizardOperator.invoke();
115         Operator.setDefaultStringComparator(oldOperator);
116         RepositoryStepOperator rso = new RepositoryStepOperator();
117         rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE);
118         Thread.sleep(1000);
119         //
120
rso.setRepositoryURL(RepositoryStepOperator.ITEM_SVN);
121         rso.txtUser().setText(RepositoryStepOperator.ITEM_SVN);
122         rso.txtPassword().setText(RepositoryStepOperator.ITEM_SVN);
123         Thread.sleep(1000);
124         //
125
rso.setRepositoryURL(RepositoryStepOperator.ITEM_SVNSSH);
126         rso.txtUser().setText(RepositoryStepOperator.ITEM_SVNSSH);
127         //rso.txtPassword().setText(RepositoryStepOperator.ITEM_SVNSSH);
128
Thread.sleep(1000);
129         //
130
rso.setRepositoryURL(RepositoryStepOperator.ITEM_HTTP);
131         rso.txtUser().setText(RepositoryStepOperator.ITEM_HTTP);
132         rso.txtPassword().setText(RepositoryStepOperator.ITEM_HTTP);
133         Thread.sleep(1000);
134         //
135
rso.setRepositoryURL(RepositoryStepOperator.ITEM_HTTPS);
136         rso.txtUser().setText(RepositoryStepOperator.ITEM_HTTPS);
137         rso.txtPassword().setText(RepositoryStepOperator.ITEM_HTTPS);
138         Thread.sleep(1000);
139         co.btCancel().pushNoBlock();
140     }
141     
142     public void testIncorrentUrl() throws Exception JavaDoc {
143         //JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 3000);
144
//JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", 3000);
145
comOperator = new Operator.DefaultStringComparator(true, true);
146         oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator();
147         Operator.setDefaultStringComparator(comOperator);
148         CheckoutWizardOperator co = CheckoutWizardOperator.invoke();
149         Operator.setDefaultStringComparator(oldOperator);
150         RepositoryStepOperator rso = new RepositoryStepOperator();
151         //wrong file
152
rso.setRepositoryURL("dfile:///");
153         assertEquals("This should be wrong url string!!!", "Invalid svn url :dfile:///", rso.lblWarning().getText());
154         //wrong svn
155
rso.setRepositoryURL("dsvn://");
156         assertEquals("This should be wrong url string!!!", "Invalid svn url :dsvn://", rso.lblWarning().getText());
157         //space in file
158
rso.setRepositoryURL("file :///");
159         assertEquals("This should be wrong url string!!!", "Invalid svn url :file :///", rso.lblWarning().getText());
160         //space in svn
161
rso.setRepositoryURL("svn ://");
162         assertEquals("This should be wrong url string!!!", "Invalid svn url :svn ://", rso.lblWarning().getText());
163         //space in http
164
rso.setRepositoryURL("http ://");
165         assertEquals("This should be wrong url string!!!", "Invalid svn url :http ://", rso.lblWarning().getText());
166         //space in https
167
rso.setRepositoryURL("https ://");
168         assertEquals("This should be wrong url string!!!", "Invalid svn url :https ://", rso.lblWarning().getText());
169         //space in svn+ssh
170
rso.setRepositoryURL("svn+ssh ://");
171         assertEquals("This should be wrong url string!!!", "Invalid svn url :svn+ssh ://", rso.lblWarning().getText());
172         
173         co.btCancel().pushNoBlock();
174     }
175     
176     public void testAvailableFields() throws Exception JavaDoc {
177         //JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 3000);
178
//JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", 3000);
179

180         comOperator = new Operator.DefaultStringComparator(true, true);
181         oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator();
182         Operator.setDefaultStringComparator(comOperator);
183         CheckoutWizardOperator co = CheckoutWizardOperator.invoke();
184         Operator.setDefaultStringComparator(oldOperator);
185         RepositoryStepOperator rso = new RepositoryStepOperator();
186         //file
187
rso.selectRepositoryURL(RepositoryStepOperator.ITEM_FILE);
188         TimeoutExpiredException tee = null;
189         try {
190             JLabelOperator lbl = rso.lblUser();
191         } catch (Exception JavaDoc e) {
192             tee = (TimeoutExpiredException) e;
193         }
194         assertNotNull("User name should not be accessible for file:///!!!" ,tee);
195         
196         tee = null;
197         try {
198             JLabelOperator lbl = rso.lblPassword();
199         } catch (Exception JavaDoc e) {
200             tee = (TimeoutExpiredException) e;
201         }
202         assertNotNull("Password should not be accessible for file:///!!!" ,tee);
203         
204         //http
205
rso = new RepositoryStepOperator();
206         rso.setRepositoryURL(RepositoryStepOperator.ITEM_HTTP);
207         JLabelOperator lblU = rso.lblUser();
208         JLabelOperator lblP = rso.lblPassword();
209         JButtonOperator btnProxy = rso.btProxyConfiguration();
210         
211         //file
212
rso = new RepositoryStepOperator();
213         rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE);
214         tee = null;
215         try {
216             JLabelOperator lbl = rso.lblUser();
217         } catch (Exception JavaDoc e) {
218             tee = (TimeoutExpiredException) e;
219         }
220         assertNotNull("User name should not be accessible for file:///!!!" ,tee);
221         
222         tee = null;
223         try {
224             JLabelOperator lbl = rso.lblPassword();
225         } catch (Exception JavaDoc e) {
226             tee = (TimeoutExpiredException) e;
227         }
228         assertNotNull("Password should not be accessible for file:///!!!" ,tee);
229         
230         //https
231
rso = new RepositoryStepOperator();
232         rso.setRepositoryURL(RepositoryStepOperator.ITEM_HTTPS);
233         lblU = rso.lblUser();
234         lblP = rso.lblPassword();
235         btnProxy = rso.btProxyConfiguration();
236         
237         //file
238
rso = new RepositoryStepOperator();
239         rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE);
240         tee = null;
241         try {
242             JLabelOperator lbl = rso.lblUser();
243         } catch (Exception JavaDoc e) {
244             tee = (TimeoutExpiredException) e;
245         }
246         assertNotNull("User name should not be accessible for file:///!!!" ,tee);
247         
248         tee = null;
249         try {
250             JLabelOperator lbl = rso.lblPassword();
251         } catch (Exception JavaDoc e) {
252             tee = (TimeoutExpiredException) e;
253         }
254         assertNotNull("Password should not be accessible for file:///!!!" ,tee);
255         
256         //svn
257
rso = new RepositoryStepOperator();
258         rso.setRepositoryURL(RepositoryStepOperator.ITEM_SVN);
259         lblU = rso.lblUser();
260         lblP = rso.lblPassword();
261         btnProxy = rso.btProxyConfiguration();
262         
263         //file
264
rso = new RepositoryStepOperator();
265         rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE);
266         tee = null;
267         try {
268             JLabelOperator lbl = rso.lblUser();
269         } catch (Exception JavaDoc e) {
270             tee = (TimeoutExpiredException) e;
271         }
272         assertNotNull("User name should not be accessible for file:///!!!" ,tee);
273         
274         tee = null;
275         try {
276             JLabelOperator lbl = rso.lblPassword();
277         } catch (Exception JavaDoc e) {
278             tee = (TimeoutExpiredException) e;
279         }
280         assertNotNull("Password should not be accessible for file:///!!!" ,tee);
281         
282         //svn+ssh
283
rso = new RepositoryStepOperator();
284         rso.setRepositoryURL(RepositoryStepOperator.ITEM_SVNSSH);
285         lblU = rso.lblUseExternal();
286         lblU = rso.lblTunnelCommand();
287         JTextFieldOperator txt = rso.txtTunnelCommand();
288         txt.typeText("plink");
289         Thread.sleep(2000);
290         //lblU = rso.lblUser();
291
//lblP = rso.lblPassword();
292
//btnProxy = rso.btProxyConfiguration();
293

294         //file
295
rso = new RepositoryStepOperator();
296         rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE);
297         tee = null;
298         try {
299             JLabelOperator lbl = rso.lblUser();
300         } catch (Exception JavaDoc e) {
301             tee = (TimeoutExpiredException) e;
302         }
303         assertNotNull("User name should not be accessible for file:///!!!" ,tee);
304         
305         tee = null;
306         try {
307             JLabelOperator lbl = rso.lblPassword();
308         } catch (Exception JavaDoc e) {
309             tee = (TimeoutExpiredException) e;
310         }
311         assertNotNull("Password should not be accessible for file:///!!!" ,tee);
312         
313         co.btCancel().pushNoBlock();
314     }
315     
316     public void testRepositoryFolder() throws Exception JavaDoc {
317         //JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 3000);
318
//JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", 3000);
319

320         comOperator = new Operator.DefaultStringComparator(true, true);
321         oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator();
322         Operator.setDefaultStringComparator(comOperator);
323         CheckoutWizardOperator co = CheckoutWizardOperator.invoke();
324         Operator.setDefaultStringComparator(oldOperator);
325         RepositoryStepOperator rso = new RepositoryStepOperator();
326     
327         //create repository...
328
new File JavaDoc(TMP_PATH).mkdirs();
329         RepositoryMaintenance.deleteFolder(new File JavaDoc(TMP_PATH + File.separator + REPO_PATH));
330         RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH);
331         RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump");
332         rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false));
333         
334         //next step
335
rso.next();
336         Thread.sleep(2000);
337         
338         WorkDirStepOperator wdso = new WorkDirStepOperator();
339         wdso.verify();
340         RepositoryBrowserOperator rbo = wdso.browseRepository();
341         rbo.verify();
342         //Try to select folders
343
rbo.selectFolder("branches");
344         rbo.selectFolder("tags");
345         rbo.selectFolder("trunk");
346         rbo.selectFolder("trunk|JavaApp|src|javaapp");
347         rbo.ok();
348         
349         assertEquals("Wrong folder selection!!!", "trunk/JavaApp/src/javaapp", wdso.getRepositoryFolder());
350         rbo = wdso.browseRepository();
351         rbo.selectFolder("trunk|JavaApp");
352         rbo.ok();
353         assertEquals("Wrong folder selection!!!", "trunk/JavaApp", wdso.getRepositoryFolder());
354         wdso.setLocalFolder("/tmp");
355         JFileChooserOperator jfc = wdso.browseLocalFolder();
356         assertEquals("Directory set in wizard not propagated to file chooser:", true, jfc.getCurrentDirectory().getAbsolutePath().endsWith("tmp"));
357         jfc.cancel();
358         wdso.setRepositoryRevision("10");
359         wdso.checkCheckoutContentOnly(true);
360         co.btCancel().pushNoBlock();
361     }
362     
363     public void testStopProcess() throws Exception JavaDoc {
364         //emmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 3000);
365
//JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", 3000);
366

367         comOperator = new Operator.DefaultStringComparator(true, true);
368         oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator();
369         Operator.setDefaultStringComparator(comOperator);
370         CheckoutWizardOperator co = CheckoutWizardOperator.invoke();
371         Operator.setDefaultStringComparator(oldOperator);
372         RepositoryStepOperator rso = new RepositoryStepOperator();
373     
374         //create repository...
375
new File JavaDoc(TMP_PATH).mkdirs();
376         RepositoryMaintenance.deleteFolder(new File JavaDoc(TMP_PATH + File.separator + REPO_PATH));
377         RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH);
378         RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump");
379         rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false));
380         
381         //next step
382
rso.next();
383         //Thread.sleep(2000);
384
rso.btStop().push();
385         assertEquals("Warning message - process was cancelled by user", "Action canceled by user", rso.lblWarning().getText());
386         co.btCancel().pushNoBlock();
387     }
388 }
389
Popular Tags