KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * MergeUiTest.java
3  *
4  * Created on 16 May 2006, 16:05
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.MergeOneRepoOperator;
23 import org.netbeans.test.subversion.operators.MergeOperator;
24 import org.netbeans.test.subversion.operators.MergeOriginOperator;
25 import org.netbeans.test.subversion.operators.MergeTwoRepoOperator;
26 import org.netbeans.test.subversion.operators.RepositoryBrowserImpOperator;
27 import org.netbeans.test.subversion.operators.RepositoryBrowserOperator;
28 import org.netbeans.test.subversion.operators.RepositoryStepOperator;
29 import org.netbeans.test.subversion.utils.RepositoryMaintenance;
30 import org.netbeans.test.subversion.utils.TestKit;
31
32 /**
33  *
34  * @author peter
35  */

36 public class MergeUiTest extends JellyTestCase {
37     
38     public static final String JavaDoc TMP_PATH = "/tmp";
39     public static final String JavaDoc REPO_PATH = "repo";
40     public static final String JavaDoc WORK_PATH = "work";
41     public static final String JavaDoc PROJECT_NAME = "SVNApplication";
42     public File JavaDoc projectPath;
43     
44     String JavaDoc os_name;
45     /** Creates a new instance of MergeUiTest */
46     public MergeUiTest(String JavaDoc name) {
47         super(name);
48     }
49     
50     protected void setUp() throws Exception JavaDoc {
51         os_name = System.getProperty("os.name");
52         //System.out.println(os_name);
53
System.out.println("### "+getName()+" ###");
54         
55     }
56     
57     protected boolean isUnix() {
58         boolean unix = false;
59         if (os_name.indexOf("Windows") == -1) {
60             unix = true;
61         }
62         return unix;
63     }
64     
65     public static void main(String JavaDoc[] args) {
66         // TODO code application logic here
67
TestRunner.run(suite());
68     }
69     
70     public static NbTestSuite suite() {
71         NbTestSuite suite = new NbTestSuite();
72         suite.addTest(new MergeUiTest("testInvokeCloseMerge"));
73         return suite;
74     }
75     
76     public void testInvokeCloseMerge() throws Exception JavaDoc {
77         //JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 3000);
78
//JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", 3000);
79
try {
80             TestKit.closeProject(PROJECT_NAME);
81
82             new File JavaDoc(TMP_PATH).mkdirs();
83             RepositoryMaintenance.deleteFolder(new File JavaDoc(TMP_PATH + File.separator + REPO_PATH));
84             RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH);
85             RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump");
86             projectPath = TestKit.prepareProject("General", "Java Application", PROJECT_NAME);
87
88             ImportWizardOperator iwo = ImportWizardOperator.invoke(ProjectsTabOperator.invoke().getProjectRootNode(PROJECT_NAME));
89             RepositoryStepOperator rso = new RepositoryStepOperator();
90             //rso.verify();
91
rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false));
92             rso.next();
93             Thread.sleep(1000);
94
95             FolderToImportStepOperator ftiso = new FolderToImportStepOperator();
96             ftiso.setRepositoryFolder("trunk/" + PROJECT_NAME);
97             ftiso.setImportMessage("initial import");
98             ftiso.next();
99             Thread.sleep(1000);
100             CommitStepOperator cso = new CommitStepOperator();
101             cso.finish();
102
103             Node projNode = new Node(new ProjectsTabOperator().tree(), PROJECT_NAME);
104             //Node projNode = new Node(new ProjectsTabOperator().tree(), "AnagramGame");
105
MergeOperator mo = MergeOperator.invoke(projNode);
106
107             //0. one repository operator
108
mo.cboMergeFrom().selectItem(0);
109             MergeOneRepoOperator moro = new MergeOneRepoOperator();
110             moro.verify();
111             RepositoryBrowserOperator rbo = moro.browseRepository();
112             //moro.selectRepositoryFolder("ok");
113
rbo.selectFolder("trunk");
114             rbo.selectFolder("branches");
115             rbo.selectFolder("tags");
116             rbo.ok();
117             assertEquals("Wrong folder selection!!!", "tags", moro.getRepositoryFolder());
118
119             //1. two repository operator
120
moro.cboMergeFrom().selectItem(1);
121             MergeTwoRepoOperator mtro = new MergeTwoRepoOperator();
122             mtro.verify();
123             rbo = mtro.browseRepositoryFolder1();
124             rbo.selectFolder("trunk");
125             rbo.selectFolder("branches");
126             rbo.selectFolder("tags");
127             rbo.ok();
128             assertEquals("Wrong folder selection!!!", "tags", mtro.getRepositoryFolder1());
129             rbo = mtro.browseRepositoryFolder2();
130             rbo.selectFolder("tags");
131             rbo.selectFolder("branches");
132             rbo.selectFolder("trunk");
133             rbo.ok();
134             assertEquals("Wrong folder selection!!!", "trunk", mtro.getRepositoryFolder2());
135
136             //2. two repository operator
137
moro.cboMergeFrom().selectItem(2);
138             MergeOriginOperator moo = new MergeOriginOperator();
139             moo.verify();
140             rbo = moo.browseRepositoryFolder();
141             rbo.selectFolder("trunk");
142             rbo.selectFolder("branches");
143             rbo.selectFolder("tags");
144             rbo.ok();
145             assertEquals("Wrong folder selection!!!", "tags", moo.getRepositoryFolder());
146             moo.cancel();
147         } catch (Exception JavaDoc e) {
148             throw new Exception JavaDoc("Test failed: " + e);
149         } finally {
150             TestKit.closeProject(PROJECT_NAME);
151         }
152     }
153 }
154
Popular Tags