KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * CopyUiTest.java
3  *
4  * Created on 16 May 2006, 10:32
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.jemmy.TimeoutExpiredException;
19 import org.netbeans.junit.NbTestSuite;
20 import org.netbeans.test.subversion.operators.CommitStepOperator;
21 import org.netbeans.test.subversion.operators.CopyToOperator;
22 import org.netbeans.test.subversion.operators.CreateNewFolderOperator;
23 import org.netbeans.test.subversion.operators.FolderToImportStepOperator;
24 import org.netbeans.test.subversion.operators.ImportWizardOperator;
25 import org.netbeans.test.subversion.operators.RepositoryBrowserImpOperator;
26 import org.netbeans.test.subversion.operators.RepositoryStepOperator;
27 import org.netbeans.test.subversion.utils.RepositoryMaintenance;
28 import org.netbeans.test.subversion.utils.TestKit;
29
30 /**
31  *
32  * @author peter
33  */

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