33import org .junit .BeforeClass ;
44import org .junit .Ignore ;
55import org .junit .Test ;
6+ import org .schabi .newpipe .downloader .DownloaderFactory ;
67import org .schabi .newpipe .downloader .DownloaderTestImpl ;
78import org .schabi .newpipe .extractor .NewPipe ;
89import org .schabi .newpipe .extractor .channel .ChannelExtractor ;
1213import org .schabi .newpipe .extractor .services .BaseChannelExtractorTest ;
1314import org .schabi .newpipe .extractor .services .youtube .extractors .YoutubeChannelExtractor ;
1415
15- import static org .junit .Assert .*;
16- import static org .schabi .newpipe .extractor .ExtractorAsserts .assertEmpty ;
16+ import java .io .IOException ;
17+
18+ import static org .junit .Assert .assertEquals ;
19+ import static org .junit .Assert .assertTrue ;
20+ import static org .junit .Assert .fail ;
1721import static org .schabi .newpipe .extractor .ExtractorAsserts .assertIsSecureUrl ;
1822import static org .schabi .newpipe .extractor .ServiceList .YouTube ;
19- import static org .schabi .newpipe .extractor .services .DefaultTests .*;
23+ import static org .schabi .newpipe .extractor .services .DefaultTests .defaultTestGetPageInNewExtractor ;
24+ import static org .schabi .newpipe .extractor .services .DefaultTests .defaultTestMoreItems ;
25+ import static org .schabi .newpipe .extractor .services .DefaultTests .defaultTestRelatedItems ;
2026
2127/**
2228 * Test for {@link ChannelExtractor}
2329 */
2430public class YoutubeChannelExtractorTest {
2531
32+ private static final String RESOURCE_PATH = DownloaderFactory .RESOURCE_PATH + "services/youtube/extractor/channel/" ;
33+
2634 public static class NotAvailable {
2735 @ BeforeClass
28- public static void setUp () {
29- NewPipe .init (DownloaderTestImpl .getInstance ());
36+ public static void setUp () throws IOException {
37+ YoutubeParsingHelper .resetClientVersionAndKey ();
38+ NewPipe .init (new DownloaderFactory ().getDownloader (RESOURCE_PATH + "notAvailable" ));
3039 }
3140
3241 @ Test (expected = ContentNotAvailableException .class )
@@ -46,8 +55,9 @@ public void nonExistentFetch() throws Exception {
4655
4756 public static class NotSupported {
4857 @ BeforeClass
49- public static void setUp () {
50- NewPipe .init (DownloaderTestImpl .getInstance ());
58+ public static void setUp () throws IOException {
59+ YoutubeParsingHelper .resetClientVersionAndKey ();
60+ NewPipe .init (new DownloaderFactory ().getDownloader (RESOURCE_PATH + "notSupported" ));
5161 }
5262
5363 @ Test (expected = ContentNotSupportedException .class )
@@ -63,7 +73,8 @@ public static class Gronkh implements BaseChannelExtractorTest {
6373
6474 @ BeforeClass
6575 public static void setUp () throws Exception {
66- NewPipe .init (DownloaderTestImpl .getInstance ());
76+ YoutubeParsingHelper .resetClientVersionAndKey ();
77+ NewPipe .init (new DownloaderFactory ().getDownloader (RESOURCE_PATH + "gronkh" ));
6778 extractor = (YoutubeChannelExtractor ) YouTube
6879 .getChannelExtractor ("http://www.youtube.com/user/Gronkh" );
6980 extractor .fetchPage ();
@@ -153,7 +164,8 @@ public static class VSauce implements BaseChannelExtractorTest {
153164
154165 @ BeforeClass
155166 public static void setUp () throws Exception {
156- NewPipe .init (DownloaderTestImpl .getInstance ());
167+ YoutubeParsingHelper .resetClientVersionAndKey ();
168+ NewPipe .init (new DownloaderFactory ().getDownloader (RESOURCE_PATH + "VSauce" ));
157169 extractor = (YoutubeChannelExtractor ) YouTube
158170 .getChannelExtractor ("https://www.youtube.com/user/Vsauce" );
159171 extractor .fetchPage ();
@@ -244,22 +256,13 @@ public static class Kurzgesagt implements BaseChannelExtractorTest {
244256
245257 @ BeforeClass
246258 public static void setUp () throws Exception {
247- NewPipe .init (DownloaderTestImpl .getInstance ());
259+ YoutubeParsingHelper .resetClientVersionAndKey ();
260+ NewPipe .init (new DownloaderFactory ().getDownloader (RESOURCE_PATH + "kurzgesagt" ));
248261 extractor = (YoutubeChannelExtractor ) YouTube
249262 .getChannelExtractor ("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q" );
250263 extractor .fetchPage ();
251264 }
252265
253- /*//////////////////////////////////////////////////////////////////////////
254- // Additional Testing
255- //////////////////////////////////////////////////////////////////////////*/
256-
257- @ Test
258- public void testGetPageInNewExtractor () throws Exception {
259- final ChannelExtractor newExtractor = YouTube .getChannelExtractor (extractor .getUrl ());
260- defaultTestGetPageInNewExtractor (extractor , newExtractor );
261- }
262-
263266 /*//////////////////////////////////////////////////////////////////////////
264267 // Extractor
265268 //////////////////////////////////////////////////////////////////////////*/
@@ -341,12 +344,33 @@ public void testSubscriberCount() throws Exception {
341344 }
342345 }
343346
344- public static class CaptainDisillusion implements BaseChannelExtractorTest {
347+ public static class KurzgesagtAdditional {
348+
345349 private static YoutubeChannelExtractor extractor ;
346350
347351 @ BeforeClass
348352 public static void setUp () throws Exception {
353+ // Test is not deterministic, mocks can't be used
349354 NewPipe .init (DownloaderTestImpl .getInstance ());
355+ extractor = (YoutubeChannelExtractor ) YouTube
356+ .getChannelExtractor ("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q" );
357+ extractor .fetchPage ();
358+ }
359+
360+ @ Test
361+ public void testGetPageInNewExtractor () throws Exception {
362+ final ChannelExtractor newExtractor = YouTube .getChannelExtractor (extractor .getUrl ());
363+ defaultTestGetPageInNewExtractor (extractor , newExtractor );
364+ }
365+ }
366+
367+ public static class CaptainDisillusion implements BaseChannelExtractorTest {
368+ private static YoutubeChannelExtractor extractor ;
369+
370+ @ BeforeClass
371+ public static void setUp () throws Exception {
372+ YoutubeParsingHelper .resetClientVersionAndKey ();
373+ NewPipe .init (new DownloaderFactory ().getDownloader (RESOURCE_PATH + "captainDisillusion" ));
350374 extractor = (YoutubeChannelExtractor ) YouTube
351375 .getChannelExtractor ("https://www.youtube.com/user/CaptainDisillusion/videos" );
352376 extractor .fetchPage ();
@@ -435,7 +459,8 @@ public static class RandomChannel implements BaseChannelExtractorTest {
435459
436460 @ BeforeClass
437461 public static void setUp () throws Exception {
438- NewPipe .init (DownloaderTestImpl .getInstance ());
462+ YoutubeParsingHelper .resetClientVersionAndKey ();
463+ NewPipe .init (new DownloaderFactory ().getDownloader (RESOURCE_PATH + "random" ));
439464 extractor = (YoutubeChannelExtractor ) YouTube
440465 .getChannelExtractor ("https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w" );
441466 extractor .fetchPage ();
0 commit comments