KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * RevertUiTest.java
3  *
4  * Created on 18 May 2006, 17:22
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.FolderToImportStepOperator;
22 import org.netbeans.test.subversion.operators.ImportWizardOperator;
23 import org.netbeans.test.subversion.operators.RepositoryStepOperator;
24 import org.netbeans.test.subversion.operators.RevertModificationsOperator;
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 RevertUiTest 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 RevertUiTest */
43     public RevertUiTest(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 RevertUiTest("testInvokeCloseRevert"));
70         return suite;
71     }
72     
73     public void testInvokeCloseRevert() 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             //Node projNode = new Node(new ProjectsTabOperator().tree(), "AnagramGame");
102
RevertModificationsOperator rmo = RevertModificationsOperator.invoke(projNode);
103             rmo.verify();
104             TimeoutExpiredException tee = null;
105             try {
106                 rmo.setStartRevision("1");
107             } catch (Exception JavaDoc e) {
108                 tee = (TimeoutExpiredException) e;
109             }
110             assertNotNull("Components shouldn't be accessed", tee);
111             tee = null;
112             try {
113                 rmo.setEndRevision("1");
114             } catch (Exception JavaDoc e) {
115                 tee = (TimeoutExpiredException) e;
116             }
117             assertNotNull("Components shouldn't be accessed", tee);
118             tee = null;
119             try {
120                 rmo.setEndRevision("1");
121             } catch (Exception JavaDoc e) {
122                 tee = (TimeoutExpiredException) e;
123             }
124             assertNotNull("Components shouldn't be accessed", tee);
125
126             rmo.rbPreviousCommits().push();
127             rmo.setStartRevision("1");
128             rmo.setEndRevision("2");
129
130             tee = null;
131             try {
132                 rmo.setRevision("3");
133             } catch (Exception JavaDoc e) {
134                 tee = (TimeoutExpiredException) e;
135             }
136             assertNotNull("Components shouldn't be accessed", tee);
137
138             rmo.rbSingleCommit().push();
139             rmo.setRevision("3");
140
141             tee = null;
142             try {
143                 rmo.setStartRevision("1");
144             } catch (Exception JavaDoc e) {
145                 tee = (TimeoutExpiredException) e;
146             }
147             assertNotNull("Components shouldn't be accessed", tee);
148
149             tee = null;
150             try {
151                 rmo.setEndRevision("2");
152             } catch (Exception JavaDoc e) {
153                 tee = (TimeoutExpiredException) e;
154             }
155             assertNotNull("Components shouldn't be accessed", tee);
156
157             rmo.cancel();
158         } catch (Exception JavaDoc e) {
159             throw new Exception JavaDoc("Test failed: " + e);
160         } finally {
161             TestKit.closeProject(PROJECT_NAME);
162         }
163         
164     }
165 }
166
Popular Tags