1 package net.sourceforge.cvsgrab.web; 2 3 import net.sourceforge.cvsgrab.AbstractTestCase; 4 import net.sourceforge.cvsgrab.CVSGrab; 5 import net.sourceforge.cvsgrab.RemoteDirectory; 6 import net.sourceforge.cvsgrab.RemoteFile; 7 import net.sourceforge.cvsgrab.RemoteRepository; 8 9 import org.w3c.dom.Document ; 10 11 import java.util.Properties ; 12 13 14 21 public class FishEye_1_0InterfaceTest extends AbstractTestCase { 22 23 private FishEye1_0Interface _interface; 24 private CVSGrab _grabber; 25 26 30 public FishEye_1_0InterfaceTest(String testName) { 31 super(testName); 32 } 33 34 protected void setUp() throws Exception { 35 super.setUp(); 36 _grabber = new CVSGrab(); 37 _interface = new FishEye1_0Interface(_grabber); 38 } 39 40 public void testDetect() throws Exception { 41 Document doc = getDocument("src/test/html_docs/fisheye_0_8.html"); 42 43 _grabber.getWebOptions().setRootUrl("http://cvs.codehaus.org/viewrep/"); 44 _interface.detect(doc); 45 46 48 doc = getDocument("src/test/html_docs/fisheye_1_0_1.html"); 49 50 _grabber.getWebOptions().setRootUrl("http://cvs.groovy.codehaus.org/viewrep/"); 51 _interface.detect(doc); 52 53 assertEquals("FishEye (1.0.1 build-78)", _interface.getType()); 54 55 } 56 57 public void testGetFiles() throws Exception { 58 Document doc = getDocument("src/test/html_docs/fisheye_0_8.html"); 59 60 int i = 0; 61 RemoteFile[] files = _interface.getFiles(doc); 62 assertEquals(".cvsignore", files[i].getName()); 63 assertFalse(files[i].isInAttic()); 64 assertEquals("1.29.2.1", files[i++].getVersion()); 65 66 assertEquals("build.xml", files[i].getName()); 67 assertFalse(files[i].isInAttic()); 68 assertEquals("1.16", files[i++].getVersion()); 69 70 assertEquals("continuous-integration.sh", files[i].getName()); 71 assertTrue(files[i].isInAttic()); 72 assertEquals("1.16", files[i++].getVersion()); 73 74 assertEquals("getdocs.rb", files[i].getName()); 75 assertTrue(files[i].isInAttic()); 76 assertEquals("1.2.2.1", files[i++].getVersion()); 77 78 assertEquals("LICENSE.txt", files[i].getName()); 79 assertFalse(files[i].isInAttic()); 80 assertEquals("1.2", files[i++].getVersion()); 81 82 assertEquals("locator.ent", files[i].getName()); 83 assertTrue(files[i].isInAttic()); 84 assertEquals("1.3", files[i++].getVersion()); 85 86 assertEquals("massage_site.rb", files[i].getName()); 87 assertFalse(files[i].isInAttic()); 88 assertEquals("1.3.2.1", files[i++].getVersion()); 89 90 assertEquals("maven.xml", files[i].getName()); 91 assertFalse(files[i].isInAttic()); 92 assertEquals("1.26", files[i++].getVersion()); 93 94 assertEquals("picocontainer.iml", files[i].getName()); 95 assertFalse(files[i].isInAttic()); 96 assertEquals("1.1.2.2", files[i++].getVersion()); 97 98 assertEquals("project.properties", files[i].getName()); 99 assertFalse(files[i].isInAttic()); 100 assertEquals("1.25", files[i++].getVersion()); 101 102 assertEquals("project.xml", files[i].getName()); 103 assertFalse(files[i].isInAttic()); 104 assertEquals("1.103", files[i++].getVersion()); 105 106 assertEquals("TODO.txt", files[i].getName()); 107 assertTrue(files[i].isInAttic()); 108 assertEquals("1.6", files[i++].getVersion()); 109 110 assertEquals("Expected no more files", i, files.length); 111 112 } 113 114 public void testGetFilesEmptyDir() throws Exception { 115 Document doc = getDocument("src/test/html_docs/fisheye_0_8_emptydir.html"); 116 117 int i = 0; 118 RemoteFile[] files = _interface.getFiles(doc); 119 assertEquals("picosite.zip", files[i].getName()); 120 assertFalse(files[i].isInAttic()); 121 assertEquals("1.2", files[i++].getVersion()); 122 123 assertEquals("Expected no more files", i, files.length); 124 125 } 126 127 public void testGetDirectories() throws Exception { 128 Document doc = getDocument("src/test/html_docs/fisheye_0_8.html"); 129 130 int i = 0; 131 String [] directories = _interface.getDirectories(doc); 132 assertEquals("site", directories[i++]); 133 assertEquals("src", directories[i++]); 134 assertEquals("xdocs", directories[i++]); 135 136 assertEquals("Expected no more directories", i, directories.length); 137 } 138 139 public void testGetDirectoriesEmptyDir() throws Exception { 140 Document doc = getDocument("src/test/html_docs/fisheye_0_8_emptydir.html"); 141 142 String [] directories = _interface.getDirectories(doc); 143 144 assertEquals("Expected no directories", 0, directories.length); 145 } 146 147 public void testGetDirectoriesNestedDir() throws Exception { 148 Document doc = getDocument("src/test/html_docs/fisheye_0_8_nesteddir.html"); 149 150 int i = 0; 151 String [] directories = _interface.getDirectories(doc); 152 153 assertEquals("alternatives", directories[i++]); 154 assertEquals("defaults", directories[i++]); 155 assertEquals("doc", directories[i++]); 156 assertEquals("extras", directories[i++]); 157 assertEquals("monitors", directories[i++]); 158 assertEquals("tck", directories[i++]); 159 assertEquals("testmodel", directories[i++]); 160 161 assertEquals("Expected no more directories", i, directories.length); 162 } 163 164 public void testGetDirectoryUrl() throws Exception { 165 assertEquals("http://cvs.codehaus.org/viewrep/picocontainer/java/picocontainer/src/", _interface.getDirectoryUrl("http://cvs.codehaus.org/viewrep/", "picocontainer/java/picocontainer/src")); 166 167 _interface.setVersionTag("MX_PROPOSAL"); 168 assertEquals("http://cvs.codehaus.org/viewrep/~br=MX_PROPOSAL/picocontainer/java/picocontainer/src/", _interface.getDirectoryUrl("http://cvs.codehaus.org/viewrep/", "picocontainer/java/picocontainer/src")); 169 } 170 171 public void testGetFilesGroovy() throws Exception { 172 Document doc = getDocument("src/test/html_docs/fisheye_1_0_1.html"); 173 174 int i = 0; 175 RemoteFile[] files = _interface.getFiles(doc); 176 assertEquals(".classpath", files[i].getName()); 177 assertFalse(files[i].isInAttic()); 178 assertEquals("1.51", files[i++].getVersion()); 179 180 assertEquals(".cvsignore", files[i].getName()); 181 assertFalse(files[i].isInAttic()); 182 assertEquals("1.14", files[i++].getVersion()); 183 184 assertEquals(".project", files[i].getName()); 185 assertFalse(files[i].isInAttic()); 186 assertEquals("1.10", files[i++].getVersion()); 187 188 assertEquals("ASM-LICENSE.txt", files[i].getName()); 189 assertFalse(files[i].isInAttic()); 190 assertEquals("1.1", files[i++].getVersion()); 191 192 assertEquals("build.xml", files[i].getName()); 193 assertFalse(files[i].isInAttic()); 194 assertEquals("1.1", files[i++].getVersion()); 195 196 assertEquals("GroovyDoc.txt", files[i].getName()); 197 assertTrue(files[i].isInAttic()); 198 assertEquals("1.3", files[i++].getVersion()); 199 200 assertEquals("LICENSE.txt", files[i].getName()); 201 assertFalse(files[i].isInAttic()); 202 assertEquals("1.2", files[i++].getVersion()); 203 204 assertEquals("maven.xml", files[i].getName()); 205 assertFalse(files[i].isInAttic()); 206 assertEquals("1.124", files[i++].getVersion()); 207 208 assertEquals("project.properties", files[i].getName()); 209 assertFalse(files[i].isInAttic()); 210 assertEquals("1.20", files[i++].getVersion()); 211 212 assertEquals("project.xml", files[i].getName()); 213 assertFalse(files[i].isInAttic()); 214 assertEquals("1.146", files[i++].getVersion()); 215 216 assertEquals("TODO-PARSER.txt", files[i].getName()); 217 assertTrue(files[i].isInAttic()); 218 assertEquals("1.14", files[i++].getVersion()); 219 220 assertEquals("TODO.txt", files[i].getName()); 221 assertFalse(files[i].isInAttic()); 222 assertEquals("1.123", files[i++].getVersion()); 223 224 assertEquals("Expected no more files", i, files.length); 225 226 } 227 228 public void testGetDirectoriesGroovy() throws Exception { 229 Document doc = getDocument("src/test/html_docs/fisheye_1_0_1.html"); 230 231 int i = 0; 232 String [] directories = _interface.getDirectories(doc); 233 assertEquals(".settings", directories[i++]); 234 assertEquals("security", directories[i++]); 236 assertEquals("src", directories[i++]); 237 assertEquals("xdocs", directories[i++]); 238 239 assertEquals("Expected no more directories", i, directories.length); 240 } 241 242 public void testGetDownloadUrl() throws Exception { 243 RemoteRepository repository = new RemoteRepository("http://cvs.codehaus.org/viewrep/", null); 245 RemoteDirectory dir = new RemoteDirectory(repository, "picocontainer/java/picocontainer", "picocontainer/java/picocontainer"); 246 RemoteFile file = new RemoteFile("build.xml", "1.12.2.1"); 247 file.setDirectory(dir); 248 249 assertEquals("http://cvs.codehaus.org/viewrep/~raw,r=1.12.2.1/picocontainer/java/picocontainer/build.xml", _interface.getDownloadUrl(file)); 250 } 251 252 public void testGuessWebProperties() { 253 Properties webProperties = _interface.guessWebProperties("http://cvs.codehaus.org/viewrep/picocontainer/java/picocontainer"); 254 assertEquals("http://cvs.codehaus.org/viewrep/", webProperties.get(CVSGrab.ROOT_URL_OPTION)); 255 assertEquals("picocontainer/java/picocontainer", webProperties.get(CVSGrab.PACKAGE_PATH_OPTION)); 256 assertNull(webProperties.get(CVSGrab.TAG_OPTION)); 257 assertNull(webProperties.get(CVSGrab.PROJECT_ROOT_OPTION)); 258 assertEquals("hideDeletedFiles=Y", webProperties.get(CVSGrab.QUERY_PARAMS_OPTION)); 259 260 webProperties = _interface.guessWebProperties("http://cvs.codehaus.org/viewrep/~br=MX_PROPOSAL/picocontainer/java/picocontainer"); 261 assertEquals("http://cvs.codehaus.org/viewrep/", webProperties.get(CVSGrab.ROOT_URL_OPTION)); 262 assertEquals("picocontainer/java/picocontainer", webProperties.get(CVSGrab.PACKAGE_PATH_OPTION)); 263 assertEquals("MX_PROPOSAL", webProperties.get(CVSGrab.TAG_OPTION)); 264 assertNull(webProperties.get(CVSGrab.PROJECT_ROOT_OPTION)); 265 assertEquals("hideDeletedFiles=Y", webProperties.get(CVSGrab.QUERY_PARAMS_OPTION)); 266 267 webProperties = _interface.guessWebProperties("http://cvs.codehaus.org/viewrep/picocontainer/java/picocontainer?hideDeletedFiles=N"); 268 assertEquals("http://cvs.codehaus.org/viewrep/", webProperties.get(CVSGrab.ROOT_URL_OPTION)); 269 assertEquals("picocontainer/java/picocontainer", webProperties.get(CVSGrab.PACKAGE_PATH_OPTION)); 270 assertNull(webProperties.get(CVSGrab.TAG_OPTION)); 271 assertNull(webProperties.get(CVSGrab.PROJECT_ROOT_OPTION)); 272 assertEquals("hideDeletedFiles=N", webProperties.get(CVSGrab.QUERY_PARAMS_OPTION)); 273 } 274 275 } 276 | Popular Tags |