1 16 17 package org.apache.roller.util.rome; 18 19 import java.io.File ; 20 import java.net.URL ; 21 22 import junit.framework.Test; 23 import junit.framework.TestCase; 24 import junit.framework.TestSuite; 25 26 import org.apache.roller.business.FileManagerTest; 27 import com.sun.syndication.fetcher.impl.SyndFeedInfo; 28 29 32 public class DiskFeedInfoCacheTest extends TestCase 33 { 34 public static void main(String [] args) 35 { 36 junit.textui.TestRunner.run(DiskFeedInfoCacheTest.class); 37 } 38 39 public void testCache() throws Exception 40 { 41 URL url = new URL ("http://cnn.com"); 42 SyndFeedInfo info = new SyndFeedInfo(); 43 info.setUrl(url); 44 45 String buildDir = System.getProperty("ro.build"); 46 assertNotNull("ro.build not null", buildDir); 47 assertTrue("ro.build not zero length", buildDir.trim().length() > 0); 48 if (!buildDir.startsWith("/")) buildDir = ".."; 49 File file = new File (buildDir); 50 51 assertTrue("buildDir exists", file.exists()); 52 assertTrue("buildDir is directory", file.isDirectory()); 53 54 DiskFeedInfoCache cache = 55 new DiskFeedInfoCache(buildDir + "/tests/planet-cache"); 56 cache.setFeedInfo(info.getUrl(), info); 57 58 SyndFeedInfo info2 = cache.getFeedInfo(url); 59 assertNotNull(info2); 60 assertEquals(url, info2.getUrl()); 61 } 62 63 public static Test suite() 64 { 65 return new TestSuite(DiskFeedInfoCacheTest.class); 66 67 } 68 } 69 | Popular Tags |