KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > subversion > main > commit > IgnoreTest


1 /*
2  * IgnoreTest.java
3  *
4  * Created on June 8, 2006, 9:36 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.commit;
11
12 import java.io.File JavaDoc;
13 import java.io.PrintStream JavaDoc;
14 import javax.swing.table.TableModel JavaDoc;
15 import junit.textui.TestRunner;
16 import org.netbeans.jellytools.JellyTestCase;
17 import org.netbeans.jellytools.NbDialogOperator;
18 import org.netbeans.jellytools.OutputOperator;
19 import org.netbeans.jellytools.OutputTabOperator;
20 import org.netbeans.jellytools.nodes.Node;
21 import org.netbeans.jellytools.nodes.SourcePackagesNode;
22 import org.netbeans.jemmy.JemmyProperties;
23 import org.netbeans.jemmy.QueueTool;
24 import org.netbeans.jemmy.TimeoutExpiredException;
25 import org.netbeans.jemmy.operators.JButtonOperator;
26 import org.netbeans.jemmy.operators.Operator;
27 import org.netbeans.jemmy.operators.Operator.DefaultStringComparator;
28 import org.netbeans.junit.NbTestSuite;
29 import org.netbeans.junit.ide.ProjectSupport;
30 import org.netbeans.test.subversion.operators.CheckoutWizardOperator;
31 import org.netbeans.test.subversion.operators.RepositoryStepOperator;
32 import org.netbeans.test.subversion.operators.VersioningOperator;
33 import org.netbeans.test.subversion.operators.WorkDirStepOperator;
34 import org.netbeans.test.subversion.utils.RepositoryMaintenance;
35 import org.netbeans.test.subversion.utils.TestKit;
36
37 /**
38  *
39  * @author peter pis
40  */

41 public class IgnoreTest extends JellyTestCase {
42     
43     public static final String JavaDoc TMP_PATH = "/tmp";
44     public static final String JavaDoc REPO_PATH = "repo";
45     public static final String JavaDoc WORK_PATH = "work";
46     public static final String JavaDoc PROJECT_NAME = "JavaApp";
47     public File JavaDoc projectPath;
48     public PrintStream JavaDoc stream;
49     String JavaDoc os_name;
50     Operator.DefaultStringComparator comOperator;
51     Operator.DefaultStringComparator oldOperator;
52     
53     /** Creates a new instance of IgnoreTest */
54     public IgnoreTest(String JavaDoc name) {
55         super(name);
56     }
57     
58     protected void setUp() throws Exception JavaDoc {
59         os_name = System.getProperty("os.name");
60         //System.out.println(os_name);
61
System.out.println("### "+getName()+" ###");
62         
63     }
64     
65     protected boolean isUnix() {
66         boolean unix = false;
67         if (os_name.indexOf("Windows") == -1) {
68             unix = true;
69         }
70         return unix;
71     }
72     
73     public static void main(String JavaDoc[] args) {
74         // TODO code application logic here
75
TestRunner.run(suite());
76     }
77     
78     public static NbTestSuite suite() {
79         NbTestSuite suite = new NbTestSuite();
80         suite.addTest(new IgnoreTest("testIgnoreUnignoreFile"));
81         suite.addTest(new IgnoreTest("testIgnoreUnignorePackage"));
82         suite.addTest(new IgnoreTest("testIgnoreUnignoreFilePackage"));
83         suite.addTest(new IgnoreTest("testFinalRemove"));
84         return suite;
85     }
86     
87     public void testIgnoreUnignoreFile() throws Exception JavaDoc {
88         //JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 30000);
89
//JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", 30000);
90
try {
91             TestKit.closeProject(PROJECT_NAME);
92             
93             VersioningOperator vo = VersioningOperator.invoke();
94             OutputOperator oo = OutputOperator.invoke();
95             
96             stream = new PrintStream JavaDoc(new File JavaDoc(getWorkDir(), getName() + ".log"));
97             comOperator = new Operator.DefaultStringComparator(true, true);
98             oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator();
99             Operator.setDefaultStringComparator(comOperator);
100             CheckoutWizardOperator co = CheckoutWizardOperator.invoke();
101             Operator.setDefaultStringComparator(oldOperator);
102             RepositoryStepOperator rso = new RepositoryStepOperator();
103             
104             //create repository...
105
File JavaDoc work = new File JavaDoc(TMP_PATH + File.separator + WORK_PATH + File.separator + "w" + System.currentTimeMillis());
106             new File JavaDoc(TMP_PATH).mkdirs();
107             work.mkdirs();
108             RepositoryMaintenance.deleteFolder(new File JavaDoc(TMP_PATH + File.separator + REPO_PATH));
109             //RepositoryMaintenance.deleteFolder(new File(TMP_PATH + File.separator + WORK_PATH));
110
RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH);
111             RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump");
112             rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false));
113             
114             rso.next();
115             OutputTabOperator oto = new OutputTabOperator("file:///tmp/repo");
116             oto.clear();
117             WorkDirStepOperator wdso = new WorkDirStepOperator();
118             wdso.setRepositoryFolder("trunk/" + PROJECT_NAME);
119             wdso.setLocalFolder(work.getCanonicalPath());
120             wdso.checkCheckoutContentOnly(false);
121             wdso.finish();
122             //open project
123
oto.waitText("Checking out... finished.");
124             NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed");
125             JButtonOperator open = new JButtonOperator(nbdialog, "Open Project");
126             open.push();
127             
128             ProjectSupport.waitScanFinished();
129             new QueueTool().waitEmpty(1000);
130             ProjectSupport.waitScanFinished();
131             
132             oto = new OutputTabOperator("file:///tmp/repo");
133             oto.clear();
134             TestKit.createNewElement(PROJECT_NAME, "javaapp", "NewClass");
135             Node node = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp|NewClass");
136             node.performPopupAction("Subversion|Ignore");
137             oto.waitText("finished.");
138             
139             node = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp|NewClass");
140             org.openide.nodes.Node nodeIDE = (org.openide.nodes.Node) node.getOpenideNode();
141             String JavaDoc color = TestKit.getColor(nodeIDE.getHtmlDisplayName());
142             String JavaDoc status = TestKit.getStatus(nodeIDE.getHtmlDisplayName());
143             assertEquals("Wrong color of node - file color should be ignored!!!", TestKit.IGNORED_COLOR, color);
144             assertEquals("Wrong annotation of node - file status should be ignored!!!", TestKit.IGNORED_STATUS, status);
145             
146             node = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp|NewClass");
147             TimeoutExpiredException tee = null;
148             try {
149                 node.performPopupAction("Subversion|Ignore");
150             } catch (Exception JavaDoc e) {
151                 tee = (TimeoutExpiredException) e;
152             }
153             assertNotNull("Ingnore action should be disabled!!!", tee);
154             
155             //unignore file
156
oto = new OutputTabOperator("file:///tmp/repo");
157             oto.clear();
158             node = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp|NewClass");
159             node.performPopupAction("Subversion|Unignore");
160             oto.waitText("finished.");
161             node = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp|NewClass");
162             nodeIDE = (org.openide.nodes.Node) node.getOpenideNode();
163             color = TestKit.getColor(nodeIDE.getHtmlDisplayName());
164             status = TestKit.getStatus(nodeIDE.getHtmlDisplayName());
165             assertEquals("Wrong color of node - file color should be new!!!", TestKit.NEW_COLOR, color);
166             assertEquals("Wrong annotation of node - file status should be new!!!", TestKit.NEW_STATUS, status);
167             
168             //verify content of Versioning view
169
oto = new OutputTabOperator("file:///tmp/repo");
170             oto.clear();
171             node = new Node(new SourcePackagesNode(PROJECT_NAME), "javaapp|NewClass");
172             node.performPopupAction("Subversion|Show Changes");
173             oto.waitText("Refreshing... finished.");
174             Thread.sleep(1000);
175             vo = VersioningOperator.invoke();
176             TableModel JavaDoc model = vo.tabFiles().getModel();
177             assertEquals("Versioning view should be empty", 1, model.getRowCount());
178             assertEquals("File should be listed in Versioning view", "NewClass.java", model.getValueAt(0, 0).toString());
179             
180             stream.flush();
181             stream.close();
182             
183         } catch (Exception JavaDoc e) {
184             throw new Exception JavaDoc("Test failed: " + e);
185         } finally {
186             TestKit.closeProject(PROJECT_NAME);
187         }
188     }
189     
190     public void testIgnoreUnignorePackage() throws Exception JavaDoc {
191         //JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 30000);
192
//JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", 30000);
193
try {
194             TestKit.closeProject(PROJECT_NAME);
195             
196             VersioningOperator vo = VersioningOperator.invoke();
197             OutputOperator oo = OutputOperator.invoke();
198             
199             stream = new PrintStream JavaDoc(new File JavaDoc(getWorkDir(), getName() + ".log"));
200             comOperator = new Operator.DefaultStringComparator(true, true);
201             oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator();
202             Operator.setDefaultStringComparator(comOperator);
203             CheckoutWizardOperator co = CheckoutWizardOperator.invoke();
204             Operator.setDefaultStringComparator(oldOperator);
205             RepositoryStepOperator rso = new RepositoryStepOperator();
206             
207             //create repository...
208
File JavaDoc work = new File JavaDoc(TMP_PATH + File.separator + WORK_PATH + File.separator + "w" + System.currentTimeMillis());
209             new File JavaDoc(TMP_PATH).mkdirs();
210             work.mkdirs();
211             RepositoryMaintenance.deleteFolder(new File JavaDoc(TMP_PATH + File.separator + REPO_PATH));
212             //RepositoryMaintenance.deleteFolder(new File(TMP_PATH + File.separator + WORK_PATH));
213
RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH);
214             RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump");
215             rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false));
216             
217             rso.next();
218             OutputTabOperator oto = new OutputTabOperator("file:///tmp/repo");
219             oto.clear();
220             WorkDirStepOperator wdso = new WorkDirStepOperator();
221             wdso.setRepositoryFolder("trunk/" + PROJECT_NAME);
222             wdso.setLocalFolder(work.getCanonicalPath());
223             wdso.checkCheckoutContentOnly(false);
224             wdso.finish();
225             //open project
226
oto.waitText("Checking out... finished.");
227             NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed");
228             JButtonOperator open = new JButtonOperator(nbdialog, "Open Project");
229             open.push();
230             
231             ProjectSupport.waitScanFinished();
232             new QueueTool().waitEmpty(1000);
233             ProjectSupport.waitScanFinished();
234             
235             oto = new OutputTabOperator("file:///tmp/repo");
236             oto.clear();
237             TestKit.createNewPackage(PROJECT_NAME, "xx");
238             Node node = new Node(new SourcePackagesNode(PROJECT_NAME), "xx");
239             node.performPopupAction("Subversion|Ignore");
240             oto.waitText("finished.");
241             
242             node = new Node(new SourcePackagesNode(PROJECT_NAME), "xx");
243             org.openide.nodes.Node nodeIDE = (org.openide.nodes.Node) node.getOpenideNode();
244             //String color = TestKit.getColor(nodeIDE.getHtmlDisplayName());
245
String JavaDoc status = TestKit.getStatus(nodeIDE.getHtmlDisplayName());
246             //assertEquals("Wrong color of node - package color should be ignored!!!", TestKit.IGNORED_COLOR, color);
247
assertEquals("Wrong annotation of node - package status should be ignored!!!", TestKit.IGNORED_STATUS, status);
248             
249         /*verify content of Versioning view
250         oto = new OutputTabOperator("file:///tmp/repo");
251         oto.clear();
252         node = new Node(new SourcePackagesNode("JavaApp"), "javaapp|NewClass");
253         node.performPopupAction("Subversion|Show Changes");
254         oto.waitText("Refreshing... finished.");
255         Thread.sleep(1000);
256         vo = VersioningOperator.invoke();
257         TableModel model = vo.tabFiles().getModel();
258         assertEquals("Versioning view should be empty", 0, model.getRowCount());*/

259             
260             node = new Node(new SourcePackagesNode(PROJECT_NAME), "xx");
261             TimeoutExpiredException tee = null;
262             try {
263                 node.performPopupAction("Subversion|Ignore");
264             } catch (Exception JavaDoc e) {
265                 tee = (TimeoutExpiredException) e;
266             }
267             assertNotNull("Ingnore action should be disabled!!!", tee);
268             
269             //unignore file
270
oto = new OutputTabOperator("file:///tmp/repo");
271             oto.clear();
272             node = new Node(new SourcePackagesNode(PROJECT_NAME), "xx");
273             node.performPopupAction("Subversion|Unignore");
274             oto.waitText("finished.");
275             node = new Node(new SourcePackagesNode(PROJECT_NAME), "xx");
276             nodeIDE = (org.openide.nodes.Node) node.getOpenideNode();
277             //color = TestKit.getColor(nodeIDE.getHtmlDisplayName());
278
status = TestKit.getStatus(nodeIDE.getHtmlDisplayName());
279             //assertEquals("Wrong color of node - package color should be new!!!", TestKit.NEW_COLOR, color);
280
assertEquals("Wrong annotation of node - package status should be new!!!", TestKit.NEW_STATUS, status);
281             
282             //verify content of Versioning view
283
oto = new OutputTabOperator("file:///tmp/repo");
284             oto.clear();
285             node = new Node(new SourcePackagesNode(PROJECT_NAME), "xx");
286             node.performPopupAction("Subversion|Show Changes");
287             oto.waitText("Refreshing... finished.");
288             Thread.sleep(1000);
289             vo = VersioningOperator.invoke();
290             TableModel JavaDoc model = vo.tabFiles().getModel();
291             assertEquals("Versioning view should be empty", 1, model.getRowCount());
292             assertEquals("Package should be listed in Versioning view", "xx", model.getValueAt(0, 0).toString());
293             
294             stream.flush();
295             stream.close();
296             
297         } catch (Exception JavaDoc e) {
298             throw new Exception JavaDoc("Test failed: " + e);
299         } finally {
300             TestKit.closeProject(PROJECT_NAME);
301         }
302     }
303     
304     public void testIgnoreUnignoreFilePackage() throws Exception JavaDoc {
305         //JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 30000);
306
//JemmyProperties.setCurrentTimeout("DialogWaiter.WaitDialogTimeout", 30000);
307

308         try {
309             TestKit.closeProject(PROJECT_NAME);
310             
311             VersioningOperator vo = VersioningOperator.invoke();
312             OutputOperator oo = OutputOperator.invoke();
313             
314             stream = new PrintStream JavaDoc(new File JavaDoc(getWorkDir(), getName() + ".log"));
315             comOperator = new Operator.DefaultStringComparator(true, true);
316             oldOperator = (DefaultStringComparator) Operator.getDefaultStringComparator();
317             Operator.setDefaultStringComparator(comOperator);
318             CheckoutWizardOperator co = CheckoutWizardOperator.invoke();
319             Operator.setDefaultStringComparator(oldOperator);
320             RepositoryStepOperator rso = new RepositoryStepOperator();
321             
322             //create repository...
323
File JavaDoc work = new File JavaDoc(TMP_PATH + File.separator + WORK_PATH + File.separator + "w" + System.currentTimeMillis());
324             new File JavaDoc(TMP_PATH).mkdirs();
325             work.mkdirs();
326             RepositoryMaintenance.deleteFolder(new File JavaDoc(TMP_PATH + File.separator + REPO_PATH));
327             //RepositoryMaintenance.deleteFolder(new File(TMP_PATH + File.separator + WORK_PATH));
328
RepositoryMaintenance.createRepository(TMP_PATH + File.separator + REPO_PATH);
329             RepositoryMaintenance.loadRepositoryFromFile(TMP_PATH + File.separator + REPO_PATH, getDataDir().getCanonicalPath() + File.separator + "repo_dump");
330             rso.setRepositoryURL(RepositoryStepOperator.ITEM_FILE + RepositoryMaintenance.changeFileSeparator(TMP_PATH + File.separator + REPO_PATH, false));
331             
332             rso.next();
333             OutputTabOperator oto = new OutputTabOperator("file:///tmp/repo");
334             oto.clear();
335             WorkDirStepOperator wdso = new WorkDirStepOperator();
336             wdso.setRepositoryFolder("trunk/" + PROJECT_NAME);
337             wdso.setLocalFolder(work.getCanonicalPath());
338             wdso.checkCheckoutContentOnly(false);
339             wdso.finish();
340             //open project
341
oto.waitText("Checking out... finished.");
342             NbDialogOperator nbdialog = new NbDialogOperator("Checkout Completed");
343             JButtonOperator open = new JButtonOperator(nbdialog, "Open Project");
344             open.push();
345             
346             ProjectSupport.waitScanFinished();
347             new QueueTool().waitEmpty(1000);
348             ProjectSupport.waitScanFinished();
349             
350             oto = new OutputTabOperator("file:///tmp/repo");
351             oto.clear();
352             TestKit.createNewElements(PROJECT_NAME, "xx", "NewClass");
353             
354             Node node = new Node(new SourcePackagesNode(PROJECT_NAME), "xx");
355             Node node2 = new Node(new SourcePackagesNode(PROJECT_NAME), "xx|NewClass");
356             node.performPopupAction("Subversion|Ignore");
357             oto.waitText("finished.");
358             
359             node = new Node(new SourcePackagesNode(PROJECT_NAME), "xx");
360             node2 = new Node(new SourcePackagesNode(PROJECT_NAME), "xx|NewClass");
361             org.openide.nodes.Node nodeIDE = (org.openide.nodes.Node) node.getOpenideNode();
362             org.openide.nodes.Node nodeIDE2 = (org.openide.nodes.Node) node2.getOpenideNode();
363             //String color = TestKit.getColor(nodeIDE.getHtmlDisplayName());
364
String JavaDoc status = TestKit.getStatus(nodeIDE.getHtmlDisplayName());
365             String JavaDoc status2 = TestKit.getStatus(nodeIDE2.getHtmlDisplayName());
366             //assertEquals("Wrong color of node - package color should be ignored!!!", TestKit.IGNORED_COLOR, color);
367
assertEquals("Wrong annotation of node - package status should be ignored!!!", TestKit.IGNORED_STATUS, status);
368             assertEquals("Wrong annotation of file - package status should be ignored!!!", TestKit.IGNORED_STATUS, status2);
369             
370             //unignore file
371
oto = new OutputTabOperator("file:///tmp/repo");
372             oto.clear();
373             node = new Node(new SourcePackagesNode(PROJECT_NAME), "xx");
374             node.performPopupAction("Subversion|Unignore");
375             oto.waitText("finished.");
376             node = new Node(new SourcePackagesNode(PROJECT_NAME), "xx");
377             node2 = new Node(new SourcePackagesNode(PROJECT_NAME), "xx|NewClass");
378             nodeIDE = (org.openide.nodes.Node) node.getOpenideNode();
379             nodeIDE2 = (org.openide.nodes.Node) node2.getOpenideNode();
380             String JavaDoc color = TestKit.getColor(nodeIDE2.getHtmlDisplayName());
381             status = TestKit.getStatus(nodeIDE.getHtmlDisplayName());
382             status2 = TestKit.getStatus(nodeIDE.getHtmlDisplayName());
383             assertEquals("Wrong color of node - file color should be new!!!", TestKit.NEW_COLOR, color);
384             assertEquals("Wrong annotation of node - package status should be new!!!", TestKit.NEW_STATUS, status);
385             assertEquals("Wrong annotation of node - file status should be new!!!", TestKit.NEW_STATUS, status2);
386             
387             //verify content of Versioning view
388
oto = new OutputTabOperator("file:///tmp/repo");
389             oto.clear();
390             node = new Node(new SourcePackagesNode(PROJECT_NAME), "xx");
391             node.performPopupAction("Subversion|Show Changes");
392             oto.waitText("Refreshing... finished.");
393             Thread.sleep(1000);
394             vo = VersioningOperator.invoke();
395             TableModel JavaDoc model = vo.tabFiles().getModel();
396             assertEquals("Versioning view should be empty", 2, model.getRowCount());
397             String JavaDoc[] expected = {"xx", "NewClass.java"};
398             String JavaDoc[] actual = new String JavaDoc[model.getRowCount()];
399             for (int i = 0; i < actual.length; i++) {
400                 actual[i] = model.getValueAt(i, 0).toString();
401             }
402             int result = TestKit.compareThem(expected, actual, false);
403             assertEquals("Wrong records in Versioning view", 2, result);
404             stream.flush();
405             stream.close();
406             
407         } catch (Exception JavaDoc e) {
408             throw new Exception JavaDoc("Test failed: " + e);
409         } finally {
410             TestKit.closeProject(PROJECT_NAME);
411         }
412     }
413     
414     public void testFinalRemove() throws Exception JavaDoc {
415         TestKit.finalRemove();
416     }
417 }
418
Popular Tags