|
2 | 2 |
|
3 | 3 | import org.junit.jupiter.api.BeforeAll; |
4 | 4 | import org.junit.jupiter.api.Disabled; |
| 5 | +import org.junit.jupiter.api.Nested; |
5 | 6 | import org.junit.jupiter.api.Test; |
| 7 | +import org.junit.jupiter.api.TestInstance; |
6 | 8 | import org.schabi.newpipe.downloader.DownloaderTestImpl; |
7 | 9 | import org.schabi.newpipe.extractor.ExtractorAsserts; |
8 | 10 | import org.schabi.newpipe.extractor.MediaFormat; |
|
30 | 32 | public class SoundcloudStreamExtractorTest { |
31 | 33 | private static final String SOUNDCLOUD = "https://soundcloud.com/"; |
32 | 34 |
|
33 | | - public static class SoundcloudGeoRestrictedTrack extends DefaultStreamExtractorTest { |
| 35 | + @Nested |
| 36 | + @TestInstance(TestInstance.Lifecycle.PER_CLASS) |
| 37 | + class SoundcloudGeoRestrictedTrack extends DefaultStreamExtractorTest { |
34 | 38 | private static final String ID = "one-touch"; |
35 | 39 | private static final String UPLOADER = SOUNDCLOUD + "jessglynne"; |
36 | 40 | private static final int TIMESTAMP = 0; |
37 | 41 | private static final String URL = UPLOADER + "/" + ID + "#t=" + TIMESTAMP; |
38 | | - private static StreamExtractor extractor; |
| 42 | + private StreamExtractor extractor; |
39 | 43 |
|
40 | 44 | @BeforeAll |
41 | | - public static void setUp() throws Exception { |
| 45 | + public void setUp() throws Exception { |
| 46 | + if (extractor != null) { |
| 47 | + throw new IllegalStateException("extractor already initialized before BeforeAll"); |
| 48 | + } |
42 | 49 | NewPipe.init(DownloaderTestImpl.getInstance()); |
43 | 50 | extractor = SoundCloud.getStreamExtractor(URL); |
44 | 51 | try { |
@@ -84,15 +91,20 @@ public void testRelatedItems() throws Exception { |
84 | 91 | } |
85 | 92 | } |
86 | 93 |
|
87 | | - public static class SoundcloudGoPlusTrack extends DefaultStreamExtractorTest { |
| 94 | + @Nested |
| 95 | + @TestInstance(TestInstance.Lifecycle.PER_CLASS) |
| 96 | + class SoundcloudGoPlusTrack extends DefaultStreamExtractorTest { |
88 | 97 | private static final String ID = "places"; |
89 | 98 | private static final String UPLOADER = SOUNDCLOUD + "martinsolveig"; |
90 | 99 | private static final int TIMESTAMP = 0; |
91 | 100 | private static final String URL = UPLOADER + "/" + ID + "#t=" + TIMESTAMP; |
92 | | - private static StreamExtractor extractor; |
| 101 | + private StreamExtractor extractor; |
93 | 102 |
|
94 | 103 | @BeforeAll |
95 | | - public static void setUp() throws Exception { |
| 104 | + public void setUp() throws Exception { |
| 105 | + if (extractor != null) { |
| 106 | + throw new IllegalStateException("extractor already initialized before BeforeAll"); |
| 107 | + } |
96 | 108 | NewPipe.init(DownloaderTestImpl.getInstance()); |
97 | 109 | extractor = SoundCloud.getStreamExtractor(URL); |
98 | 110 | try { |
@@ -140,15 +152,20 @@ public void testRelatedItems() throws Exception { |
140 | 152 | @Override public String expectedCategory() { return "Dance"; } |
141 | 153 | } |
142 | 154 |
|
143 | | - static class CreativeCommonsOpenMindsEp21 extends DefaultStreamExtractorTest { |
| 155 | + @Nested |
| 156 | + @TestInstance(TestInstance.Lifecycle.PER_CLASS) |
| 157 | + class CreativeCommonsOpenMindsEp21 extends DefaultStreamExtractorTest { |
144 | 158 | private static final String ID = "open-minds-ep-21-dr-beth-harris-and-dr-steven-zucker-of-smarthistory"; |
145 | 159 | private static final String UPLOADER = SOUNDCLOUD + "wearecc"; |
146 | 160 | private static final int TIMESTAMP = 69; |
147 | 161 | private static final String URL = UPLOADER + "/" + ID + "#t=" + TIMESTAMP; |
148 | | - private static StreamExtractor extractor; |
| 162 | + private StreamExtractor extractor; |
149 | 163 |
|
150 | 164 | @BeforeAll |
151 | | - static void setUp() throws Exception { |
| 165 | + public void setUp() throws Exception { |
| 166 | + if (extractor != null) { |
| 167 | + throw new IllegalStateException("extractor already initialized before BeforeAll"); |
| 168 | + } |
152 | 169 | NewPipe.init(DownloaderTestImpl.getInstance()); |
153 | 170 | extractor = SoundCloud.getStreamExtractor(URL); |
154 | 171 | extractor.fetchPage(); |
@@ -181,6 +198,10 @@ static void setUp() throws Exception { |
181 | 198 | @Override public boolean expectedHasFrames() { return false; } |
182 | 199 | @Override public int expectedStreamSegmentsCount() { return 0; } |
183 | 200 | @Override public String expectedLicence() { return "cc-by"; } |
| 201 | + @Override public String expectedCategory() { return "Podcast"; } |
| 202 | + @Override public List<String> expectedTags() { |
| 203 | + return Arrays.asList("ants", "collaboration", "creative commons", "stigmergy", "storytelling", "wikipedia"); |
| 204 | + } |
184 | 205 |
|
185 | 206 | @Override |
186 | 207 | @Test |
|
0 commit comments