From 23c3f13b63faab6d163b8615d020b5b3a5100bd6 Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Fri, 31 Aug 2012 16:58:24 +0200 Subject: [PATCH] Added test class for FeedHandler --- tests/.classpath | 1 + .../antennapod/test/FeedHandlerTest.java | 72 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 tests/src/de/danoeh/antennapod/test/FeedHandlerTest.java diff --git a/tests/.classpath b/tests/.classpath index 3f9691c5d..18b6d1c57 100644 --- a/tests/.classpath +++ b/tests/.classpath @@ -4,5 +4,6 @@ + diff --git a/tests/src/de/danoeh/antennapod/test/FeedHandlerTest.java b/tests/src/de/danoeh/antennapod/test/FeedHandlerTest.java new file mode 100644 index 000000000..581db7656 --- /dev/null +++ b/tests/src/de/danoeh/antennapod/test/FeedHandlerTest.java @@ -0,0 +1,72 @@ +package de.danoeh.antennapod.test; + +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Date; + +import android.test.AndroidTestCase; +import android.util.Log; +import de.danoeh.antennapod.feed.Feed; +import de.danoeh.antennapod.syndication.handler.FeedHandler; + + +/** Enqueues a list of Feeds and tests if they are parsed correctly*/ +public class FeedHandlerTest extends AndroidTestCase { + private static final String TAG = "FeedHandlerTest"; + + private static final String[] rssUrls = { + + + }; + + private static final String[] atomUrls = { + + + }; + + private ArrayList rssFeeds; + private ArrayList atomFeeds; + + protected void setUp() throws Exception { + super.setUp(); + rssFeeds = new ArrayList(); + for (String url : rssUrls) { + Feed f = new Feed(url, new Date()); + rssFeeds.add(f); + } + + atomFeeds = new ArrayList(); + for (String url : atomUrls) { + Feed f = new Feed(url, new Date()); + atomFeeds.add(f); + } + + Log.d(TAG, "Setup completed"); + } + + public InputStream getInputStream(String url) throws MalformedURLException, IOException { + HttpURLConnection connection = (HttpURLConnection) (new URL(url)).openConnection(); + int rc = connection.getResponseCode(); + if (rc == HttpURLConnection.HTTP_OK) { + return connection.getInputStream(); + } else { + return null; + } + } + + public void testParseRSS() { + Log.i(TAG, "Testing RSS feeds"); + for (Feed feed : rssFeeds) { + Log.i(TAG, "Testing feed with url " + feed.getDownload_url()); + FeedHandler handler = new FeedHandler(); + + } + + Log.i(TAG, "RSS Test completed"); + } + +}