get HttpDownloaderTest working on at least android-17 and above
The two excluded URLs seem to always resolve to IPv6 addresses first, then fail since there isn't IPv6 connectivity. Donno why, but only on old android versions, so just skip them there.
This commit is contained in:
parent
f064e33de9
commit
97ad4ddc1f
@ -2,11 +2,15 @@
|
|||||||
package org.fdroid.fdroid.net;
|
package org.fdroid.fdroid.net;
|
||||||
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.util.Log;
|
||||||
import org.fdroid.fdroid.ProgressListener;
|
import org.fdroid.fdroid.ProgressListener;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@ -15,22 +19,37 @@ import static org.junit.Assert.assertTrue;
|
|||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
public class HttpDownloaderTest {
|
public class HttpDownloaderTest {
|
||||||
|
private static final String TAG = "HttpDownloaderTest";
|
||||||
|
|
||||||
final String[] urls = {
|
static final String[] URLS;
|
||||||
"https://en.wikipedia.org/wiki/Index.html",
|
|
||||||
"https://mirrors.kernel.org/debian/dists/stable/Release",
|
// https://developer.android.com/reference/javax/net/ssl/SSLContext
|
||||||
"https://f-droid.org/repo/index.jar",
|
static {
|
||||||
// sites that use SNI for HTTPS
|
ArrayList<String> tempUrls = new ArrayList<>(Arrays.asList(
|
||||||
"https://guardianproject.info/fdroid/repo/index.jar",
|
"https://f-droid.org/repo/index-v1.jar",
|
||||||
//"https://microg.org/fdroid/repo/index.jar",
|
// sites that use SNI for HTTPS
|
||||||
//"https://grobox.de/fdroid/repo/index.jar",
|
"https://mirrors.kernel.org/debian/dists/stable/Release",
|
||||||
};
|
"https://fdroid.tetaneutral.net/fdroid/repo/index-v1.jar",
|
||||||
|
"https://ftp.fau.de/fdroid/repo/index-v1.jar",
|
||||||
|
//"https://microg.org/fdroid/repo/index-v1.jar",
|
||||||
|
//"https://grobox.de/fdroid/repo/index.jar",
|
||||||
|
"https://guardianproject.info/fdroid/repo/index-v1.jar"
|
||||||
|
));
|
||||||
|
if (Build.VERSION.SDK_INT >= 22) {
|
||||||
|
tempUrls.addAll(Arrays.asList(
|
||||||
|
"https://en.wikipedia.org/wiki/Index.html", // no SNI but weird ipv6 lookup issues
|
||||||
|
"https://mirror.cyberbits.eu/fdroid/repo/index-v1.jar" // TLSv1.2 only and SNI
|
||||||
|
));
|
||||||
|
}
|
||||||
|
URLS = tempUrls.toArray(new String[tempUrls.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean receivedProgress;
|
private boolean receivedProgress;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void downloadUninterruptedTest() throws IOException, InterruptedException {
|
public void downloadUninterruptedTest() throws IOException, InterruptedException {
|
||||||
for (String urlString : urls) {
|
for (String urlString : URLS) {
|
||||||
|
Log.i(TAG, "URL: " + urlString);
|
||||||
Uri uri = Uri.parse(urlString);
|
Uri uri = Uri.parse(urlString);
|
||||||
File destFile = File.createTempFile("dl-", "");
|
File destFile = File.createTempFile("dl-", "");
|
||||||
HttpDownloader httpDownloader = new HttpDownloader(uri, destFile);
|
HttpDownloader httpDownloader = new HttpDownloader(uri, destFile);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user