KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > cvsgrab > LiveTest


1 /*
2  * Insito J2EE - Copyright 2003-2004 Finance Active
3  */

4 package net.sourceforge.cvsgrab;
5
6 import java.io.File JavaDoc;
7
8
9
10 public class LiveTest extends AbstractTestCase {
11
12     private File JavaDoc tmpDir;
13
14     public LiveTest(String JavaDoc name) {
15         super(name);
16     }
17
18     protected void setUp() throws Exception JavaDoc {
19         super.setUp();
20         tmpDir = new File JavaDoc(getTestFile("tmp"));
21         tmpDir.mkdir();
22     }
23
24     protected void tearDown() throws Exception JavaDoc {
25         super.tearDown();
26         cleanDir(tmpDir);
27     }
28     
29     /**
30      * Test for Eclipse.org
31      */

32     public void testEclipse() throws Exception JavaDoc {
33         grab("http://dev.eclipse.org/viewcvs/index.cgi/equinox-home/services/?cvsroot=Technology_Project");
34         assertContainsFile("index.html");
35     }
36
37     /**
38      * Test for Sourceforge.net
39      */

40     public void testSourceforge() throws Exception JavaDoc {
41         grab("http://cvs.sourceforge.net/viewcvs.py/cvsgrab/cvsgrab/etc/script");
42         assertContainsFile("cvsgrab.bat");
43     }
44     
45     /**
46      * Test for Apache.org
47      */

48     public void testApache() throws Exception JavaDoc {
49         grab("http://cvs.apache.org/viewcvs.cgi/ws-fx/wss4j/interop/keys/");
50         assertContainsFile("README.txt");
51     }
52
53     /**
54      * Test for Savannah.gnu.org
55      */

56     public void testSavannah() throws Exception JavaDoc {
57         grab("http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/faq/?cvsroot=Web");
58         assertContainsFile("faq.html");
59     }
60     
61     /**
62      * Test for Netbeans.org
63      */

64     public void testNetbeans() throws Exception JavaDoc {
65         grab("http://www.netbeans.org/source/browse/javacvs/src/org/netbeans/modules/javacvs/util/");
66         assertContainsFile("Debug.java");
67     }
68     
69     /**
70      * Test for dev.java.net
71      */

72     public void testDevJava() throws Exception JavaDoc {
73         grab("https://swingfx.dev.java.net/source/browse/swingfx/src/net/java/swingfx/common/");
74         assertContainsFile("package.html");
75     }
76
77     /**
78      * Test for w3
79      */

80     public void testW3() throws Exception JavaDoc {
81         grab("http://dev.w3.org/cvsweb/Amaya/templates/conf/");
82         assertContainsFile("templates.conf");
83     }
84     
85     /**
86      * Test for HelixCommunity
87      */

88     public void testHelixCommunity() throws Exception JavaDoc {
89         grab("https://helixcommunity.org/viewcvs/cgi/viewcvs.cgi/xiph/www/", "ViewCvs1_0");
90         assertContainsFile("LICENSE.txt");
91     }
92     
93     /**
94      * Test for Openoffice
95      */

96     public void testOpenoffice() throws Exception JavaDoc {
97         grab("http://lingucomponent.openoffice.org/source/browse/lingucomponent/source/lingutil/");
98         assertContainsFile("makefile.mk");
99     }
100     
101     /**
102      * Test for Php.net
103      */

104     public void testPhpNet() throws Exception JavaDoc {
105         grab("http://cvs.php.net/smarty/docs/scripts/");
106         assertContainsFile(".cvsignore");
107     }
108     
109     private void assertContainsFile(String JavaDoc name) {
110         File JavaDoc f = new File JavaDoc(tmpDir, "test/" + name);
111         assertTrue(name + " not found", f.exists());
112     }
113
114     private void grab(String JavaDoc url) {
115         CVSGrab.main(new String JavaDoc[] {"-url", url, "-packageDir", "test", "-destDir", tmpDir.getName()});
116     }
117     
118     private void grab(String JavaDoc url, String JavaDoc webInterface) {
119         CVSGrab.main(new String JavaDoc[] {"-url", url, "-packageDir", "test", "-destDir", tmpDir.getName(), "-webInterface", webInterface});
120     }
121     
122     private void cleanDir(File JavaDoc dir) {
123         File JavaDoc[] files = dir.listFiles();
124         for (int i = 0; i < files.length; i++) {
125             if (files[i].isDirectory()) {
126                 cleanDir(files[i]);
127             } else {
128                 files[i].delete();
129             }
130         }
131         dir.delete();
132     }
133
134 }
135
Popular Tags