# HG changeset patch # User stechong # Date 1242844463 18000 # Node ID 619ca8fc1260c1d2b1f16c78ab6e374b986a52e5 # Parent 5afc27b54777e1190ea97f752fb9842b6a3a760e Improved test of saving to feed cache. diff -r 5afc27b54777 -r 619ca8fc1260 core/com.nokia.carbide.cpp.news.reader.tests/src/com/nokia/carbide/cpp/news/reader/tests/FeedCacheManagerTest.java --- a/core/com.nokia.carbide.cpp.news.reader.tests/src/com/nokia/carbide/cpp/news/reader/tests/FeedCacheManagerTest.java Wed May 20 13:32:51 2009 -0500 +++ b/core/com.nokia.carbide.cpp.news.reader.tests/src/com/nokia/carbide/cpp/news/reader/tests/FeedCacheManagerTest.java Wed May 20 13:34:23 2009 -0500 @@ -19,9 +19,11 @@ import java.io.File; import java.net.URL; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import com.nokia.carbide.cpp.internal.news.reader.feed.CarbideSyndEntry; import com.nokia.carbide.cpp.internal.news.reader.feed.CarbideSyndFeed; import com.nokia.carbide.cpp.internal.news.reader.feed.FeedManager; import com.nokia.carbide.cpp.internal.news.reader.gen.FeedCache.FeedCacheFactory; @@ -29,6 +31,10 @@ import com.nokia.carbide.cpp.internal.news.reader.gen.FeedCache.FeedCacheType; import com.nokia.carbide.cpp.internal.news.reader.gen.FeedCache.FeedType; import com.nokia.carbide.cpp.internal.news.reader.gen.FeedCache.IFeedCacheChangedlistener; +import com.sun.syndication.feed.synd.SyndEntry; +import com.sun.syndication.feed.synd.SyndEntryImpl; +import com.sun.syndication.feed.synd.SyndFeed; +import com.sun.syndication.feed.synd.SyndFeedImpl; import junit.framework.TestCase; @@ -190,6 +196,32 @@ } } + public void testSaveFeedToCache() { + try { + feedCacheManager.setFeedCache(null); + feedCacheManager.saveFeedToCache(null); + assertNull(feedCacheManager.getFeedCache()); + File file = getDefaultFeedCacheFile(); + URL url = file.toURL(); + if (feedCacheManager.loadCacheFromFile(url)) { + SyndFeed syndFeed = new SyndFeedImpl(); + CarbideSyndFeed feed = new CarbideSyndFeed(syndFeed); + List entries = new ArrayList(); + SyndEntry syndEntry = new SyndEntryImpl(); + CarbideSyndEntry entry = new CarbideSyndEntry(syndEntry); + entries.add(entry); + feed.setEntries(entries); + feed.setDescription("A feed for testing feed cache manager."); + feed.setTitle("Test feed"); + feed.setLink("http://www.nokia.com"); + feedCacheManager.saveFeedToCache(feed); + assertTrue(feedCacheManager.isFeedInCache(feed)); + } + } catch (Exception e) { + fail(); + } + } + public void testSetCacheUpdated() { feedCacheManager.setCacheUpdated(true); assertTrue(feedCacheManager.isCacheUpdated());