KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > subversion > main > checkout > CheckoutContentTest


1 /*
2  * CheckoutContentTest.java
3  *
4  * Created on 26 May 2006, 20: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.checkout;
11
12 import java.io.File JavaDoc;
13 import junit.textui.TestRunner;
14 import org.netbeans.jellytools.JellyTestCase;
15 import org.netbeans.jellytools.NbDialogOperator;
16 import org.netbeans.jellytools.OutputOperator;
17 import org.netbeans.jellytools.OutputTabOperator;
18 import org.netbeans.jellytools.ProjectsTabOperator;
19 import org.netbeans.jellytools.nodes.Node;
20 import org.netbeans.jemmy.JemmyProperties;
21 import org.netbeans.jemmy.QueueTool;
22 import org.netbeans.jemmy.operators.JButtonOperator;
23 import org.netbeans.jemmy.operators.Operator;
24 import org.netbeans.jemmy.operators.Operator.DefaultStringComparator;
25 import org.netbeans.junit.NbTestSuite;
26 import org.netbeans.junit.ide.ProjectSupport;
27 import org.netbeans.test.subversion.operators.CheckoutWizardOperator;
28 import org.netbeans.test.subversion.operators.RepositoryStepOperator;
29 import org.netbeans.test.subversion.operators.WorkDirStepOperator;
30 import org.netbeans.test.subversion.utils.RepositoryMaintenance;
31 import org.netbeans.test.subversion.utils.TestKit;
32
33 /**
34  *
35  * @author peter
36  */

37 public class CheckoutContentTest extends JellyTestCase {
38     
39     public static final String JavaDoc TMP_PATH = "/tmp";
40     public static final String JavaDoc REPO_PATH = "repo";
41     public static final String JavaDoc WORK_PATH = "work";
42     public static final String JavaDoc PROJECT_NAME = "JavaApp";
43     public File JavaDoc projectPath;
44     String JavaDoc os_name;
45     Operator.DefaultStringComparator comOperator;
46     Operator.DefaultStringComparator oldOperator;
47     
48     /**
49      * Creates a new instance of CheckoutContentTest
50      */

51     public CheckoutContentTest(String JavaDoc name) {
52         super(name);
53     }
54     
55     protected void setUp() throws Exception JavaDoc {
56         os_name = System.getProperty("os.name");
57         //System.out.println(os_name);
58
System.out.println("### "+getName()+" ###");
59         
60     }
61     
62     protected boolean isUnix() {
63         boolean unix = false;
64         if (os_name.indexOf("Windows") == -1) {
65             unix = true;
66         }
67         return unix;
68     }
69     
70     public static void main(String JavaDoc[] args) {
71         // TODO code application logic here
72
TestRunner.run(suite());
73     }
74     
75     public static NbTestSuite suite() {
76         NbTestSuite suite = new NbTestSuite();
77         suite.addTest(new CheckoutContentTest("testCheckoutProject"));
78         suite.addTest(new CheckoutContentTest("testCheckoutContent"));
79         return suite;
80     }
81     
82     public void testCheckoutProject() throws Exception JavaDoc {
83         //JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 30000);
84
//JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", 30000);
85
try {
86             TestKit.closeProject(PROJECT_NAME);
87             OutputTabOperator oto;
88             OutputOperator oo = OutputOperator.invoke();
89             
90             comOperator = new Operator.DefaultStringComparator(true, true);
91             oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator();
92             Operator.setDefaultStringComparator(comOperator);
93             CheckoutWizardOperator co = CheckoutWizardOperator.invoke();
94             Operator.setDefaultStringComparator(oldOperator);
95             RepositoryStepOperator rso = new RepositoryStepOperator();
96             
97             //create repository...
98
File JavaDoc work = new File JavaDoc(TMP_PATH + File.separator + WORK_PATH + File.separator + "w" + System.currentTimeMillis());
99             new File JavaDoc(TMP_PATH).mkdirs();
100             work.mkdirs();
101             RepositoryMaintenance.deleteFolder(new File JavaDoc(TMP_PATH + File.separator + REPO_PATH));
102             //RepositoryMaintenance.deleteFolder(new File(TMP_PATH + File.separator + WORK_PATH));
103
RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH);
104             RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump");
105             rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false));
106             
107             rso.next();
108             oto = new OutputTabOperator("file:///tmp/repo");
109             oto.clear();
110             WorkDirStepOperator wdso = new WorkDirStepOperator();
111             wdso.setRepositoryFolder("trunk/" + PROJECT_NAME);
112             wdso.setLocalFolder(work.getCanonicalPath());
113             wdso.checkCheckoutContentOnly(false);
114             wdso.finish();
115             //open project
116
oto.waitText("Checking out... finished.");
117             NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed");
118             JButtonOperator open = new JButtonOperator(nbdialog, "Open Project");
119             open.push();
120             
121             ProjectSupport.waitScanFinished();
122             new QueueTool().waitEmpty(1000);
123             ProjectSupport.waitScanFinished();
124             
125             Node projNode = new Node(new ProjectsTabOperator().tree(), PROJECT_NAME);
126             
127         } catch (Exception JavaDoc e) {
128             throw new Exception JavaDoc("Test failed: " + e);
129         } finally {
130             TestKit.closeProject(PROJECT_NAME);
131         }
132     }
133     
134     public void testCheckoutContent() throws Exception JavaDoc {
135         //JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 30000);
136
//JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", 30000);
137
try {
138             TestKit.closeProject(PROJECT_NAME);
139             
140             comOperator = new Operator.DefaultStringComparator(true, true);
141             oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator();
142             Operator.setDefaultStringComparator(comOperator);
143             CheckoutWizardOperator co = CheckoutWizardOperator.invoke();
144             Operator.setDefaultStringComparator(oldOperator);
145             RepositoryStepOperator rso = new RepositoryStepOperator();
146             
147             //create repository...
148
File JavaDoc work = new File JavaDoc(TMP_PATH + File.separator + WORK_PATH + File.separator + "w" + System.currentTimeMillis());
149             new File JavaDoc(TMP_PATH).mkdirs();
150             work.mkdirs();
151             RepositoryMaintenance.deleteFolder(new File JavaDoc(TMP_PATH + File.separator + REPO_PATH));
152             //RepositoryMaintenance.deleteFolder(new File(TMP_PATH + File.separator + WORK_PATH));
153
RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH);
154             RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump");
155             rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false));
156             
157             rso.next();
158             OutputTabOperator oto = new OutputTabOperator("file:///tmp/repo");
159             oto.clear();
160             WorkDirStepOperator wdso = new WorkDirStepOperator();
161             wdso.setRepositoryFolder("trunk/JavaApp/src");
162             wdso.checkCheckoutContentOnly(true);
163             wdso.setLocalFolder(work.getCanonicalPath());
164             wdso.finish();
165             //open project
166
oto.waitText("Checking out... finished.");
167             NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed");
168             JButtonOperator create = new JButtonOperator(nbdialog, "Create Project...");
169             JButtonOperator close = new JButtonOperator(nbdialog, "Close");
170             close.push();
171             
172         } catch (Exception JavaDoc e) {
173             throw new Exception JavaDoc("Test failed: " + e);
174         } finally {
175             TestKit.closeProject(PROJECT_NAME);
176         }
177     }
178 }
179
Popular Tags