KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * CreateProjectVersionedDirTest.java
3  *
4  * Created on Pondelok, 2006, september 25, 10:08
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.NewProjectNameLocationStepOperator;
17 import org.netbeans.jellytools.NewProjectWizardOperator;
18 import org.netbeans.jellytools.OutputOperator;
19 import org.netbeans.jellytools.OutputTabOperator;
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.JTextFieldOperator;
24 import org.netbeans.jemmy.operators.Operator;
25 import org.netbeans.jemmy.operators.Operator.DefaultStringComparator;
26 import org.netbeans.junit.NbTestSuite;
27 import org.netbeans.junit.ide.ProjectSupport;
28 import org.netbeans.test.subversion.operators.CheckoutWizardOperator;
29 import org.netbeans.test.subversion.operators.RepositoryStepOperator;
30 import org.netbeans.test.subversion.operators.WorkDirStepOperator;
31 import org.netbeans.test.subversion.utils.RepositoryMaintenance;
32 import org.netbeans.test.subversion.utils.TestKit;
33
34 /**
35  *
36  * @author pvcs
37  */

38 public class CreateProjectVersionedDirTest extends JellyTestCase {
39     
40     public static final String JavaDoc TMP_PATH = "/tmp";
41     public static final String JavaDoc REPO_PATH = "repo";
42     public static final String JavaDoc WORK_PATH = "work";
43     public static final String JavaDoc PROJECT_NAME = "JavaApp";
44     public File JavaDoc projectPath;
45     String JavaDoc os_name;
46     Operator.DefaultStringComparator comOperator;
47     Operator.DefaultStringComparator oldOperator;
48     
49     /** Creates a new instance of CreateProjectVersionedDirTest */
50     public CreateProjectVersionedDirTest(String JavaDoc name) {
51         super(name);
52     }
53     
54     protected void setUp() throws Exception JavaDoc {
55         os_name = System.getProperty("os.name");
56         //System.out.println(os_name);
57
System.out.println("### "+getName()+" ###");
58         
59     }
60     
61     protected boolean isUnix() {
62         boolean unix = false;
63         if (os_name.indexOf("Windows") == -1) {
64             unix = true;
65         }
66         return unix;
67     }
68     
69     public static void main(String JavaDoc[] args) {
70         // TODO code application logic here
71
TestRunner.run(suite());
72     }
73     
74     public static NbTestSuite suite() {
75         NbTestSuite suite = new NbTestSuite();
76         suite.addTest(new CreateProjectVersionedDirTest("testCreateNewProject"));
77         return suite;
78     }
79     
80     public void testCreateNewProject() throws Exception JavaDoc {
81         //JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 30000);
82
//JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", 30000);
83
try {
84             TestKit.closeProject(PROJECT_NAME);
85             OutputTabOperator oto;
86             OutputOperator oo = OutputOperator.invoke();
87             comOperator = new Operator.DefaultStringComparator(true, true);
88             oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator();
89             Operator.setDefaultStringComparator(comOperator);
90             CheckoutWizardOperator co = CheckoutWizardOperator.invoke();
91             Operator.setDefaultStringComparator(oldOperator);
92             RepositoryStepOperator rso = new RepositoryStepOperator();
93             
94             //create repository...
95
File JavaDoc work = new File JavaDoc(TMP_PATH + File.separator + WORK_PATH + File.separator + "w" + System.currentTimeMillis());
96             new File JavaDoc(TMP_PATH).mkdirs();
97             work.mkdirs();
98             RepositoryMaintenance.deleteFolder(new File JavaDoc(TMP_PATH + File.separator + REPO_PATH));
99             //RepositoryMaintenance.deleteFolder(new File(TMP_PATH + File.separator + WORK_PATH));
100
RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH);
101             RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump");
102             rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false));
103             
104             rso.next();
105             oto = new OutputTabOperator("file:///tmp/repo");
106             oto.clear();
107             WorkDirStepOperator wdso = new WorkDirStepOperator();
108             wdso.setRepositoryFolder("trunk/" + PROJECT_NAME);
109             wdso.setLocalFolder(work.getCanonicalPath());
110             wdso.checkCheckoutContentOnly(false);
111             wdso.finish();
112             //open project
113
oto.waitText("Checking out... finished.");
114             NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed");
115             JButtonOperator open = new JButtonOperator(nbdialog, "Open Project");
116             open.push();
117             
118             ProjectSupport.waitScanFinished();
119             new QueueTool().waitEmpty(1000);
120             ProjectSupport.waitScanFinished();
121             
122             NewProjectWizardOperator npwo = NewProjectWizardOperator.invoke();
123             npwo.selectCategory("General");
124             npwo.selectProject("Java Application");
125             npwo.next();
126             NewProjectNameLocationStepOperator npnlso = new NewProjectNameLocationStepOperator();
127             new JTextFieldOperator(npnlso, 1).setText(work.getAbsolutePath() + File.separator + PROJECT_NAME + File.separator+ "src"); // NOI18N
128
new JTextFieldOperator(npnlso, 0).setText(PROJECT_NAME); // NOI18N
129
//new JTextFieldOperator(npnlso, 2).setText(folder); // NOI18N
130
new NewProjectWizardOperator().finish();
131             // wait classpath scanning finished
132
ProjectSupport.waitScanFinished();
133             
134         } catch (Exception JavaDoc e) {
135             throw new Exception JavaDoc("Test failed: " + e);
136         } finally {
137             TestKit.closeProject(PROJECT_NAME);
138         }
139     }
140 }
141
Popular Tags