From 1563ab4ff8237dde23b97db39132306d248072da Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Wed, 21 Aug 2013 17:39:01 +0200 Subject: Added classes for accessing gpodder.net service Directory + Subscription upload/download --- .../antennapod/gpodnet/GPodnetServiceTest.java | 102 +++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 src/instrumentationTest/de/test/antennapod/gpodnet/GPodnetServiceTest.java (limited to 'src/instrumentationTest') diff --git a/src/instrumentationTest/de/test/antennapod/gpodnet/GPodnetServiceTest.java b/src/instrumentationTest/de/test/antennapod/gpodnet/GPodnetServiceTest.java new file mode 100644 index 000000000..bcf0d5d43 --- /dev/null +++ b/src/instrumentationTest/de/test/antennapod/gpodnet/GPodnetServiceTest.java @@ -0,0 +1,102 @@ +package instrumentationTest.de.test.antennapod.gpodnet; + +import android.test.AndroidTestCase; +import de.danoeh.antennapod.gpoddernet.GpodnetService; +import de.danoeh.antennapod.gpoddernet.GpodnetServiceException; +import de.danoeh.antennapod.gpoddernet.model.GpodnetDevice; +import de.danoeh.antennapod.gpoddernet.model.GpodnetTag; + +import java.util.ArrayList; +import java.util.List; + +/** + * Test class for GpodnetService + */ +public class GPodnetServiceTest extends AndroidTestCase { + + private GpodnetService service; + + private static final String USER = ""; + private static final String PW = ""; + + @Override + protected void setUp() throws Exception { + super.setUp(); + service = new GpodnetService(); + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + } + + private void authenticate() throws GpodnetServiceException { + service.authenticate(USER, PW); + } + + public void testUploadSubscription() throws GpodnetServiceException { + authenticate(); + ArrayList l = new ArrayList(); + l.add("http://bitsundso.de/feed"); + service.uploadSubscriptions(USER, "radio", l); + } + + public void testUploadSubscription2() throws GpodnetServiceException { + authenticate(); + ArrayList l = new ArrayList(); + l.add("http://bitsundso.de/feed"); + l.add("http://gamesundso.de/feed"); + service.uploadSubscriptions(USER, "radio", l); + } + + public void testGetSubscriptionChanges() throws GpodnetServiceException { + authenticate(); + service.getSubscriptionChanges(USER, "radio", 1362322610L); + } + + public void testGetSubscriptionsOfUser() + throws GpodnetServiceException { + authenticate(); + service.getSubscriptionsOfUser(USER); + } + + public void testGetSubscriptionsOfDevice() + throws GpodnetServiceException { + authenticate(); + service.getSubscriptionsOfDevice(USER, "radio"); + } + + public void testConfigureDevices() throws GpodnetServiceException { + authenticate(); + service.configureDevice(USER, "foo", "This is an updated caption", + GpodnetDevice.DeviceType.LAPTOP); + } + + public void testGetDevices() throws GpodnetServiceException { + authenticate(); + service.getDevices(USER); + } + + public void testGetSuggestions() throws GpodnetServiceException { + authenticate(); + service.getSuggestions(10); + } + + public void testTags() throws GpodnetServiceException { + service.getTopTags(20); + } + + public void testPodcastForTags() throws GpodnetServiceException { + List tags = service.getTopTags(20); + service.getPodcastsForTag(tags.get(1), + 10); + } + + public void testSearch() throws GpodnetServiceException { + service.searchPodcasts("linux", 64); + } + + public void testToplist() throws GpodnetServiceException { + service.getPodcastToplist(10); + } +} -- cgit v1.2.3 From 1f594ad311b8f72fb78f14d137dfb53f59b03f85 Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Mon, 2 Sep 2013 15:13:00 +0200 Subject: Upload changes instead of whole subscription list --- .../de/test/antennapod/gpodnet/GPodnetServiceTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/instrumentationTest') diff --git a/src/instrumentationTest/de/test/antennapod/gpodnet/GPodnetServiceTest.java b/src/instrumentationTest/de/test/antennapod/gpodnet/GPodnetServiceTest.java index bcf0d5d43..a96fc7aab 100644 --- a/src/instrumentationTest/de/test/antennapod/gpodnet/GPodnetServiceTest.java +++ b/src/instrumentationTest/de/test/antennapod/gpodnet/GPodnetServiceTest.java @@ -1,12 +1,14 @@ package instrumentationTest.de.test.antennapod.gpodnet; import android.test.AndroidTestCase; +import android.util.Log; import de.danoeh.antennapod.gpoddernet.GpodnetService; import de.danoeh.antennapod.gpoddernet.GpodnetServiceException; import de.danoeh.antennapod.gpoddernet.model.GpodnetDevice; import de.danoeh.antennapod.gpoddernet.model.GpodnetTag; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -49,6 +51,16 @@ public class GPodnetServiceTest extends AndroidTestCase { service.uploadSubscriptions(USER, "radio", l); } + public void testUploadChanges() throws GpodnetServiceException { + authenticate(); + String[] URLS = {"http://bitsundso.de/feed", "http://gamesundso.de/feed", "http://cre.fm/feed/mp3/", "http://freakshow.fm/feed/m4a/"}; + List subscriptions = Arrays.asList(URLS[0], URLS[1]); + List removed = Arrays.asList(URLS[0]); + List added = Arrays.asList(URLS[2], URLS[3]); + service.uploadSubscriptions(USER, "radio", subscriptions); + service.uploadChanges(USER, "radio", added, removed); + } + public void testGetSubscriptionChanges() throws GpodnetServiceException { authenticate(); service.getSubscriptionChanges(USER, "radio", 1362322610L); -- cgit v1.2.3