diff --git a/extractor/src/test/java/org/schabi/newpipe/downloader/DownloaderFactory.java b/extractor/src/test/java/org/schabi/newpipe/downloader/DownloaderFactory.java new file mode 100644 index 000000000..96cbc6621 --- /dev/null +++ b/extractor/src/test/java/org/schabi/newpipe/downloader/DownloaderFactory.java @@ -0,0 +1,30 @@ +package org.schabi.newpipe.downloader; + +import org.schabi.newpipe.extractor.downloader.Downloader; + +import java.io.IOException; + +public class DownloaderFactory { + + private final static DownloaderType DEFAULT_DOWNLOADER = DownloaderType.REAL; + + public Downloader getDownloader(String path) throws IOException { + DownloaderType type; + try { + type = DownloaderType.valueOf(System.getProperty("downloader")); + } catch (Exception e) { + type = DEFAULT_DOWNLOADER; + } + + switch (type) { + case REAL: + return DownloaderTestImpl.getInstance(); + case MOCK: + return new MockDownloader(path); + case RECORDING: + return new RecordingDownloader(path); + default: + throw new UnsupportedOperationException("Unknown downloader type: " + type.toString()); + } + } +} diff --git a/extractor/src/test/java/org/schabi/newpipe/downloader/DownloaderType.java b/extractor/src/test/java/org/schabi/newpipe/downloader/DownloaderType.java new file mode 100644 index 000000000..090a5067c --- /dev/null +++ b/extractor/src/test/java/org/schabi/newpipe/downloader/DownloaderType.java @@ -0,0 +1,5 @@ +package org.schabi.newpipe.downloader; + +public enum DownloaderType { + REAL, MOCK, RECORDING +} \ No newline at end of file