From 292f05f7ea50d442a194e4ecd276da76640b5d94 Mon Sep 17 00:00:00 2001 From: TobiGr Date: Tue, 14 May 2024 09:20:55 +0200 Subject: [PATCH] [Bandcamp] Add support for mocks in unit tests --- .../bandcamp/BandcampChannelExtractorTest.java | 6 +++--- .../BandcampChannelLinkHandlerFactoryTest.java | 11 ++++++++--- .../bandcamp/BandcampChannelTabExtractorTest.java | 14 +++++--------- .../bandcamp/BandcampCommentsExtractorTest.java | 5 +++-- .../BandcampCommentsLinkHandlerFactoryTest.java | 10 +++++++--- .../bandcamp/BandcampFeaturedExtractorTest.java | 5 +++-- .../bandcamp/BandcampPlaylistExtractorTest.java | 9 +++++---- .../BandcampPlaylistLinkHandlerFactoryTest.java | 10 +++++++--- .../bandcamp/BandcampRadioExtractorTest.java | 5 +++-- .../{ => search}/BandcampSearchExtractorTest.java | 14 ++++++++------ .../BandcampSearchQueryHandlerFactoryTest.java | 6 +----- .../BandcampSuggestionExtractorTest.java | 9 +++++---- .../BandcampPaidStreamExtractorTest.java | 12 ++++++++---- .../BandcampRadioStreamExtractorTest.java | 8 +++++--- .../{ => stream}/BandcampStreamExtractorTest.java | 8 +++++--- .../BandcampStreamLinkHandlerFactoryTest.java | 11 +++++++---- 16 files changed, 83 insertions(+), 60 deletions(-) rename extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/{ => search}/BandcampSearchExtractorTest.java (90%) rename extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/{ => search}/BandcampSearchQueryHandlerFactoryTest.java (85%) rename extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/{ => search}/BandcampSuggestionExtractorTest.java (75%) rename extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/{ => stream}/BandcampPaidStreamExtractorTest.java (65%) rename extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/{ => stream}/BandcampRadioStreamExtractorTest.java (92%) rename extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/{ => stream}/BandcampStreamExtractorTest.java (91%) rename extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/{ => stream}/BandcampStreamLinkHandlerFactoryTest.java (84%) diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelExtractorTest.java index 0fae98b53..4f3c85200 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelExtractorTest.java @@ -4,7 +4,7 @@ package org.schabi.newpipe.extractor.services.bandcamp; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.schabi.newpipe.downloader.DownloaderTestImpl; +import org.schabi.newpipe.downloader.DownloaderFactory; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.channel.ChannelExtractor; import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs; @@ -18,12 +18,12 @@ import static org.schabi.newpipe.extractor.ExtractorAsserts.assertTabsContain; import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; public class BandcampChannelExtractorTest implements BaseChannelExtractorTest { - + private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/channel"; private static ChannelExtractor extractor; @BeforeAll public static void setUp() throws Exception { - NewPipe.init(DownloaderTestImpl.getInstance()); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH)); extractor = Bandcamp.getChannelExtractor("https://toupie.bandcamp.com/releases"); extractor.fetchPage(); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelLinkHandlerFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelLinkHandlerFactoryTest.java index 9c9473cf4..0224a494d 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelLinkHandlerFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelLinkHandlerFactoryTest.java @@ -4,23 +4,28 @@ package org.schabi.newpipe.extractor.services.bandcamp; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.schabi.newpipe.downloader.DownloaderTestImpl; +import org.schabi.newpipe.downloader.DownloaderFactory; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampChannelLinkHandlerFactory; +import java.io.IOException; + import static org.junit.jupiter.api.Assertions.*; /** * Test for {@link BandcampChannelLinkHandlerFactory} */ public class BandcampChannelLinkHandlerFactoryTest { + + private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/linkHandler/channel"; private static BandcampChannelLinkHandlerFactory linkHandler; @BeforeAll - public static void setUp() { + public static void setUp() throws IOException { + // BandcampChannelLinkHandlerFactory needs a Downloader to check if domain is supported + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH)); linkHandler = BandcampChannelLinkHandlerFactory.getInstance(); - NewPipe.init(DownloaderTestImpl.getInstance()); } @Test diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelTabExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelTabExtractorTest.java index 13359136b..19e260f36 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelTabExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelTabExtractorTest.java @@ -1,34 +1,30 @@ package org.schabi.newpipe.extractor.services.bandcamp; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.schabi.newpipe.downloader.DownloaderTestImpl; +import org.schabi.newpipe.downloader.DownloaderFactory; import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.channel.tabs.ChannelTabExtractor; import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs; import org.schabi.newpipe.extractor.exceptions.ExtractionException; -import org.schabi.newpipe.extractor.exceptions.ParsingException; -import org.schabi.newpipe.extractor.services.BaseListExtractorTest; import org.schabi.newpipe.extractor.services.DefaultListExtractorTest; import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampChannelTabExtractor; import java.io.IOException; -import static org.junit.jupiter.api.Assertions.assertEquals; import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; -import static org.schabi.newpipe.extractor.ServiceList.PeerTube; -import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems; class BandcampChannelTabExtractorTest { + private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/channel/tab/"; static class Tracks extends DefaultListExtractorTest { + private static BandcampChannelTabExtractor extractor; @BeforeAll static void setUp() throws IOException, ExtractionException { - NewPipe.init(DownloaderTestImpl.getInstance()); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "tracks")); extractor = (BandcampChannelTabExtractor) Bandcamp .getChannelTabExtractorFromId("2464198920", ChannelTabs.TRACKS); extractor.fetchPage(); @@ -49,7 +45,7 @@ class BandcampChannelTabExtractorTest { @BeforeAll static void setUp() throws IOException, ExtractionException { - NewPipe.init(DownloaderTestImpl.getInstance()); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "albums")); extractor = (BandcampChannelTabExtractor) Bandcamp .getChannelTabExtractorFromId("2450875064", ChannelTabs.ALBUMS); extractor.fetchPage(); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampCommentsExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampCommentsExtractorTest.java index ed4985296..c8671294c 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampCommentsExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampCommentsExtractorTest.java @@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.bandcamp; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.schabi.newpipe.downloader.DownloaderTestImpl; +import org.schabi.newpipe.downloader.DownloaderFactory; import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.comments.CommentsExtractor; @@ -20,11 +20,12 @@ import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; public class BandcampCommentsExtractorTest { + private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/comments"; private static CommentsExtractor extractor; @BeforeAll public static void setUp() throws ExtractionException, IOException { - NewPipe.init(DownloaderTestImpl.getInstance()); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH)); extractor = Bandcamp.getCommentsExtractor("https://floatingpoints.bandcamp.com/album/promises"); extractor.fetchPage(); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampCommentsLinkHandlerFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampCommentsLinkHandlerFactoryTest.java index 94361bbf6..8f3008e88 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampCommentsLinkHandlerFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampCommentsLinkHandlerFactoryTest.java @@ -4,11 +4,13 @@ package org.schabi.newpipe.extractor.services.bandcamp; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.schabi.newpipe.downloader.DownloaderTestImpl; +import org.schabi.newpipe.downloader.DownloaderFactory; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampCommentsLinkHandlerFactory; +import java.io.IOException; + import static org.junit.jupiter.api.Assertions.*; /** @@ -16,12 +18,14 @@ import static org.junit.jupiter.api.Assertions.*; */ public class BandcampCommentsLinkHandlerFactoryTest { + private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/linkHandler/comments"; private static BandcampCommentsLinkHandlerFactory linkHandler; @BeforeAll - public static void setUp() { + public static void setUp() throws IOException { + // BandcampCommentsLinkHandlerFactory needs a Downloader to check if domain is supported + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH)); linkHandler = BandcampCommentsLinkHandlerFactory.getInstance(); - NewPipe.init(DownloaderTestImpl.getInstance()); } @Test diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampFeaturedExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampFeaturedExtractorTest.java index 74fff36a6..1fdbc20cc 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampFeaturedExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampFeaturedExtractorTest.java @@ -4,7 +4,7 @@ package org.schabi.newpipe.extractor.services.bandcamp; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.schabi.newpipe.downloader.DownloaderTestImpl; +import org.schabi.newpipe.downloader.DownloaderFactory; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.Page; import org.schabi.newpipe.extractor.exceptions.ExtractionException; @@ -26,11 +26,12 @@ import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; */ public class BandcampFeaturedExtractorTest implements BaseListExtractorTest { + private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/featured"; private static BandcampFeaturedExtractor extractor; @BeforeAll public static void setUp() throws ExtractionException, IOException { - NewPipe.init(DownloaderTestImpl.getInstance()); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH)); extractor = (BandcampFeaturedExtractor) Bandcamp .getKioskList().getDefaultKioskExtractor(); extractor.fetchPage(); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistExtractorTest.java index 448cca262..e33ce603b 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistExtractorTest.java @@ -5,7 +5,7 @@ package org.schabi.newpipe.extractor.services.bandcamp; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; -import org.schabi.newpipe.downloader.DownloaderTestImpl; +import org.schabi.newpipe.downloader.DownloaderFactory; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException; import org.schabi.newpipe.extractor.exceptions.ExtractionException; @@ -36,10 +36,11 @@ import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; * Tests for {@link BandcampPlaylistExtractor} */ public class BandcampPlaylistExtractorTest { + private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/playlist/"; @BeforeAll - public static void setUp() { - NewPipe.init(DownloaderTestImpl.getInstance()); + public static void setUp() throws IOException { + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH)); } /** @@ -110,7 +111,7 @@ public class BandcampPlaylistExtractorTest { @BeforeAll public static void setUp() throws ExtractionException, IOException { - NewPipe.init(DownloaderTestImpl.getInstance()); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "coming-of-age")); extractor = Bandcamp.getPlaylistExtractor("https://macbenson.bandcamp.com/album/coming-of-age"); extractor.fetchPage(); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistLinkHandlerFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistLinkHandlerFactoryTest.java index 3d9368f6f..067b47525 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistLinkHandlerFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistLinkHandlerFactoryTest.java @@ -4,11 +4,13 @@ package org.schabi.newpipe.extractor.services.bandcamp; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.schabi.newpipe.downloader.DownloaderTestImpl; +import org.schabi.newpipe.downloader.DownloaderFactory; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampPlaylistLinkHandlerFactory; +import java.io.IOException; + import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -17,12 +19,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue; */ public class BandcampPlaylistLinkHandlerFactoryTest { + private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/linkHandler/playlist"; private static BandcampPlaylistLinkHandlerFactory linkHandler; @BeforeAll - public static void setUp() { + public static void setUp() throws IOException { + // BandcampPlaylistLinkHandlerFactory needs a Downloader to check if the domain is supported + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH)); linkHandler = BandcampPlaylistLinkHandlerFactory.getInstance(); - NewPipe.init(DownloaderTestImpl.getInstance()); } @Test diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampRadioExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampRadioExtractorTest.java index 9b3f3cedd..3586bfc87 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampRadioExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampRadioExtractorTest.java @@ -4,7 +4,7 @@ package org.schabi.newpipe.extractor.services.bandcamp; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.schabi.newpipe.downloader.DownloaderTestImpl; +import org.schabi.newpipe.downloader.DownloaderFactory; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.services.BaseListExtractorTest; @@ -23,11 +23,12 @@ import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; */ public class BandcampRadioExtractorTest implements BaseListExtractorTest { + private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/radio"; private static BandcampRadioExtractor extractor; @BeforeAll public static void setUp() throws ExtractionException, IOException { - NewPipe.init(DownloaderTestImpl.getInstance()); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH)); extractor = (BandcampRadioExtractor) Bandcamp .getKioskList() .getExtractorById("Radio", null); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampSearchExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/search/BandcampSearchExtractorTest.java similarity index 90% rename from extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampSearchExtractorTest.java rename to extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/search/BandcampSearchExtractorTest.java index 3b4052424..684859fcb 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampSearchExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/search/BandcampSearchExtractorTest.java @@ -1,13 +1,13 @@ // Created by Fynn Godau 2019, licensed GNU GPL version 3 or later -package org.schabi.newpipe.extractor.services.bandcamp; +package org.schabi.newpipe.extractor.services.bandcamp.search; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.schabi.newpipe.downloader.DownloaderTestImpl; +import org.schabi.newpipe.downloader.DownloaderFactory; import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.NewPipe; @@ -17,6 +17,7 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem; import org.schabi.newpipe.extractor.search.SearchExtractor; import org.schabi.newpipe.extractor.services.DefaultSearchExtractorTest; +import org.schabi.newpipe.extractor.services.bandcamp.BandcampTestUtils; import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampSearchExtractor; import org.schabi.newpipe.extractor.stream.StreamInfoItem; @@ -29,10 +30,11 @@ import javax.annotation.Nullable; */ public class BandcampSearchExtractorTest { - @BeforeAll - public static void setUp() { - NewPipe.init(DownloaderTestImpl.getInstance()); + private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/search"; + @BeforeAll + public static void setUp() throws IOException { + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH)); } /** @@ -108,7 +110,7 @@ public class BandcampSearchExtractorTest { @BeforeAll public static void setUp() throws Exception { - NewPipe.init(DownloaderTestImpl.getInstance()); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "default")); extractor = Bandcamp.getSearchExtractor(QUERY); extractor.fetchPage(); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampSearchQueryHandlerFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/search/BandcampSearchQueryHandlerFactoryTest.java similarity index 85% rename from extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampSearchQueryHandlerFactoryTest.java rename to extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/search/BandcampSearchQueryHandlerFactoryTest.java index 5789c649e..298f11e1e 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampSearchQueryHandlerFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/search/BandcampSearchQueryHandlerFactoryTest.java @@ -1,11 +1,9 @@ // Created by Fynn Godau 2019, licensed GNU GPL version 3 or later -package org.schabi.newpipe.extractor.services.bandcamp; +package org.schabi.newpipe.extractor.services.bandcamp.search; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.schabi.newpipe.downloader.DownloaderTestImpl; -import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampSearchQueryHandlerFactory; @@ -18,8 +16,6 @@ public class BandcampSearchQueryHandlerFactoryTest { @BeforeAll public static void setUp() { - NewPipe.init(DownloaderTestImpl.getInstance()); - searchQuery = (BandcampSearchQueryHandlerFactory) Bandcamp .getSearchQHFactory(); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampSuggestionExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/search/BandcampSuggestionExtractorTest.java similarity index 75% rename from extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampSuggestionExtractorTest.java rename to extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/search/BandcampSuggestionExtractorTest.java index a71ab3893..63349d8dc 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampSuggestionExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/search/BandcampSuggestionExtractorTest.java @@ -1,10 +1,10 @@ // Created by Fynn Godau 2019, licensed GNU GPL version 3 or later -package org.schabi.newpipe.extractor.services.bandcamp; +package org.schabi.newpipe.extractor.services.bandcamp.search; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.schabi.newpipe.downloader.DownloaderTestImpl; +import org.schabi.newpipe.downloader.DownloaderFactory; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampSuggestionExtractor; @@ -20,11 +20,12 @@ import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; */ public class BandcampSuggestionExtractorTest { + private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/search/suggestion"; private static BandcampSuggestionExtractor extractor; @BeforeAll - public static void setUp() { - NewPipe.init(DownloaderTestImpl.getInstance()); + public static void setUp() throws IOException { + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH)); extractor = (BandcampSuggestionExtractor) Bandcamp.getSuggestionExtractor(); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPaidStreamExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/stream/BandcampPaidStreamExtractorTest.java similarity index 65% rename from extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPaidStreamExtractorTest.java rename to extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/stream/BandcampPaidStreamExtractorTest.java index 88eca9fdd..30f68540d 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPaidStreamExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/stream/BandcampPaidStreamExtractorTest.java @@ -1,20 +1,24 @@ -package org.schabi.newpipe.extractor.services.bandcamp; +package org.schabi.newpipe.extractor.services.bandcamp.stream; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.schabi.newpipe.downloader.DownloaderTestImpl; +import org.schabi.newpipe.downloader.DownloaderFactory; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.PaidContentException; +import java.io.IOException; + public class BandcampPaidStreamExtractorTest { + private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/stream/paid"; + @BeforeAll - public static void setUp() { - NewPipe.init(DownloaderTestImpl.getInstance()); + public static void setUp() throws IOException { + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH)); } @Test diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampRadioStreamExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/stream/BandcampRadioStreamExtractorTest.java similarity index 92% rename from extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampRadioStreamExtractorTest.java rename to extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/stream/BandcampRadioStreamExtractorTest.java index 920c32a7b..cb65a3f16 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampRadioStreamExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/stream/BandcampRadioStreamExtractorTest.java @@ -1,8 +1,8 @@ -package org.schabi.newpipe.extractor.services.bandcamp; +package org.schabi.newpipe.extractor.services.bandcamp.stream; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.schabi.newpipe.downloader.DownloaderTestImpl; +import org.schabi.newpipe.downloader.DownloaderFactory; import org.schabi.newpipe.extractor.ExtractorAsserts; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.StreamingService; @@ -11,6 +11,7 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest; import org.schabi.newpipe.extractor.services.DefaultTests; +import org.schabi.newpipe.extractor.services.bandcamp.BandcampTestUtils; import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampRadioStreamExtractor; import org.schabi.newpipe.extractor.stream.StreamExtractor; import org.schabi.newpipe.extractor.stream.StreamType; @@ -25,6 +26,7 @@ import static org.junit.jupiter.api.Assertions.*; import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; public class BandcampRadioStreamExtractorTest extends DefaultStreamExtractorTest { + private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/stream/radio"; private static StreamExtractor extractor; @@ -32,7 +34,7 @@ public class BandcampRadioStreamExtractorTest extends DefaultStreamExtractorTest @BeforeAll public static void setUp() throws IOException, ExtractionException { - NewPipe.init(DownloaderTestImpl.getInstance()); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH)); extractor = Bandcamp.getStreamExtractor(URL); extractor.fetchPage(); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampStreamExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/stream/BandcampStreamExtractorTest.java similarity index 91% rename from extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampStreamExtractorTest.java rename to extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/stream/BandcampStreamExtractorTest.java index 03eb2732b..d20013ca0 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampStreamExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/stream/BandcampStreamExtractorTest.java @@ -1,15 +1,16 @@ // Created by Fynn Godau 2019, licensed GNU GPL version 3 or later -package org.schabi.newpipe.extractor.services.bandcamp; +package org.schabi.newpipe.extractor.services.bandcamp.stream; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.schabi.newpipe.downloader.DownloaderTestImpl; +import org.schabi.newpipe.downloader.DownloaderFactory; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest; +import org.schabi.newpipe.extractor.services.bandcamp.BandcampTestUtils; import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper; import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampStreamExtractor; import org.schabi.newpipe.extractor.stream.StreamExtractor; @@ -27,11 +28,12 @@ import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; */ public class BandcampStreamExtractorTest extends DefaultStreamExtractorTest { + private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/stream/"; private static BandcampStreamExtractor extractor; @BeforeAll public static void setUp() throws ExtractionException, IOException { - NewPipe.init(DownloaderTestImpl.getInstance()); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH)); extractor = (BandcampStreamExtractor) Bandcamp .getStreamExtractor("https://teaganbear.bandcamp.com/track/just-for-the-halibut"); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampStreamLinkHandlerFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/stream/BandcampStreamLinkHandlerFactoryTest.java similarity index 84% rename from extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampStreamLinkHandlerFactoryTest.java rename to extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/stream/BandcampStreamLinkHandlerFactoryTest.java index f895dd351..4da1d6d04 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampStreamLinkHandlerFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/stream/BandcampStreamLinkHandlerFactoryTest.java @@ -1,14 +1,16 @@ // Created by Fynn Godau 2019, licensed GNU GPL version 3 or later -package org.schabi.newpipe.extractor.services.bandcamp; +package org.schabi.newpipe.extractor.services.bandcamp.stream; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.schabi.newpipe.downloader.DownloaderTestImpl; +import org.schabi.newpipe.downloader.DownloaderFactory; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampStreamLinkHandlerFactory; +import java.io.IOException; + import static org.junit.jupiter.api.Assertions.*; /** @@ -16,12 +18,13 @@ import static org.junit.jupiter.api.Assertions.*; */ public class BandcampStreamLinkHandlerFactoryTest { + private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/linkHandler/stream"; private static BandcampStreamLinkHandlerFactory linkHandler; @BeforeAll - public static void setUp() { + public static void setUp() throws IOException { + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH)); linkHandler = BandcampStreamLinkHandlerFactory.getInstance(); - NewPipe.init(DownloaderTestImpl.getInstance()); } @Test