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 18 public class Sourcecast1_0InterfaceTest extends AbstractTestCase { 19 20 private Sourcecast1_0Interface _interface; 21 private CVSGrab _grabber; 22 23 27 public Sourcecast1_0InterfaceTest(String testName) { 28 super(testName); 29 } 30 31 protected void setUp() throws Exception { 32 super.setUp(); 33 _grabber = new CVSGrab(); 34 _interface = new Sourcecast1_0Interface(_grabber); 35 } 36 37 public void testDetect() throws Exception { 38 Document doc = getDocument("src/test/html_docs/sourcecast_1_0.html"); 39 _grabber.getWebOptions().setRootUrl("http://javacvs.netbeans.org/source/browse/"); 40 _interface.detect(doc); 41 42 assertEquals("SourceCast 1.1.3.000", _interface.getType()); 43 } 44 45 public void testGetFiles() throws Exception { 46 Document doc = getDocument("src/test/html_docs/sourcecast_1_0.html"); 47 48 int i = 0; 49 RemoteFile[] files = _interface.getFiles(doc); 50 assertEquals(".cvsignore", files[i].getName()); 51 assertFalse(files[i].isInAttic()); 52 assertEquals("1.2", files[i++].getVersion()); 53 54 assertEquals("build.xml", files[i].getName()); 55 assertFalse(files[i].isInAttic()); 56 assertEquals("1.35", files[i++].getVersion()); 57 58 assertEquals("l10n.list", files[i].getName()); 59 assertFalse(files[i].isInAttic()); 60 assertEquals("1.6", files[i++].getVersion()); 61 62 assertEquals("manifest.mf", files[i].getName()); 63 assertFalse(files[i].isInAttic()); 64 assertEquals("1.28", files[i++].getVersion()); 65 66 assertEquals("nbl10n.list.generated", files[i].getName()); 67 assertFalse(files[i].isInAttic()); 68 assertEquals("1.8", files[i++].getVersion()); 69 70 assertEquals("Expected no more files", i, files.length); 71 } 72 73 public void testGetDirectories() throws Exception { 74 Document doc = getDocument("src/test/html_docs/sourcecast_1_0.html"); 75 76 int i = 0; 77 String [] directories = _interface.getDirectories(doc); 78 assertEquals("changelog", directories[i++]); 79 assertEquals("compat", directories[i++]); 80 assertEquals("libmodule", directories[i++]); 81 assertEquals("libsrc", directories[i++]); 82 assertEquals("src", directories[i++]); 83 assertEquals("test", directories[i++]); 84 assertEquals("www", directories[i++]); 85 86 assertEquals("Expected no more directories", i, directories.length); 87 88 } 89 90 public void testGetDirectoryUrl() throws Exception { 91 assertEquals("http://javacvs.netbeans.org/source/browse/javacvs/", _interface.getDirectoryUrl("http://javacvs.netbeans.org/source/browse/", "javacvs")); 92 _interface.setVersionTag("release35R"); 93 assertEquals("http://javacvs.netbeans.org/source/browse/javacvs/?only_with_tag=release35R", _interface.getDirectoryUrl("http://javacvs.netbeans.org/source/browse/", "javacvs")); 94 } 95 96 public void testGetDownloadUrl() throws Exception { 97 RemoteRepository repository = new RemoteRepository("http://javacvs.netbeans.org/source/browse/", null); 98 RemoteDirectory dir = new RemoteDirectory(repository, "javacvs", "javacvs"); 99 RemoteFile file = new RemoteFile("build.xml", "1.32.6.1"); 100 file.setDirectory(dir); 101 102 assertEquals("http://javacvs.netbeans.org/source/browse/~checkout~/javacvs/build.xml?rev=1.32.6.1", _interface.getDownloadUrl(file)); 103 104 } 105 106 public void testGuessWebProperties() { 107 Properties webProperties = _interface.guessWebProperties("http://javacvs.netbeans.org/source/browse/javacvs/"); 108 assertEquals("http://javacvs.netbeans.org/source/browse/", webProperties.get(CVSGrab.ROOT_URL_OPTION)); 109 assertEquals("javacvs/", webProperties.get(CVSGrab.PACKAGE_PATH_OPTION)); 110 assertNull(webProperties.get(CVSGrab.TAG_OPTION)); 111 assertNull(webProperties.get(CVSGrab.PROJECT_ROOT_OPTION)); 112 assertNull(webProperties.get(CVSGrab.QUERY_PARAMS_OPTION)); 113 webProperties = _interface.guessWebProperties("http://javacvs.netbeans.org/source/browse/javacvs/?only_with_tag=sierrafixes"); 114 assertEquals("http://javacvs.netbeans.org/source/browse/", webProperties.get(CVSGrab.ROOT_URL_OPTION)); 115 assertEquals("javacvs/", webProperties.get(CVSGrab.PACKAGE_PATH_OPTION)); 116 assertEquals("sierrafixes", webProperties.get(CVSGrab.TAG_OPTION)); 117 assertNull(webProperties.get(CVSGrab.PROJECT_ROOT_OPTION)); 118 assertNull(webProperties.get(CVSGrab.QUERY_PARAMS_OPTION)); 119 } 120 121 } 122 | Popular Tags |