KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > subversion > main > branches > SwitchUiTest


1 /*
2  * SwitchUiTest.java
3  *
4  * Created on 17 May 2006, 22:17
5  *
6  * To change this template, choose Tools | Template Manager
7  * and open the template in the editor.
8  */

9
10 package org.netbeans.test.subversion.main.branches;
11
12 import java.io.File JavaDoc;
13 import junit.textui.TestRunner;
14 import org.netbeans.jellytools.JellyTestCase;
15 import org.netbeans.jellytools.ProjectsTabOperator;
16 import org.netbeans.jellytools.nodes.Node;
17 import org.netbeans.jemmy.JemmyProperties;
18 import org.netbeans.junit.NbTestSuite;
19 import org.netbeans.test.subversion.operators.CommitStepOperator;
20 import org.netbeans.test.subversion.operators.FolderToImportStepOperator;
21 import org.netbeans.test.subversion.operators.ImportWizardOperator;
22 import org.netbeans.test.subversion.operators.RepositoryBrowserOperator;
23 import org.netbeans.test.subversion.operators.RepositoryStepOperator;
24 import org.netbeans.test.subversion.operators.SwitchOperator;
25 import org.netbeans.test.subversion.utils.RepositoryMaintenance;
26 import org.netbeans.test.subversion.utils.TestKit;
27
28 /**
29  *
30  * @author peter
31  */

32 public class SwitchUiTest extends JellyTestCase{
33     
34     public static final String JavaDoc TMP_PATH = "/tmp";
35     public static final String JavaDoc REPO_PATH = "repo";
36     public static final String JavaDoc WORK_PATH = "work";
37     public static final String JavaDoc PROJECT_NAME = "SVNApplication";
38     public File JavaDoc projectPath;
39     
40     String JavaDoc os_name;
41     
42     /** Creates a new instance of SwitchUiTest */
43     public SwitchUiTest(String JavaDoc name) {
44         super(name);
45     }
46     
47     protected void setUp() throws Exception JavaDoc {
48         os_name = System.getProperty("os.name");
49         //System.out.println(os_name);
50
System.out.println("### "+getName()+" ###");
51         
52     }
53     
54     protected boolean isUnix() {
55         boolean unix = false;
56         if (os_name.indexOf("Windows") == -1) {
57             unix = true;
58         }
59         return unix;
60     }
61     
62     public static void main(String JavaDoc[] args) {
63         // TODO code application logic here
64
TestRunner.run(suite());
65     }
66     
67     public static NbTestSuite suite() {
68         NbTestSuite suite = new NbTestSuite();
69         suite.addTest(new SwitchUiTest("testInvokeCloseSwitch"));
70         return suite;
71     }
72     
73     public void testInvokeCloseSwitch() throws Exception JavaDoc {
74         //JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 3000);
75
//JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", 3000);
76
try {
77             TestKit.closeProject(PROJECT_NAME);
78             
79             new File JavaDoc(TMP_PATH).mkdirs();
80             RepositoryMaintenance.deleteFolder(new File JavaDoc(TMP_PATH + File.separator + REPO_PATH));
81             RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH);
82             RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump");
83             projectPath = TestKit.prepareProject("General", "Java Application", PROJECT_NAME);
84             
85             ImportWizardOperator iwo = ImportWizardOperator.invoke(ProjectsTabOperator.invoke().getProjectRootNode(PROJECT_NAME));
86             RepositoryStepOperator rso = new RepositoryStepOperator();
87             //rso.verify();
88
rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false));
89             rso.next();
90             Thread.sleep(1000);
91             
92             FolderToImportStepOperator ftiso = new FolderToImportStepOperator();
93             ftiso.setRepositoryFolder("trunk/" + PROJECT_NAME);
94             ftiso.setImportMessage("initial import");
95             ftiso.next();
96             Thread.sleep(1000);
97             CommitStepOperator cso = new CommitStepOperator();
98             cso.finish();
99             
100             Node projNode = new Node(new ProjectsTabOperator().tree(), PROJECT_NAME);
101             SwitchOperator so = SwitchOperator.invoke(projNode);
102             RepositoryBrowserOperator rbo = so.browseRepositoryFolder();
103             so.verify();
104             rbo.selectFolder("tags");
105             rbo.selectFolder("trunk");
106             rbo.selectFolder("branches");
107             rbo.ok();
108             assertEquals("Folder wasn't created", "branches", so.getRepositoryFolder());
109             
110             so.cancel();
111             
112         } catch (Exception JavaDoc e) {
113             throw new Exception JavaDoc("Test failed: " + e);
114         } finally {
115             TestKit.closeProject(PROJECT_NAME);
116         }
117     }
118 }
119
Popular Tags