diff options
author | H. Lehmann <ByteHamster@users.noreply.github.com> | 2019-12-20 00:12:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-20 00:12:51 +0100 |
commit | 707fcdbc7fc874b99cc08e14906310c718b5e8a7 (patch) | |
tree | 6de1485cb2494299b39e70488e68c658ee8fb442 /app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java | |
parent | 19890afc663d067f70e0286eeaa73cb8cb7acbad (diff) | |
parent | 6dc361c5424a9b5b3f516cd2aa531b88011a3413 (diff) | |
download | AntennaPod-707fcdbc7fc874b99cc08e14906310c718b5e8a7.zip |
Merge pull request #3654 from ByteHamster/emulator-test
Run integration tests on CI
Diffstat (limited to 'app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java')
-rw-r--r-- | app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java b/app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java index 4530b7679..7d9ec7c98 100644 --- a/app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java +++ b/app/src/androidTest/java/de/test/antennapod/service/download/HttpDownloaderTest.java @@ -29,10 +29,9 @@ public class HttpDownloaderTest { private static final String TAG = "HttpDownloaderTest"; private static final String DOWNLOAD_DIR = "testdownloads"; - private static boolean successful = true; - + private String url404; + private String urlAuth; private File destDir; - private HTTPBin httpServer; public HttpDownloaderTest() { @@ -57,6 +56,8 @@ public class HttpDownloaderTest { assertTrue(destDir.exists()); httpServer = new HTTPBin(); httpServer.start(); + url404 = httpServer.getBaseUrl() + "/status/404"; + urlAuth = httpServer.getBaseUrl() + "/basic-auth/user/passwd"; } private FeedFileImpl setupFeedFile(String downloadUrl, String title, boolean deleteExisting) { @@ -88,33 +89,29 @@ public class HttpDownloaderTest { return downloader; } - - private static final String URL_404 = HTTPBin.BASE_URL + "/status/404"; - private static final String URL_AUTH = HTTPBin.BASE_URL + "/basic-auth/user/passwd"; - @Test public void testPassingHttp() { - download(HTTPBin.BASE_URL + "/status/200", "test200", true); + download(httpServer.getBaseUrl() + "/status/200", "test200", true); } @Test public void testRedirect() { - download(HTTPBin.BASE_URL + "/redirect/4", "testRedirect", true); + download(httpServer.getBaseUrl() + "/redirect/4", "testRedirect", true); } @Test public void testGzip() { - download(HTTPBin.BASE_URL + "/gzip/100", "testGzip", true); + download(httpServer.getBaseUrl() + "/gzip/100", "testGzip", true); } @Test public void test404() { - download(URL_404, "test404", false); + download(url404, "test404", false); } @Test public void testCancel() { - final String url = HTTPBin.BASE_URL + "/delay/3"; + final String url = httpServer.getBaseUrl() + "/delay/3"; FeedFileImpl feedFile = setupFeedFile(url, "delay", true); final Downloader downloader = new HttpDownloader(new DownloadRequest(feedFile.getFile_url(), url, "delay", 0, feedFile.getTypeAsInt())); Thread t = new Thread() { @@ -139,7 +136,7 @@ public class HttpDownloaderTest { @Test public void testDeleteOnFailShouldDelete() { - Downloader downloader = download(URL_404, "testDeleteOnFailShouldDelete", false, true, null, null, true); + Downloader downloader = download(url404, "testDeleteOnFailShouldDelete", false, true, null, null, true); assertFalse(new File(downloader.getDownloadRequest().getDestination()).exists()); } @@ -149,18 +146,18 @@ public class HttpDownloaderTest { File dest = new File(destDir, filename); dest.delete(); assertTrue(dest.createNewFile()); - Downloader downloader = download(URL_404, filename, false, false, null, null, false); + Downloader downloader = download(url404, filename, false, false, null, null, false); assertTrue(new File(downloader.getDownloadRequest().getDestination()).exists()); } @Test public void testAuthenticationShouldSucceed() throws InterruptedException { - download(URL_AUTH, "testAuthSuccess", true, true, "user", "passwd", true); + download(urlAuth, "testAuthSuccess", true, true, "user", "passwd", true); } @Test public void testAuthenticationShouldFail() { - Downloader downloader = download(URL_AUTH, "testAuthSuccess", false, true, "user", "Wrong passwd", true); + Downloader downloader = download(urlAuth, "testAuthSuccess", false, true, "user", "Wrong passwd", true); assertEquals(DownloadError.ERROR_UNAUTHORIZED, downloader.getResult().getReason()); } |