KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > subversion > main > archeology > AnnotationsTest


1 /*
2  * AnnotationsTest.java
3  *
4  * Created on June 30, 2006, 2:05 PM
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.archeology;
11
12 import java.io.File JavaDoc;
13 import java.io.PrintStream JavaDoc;
14 import junit.textui.TestRunner;
15 import org.netbeans.jellytools.JellyTestCase;
16 import org.netbeans.jellytools.NbDialogOperator;
17 import org.netbeans.jellytools.OutputTabOperator;
18 import org.netbeans.jellytools.nodes.Node;
19 import org.netbeans.jellytools.nodes.SourcePackagesNode;
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.test.subversion.operators.CheckoutWizardOperator;
27 import org.netbeans.test.subversion.operators.RepositoryStepOperator;
28 import org.netbeans.test.subversion.operators.VersioningOperator;
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 import org.netbeans.junit.ide.ProjectSupport;
33
34 /**
35  *
36  * @author pvcs
37  */

38 public class AnnotationsTest 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     public PrintStream JavaDoc stream;
46     String JavaDoc os_name;
47     Operator.DefaultStringComparator comOperator;
48     Operator.DefaultStringComparator oldOperator;
49     
50     /** Creates a new instance of AnnotationsTest */
51     public AnnotationsTest(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 AnnotationsTest("testShowAnnotations"));
78         return suite;
79     }
80     
81     public void testShowAnnotations() throws Exception JavaDoc {
82         //JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 30000);
83
//JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", 30000);
84
try {
85             TestKit.closeProject(PROJECT_NAME);
86
87             stream = new PrintStream JavaDoc(new File JavaDoc(getWorkDir(), getName() + ".log"));
88             comOperator = new Operator.DefaultStringComparator(true, true);
89             oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator();
90             Operator.setDefaultStringComparator(comOperator);
91             CheckoutWizardOperator co = CheckoutWizardOperator.invoke();
92             Operator.setDefaultStringComparator(oldOperator);
93             RepositoryStepOperator rso = new RepositoryStepOperator();
94
95             //create repository...
96
File JavaDoc work = new File JavaDoc(TMP_PATH + File.separator + WORK_PATH + File.separator + "w" + System.currentTimeMillis());
97             new File JavaDoc(TMP_PATH).mkdirs();
98             work.mkdirs();
99             RepositoryMaintenance.deleteFolder(new File JavaDoc(TMP_PATH + File.separator + REPO_PATH));
100             //RepositoryMaintenance.deleteFolder(new File(TMP_PATH + File.separator + WORK_PATH));
101
RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH);
102             RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump");
103             rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false));
104
105             rso.next();
106             WorkDirStepOperator wdso = new WorkDirStepOperator();
107             wdso.setRepositoryFolder("trunk/" + PROJECT_NAME);
108             wdso.setLocalFolder(work.getCanonicalPath());
109             wdso.checkCheckoutContentOnly(false);
110             OutputTabOperator oto = new OutputTabOperator("file:///tmp/repo");
111             oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000);
112             oto.clear();
113             wdso.finish();
114             //open project
115
oto.waitText("Checking out... finished.");
116             NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed");
117             JButtonOperator open = new JButtonOperator(nbdialog, "Open Project");
118             open.push();
119
120             ProjectSupport.waitScanFinished();
121             new QueueTool().waitEmpty(1000);
122             ProjectSupport.waitScanFinished();
123
124             oto = new OutputTabOperator("file:///tmp/repo");
125             oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000);
126             oto.clear();
127             Node node = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp|Main.java");
128             node.performPopupAction("Subversion|Show Annotations");
129             oto.waitText("Annotating... finished.");
130
131             stream.flush();
132             stream.close();
133         } catch (Exception JavaDoc e) {
134             throw new Exception JavaDoc("Test failed: " + e);
135         } finally {
136             TestKit.closeProject(PROJECT_NAME);
137         }
138     }
139 }
140
Popular Tags