Added test class for FeedHandler
This commit is contained in:
parent
a224ef614e
commit
23c3f13b63
@ -4,5 +4,6 @@
|
|||||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="src" path="gen"/>
|
<classpathentry kind="src" path="gen"/>
|
||||||
|
<classpathentry combineaccessrules="false" kind="src" path="/Antennapod"/>
|
||||||
<classpathentry kind="output" path="bin/classes"/>
|
<classpathentry kind="output" path="bin/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
72
tests/src/de/danoeh/antennapod/test/FeedHandlerTest.java
Normal file
72
tests/src/de/danoeh/antennapod/test/FeedHandlerTest.java
Normal file
@ -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<Feed> rssFeeds;
|
||||||
|
private ArrayList<Feed> atomFeeds;
|
||||||
|
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
|
rssFeeds = new ArrayList<Feed>();
|
||||||
|
for (String url : rssUrls) {
|
||||||
|
Feed f = new Feed(url, new Date());
|
||||||
|
rssFeeds.add(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
atomFeeds = new ArrayList<Feed>();
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user