1 6 package fr.jayasoft.ivy.url; 7 8 import junit.framework.TestCase; 9 10 import java.net.URL ; 11 import java.util.Iterator ; 12 import java.util.List ; 13 14 15 21 public class ApacheURLListerTest extends TestCase { 22 23 28 public void testRetrieveListing() throws Exception { 29 ApacheURLLister lister = new ApacheURLLister(); 30 31 List files = lister.retrieveListing(ApacheURLListerTest.class.getResource("apache-file-listing.html"), true, false); 32 assertNotNull(files); 33 assertTrue(files.size() > 0); 34 for (Iterator iter = files.iterator(); iter.hasNext();) { 35 URL file = (URL ) iter.next(); 36 assertTrue("found a non matching file: "+file, file.getPath().matches(".*/[^/]+\\.(jar|md5|sha1)")); 37 } 38 39 40 List dirs = lister.retrieveListing(ApacheURLListerTest.class.getResource("apache-dir-listing.html"), false, true); 42 assertNotNull(dirs); 43 assertEquals(4, dirs.size()); 44 45 46 List empty = lister.retrieveListing(ApacheURLListerTest.class.getResource("apache-dir-listing.html"), true, false); 47 assertTrue(empty.isEmpty()); 48 } 49 50 55 public void testRetrieveListingWithSpaces() throws Exception { 56 ApacheURLLister lister = new ApacheURLLister(); 57 58 List files = lister.retrieveListing(ApacheURLListerTest.class.getResource("listing-with-spaces.html"), true, false); 59 assertNotNull(files); 60 assertTrue(files.size() > 0); 61 } 62 } 63 | Popular Tags |