KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > subversion > main > commit > CommitUiTest


1 /*
2  * CommitUiTest.java
3  *
4  * Created on 15 May 2006, 16:58
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.commit;
11
12 import java.io.File JavaDoc;
13 import javax.swing.table.TableModel JavaDoc;
14 import junit.textui.TestRunner;
15 import org.netbeans.jellytools.JellyTestCase;
16 import org.netbeans.jellytools.ProjectsTabOperator;
17 import org.netbeans.jellytools.nodes.Node;
18 import org.netbeans.jellytools.nodes.SourcePackagesNode;
19 import org.netbeans.jemmy.JemmyProperties;
20 import org.netbeans.jemmy.operators.JTableOperator;
21 import org.netbeans.junit.NbTestSuite;
22 import org.netbeans.test.subversion.operators.CommitOperator;
23 import org.netbeans.test.subversion.operators.CommitStepOperator;
24 import org.netbeans.test.subversion.operators.FolderToImportStepOperator;
25 import org.netbeans.test.subversion.operators.ImportWizardOperator;
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 CommitUiTest 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 CheckoutUITest */
45     public CommitUiTest(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 CommitUiTest("testInvokeCloseCommit"));
72         return suite;
73     }
74     
75     public void testInvokeCloseCommit() 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             TestKit.createNewElements(PROJECT_NAME, "xx", "NewClass");
103             TestKit.createNewElement(PROJECT_NAME, "xx", "NewClass2");
104             TestKit.createNewElement(PROJECT_NAME, "xx", "NewClass3");
105             Node packNode = new Node(new SourcePackagesNode(PROJECT_NAME), "xx");
106             CommitOperator co = CommitOperator.invoke(packNode);
107             
108             co.selectCommitAction("NewClass.java", "Add As Text");
109             co.selectCommitAction("NewClass.java", "Add As Binary");
110             co.selectCommitAction("NewClass.java", "Exclude from Commit");
111             co.selectCommitAction(2, "Add As Text");
112             co.selectCommitAction(2, "Add As Binary");
113             co.selectCommitAction(2, "Exclude from Commit");
114             
115             JTableOperator table = co.tabFiles();
116             TableModel JavaDoc model = table.getModel();
117             String JavaDoc[] expected = {"xx", "NewClass.java", "NewClass2.java", "NewClass3.java"};
118             String JavaDoc[] actual = new String JavaDoc[model.getRowCount()];
119             for (int i = 0; i < model.getRowCount(); i++) {
120                 actual[i] = model.getValueAt(i, 0).toString();
121             }
122             int result = TestKit.compareThem(expected, actual, false);
123             assertEquals("Commit table doesn't contain all files!!!", expected.length, result);
124             
125             co.verify();
126             co.cancel();
127             //TestKit.removeAllData(PROJECT_NAME);
128

129         } catch (Exception JavaDoc e) {
130             throw new Exception JavaDoc("Test failed: " + e);
131         } finally {
132             TestKit.closeProject(PROJECT_NAME);
133         }
134     }
135 }
136
Popular Tags