[Bandcamp] Add support for mocks in unit tests

This commit is contained in:
TobiGr 2024-05-14 09:20:55 +02:00
parent fafd471606
commit 292f05f7ea
16 changed files with 83 additions and 60 deletions

View File

@ -4,7 +4,7 @@ package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; 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.NewPipe;
import org.schabi.newpipe.extractor.channel.ChannelExtractor; import org.schabi.newpipe.extractor.channel.ChannelExtractor;
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs; 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; import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
public class BandcampChannelExtractorTest implements BaseChannelExtractorTest { public class BandcampChannelExtractorTest implements BaseChannelExtractorTest {
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/channel";
private static ChannelExtractor extractor; private static ChannelExtractor extractor;
@BeforeAll @BeforeAll
public static void setUp() throws Exception { 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 = Bandcamp.getChannelExtractor("https://toupie.bandcamp.com/releases");
extractor.fetchPage(); extractor.fetchPage();
} }

View File

@ -4,23 +4,28 @@ package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; 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.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampChannelLinkHandlerFactory; import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampChannelLinkHandlerFactory;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
/** /**
* Test for {@link BandcampChannelLinkHandlerFactory} * Test for {@link BandcampChannelLinkHandlerFactory}
*/ */
public class BandcampChannelLinkHandlerFactoryTest { public class BandcampChannelLinkHandlerFactoryTest {
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/linkHandler/channel";
private static BandcampChannelLinkHandlerFactory linkHandler; private static BandcampChannelLinkHandlerFactory linkHandler;
@BeforeAll @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(); linkHandler = BandcampChannelLinkHandlerFactory.getInstance();
NewPipe.init(DownloaderTestImpl.getInstance());
} }
@Test @Test

View File

@ -1,34 +1,30 @@
package org.schabi.newpipe.extractor.services.bandcamp; package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.schabi.newpipe.downloader.DownloaderFactory;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabExtractor; import org.schabi.newpipe.extractor.channel.tabs.ChannelTabExtractor;
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs; import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs;
import org.schabi.newpipe.extractor.exceptions.ExtractionException; 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.DefaultListExtractorTest;
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampChannelTabExtractor; import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampChannelTabExtractor;
import java.io.IOException; 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.Bandcamp;
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems;
class BandcampChannelTabExtractorTest { class BandcampChannelTabExtractorTest {
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/channel/tab/";
static class Tracks extends DefaultListExtractorTest<ChannelTabExtractor> { static class Tracks extends DefaultListExtractorTest<ChannelTabExtractor> {
private static BandcampChannelTabExtractor extractor; private static BandcampChannelTabExtractor extractor;
@BeforeAll @BeforeAll
static void setUp() throws IOException, ExtractionException { static void setUp() throws IOException, ExtractionException {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "tracks"));
extractor = (BandcampChannelTabExtractor) Bandcamp extractor = (BandcampChannelTabExtractor) Bandcamp
.getChannelTabExtractorFromId("2464198920", ChannelTabs.TRACKS); .getChannelTabExtractorFromId("2464198920", ChannelTabs.TRACKS);
extractor.fetchPage(); extractor.fetchPage();
@ -49,7 +45,7 @@ class BandcampChannelTabExtractorTest {
@BeforeAll @BeforeAll
static void setUp() throws IOException, ExtractionException { static void setUp() throws IOException, ExtractionException {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "albums"));
extractor = (BandcampChannelTabExtractor) Bandcamp extractor = (BandcampChannelTabExtractor) Bandcamp
.getChannelTabExtractorFromId("2450875064", ChannelTabs.ALBUMS); .getChannelTabExtractorFromId("2450875064", ChannelTabs.ALBUMS);
extractor.fetchPage(); extractor.fetchPage();

View File

@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; 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.ListExtractor;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.comments.CommentsExtractor; import org.schabi.newpipe.extractor.comments.CommentsExtractor;
@ -20,11 +20,12 @@ import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
public class BandcampCommentsExtractorTest { public class BandcampCommentsExtractorTest {
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/comments";
private static CommentsExtractor extractor; private static CommentsExtractor extractor;
@BeforeAll @BeforeAll
public static void setUp() throws ExtractionException, IOException { 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 = Bandcamp.getCommentsExtractor("https://floatingpoints.bandcamp.com/album/promises");
extractor.fetchPage(); extractor.fetchPage();
} }

View File

@ -4,11 +4,13 @@ package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; 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.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampCommentsLinkHandlerFactory; import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampCommentsLinkHandlerFactory;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
/** /**
@ -16,12 +18,14 @@ import static org.junit.jupiter.api.Assertions.*;
*/ */
public class BandcampCommentsLinkHandlerFactoryTest { public class BandcampCommentsLinkHandlerFactoryTest {
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/linkHandler/comments";
private static BandcampCommentsLinkHandlerFactory linkHandler; private static BandcampCommentsLinkHandlerFactory linkHandler;
@BeforeAll @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(); linkHandler = BandcampCommentsLinkHandlerFactory.getInstance();
NewPipe.init(DownloaderTestImpl.getInstance());
} }
@Test @Test

View File

@ -4,7 +4,7 @@ package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; 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.NewPipe;
import org.schabi.newpipe.extractor.Page; import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ExtractionException;
@ -26,11 +26,12 @@ import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
*/ */
public class BandcampFeaturedExtractorTest implements BaseListExtractorTest { public class BandcampFeaturedExtractorTest implements BaseListExtractorTest {
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/featured";
private static BandcampFeaturedExtractor extractor; private static BandcampFeaturedExtractor extractor;
@BeforeAll @BeforeAll
public static void setUp() throws ExtractionException, IOException { public static void setUp() throws ExtractionException, IOException {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH));
extractor = (BandcampFeaturedExtractor) Bandcamp extractor = (BandcampFeaturedExtractor) Bandcamp
.getKioskList().getDefaultKioskExtractor(); .getKioskList().getDefaultKioskExtractor();
extractor.fetchPage(); extractor.fetchPage();

View File

@ -5,7 +5,7 @@ package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout; 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.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException; import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ExtractionException;
@ -36,10 +36,11 @@ import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
* Tests for {@link BandcampPlaylistExtractor} * Tests for {@link BandcampPlaylistExtractor}
*/ */
public class BandcampPlaylistExtractorTest { public class BandcampPlaylistExtractorTest {
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/playlist/";
@BeforeAll @BeforeAll
public static void setUp() { public static void setUp() throws IOException {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH));
} }
/** /**
@ -110,7 +111,7 @@ public class BandcampPlaylistExtractorTest {
@BeforeAll @BeforeAll
public static void setUp() throws ExtractionException, IOException { 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 = Bandcamp.getPlaylistExtractor("https://macbenson.bandcamp.com/album/coming-of-age");
extractor.fetchPage(); extractor.fetchPage();
} }

View File

@ -4,11 +4,13 @@ package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; 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.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampPlaylistLinkHandlerFactory; 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.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
@ -17,12 +19,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
*/ */
public class BandcampPlaylistLinkHandlerFactoryTest { public class BandcampPlaylistLinkHandlerFactoryTest {
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/linkHandler/playlist";
private static BandcampPlaylistLinkHandlerFactory linkHandler; private static BandcampPlaylistLinkHandlerFactory linkHandler;
@BeforeAll @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(); linkHandler = BandcampPlaylistLinkHandlerFactory.getInstance();
NewPipe.init(DownloaderTestImpl.getInstance());
} }
@Test @Test

View File

@ -4,7 +4,7 @@ package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; 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.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.services.BaseListExtractorTest; import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
@ -23,11 +23,12 @@ import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
*/ */
public class BandcampRadioExtractorTest implements BaseListExtractorTest { public class BandcampRadioExtractorTest implements BaseListExtractorTest {
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/radio";
private static BandcampRadioExtractor extractor; private static BandcampRadioExtractor extractor;
@BeforeAll @BeforeAll
public static void setUp() throws ExtractionException, IOException { public static void setUp() throws ExtractionException, IOException {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH));
extractor = (BandcampRadioExtractor) Bandcamp extractor = (BandcampRadioExtractor) Bandcamp
.getKioskList() .getKioskList()
.getExtractorById("Radio", null); .getExtractorById("Radio", null);

View File

@ -1,13 +1,13 @@
// Created by Fynn Godau 2019, licensed GNU GPL version 3 or later // 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.junit.jupiter.api.Assertions.assertEquals;
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; 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.InfoItem;
import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.NewPipe; 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.playlist.PlaylistInfoItem;
import org.schabi.newpipe.extractor.search.SearchExtractor; import org.schabi.newpipe.extractor.search.SearchExtractor;
import org.schabi.newpipe.extractor.services.DefaultSearchExtractorTest; 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.services.bandcamp.extractors.BandcampSearchExtractor;
import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItem;
@ -29,10 +30,11 @@ import javax.annotation.Nullable;
*/ */
public class BandcampSearchExtractorTest { public class BandcampSearchExtractorTest {
@BeforeAll private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/search";
public static void setUp() {
NewPipe.init(DownloaderTestImpl.getInstance());
@BeforeAll
public static void setUp() throws IOException {
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH));
} }
/** /**
@ -108,7 +110,7 @@ public class BandcampSearchExtractorTest {
@BeforeAll @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "default"));
extractor = Bandcamp.getSearchExtractor(QUERY); extractor = Bandcamp.getSearchExtractor(QUERY);
extractor.fetchPage(); extractor.fetchPage();
} }

View File

@ -1,11 +1,9 @@
// Created by Fynn Godau 2019, licensed GNU GPL version 3 or later // 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.BeforeAll;
import org.junit.jupiter.api.Test; 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.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampSearchQueryHandlerFactory; import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampSearchQueryHandlerFactory;
@ -18,8 +16,6 @@ public class BandcampSearchQueryHandlerFactoryTest {
@BeforeAll @BeforeAll
public static void setUp() { public static void setUp() {
NewPipe.init(DownloaderTestImpl.getInstance());
searchQuery = (BandcampSearchQueryHandlerFactory) Bandcamp searchQuery = (BandcampSearchQueryHandlerFactory) Bandcamp
.getSearchQHFactory(); .getSearchQHFactory();
} }

View File

@ -1,10 +1,10 @@
// Created by Fynn Godau 2019, licensed GNU GPL version 3 or later // 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.BeforeAll;
import org.junit.jupiter.api.Test; 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.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampSuggestionExtractor; import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampSuggestionExtractor;
@ -20,11 +20,12 @@ import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
*/ */
public class BandcampSuggestionExtractorTest { public class BandcampSuggestionExtractorTest {
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/search/suggestion";
private static BandcampSuggestionExtractor extractor; private static BandcampSuggestionExtractor extractor;
@BeforeAll @BeforeAll
public static void setUp() { public static void setUp() throws IOException {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH));
extractor = (BandcampSuggestionExtractor) Bandcamp.getSuggestionExtractor(); extractor = (BandcampSuggestionExtractor) Bandcamp.getSuggestionExtractor();
} }

View File

@ -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.junit.jupiter.api.Assertions.assertThrows;
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; 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.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.PaidContentException; import org.schabi.newpipe.extractor.exceptions.PaidContentException;
import java.io.IOException;
public class BandcampPaidStreamExtractorTest { public class BandcampPaidStreamExtractorTest {
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/stream/paid";
@BeforeAll @BeforeAll
public static void setUp() { public static void setUp() throws IOException {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH));
} }
@Test @Test

View File

@ -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.BeforeAll;
import org.junit.jupiter.api.Test; 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.ExtractorAsserts;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService; 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.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest; import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
import org.schabi.newpipe.extractor.services.DefaultTests; 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.services.bandcamp.extractors.BandcampRadioStreamExtractor;
import org.schabi.newpipe.extractor.stream.StreamExtractor; import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.stream.StreamType; 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; import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
public class BandcampRadioStreamExtractorTest extends DefaultStreamExtractorTest { public class BandcampRadioStreamExtractorTest extends DefaultStreamExtractorTest {
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/stream/radio";
private static StreamExtractor extractor; private static StreamExtractor extractor;
@ -32,7 +34,7 @@ public class BandcampRadioStreamExtractorTest extends DefaultStreamExtractorTest
@BeforeAll @BeforeAll
public static void setUp() throws IOException, ExtractionException { public static void setUp() throws IOException, ExtractionException {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH));
extractor = Bandcamp.getStreamExtractor(URL); extractor = Bandcamp.getStreamExtractor(URL);
extractor.fetchPage(); extractor.fetchPage();
} }

View File

@ -1,15 +1,16 @@
// Created by Fynn Godau 2019, licensed GNU GPL version 3 or later // 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.BeforeAll;
import org.junit.jupiter.api.Test; 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.NewPipe;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest; 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.BandcampExtractorHelper;
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampStreamExtractor; import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampStreamExtractor;
import org.schabi.newpipe.extractor.stream.StreamExtractor; import org.schabi.newpipe.extractor.stream.StreamExtractor;
@ -27,11 +28,12 @@ import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
*/ */
public class BandcampStreamExtractorTest extends DefaultStreamExtractorTest { public class BandcampStreamExtractorTest extends DefaultStreamExtractorTest {
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/stream/";
private static BandcampStreamExtractor extractor; private static BandcampStreamExtractor extractor;
@BeforeAll @BeforeAll
public static void setUp() throws ExtractionException, IOException { public static void setUp() throws ExtractionException, IOException {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH));
extractor = (BandcampStreamExtractor) Bandcamp extractor = (BandcampStreamExtractor) Bandcamp
.getStreamExtractor("https://teaganbear.bandcamp.com/track/just-for-the-halibut"); .getStreamExtractor("https://teaganbear.bandcamp.com/track/just-for-the-halibut");

View File

@ -1,14 +1,16 @@
// Created by Fynn Godau 2019, licensed GNU GPL version 3 or later // 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.BeforeAll;
import org.junit.jupiter.api.Test; 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.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampStreamLinkHandlerFactory; import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampStreamLinkHandlerFactory;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
/** /**
@ -16,12 +18,13 @@ import static org.junit.jupiter.api.Assertions.*;
*/ */
public class BandcampStreamLinkHandlerFactoryTest { public class BandcampStreamLinkHandlerFactoryTest {
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/bandcamp/extractor/linkHandler/stream";
private static BandcampStreamLinkHandlerFactory linkHandler; private static BandcampStreamLinkHandlerFactory linkHandler;
@BeforeAll @BeforeAll
public static void setUp() { public static void setUp() throws IOException {
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH));
linkHandler = BandcampStreamLinkHandlerFactory.getInstance(); linkHandler = BandcampStreamLinkHandlerFactory.getInstance();
NewPipe.init(DownloaderTestImpl.getInstance());
} }
@Test @Test