KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * SearchRevisionsTest.java
3  *
4  * Created on July 3, 2006, 10:39 AM
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.OutputTabOperator;
17 import org.netbeans.jemmy.JemmyProperties;
18 import org.netbeans.jemmy.operators.Operator;
19 import org.netbeans.jemmy.operators.Operator.DefaultStringComparator;
20 import org.netbeans.junit.NbTestSuite;
21 import org.netbeans.test.subversion.operators.CheckoutWizardOperator;
22 import org.netbeans.test.subversion.operators.RepositoryStepOperator;
23 import org.netbeans.test.subversion.operators.SearchRevisionsOperator;
24 import org.netbeans.test.subversion.operators.VersioningOperator;
25 import org.netbeans.test.subversion.operators.WorkDirStepOperator;
26 import org.netbeans.test.subversion.utils.RepositoryMaintenance;
27 import org.netbeans.test.subversion.utils.TestKit;
28
29 /**
30  *
31  * @author pvcs
32  */

33 public class SearchRevisionsTest extends JellyTestCase {
34     
35     public static final String JavaDoc TMP_PATH = "/tmp";
36     public static final String JavaDoc REPO_PATH = "repo";
37     public static final String JavaDoc WORK_PATH = "work";
38     public static final String JavaDoc PROJECT_NAME = "JavaApp";
39     public File JavaDoc projectPath;
40     public PrintStream JavaDoc stream;
41     String JavaDoc os_name;
42     Operator.DefaultStringComparator comOperator;
43     Operator.DefaultStringComparator oldOperator;
44     
45     /** Creates a new instance of SearchRevisionsTest */
46     public SearchRevisionsTest(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 SearchRevisionsTest("testSearchRevisionsTest"));
73         return suite;
74     }
75     
76     public void testSearchRevisionsTest() throws Exception JavaDoc {
77         //JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 30000);
78
//JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", 30000);
79
try {
80             TestKit.closeProject(PROJECT_NAME);
81
82             stream = new PrintStream JavaDoc(new File JavaDoc(getWorkDir(), getName() + ".log"));
83             comOperator = new Operator.DefaultStringComparator(true, true);
84             oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator();
85             Operator.setDefaultStringComparator(comOperator);
86             CheckoutWizardOperator co = CheckoutWizardOperator.invoke();
87             Operator.setDefaultStringComparator(oldOperator);
88             RepositoryStepOperator rso = new RepositoryStepOperator();
89
90             //create repository...
91
File JavaDoc work = new File JavaDoc(TMP_PATH + File.separator + WORK_PATH + File.separator + "w" + System.currentTimeMillis());
92             new File JavaDoc(TMP_PATH).mkdirs();
93             work.mkdirs();
94             RepositoryMaintenance.deleteFolder(new File JavaDoc(TMP_PATH + File.separator + REPO_PATH));
95             //RepositoryMaintenance.deleteFolder(new File(TMP_PATH + File.separator + WORK_PATH));
96
RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH);
97             RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump");
98             rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false));
99
100             rso.next();
101
102             WorkDirStepOperator wdso = new WorkDirStepOperator();
103             wdso.setRepositoryFolder("trunk/" + PROJECT_NAME);
104             wdso.setLocalFolder(work.getCanonicalPath());
105             wdso.checkCheckoutContentOnly(false);
106
107             OutputTabOperator oto = new OutputTabOperator("file:///tmp/repo");
108             oto.clear();
109             SearchRevisionsOperator sro = wdso.search();
110             sro.setFrom("");
111             sro.list();
112             oto.waitText("Searching revisions finished.");
113             sro.verify();
114             sro.selectListItem(0);
115             sro.ok();
116             assertEquals("Requested repository revision is not propagated!!!", "5", wdso.getRevisionNumber());
117             wdso.cancel();
118
119             stream.flush();
120             stream.close();
121         } catch (Exception JavaDoc e) {
122             throw new Exception JavaDoc("Test failed: " + e);
123         } finally {
124             TestKit.closeProject(PROJECT_NAME);
125         }
126     }
127 }
128
Popular Tags