KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * SearchHistoryUITest.java
3  *
4  * Created on 14 June 2006, 15:29
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 org.netbeans.jellytools.JellyTestCase;
15 import org.netbeans.jellytools.NbDialogOperator;
16 import org.netbeans.jellytools.OutputTabOperator;
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.JButtonOperator;
21 import org.netbeans.junit.NbTestSuite;
22 import org.netbeans.test.subversion.operators.CheckoutWizardOperator;
23 import org.netbeans.test.subversion.operators.RepositoryBrowserOperator;
24 import org.netbeans.test.subversion.operators.RepositoryBrowserSearchHistoryOperator;
25 import org.netbeans.test.subversion.operators.RepositoryStepOperator;
26 import org.netbeans.test.subversion.operators.SearchHistoryOperator;
27 import org.netbeans.test.subversion.operators.VersioningOperator;
28 import org.netbeans.test.subversion.operators.WorkDirStepOperator;
29 import org.netbeans.test.subversion.utils.RepositoryMaintenance;
30 import org.netbeans.test.subversion.utils.TestKit;
31 import org.netbeans.junit.ide.ProjectSupport;
32 import junit.textui.TestRunner;
33 import org.netbeans.jellytools.EditorOperator;
34 import org.netbeans.jemmy.QueueTool;
35 import org.netbeans.jemmy.operators.Operator;
36 import org.netbeans.jemmy.operators.Operator.DefaultStringComparator;
37 import org.netbeans.test.subversion.operators.RepositoryBrowserOperator;
38
39 /**
40  *
41  * @author peter
42  */

43 public class SearchHistoryUITest extends JellyTestCase{
44     
45     public static final String JavaDoc TMP_PATH = "/tmp";
46     public static final String JavaDoc REPO_PATH = "repo";
47     public static final String JavaDoc WORK_PATH = "work";
48     public static final String JavaDoc PROJECT_NAME = "JavaApp";
49     public File JavaDoc projectPath;
50     public PrintStream JavaDoc stream;
51     String JavaDoc os_name;
52     Operator.DefaultStringComparator comOperator;
53     Operator.DefaultStringComparator oldOperator;
54     
55     /** Creates a new instance of SearchHistoryUITest */
56     public SearchHistoryUITest(String JavaDoc name) {
57         super(name);
58     }
59     
60     protected void setUp() throws Exception JavaDoc {
61         os_name = System.getProperty("os.name");
62         //System.out.println(os_name);
63
System.out.println("### "+getName()+" ###");
64         
65     }
66     
67     protected boolean isUnix() {
68         boolean unix = false;
69         if (os_name.indexOf("Windows") == -1) {
70             unix = true;
71         }
72         return unix;
73     }
74     
75     public static void main(String JavaDoc[] args) {
76         // TODO code application logic here
77
TestRunner.run(suite());
78     }
79     
80     public static NbTestSuite suite() {
81         NbTestSuite suite = new NbTestSuite();
82         suite.addTest(new SearchHistoryUITest("testInvokeSearch"));
83         return suite;
84     }
85     
86     public void testInvokeSearch() throws Exception JavaDoc {
87         //JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 30000);
88
//JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", 30000);
89
try {
90             TestKit.closeProject(PROJECT_NAME);
91         
92             stream = new PrintStream JavaDoc(new File JavaDoc(getWorkDir(), getName() + ".log"));
93             comOperator = new Operator.DefaultStringComparator(true, true);
94             oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator();
95             Operator.setDefaultStringComparator(comOperator);
96             CheckoutWizardOperator co = CheckoutWizardOperator.invoke();
97             Operator.setDefaultStringComparator(oldOperator);
98             RepositoryStepOperator rso = new RepositoryStepOperator();
99
100             //create repository...
101
File JavaDoc work = new File JavaDoc(TMP_PATH + File.separator + WORK_PATH + File.separator + "w" + System.currentTimeMillis());
102             new File JavaDoc(TMP_PATH).mkdirs();
103             work.mkdirs();
104             RepositoryMaintenance.deleteFolder(new File JavaDoc(TMP_PATH + File.separator + REPO_PATH));
105             //RepositoryMaintenance.deleteFolder(new File(TMP_PATH + File.separator + WORK_PATH));
106
RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH);
107             RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump");
108             rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false));
109
110             rso.next();
111             WorkDirStepOperator wdso = new WorkDirStepOperator();
112             wdso.setRepositoryFolder("trunk/" + PROJECT_NAME);
113             wdso.setLocalFolder(work.getCanonicalPath());
114             wdso.checkCheckoutContentOnly(false);
115             OutputTabOperator oto = new OutputTabOperator("file:///tmp/repo");
116             oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000);
117             oto.clear();
118             wdso.finish();
119             //open project
120
oto.waitText("Checking out... finished.");
121             NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed");
122             JButtonOperator open = new JButtonOperator(nbdialog, "Open Project");
123             open.push();
124
125             ProjectSupport.waitScanFinished();
126             new QueueTool().waitEmpty(1000);
127             ProjectSupport.waitScanFinished();
128
129             oto = new OutputTabOperator("file:///tmp/repo");
130             oto.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 30000);
131             oto.clear();
132             Node node = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp|Main.java");
133             SearchHistoryOperator sho = SearchHistoryOperator.invoke(node);
134
135             oto.waitText("Searching History... finished.");
136             oto = new OutputTabOperator("file:///tmp/repo");
137             oto.clear();
138             sho.verify();
139             RepositoryBrowserOperator rbo = sho.getRevisionFrom();
140             oto.waitText("Loading... finished.");
141             rbo.verify();
142             rbo.cancel();
143
144             oto = new OutputTabOperator("file:///tmp/repo");
145             oto.clear();
146             rbo = sho.getRevisionTo();
147             oto.waitText("Loading... finished.");
148             rbo.verify();
149             rbo.cancel();
150
151             sho.setUsername("test");
152             sho.setFrom("1");
153             sho.setTo("2");
154
155             stream.flush();
156             stream.close();
157         } catch (Exception JavaDoc e) {
158             throw new Exception JavaDoc("Test failed: " + e);
159         } finally {
160             TestKit.closeProject(PROJECT_NAME);
161         }
162     }
163 }
164
Popular Tags