Merge pull request #768 from litetex/junit-5

JUnit 5
This commit is contained in:
Stypox 2022-01-24 16:56:16 +01:00 committed by GitHub
commit 59e0aeba88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
116 changed files with 3172 additions and 1220 deletions

View File

@ -29,7 +29,7 @@ allprojects {
ext { ext {
nanojsonVersion = "1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751" nanojsonVersion = "1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751"
spotbugsVersion = "4.5.2" spotbugsVersion = "4.5.2"
junitVersion = "4.13.2" junitVersion = "5.8.2"
} }
} }

View File

@ -3,6 +3,7 @@ test {
if (System.properties.containsKey('downloader')) { if (System.properties.containsKey('downloader')) {
systemProperty('downloader', System.getProperty('downloader')) systemProperty('downloader', System.getProperty('downloader'))
} }
useJUnitPlatform()
} }
dependencies { dependencies {
@ -14,7 +15,11 @@ dependencies {
implementation "com.github.spotbugs:spotbugs-annotations:$spotbugsVersion" implementation "com.github.spotbugs:spotbugs-annotations:$spotbugsVersion"
implementation 'org.nibor.autolink:autolink:0.10.0' implementation 'org.nibor.autolink:autolink:0.10.0'
testImplementation "junit:junit:$junitVersion" testImplementation platform("org.junit:junit-bom:$junitVersion")
testImplementation 'org.junit.jupiter:junit-jupiter-api'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testImplementation 'org.junit.jupiter:junit-jupiter-params'
testImplementation "com.squareup.okhttp3:okhttp:3.12.13" testImplementation "com.squareup.okhttp3:okhttp:3.12.13"
testImplementation 'com.google.code.gson:gson:2.8.9' testImplementation 'com.google.code.gson:gson:2.8.9'
} }

View File

@ -41,7 +41,7 @@ import static org.schabi.newpipe.extractor.utils.Utils.*;
public class SoundcloudParsingHelper { public class SoundcloudParsingHelper {
static final String HARDCODED_CLIENT_ID = static final String HARDCODED_CLIENT_ID =
"1NKODbzHzEpoowFHxTAmS7oB08DObPuK"; // Updated on 08/12/21 "JpcTFmpEz9lMPDrM6TDAC9izag7Be06D"; // Updated on 2022-01-07
private static String clientId; private static String clientId;
public static final String SOUNDCLOUD_API_V2_URL = "https://api-v2.soundcloud.com/"; public static final String SOUNDCLOUD_API_V2_URL = "https://api-v2.soundcloud.com/";

View File

@ -20,13 +20,14 @@ import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.function.IntUnaryOperator;
import static org.schabi.newpipe.extractor.services.soundcloud.linkHandler.SoundcloudSearchQueryHandlerFactory.ITEMS_PER_PAGE; import static org.schabi.newpipe.extractor.services.soundcloud.linkHandler.SoundcloudSearchQueryHandlerFactory.ITEMS_PER_PAGE;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING; import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
public class SoundcloudSearchExtractor extends SearchExtractor { public class SoundcloudSearchExtractor extends SearchExtractor {
private JsonArray searchCollection; private JsonArray initialSearchCollection;
public SoundcloudSearchExtractor(final StreamingService service, public SoundcloudSearchExtractor(final StreamingService service,
final SearchQueryHandler linkHandler) { final SearchQueryHandler linkHandler) {
@ -53,8 +54,9 @@ public class SoundcloudSearchExtractor extends SearchExtractor {
@Nonnull @Nonnull
@Override @Override
public InfoItemsPage<InfoItem> getInitialPage() throws IOException, ExtractionException { public InfoItemsPage<InfoItem> getInitialPage() throws IOException, ExtractionException {
return new InfoItemsPage<>(collectItems(searchCollection), getNextPageFromCurrentUrl( return new InfoItemsPage<>(
getUrl())); collectItems(initialSearchCollection),
getNextPageFromCurrentUrl(getUrl(), currentOffset -> ITEMS_PER_PAGE));
} }
@Override @Override
@ -65,6 +67,7 @@ public class SoundcloudSearchExtractor extends SearchExtractor {
} }
final Downloader dl = getDownloader(); final Downloader dl = getDownloader();
final JsonArray searchCollection;
try { try {
final String response = dl.get(page.getUrl(), getExtractorLocalization()) final String response = dl.get(page.getUrl(), getExtractorLocalization())
.responseBody(); .responseBody();
@ -73,8 +76,9 @@ public class SoundcloudSearchExtractor extends SearchExtractor {
throw new ParsingException("Could not parse json response", e); throw new ParsingException("Could not parse json response", e);
} }
return new InfoItemsPage<>(collectItems(searchCollection), getNextPageFromCurrentUrl(page return new InfoItemsPage<>(
.getUrl())); collectItems(searchCollection),
getNextPageFromCurrentUrl(page.getUrl(), currentOffset -> currentOffset + ITEMS_PER_PAGE));
} }
@Override @Override
@ -84,12 +88,12 @@ public class SoundcloudSearchExtractor extends SearchExtractor {
final String url = getUrl(); final String url = getUrl();
try { try {
final String response = dl.get(url, getExtractorLocalization()).responseBody(); final String response = dl.get(url, getExtractorLocalization()).responseBody();
searchCollection = JsonParser.object().from(response).getArray("collection"); initialSearchCollection = JsonParser.object().from(response).getArray("collection");
} catch (final JsonParserException e) { } catch (final JsonParserException e) {
throw new ParsingException("Could not parse json response", e); throw new ParsingException("Could not parse json response", e);
} }
if (searchCollection.isEmpty()) { if (initialSearchCollection.isEmpty()) {
throw new SearchExtractor.NothingFoundException("Nothing found"); throw new SearchExtractor.NothingFoundException("Nothing found");
} }
} }
@ -118,12 +122,14 @@ public class SoundcloudSearchExtractor extends SearchExtractor {
return collector; return collector;
} }
private Page getNextPageFromCurrentUrl(final String currentUrl) private Page getNextPageFromCurrentUrl(final String currentUrl, final IntUnaryOperator newPageOffsetCalculator)
throws MalformedURLException, UnsupportedEncodingException { throws MalformedURLException, UnsupportedEncodingException {
final int pageOffset = Integer.parseInt( final int currentPageOffset = Integer.parseInt(
Parser.compatParseMap(new URL(currentUrl).getQuery()).get("offset")); Parser.compatParseMap(new URL(currentUrl).getQuery()).get("offset"));
return new Page(currentUrl.replace("&offset=" + pageOffset, "&offset=" return new Page(
+ (pageOffset + ITEMS_PER_PAGE))); currentUrl.replace(
"&offset=" + currentPageOffset,
"&offset=" + newPageOffsetCalculator.applyAsInt(currentPageOffset)));
} }
} }

View File

@ -1,25 +0,0 @@
package org.schabi.newpipe;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.annotation.Nonnull;
/**
* Marker annotation to skip test in certain cases.
*
* {@link MockOnlyRule}
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@Inherited
public @interface MockOnly {
/**
* Explanation why this test should be skipped
*/
@Nonnull String reason();
}

View File

@ -1,51 +0,0 @@
package org.schabi.newpipe;
import org.junit.Assume;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.schabi.newpipe.downloader.DownloaderType;
import javax.annotation.Nonnull;
/**
*
* <p>
* Allows skipping unreliable or time sensitive tests in CI pipeline.
* </p>
*
* <p>
* Use it by creating a public variable of this inside the test class and annotate it with
* {@link org.junit.Rule}. Then annotate the specific tests to be skipped with {@link MockOnly}
* </p>
*
* <p>
* It works by checking if the system variable "downloader" is set to "REAL" and skips the tests if it is.
* Otherwise it executes the test.
* </p>
*/
public class MockOnlyRule implements TestRule {
final String downloader = System.getProperty("downloader");
@Override
@Nonnull
public Statement apply(@Nonnull Statement base, @Nonnull Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
final MockOnly annotation = description.getAnnotation(MockOnly.class);
if (annotation != null) {
final boolean isMockDownloader = downloader == null ||
!downloader.equalsIgnoreCase(DownloaderType.REAL.toString());
Assume.assumeTrue("The test is not reliable against real website. Reason: "
+ annotation.reason(), isMockDownloader);
}
base.evaluate();
}
};
}
}

View File

@ -4,18 +4,16 @@ import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import static org.junit.Assert.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.Assert.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.Assert.assertTrue;
public class ExtractorAsserts { public class ExtractorAsserts {
public static void assertEmptyErrors(String message, List<Throwable> errors) { public static void assertEmptyErrors(String message, List<Throwable> errors) {
@ -44,7 +42,7 @@ public class ExtractorAsserts {
public static void assertIsSecureUrl(String urlToCheck) { public static void assertIsSecureUrl(String urlToCheck) {
URL url = urlFromString(urlToCheck); URL url = urlFromString(urlToCheck);
assertEquals("Protocol of URL is not secure", "https", url.getProtocol()); assertEquals("https", url.getProtocol(), "Protocol of URL is not secure");
} }
public static void assertNotEmpty(String stringToCheck) { public static void assertNotEmpty(String stringToCheck) {
@ -53,7 +51,7 @@ public class ExtractorAsserts {
public static void assertNotEmpty(@Nullable String message, String stringToCheck) { public static void assertNotEmpty(@Nullable String message, String stringToCheck) {
assertNotNull(message, stringToCheck); assertNotNull(message, stringToCheck);
assertFalse(message, stringToCheck.isEmpty()); assertFalse(stringToCheck.isEmpty(), message);
} }
public static void assertEmpty(String stringToCheck) { public static void assertEmpty(String stringToCheck) {
@ -62,12 +60,56 @@ public class ExtractorAsserts {
public static void assertEmpty(@Nullable String message, String stringToCheck) { public static void assertEmpty(@Nullable String message, String stringToCheck) {
if (stringToCheck != null) { if (stringToCheck != null) {
assertTrue(message, stringToCheck.isEmpty()); assertTrue(stringToCheck.isEmpty(), message);
} }
} }
public static void assertAtLeast(long expected, long actual) { public static void assertGreater(final long expected, final long actual) {
assertTrue(actual + " is not at least " + expected, actual >= expected); assertGreater(expected, actual, actual + " is not > " + expected);
}
public static void assertGreater(
final long expected,
final long actual,
final String message
) {
assertTrue(actual > expected, message);
}
public static void assertGreaterOrEqual(final long expected, final long actual) {
assertGreaterOrEqual(expected, actual, actual + " is not >= " + expected);
}
public static void assertGreaterOrEqual(
final long expected,
final long actual,
final String message
) {
assertTrue(actual >= expected, message);
}
public static void assertLess(final long expected, final long actual) {
assertLess(expected, actual, actual + " is not < " + expected);
}
public static void assertLess(
final long expected,
final long actual,
final String message
) {
assertTrue(actual < expected, message);
}
public static void assertLessOrEqual(final long expected, final long actual) {
assertLessOrEqual(expected, actual, actual + " is not <= " + expected);
}
public static void assertLessOrEqual(
final long expected,
final long actual,
final String message
) {
assertTrue(actual <= expected, message);
} }
// this assumes that sorting a and b in-place is not an issue, so it's only intended for tests // this assumes that sorting a and b in-place is not an issue, so it's only intended for tests
@ -85,4 +127,13 @@ public class ExtractorAsserts {
// using new ArrayList<> to make sure the type is the same // using new ArrayList<> to make sure the type is the same
assertEquals(new ArrayList<>(expected), new ArrayList<>(actual)); assertEquals(new ArrayList<>(expected), new ArrayList<>(actual));
} }
public static void assertContains(
final String shouldBeContained,
final String container) {
assertNotNull(shouldBeContained, "shouldBeContained is null");
assertNotNull(container, "container is null");
assertTrue(container.contains(shouldBeContained),
"'" + shouldBeContained + "' should be contained inside '" + container +"'");
}
} }

View File

@ -1,10 +1,10 @@
package org.schabi.newpipe.extractor; package org.schabi.newpipe.extractor;
import org.junit.Test; import org.junit.jupiter.api.Test;
import java.util.HashSet; import java.util.HashSet;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import static org.schabi.newpipe.extractor.NewPipe.getServiceByUrl; import static org.schabi.newpipe.extractor.NewPipe.getServiceByUrl;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.ServiceList.YouTube;
@ -19,9 +19,11 @@ public class NewPipeTest {
public void testAllServicesHaveDifferentId() throws Exception { public void testAllServicesHaveDifferentId() throws Exception {
HashSet<Integer> servicesId = new HashSet<>(); HashSet<Integer> servicesId = new HashSet<>();
for (StreamingService streamingService : NewPipe.getServices()) { for (StreamingService streamingService : NewPipe.getServices()) {
String errorMsg = "There are services with the same id = " + streamingService.getServiceId() + " (current service > " + streamingService.getServiceInfo().getName() + ")"; final String errorMsg =
"There are services with the same id = " + streamingService.getServiceId()
+ " (current service > " + streamingService.getServiceInfo().getName() + ")";
assertTrue(errorMsg, servicesId.add(streamingService.getServiceId())); assertTrue(servicesId.add(streamingService.getServiceId()), errorMsg);
} }
} }

View File

@ -1,11 +1,11 @@
package org.schabi.newpipe.extractor.services; package org.schabi.newpipe.extractor.services;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.extractor.Extractor; import org.schabi.newpipe.extractor.Extractor;
import org.schabi.newpipe.extractor.ExtractorAsserts;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
import static org.hamcrest.CoreMatchers.*; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.Assert.*;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
public abstract class DefaultExtractorTest<T extends Extractor> implements BaseExtractorTest { public abstract class DefaultExtractorTest<T extends Extractor> implements BaseExtractorTest {
@ -40,7 +40,7 @@ public abstract class DefaultExtractorTest<T extends Extractor> implements BaseE
public void testUrl() throws Exception { public void testUrl() throws Exception {
final String url = extractor().getUrl(); final String url = extractor().getUrl();
assertIsSecureUrl(url); assertIsSecureUrl(url);
assertThat(url, containsString(expectedUrlContains())); ExtractorAsserts.assertContains(expectedUrlContains(), url);
} }
@Test @Test
@ -48,6 +48,6 @@ public abstract class DefaultExtractorTest<T extends Extractor> implements BaseE
public void testOriginalUrl() throws Exception { public void testOriginalUrl() throws Exception {
final String originalUrl = extractor().getOriginalUrl(); final String originalUrl = extractor().getOriginalUrl();
assertIsSecureUrl(originalUrl); assertIsSecureUrl(originalUrl);
assertThat(originalUrl, containsString(expectedOriginalUrlContains())); ExtractorAsserts.assertContains(expectedOriginalUrlContains(), originalUrl);
} }
} }

View File

@ -1,6 +1,6 @@
package org.schabi.newpipe.extractor.services; package org.schabi.newpipe.extractor.services;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.ListExtractor;

View File

@ -1,6 +1,6 @@
package org.schabi.newpipe.extractor.services; package org.schabi.newpipe.extractor.services;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.extractor.MetaInfo; import org.schabi.newpipe.extractor.MetaInfo;
import org.schabi.newpipe.extractor.search.SearchExtractor; import org.schabi.newpipe.extractor.search.SearchExtractor;
@ -13,8 +13,8 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;

View File

@ -1,6 +1,7 @@
package org.schabi.newpipe.extractor.services; package org.schabi.newpipe.extractor.services;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.extractor.ExtractorAsserts;
import org.schabi.newpipe.extractor.InfoItemsCollector; import org.schabi.newpipe.extractor.InfoItemsCollector;
import org.schabi.newpipe.extractor.MediaFormat; import org.schabi.newpipe.extractor.MediaFormat;
import org.schabi.newpipe.extractor.MetaInfo; import org.schabi.newpipe.extractor.MetaInfo;
@ -23,14 +24,12 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.hamcrest.CoreMatchers.containsString; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.Assert.assertNull; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertGreaterOrEqual;
import static org.junit.Assert.assertTrue;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertAtLeast;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEqualsOrderIndependent; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEqualsOrderIndependent;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsValidUrl; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsValidUrl;
@ -149,13 +148,13 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
assertNotNull(description); assertNotNull(description);
if (expectedDescriptionIsEmpty()) { if (expectedDescriptionIsEmpty()) {
assertTrue("description is not empty", description.getContent().isEmpty()); assertTrue(description.getContent().isEmpty(), "description is not empty");
} else { } else {
assertFalse("description is empty", description.getContent().isEmpty()); assertFalse(description.getContent().isEmpty(), "description is empty");
} }
for (final String s : expectedDescriptionContains()) { for (final String s : expectedDescriptionContains()) {
assertThat(description.getContent(), containsString(s)); ExtractorAsserts.assertContains(s, description.getContent());
} }
} }
@ -174,7 +173,7 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
@Test @Test
@Override @Override
public void testViewCount() throws Exception { public void testViewCount() throws Exception {
assertAtLeast(expectedViewCountAtLeast(), extractor().getViewCount()); assertGreaterOrEqual(expectedViewCountAtLeast(), extractor().getViewCount());
} }
@Test @Test
@ -207,7 +206,7 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
if (expectedLikeCountAtLeast() == -1) { if (expectedLikeCountAtLeast() == -1) {
assertEquals(-1, extractor().getLikeCount()); assertEquals(-1, extractor().getLikeCount());
} else { } else {
assertAtLeast(expectedLikeCountAtLeast(), extractor().getLikeCount()); assertGreaterOrEqual(expectedLikeCountAtLeast(), extractor().getLikeCount());
} }
} }
@ -217,7 +216,7 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
if (expectedDislikeCountAtLeast() == -1) { if (expectedDislikeCountAtLeast() == -1) {
assertEquals(-1, extractor().getDislikeCount()); assertEquals(-1, extractor().getDislikeCount());
} else { } else {
assertAtLeast(expectedDislikeCountAtLeast(), extractor().getDislikeCount()); assertGreaterOrEqual(expectedDislikeCountAtLeast(), extractor().getDislikeCount());
} }
} }
@ -265,8 +264,8 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
final int formatId = stream.getFormatId(); final int formatId = stream.getFormatId();
// see MediaFormat: video stream formats range from 0 to 0x100 // see MediaFormat: video stream formats range from 0 to 0x100
assertTrue("format id does not fit a video stream: " + formatId, assertTrue(0 <= formatId && formatId < 0x100,
0 <= formatId && formatId < 0x100); "format id does not fit a video stream: " + formatId);
} }
} else { } else {
assertTrue(videoStreams.isEmpty()); assertTrue(videoStreams.isEmpty());
@ -287,8 +286,8 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
final int formatId = stream.getFormatId(); final int formatId = stream.getFormatId();
// see MediaFormat: video stream formats range from 0x100 to 0x1000 // see MediaFormat: video stream formats range from 0x100 to 0x1000
assertTrue("format id does not fit an audio stream: " + formatId, assertTrue(0x100 <= formatId && formatId < 0x1000,
0x100 <= formatId && formatId < 0x1000); "format id does not fit an audio stream: " + formatId);
} }
} else { } else {
assertTrue(audioStreams.isEmpty()); assertTrue(audioStreams.isEmpty());
@ -309,8 +308,8 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
final int formatId = stream.getFormatId(); final int formatId = stream.getFormatId();
// see MediaFormat: video stream formats range from 0x1000 to 0x10000 // see MediaFormat: video stream formats range from 0x1000 to 0x10000
assertTrue("format id does not fit a subtitles stream: " + formatId, assertTrue(0x1000 <= formatId && formatId < 0x10000,
0x1000 <= formatId && formatId < 0x10000); "format id does not fit a subtitles stream: " + formatId);
} }
} else { } else {
assertTrue(subtitles.isEmpty()); assertTrue(subtitles.isEmpty());
@ -333,7 +332,7 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
assertTrue(dashMpdUrl.isEmpty()); assertTrue(dashMpdUrl.isEmpty());
} else { } else {
assertIsSecureUrl(dashMpdUrl); assertIsSecureUrl(dashMpdUrl);
assertThat(extractor().getDashMpdUrl(), containsString(expectedDashMpdUrlContains())); ExtractorAsserts.assertContains(expectedDashMpdUrlContains(), extractor().getDashMpdUrl());
} }
} }

View File

@ -14,16 +14,15 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import static junit.framework.TestCase.assertFalse; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.Assert.*;
import static org.schabi.newpipe.extractor.ExtractorAsserts.*; import static org.schabi.newpipe.extractor.ExtractorAsserts.*;
import static org.schabi.newpipe.extractor.StreamingService.LinkType; import static org.schabi.newpipe.extractor.StreamingService.LinkType;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
public final class DefaultTests { public final class DefaultTests {
public static void defaultTestListOfItems(StreamingService expectedService, List<? extends InfoItem> itemsList, List<Throwable> errors) throws ParsingException { public static void defaultTestListOfItems(StreamingService expectedService, List<? extends InfoItem> itemsList, List<Throwable> errors) throws ParsingException {
assertFalse("List of items is empty", itemsList.isEmpty()); assertFalse(itemsList.isEmpty(), "List of items is empty");
assertFalse("List of items contains a null element", itemsList.contains(null)); assertFalse(itemsList.contains(null), "List of items contains a null element");
assertEmptyErrors("Errors during extraction", errors); assertEmptyErrors("Errors during extraction", errors);
for (InfoItem item : itemsList) { for (InfoItem item : itemsList) {
@ -33,8 +32,8 @@ public final class DefaultTests {
if (!isNullOrEmpty(thumbnailUrl)) { if (!isNullOrEmpty(thumbnailUrl)) {
assertIsSecureUrl(thumbnailUrl); assertIsSecureUrl(thumbnailUrl);
} }
assertNotNull("InfoItem type not set: " + item, item.getInfoType()); assertNotNull(item.getInfoType(), "InfoItem type not set: " + item);
assertEquals("Unexpected item service id", expectedService.getServiceId(), item.getServiceId()); assertEquals(expectedService.getServiceId(), item.getServiceId(), "Unexpected item service id");
assertNotEmpty("Item name not set: " + item, item.getName()); assertNotEmpty("Item name not set: " + item, item.getName());
if (item instanceof StreamInfoItem) { if (item instanceof StreamInfoItem) {
@ -57,7 +56,7 @@ public final class DefaultTests {
if (!isNullOrEmpty(streamInfoItem.getTextualUploadDate())) { if (!isNullOrEmpty(streamInfoItem.getTextualUploadDate())) {
final DateWrapper uploadDate = streamInfoItem.getUploadDate(); final DateWrapper uploadDate = streamInfoItem.getUploadDate();
assertNotNull("No parsed upload date", uploadDate); assertNotNull(uploadDate,"No parsed upload date");
} }
} else if (item instanceof ChannelInfoItem) { } else if (item instanceof ChannelInfoItem) {
@ -74,22 +73,22 @@ public final class DefaultTests {
private static void assertExpectedLinkType(StreamingService expectedService, String url, LinkType expectedLinkType) throws ParsingException { private static void assertExpectedLinkType(StreamingService expectedService, String url, LinkType expectedLinkType) throws ParsingException {
final LinkType linkTypeByUrl = expectedService.getLinkTypeByUrl(url); final LinkType linkTypeByUrl = expectedService.getLinkTypeByUrl(url);
assertNotEquals("Url is not recognized by its own service: \"" + url + "\"", assertNotEquals(LinkType.NONE, linkTypeByUrl,
LinkType.NONE, linkTypeByUrl); "Url is not recognized by its own service: \"" + url + "\"");
assertEquals("Service returned wrong link type for: \"" + url + "\"", assertEquals(expectedLinkType, linkTypeByUrl,
expectedLinkType, linkTypeByUrl); "Service returned wrong link type for: \"" + url + "\"");
} }
public static void assertOnlyContainsType(ListExtractor.InfoItemsPage<? extends InfoItem> items, InfoItem.InfoType expectedType) { public static void assertOnlyContainsType(ListExtractor.InfoItemsPage<? extends InfoItem> items, InfoItem.InfoType expectedType) {
for (InfoItem item : items.getItems()) { for (InfoItem item : items.getItems()) {
assertEquals("Item list contains unexpected info types", assertEquals(expectedType, item.getInfoType(),
expectedType, item.getInfoType()); "Item list contains unexpected info types");
} }
} }
public static <T extends InfoItem> void assertNoMoreItems(ListExtractor<T> extractor) throws Exception { public static <T extends InfoItem> void assertNoMoreItems(ListExtractor<T> extractor) throws Exception {
final ListExtractor.InfoItemsPage<T> initialPage = extractor.getInitialPage(); final ListExtractor.InfoItemsPage<T> initialPage = extractor.getInitialPage();
assertFalse("More items available when it shouldn't", initialPage.hasNextPage()); assertFalse(initialPage.hasNextPage(), "More items available when it shouldn't");
} }
public static void assertNoDuplicatedItems(StreamingService expectedService, public static void assertNoDuplicatedItems(StreamingService expectedService,
@ -122,10 +121,10 @@ public final class DefaultTests {
public static <T extends InfoItem> ListExtractor.InfoItemsPage<T> defaultTestMoreItems(ListExtractor<T> extractor) throws Exception { public static <T extends InfoItem> ListExtractor.InfoItemsPage<T> defaultTestMoreItems(ListExtractor<T> extractor) throws Exception {
final ListExtractor.InfoItemsPage<T> initialPage = extractor.getInitialPage(); final ListExtractor.InfoItemsPage<T> initialPage = extractor.getInitialPage();
assertTrue("Doesn't have more items", initialPage.hasNextPage()); assertTrue(initialPage.hasNextPage(), "Doesn't have more items");
ListExtractor.InfoItemsPage<T> nextPage = extractor.getPage(initialPage.getNextPage()); ListExtractor.InfoItemsPage<T> nextPage = extractor.getPage(initialPage.getNextPage());
final List<T> items = nextPage.getItems(); final List<T> items = nextPage.getItems();
assertFalse("Next page is empty", items.isEmpty()); assertFalse(items.isEmpty(), "Next page is empty");
assertEmptyErrors("Next page have errors", nextPage.getErrors()); assertEmptyErrors("Next page have errors", nextPage.getErrors());
defaultTestListOfItems(extractor.getService(), nextPage.getItems(), nextPage.getErrors()); defaultTestListOfItems(extractor.getService(), nextPage.getItems(), nextPage.getErrors());

View File

@ -2,8 +2,8 @@
package org.schabi.newpipe.extractor.services.bandcamp; package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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;
@ -12,14 +12,14 @@ import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
import java.io.IOException; import java.io.IOException;
import static org.junit.Assert.*; 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 BandcampChannelExtractorTest implements BaseChannelExtractorTest { public class BandcampChannelExtractorTest implements BaseChannelExtractorTest {
private static ChannelExtractor extractor; private static ChannelExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = Bandcamp.getChannelExtractor("https://toupie.bandcamp.com/releases"); extractor = Bandcamp.getChannelExtractor("https://toupie.bandcamp.com/releases");
@ -39,12 +39,12 @@ public class BandcampChannelExtractorTest implements BaseChannelExtractorTest {
@Override @Override
public void testAvatarUrl() throws Exception { public void testAvatarUrl() throws Exception {
assertTrue("unexpected avatar URL", extractor.getAvatarUrl().contains("://f4.bcbits.com/")); assertTrue(extractor.getAvatarUrl().contains("://f4.bcbits.com/"), "unexpected avatar URL");
} }
@Override @Override
public void testBannerUrl() throws Exception { public void testBannerUrl() throws Exception {
assertTrue("unexpected banner URL", extractor.getBannerUrl().contains("://f4.bcbits.com/")); assertTrue(extractor.getBannerUrl().contains("://f4.bcbits.com/"), "unexpected banner URL");
} }
@Override @Override

View File

@ -2,14 +2,14 @@
package org.schabi.newpipe.extractor.services.bandcamp; package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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 static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
/** /**
* Test for {@link BandcampChannelLinkHandlerFactory} * Test for {@link BandcampChannelLinkHandlerFactory}
@ -17,7 +17,7 @@ import static org.junit.Assert.*;
public class BandcampChannelLinkHandlerFactoryTest { public class BandcampChannelLinkHandlerFactoryTest {
private static BandcampChannelLinkHandlerFactory linkHandler; private static BandcampChannelLinkHandlerFactory linkHandler;
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
linkHandler = new BandcampChannelLinkHandlerFactory(); linkHandler = new BandcampChannelLinkHandlerFactory();
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
@ -73,14 +73,14 @@ public class BandcampChannelLinkHandlerFactoryTest {
assertEquals("https://lobstertheremin.com", linkHandler.getUrl("2735462545")); assertEquals("https://lobstertheremin.com", linkHandler.getUrl("2735462545"));
} }
@Test(expected = ParsingException.class) @Test
public void testGetUrlWithInvalidId() throws ParsingException { public void testGetUrlWithInvalidId() {
linkHandler.getUrl("0"); assertThrows(ParsingException.class, () -> linkHandler.getUrl("0"));
} }
@Test(expected = ParsingException.class) @Test
public void testGetIdWithInvalidUrl() throws ParsingException { public void testGetIdWithInvalidUrl() {
linkHandler.getId("https://bandcamp.com"); assertThrows(ParsingException.class, () -> linkHandler.getUrl("https://bandcamp.com"));
} }
} }

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.bandcamp; package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
@ -13,16 +13,16 @@ import org.schabi.newpipe.extractor.utils.Utils;
import java.io.IOException; import java.io.IOException;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
public class BandcampCommentsExtractorTest { public class BandcampCommentsExtractorTest {
private static CommentsExtractor extractor; private static CommentsExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws ExtractionException, IOException { public static void setUp() throws ExtractionException, IOException {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = Bandcamp.getCommentsExtractor("https://floatingpoints.bandcamp.com/album/promises"); extractor = Bandcamp.getCommentsExtractor("https://floatingpoints.bandcamp.com/album/promises");

View File

@ -2,15 +2,14 @@
package org.schabi.newpipe.extractor.services.bandcamp; package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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 org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampStreamLinkHandlerFactory;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
/** /**
* Test for {@link BandcampCommentsLinkHandlerFactory} * Test for {@link BandcampCommentsLinkHandlerFactory}
@ -19,7 +18,7 @@ public class BandcampCommentsLinkHandlerFactoryTest {
private static BandcampCommentsLinkHandlerFactory linkHandler; private static BandcampCommentsLinkHandlerFactory linkHandler;
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
linkHandler = new BandcampCommentsLinkHandlerFactory(); linkHandler = new BandcampCommentsLinkHandlerFactory();
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());

View File

@ -2,8 +2,8 @@
package org.schabi.newpipe.extractor.services.bandcamp; package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.Page; import org.schabi.newpipe.extractor.Page;
@ -16,9 +16,9 @@ import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampFeature
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
/** /**
@ -28,7 +28,7 @@ public class BandcampFeaturedExtractorTest implements BaseListExtractorTest {
private static BandcampFeaturedExtractor extractor; private static BandcampFeaturedExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws ExtractionException, IOException { public static void setUp() throws ExtractionException, IOException {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (BandcampFeaturedExtractor) Bandcamp extractor = (BandcampFeaturedExtractor) Bandcamp

View File

@ -2,12 +2,12 @@
package org.schabi.newpipe.extractor.services.bandcamp; package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampFeaturedLinkHandlerFactory; import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampFeaturedLinkHandlerFactory;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
/** /**
* Tests for {@link BandcampFeaturedLinkHandlerFactory} * Tests for {@link BandcampFeaturedLinkHandlerFactory}
@ -16,7 +16,7 @@ public class BandcampFeaturedLinkHandlerFactoryTest {
private static BandcampFeaturedLinkHandlerFactory linkHandler; private static BandcampFeaturedLinkHandlerFactory linkHandler;
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
linkHandler = new BandcampFeaturedLinkHandlerFactory(); linkHandler = new BandcampFeaturedLinkHandlerFactory();
} }

View File

@ -2,8 +2,9 @@
package org.schabi.newpipe.extractor.services.bandcamp; package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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;
@ -17,7 +18,7 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
/** /**
@ -25,7 +26,7 @@ import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
*/ */
public class BandcampPlaylistExtractorTest { public class BandcampPlaylistExtractorTest {
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
} }
@ -57,7 +58,8 @@ public class BandcampPlaylistExtractorTest {
/** /**
* Tests that no attempt to load every track's cover individually is made * Tests that no attempt to load every track's cover individually is made
*/ */
@Test(timeout = 10000L) @Test
@Timeout(10)
public void testDifferentTrackCoversDuration() throws ExtractionException, IOException { public void testDifferentTrackCoversDuration() throws ExtractionException, IOException {
final PlaylistExtractor extractor = Bandcamp.getPlaylistExtractor("https://infiniteammo.bandcamp.com/album/night-in-the-woods-vol-1-at-the-end-of-everything"); final PlaylistExtractor extractor = Bandcamp.getPlaylistExtractor("https://infiniteammo.bandcamp.com/album/night-in-the-woods-vol-1-at-the-end-of-everything");
extractor.fetchPage(); extractor.fetchPage();
@ -73,10 +75,11 @@ public class BandcampPlaylistExtractorTest {
/** /**
* Test playlists with locked content * Test playlists with locked content
*/ */
@Test(expected = ContentNotAvailableException.class) @Test
public void testLockedContent() throws ExtractionException, IOException { public void testLockedContent() throws ExtractionException, IOException {
final PlaylistExtractor extractor = Bandcamp.getPlaylistExtractor("https://billwurtz.bandcamp.com/album/high-enough"); final PlaylistExtractor extractor = Bandcamp.getPlaylistExtractor("https://billwurtz.bandcamp.com/album/high-enough");
extractor.fetchPage();
assertThrows(ContentNotAvailableException.class, extractor::fetchPage);
} }
/** /**
@ -95,7 +98,7 @@ public class BandcampPlaylistExtractorTest {
private static PlaylistExtractor extractor; private static PlaylistExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws ExtractionException, IOException { public static void setUp() throws ExtractionException, IOException {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = Bandcamp.getPlaylistExtractor("https://macbenson.bandcamp.com/album/coming-of-age"); extractor = Bandcamp.getPlaylistExtractor("https://macbenson.bandcamp.com/album/coming-of-age");

View File

@ -2,15 +2,15 @@
package org.schabi.newpipe.extractor.services.bandcamp; package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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 static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
/** /**
* Test for {@link BandcampPlaylistLinkHandlerFactory} * Test for {@link BandcampPlaylistLinkHandlerFactory}
@ -19,7 +19,7 @@ public class BandcampPlaylistLinkHandlerFactoryTest {
private static BandcampPlaylistLinkHandlerFactory linkHandler; private static BandcampPlaylistLinkHandlerFactory linkHandler;
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
linkHandler = new BandcampPlaylistLinkHandlerFactory(); linkHandler = new BandcampPlaylistLinkHandlerFactory();
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());

View File

@ -2,8 +2,8 @@
package org.schabi.newpipe.extractor.services.bandcamp; package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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;
@ -14,8 +14,8 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
/** /**
@ -25,7 +25,7 @@ public class BandcampRadioExtractorTest implements BaseListExtractorTest {
private static BandcampRadioExtractor extractor; private static BandcampRadioExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws ExtractionException, IOException { public static void setUp() throws ExtractionException, IOException {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (BandcampRadioExtractor) Bandcamp extractor = (BandcampRadioExtractor) Bandcamp

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.bandcamp; package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
@ -19,7 +19,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
import static org.junit.Assert.*; 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 {
@ -28,7 +28,7 @@ public class BandcampRadioStreamExtractorTest extends DefaultStreamExtractorTest
private static final String URL = "https://bandcamp.com/?show=230"; private static final String URL = "https://bandcamp.com/?show=230";
@BeforeClass @BeforeAll
public static void setUp() throws IOException, ExtractionException { public static void setUp() throws IOException, ExtractionException {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = Bandcamp.getStreamExtractor(URL); extractor = Bandcamp.getStreamExtractor(URL);
@ -56,15 +56,15 @@ public class BandcampRadioStreamExtractorTest extends DefaultStreamExtractorTest
@Override public String expectedUploaderName() { return "Andrew Jervis"; } @Override public String expectedUploaderName() { return "Andrew Jervis"; }
@Override public int expectedStreamSegmentsCount() { return 30; } @Override public int expectedStreamSegmentsCount() { return 30; }
@Test(expected = ContentNotSupportedException.class) @Test
public void testGetUploaderUrl() throws ParsingException { public void testGetUploaderUrl() {
extractor.getUploaderUrl(); assertThrows(ContentNotSupportedException.class, extractor::getUploaderUrl);
} }
@Test(expected = ContentNotSupportedException.class) @Test
@Override @Override
public void testUploaderUrl() throws Exception { public void testUploaderUrl() throws Exception {
super.testUploaderUrl(); assertThrows(ContentNotSupportedException.class, super::testUploaderUrl);
} }
@Override public String expectedUploaderUrl() { return null; } @Override public String expectedUploaderUrl() { return null; }

View File

@ -2,8 +2,8 @@
package org.schabi.newpipe.extractor.services.bandcamp; package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.*; import org.schabi.newpipe.extractor.*;
import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ExtractionException;
@ -16,8 +16,8 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
/** /**
@ -25,7 +25,7 @@ import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
*/ */
public class BandcampSearchExtractorTest { public class BandcampSearchExtractorTest {
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
@ -106,7 +106,7 @@ public class BandcampSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "noise"; private static final String QUERY = "noise";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = Bandcamp.getSearchExtractor(QUERY); extractor = Bandcamp.getSearchExtractor(QUERY);

View File

@ -2,21 +2,21 @@
package org.schabi.newpipe.extractor.services.bandcamp; package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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.BandcampSearchQueryHandlerFactory; import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampSearchQueryHandlerFactory;
import static org.junit.Assert.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;
public class BandcampSearchQueryHandlerFactoryTest { public class BandcampSearchQueryHandlerFactoryTest {
static BandcampSearchQueryHandlerFactory searchQuery; static BandcampSearchQueryHandlerFactory searchQuery;
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());

View File

@ -2,8 +2,8 @@
package org.schabi.newpipe.extractor.services.bandcamp; package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
@ -19,8 +19,8 @@ import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
/** /**
@ -30,7 +30,7 @@ public class BandcampStreamExtractorTest extends DefaultStreamExtractorTest {
private static BandcampStreamExtractor extractor; private static BandcampStreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws ExtractionException, IOException { public static void setUp() throws ExtractionException, IOException {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());

View File

@ -2,14 +2,14 @@
package org.schabi.newpipe.extractor.services.bandcamp; package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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 static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
/** /**
* Test for {@link BandcampStreamLinkHandlerFactory} * Test for {@link BandcampStreamLinkHandlerFactory}
@ -18,7 +18,7 @@ public class BandcampStreamLinkHandlerFactoryTest {
private static BandcampStreamLinkHandlerFactory linkHandler; private static BandcampStreamLinkHandlerFactory linkHandler;
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
linkHandler = new BandcampStreamLinkHandlerFactory(); linkHandler = new BandcampStreamLinkHandlerFactory();
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());

View File

@ -2,8 +2,8 @@
package org.schabi.newpipe.extractor.services.bandcamp; package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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;
@ -12,7 +12,7 @@ import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampSuggest
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp; import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
/** /**
@ -22,7 +22,7 @@ public class BandcampSuggestionExtractorTest {
private static BandcampSuggestionExtractor extractor; private static BandcampSuggestionExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (BandcampSuggestionExtractor) Bandcamp.getSuggestionExtractor(); extractor = (BandcampSuggestionExtractor) Bandcamp.getSuggestionExtractor();

View File

@ -1,13 +1,13 @@
package org.schabi.newpipe.extractor.services.media_ccc; package org.schabi.newpipe.extractor.services.media_ccc;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCConferenceExtractor; import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCConferenceExtractor;
import static junit.framework.TestCase.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC; import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
/** /**
@ -17,7 +17,7 @@ public class MediaCCCConferenceExtractorTest {
public static class FrOSCon2017 { public static class FrOSCon2017 {
private static MediaCCCConferenceExtractor extractor; private static MediaCCCConferenceExtractor extractor;
@BeforeClass @BeforeAll
public static void setUpClass() throws Exception { public static void setUpClass() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (MediaCCCConferenceExtractor) MediaCCC.getChannelExtractor("https://media.ccc.de/c/froscon2017"); extractor = (MediaCCCConferenceExtractor) MediaCCC.getChannelExtractor("https://media.ccc.de/c/froscon2017");
@ -53,7 +53,7 @@ public class MediaCCCConferenceExtractorTest {
public static class Oscal2019 { public static class Oscal2019 {
private static MediaCCCConferenceExtractor extractor; private static MediaCCCConferenceExtractor extractor;
@BeforeClass @BeforeAll
public static void setUpClass() throws Exception { public static void setUpClass() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (MediaCCCConferenceExtractor) MediaCCC.getChannelExtractor("https://media.ccc.de/c/oscal19"); extractor = (MediaCCCConferenceExtractor) MediaCCC.getChannelExtractor("https://media.ccc.de/c/oscal19");

View File

@ -1,18 +1,18 @@
package org.schabi.newpipe.extractor.services.media_ccc; package org.schabi.newpipe.extractor.services.media_ccc;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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.media_ccc.linkHandler.MediaCCCConferenceLinkHandlerFactory; import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCConferenceLinkHandlerFactory;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
public class MediaCCCConferenceLinkHandlerFactoryTest { public class MediaCCCConferenceLinkHandlerFactoryTest {
private static MediaCCCConferenceLinkHandlerFactory linkHandler; private static MediaCCCConferenceLinkHandlerFactory linkHandler;
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
linkHandler = new MediaCCCConferenceLinkHandlerFactory(); linkHandler = new MediaCCCConferenceLinkHandlerFactory();
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());

View File

@ -1,16 +1,22 @@
package org.schabi.newpipe.extractor.services.media_ccc; package org.schabi.newpipe.extractor.services.media_ccc;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.ExtractorAsserts;
import org.schabi.newpipe.extractor.Info;
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.kiosk.KioskExtractor; import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCConferenceKiosk; import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCConferenceKiosk;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import java.util.List; import java.util.List;
import java.util.Objects;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC; import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
@ -21,7 +27,7 @@ public class MediaCCCConferenceListExtractorTest {
private static KioskExtractor extractor; private static KioskExtractor extractor;
@BeforeClass @BeforeAll
public static void setUpClass() throws Exception { public static void setUpClass() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = MediaCCC.getKioskList().getExtractorById("conferences", null); extractor = MediaCCC.getKioskList().getExtractorById("conferences", null);
@ -29,30 +35,25 @@ public class MediaCCCConferenceListExtractorTest {
} }
@Test @Test
public void getConferencesListTest() throws Exception { void getConferencesListTest() throws Exception {
assertTrue("returned list was to small", ExtractorAsserts.assertGreaterOrEqual(174, extractor.getInitialPage().getItems().size());
extractor.getInitialPage().getItems().size() >= 174);
} }
@Test @ParameterizedTest
public void conferenceTypeTest() throws Exception { @ValueSource(strings = {
assertTrue(contains(extractor.getInitialPage().getItems(), "FrOSCon 2016")); "FrOSCon 2016",
assertTrue(contains(extractor.getInitialPage().getItems(), "ChaosWest @ 35c3")); "ChaosWest @ 35c3",
assertTrue(contains(extractor.getInitialPage().getItems(), "CTreffOS chaOStalks")); "CTreffOS chaOStalks",
assertTrue(contains(extractor.getInitialPage().getItems(), "Datenspuren 2015")); "Datenspuren 2015",
assertTrue(contains(extractor.getInitialPage().getItems(), "Chaos Singularity 2017")); "Chaos Singularity 2017",
assertTrue(contains(extractor.getInitialPage().getItems(), "SIGINT10")); "SIGINT10",
assertTrue(contains(extractor.getInitialPage().getItems(), "Vintage Computing Festival Berlin 2015")); "Vintage Computing Festival Berlin 2015",
assertTrue(contains(extractor.getInitialPage().getItems(), "FIfFKon 2015")); "FIfFKon 2015",
assertTrue(contains(extractor.getInitialPage().getItems(), "33C3: trailers")); "33C3: trailers",
assertTrue(contains(extractor.getInitialPage().getItems(), "Blinkenlights")); "Blinkenlights"
} })
void conferenceTypeTest(final String name) throws Exception {
private boolean contains(List<InfoItem> itemList, String name) { final List<InfoItem> itemList = extractor.getInitialPage().getItems();
for (InfoItem item : itemList) { assertTrue(itemList.stream().anyMatch(item -> name.equals(item.getName())));
if (item.getName().equals(name))
return true;
}
return false;
} }
} }

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.media_ccc; package org.schabi.newpipe.extractor.services.media_ccc;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; 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;
@ -14,7 +14,7 @@ import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
public class MediaCCCLiveStreamListExtractorTest { public class MediaCCCLiveStreamListExtractorTest {
private static KioskExtractor extractor; private static KioskExtractor extractor;
@BeforeClass @BeforeAll
public static void setUpClass() throws Exception { public static void setUpClass() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = MediaCCC.getKioskList().getExtractorById("live", null); extractor = MediaCCC.getKioskList().getExtractorById("live", null);

View File

@ -1,14 +1,14 @@
package org.schabi.newpipe.extractor.services.media_ccc; package org.schabi.newpipe.extractor.services.media_ccc;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCStreamExtractor; import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCStreamExtractor;
import org.schabi.newpipe.extractor.stream.AudioStream; import org.schabi.newpipe.extractor.stream.AudioStream;
import org.schabi.newpipe.extractor.stream.StreamExtractor; import org.schabi.newpipe.extractor.stream.StreamExtractor;
import static junit.framework.TestCase.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC; import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
/** /**
@ -18,7 +18,7 @@ public class MediaCCCOggTest {
// test against https://media.ccc.de/public/events/1317 // test against https://media.ccc.de/public/events/1317
private static StreamExtractor extractor; private static StreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUpClass() throws Exception { public static void setUpClass() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());

View File

@ -1,24 +1,22 @@
package org.schabi.newpipe.extractor.services.media_ccc; package org.schabi.newpipe.extractor.services.media_ccc;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Ignore; import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.kiosk.KioskExtractor; import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import java.time.OffsetDateTime;
import java.util.List; import java.util.List;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC; import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
public class MediaCCCRecentListExtractorTest { public class MediaCCCRecentListExtractorTest {
private static KioskExtractor extractor; private static KioskExtractor extractor;
@BeforeClass @BeforeAll
public static void setUpClass() throws Exception { public static void setUpClass() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = MediaCCC.getKioskList().getExtractorById("recent", null); extractor = MediaCCC.getKioskList().getExtractorById("recent", null);

View File

@ -1,23 +1,22 @@
package org.schabi.newpipe.extractor.services.media_ccc; package org.schabi.newpipe.extractor.services.media_ccc;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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.ParsingException;
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest; import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCStreamExtractor; import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCStreamExtractor;
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;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import static junit.framework.TestCase.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC; import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
/** /**
@ -31,7 +30,7 @@ public class MediaCCCStreamExtractorTest {
private static final String URL = BASE_URL + ID; private static final String URL = BASE_URL + ID;
private static StreamExtractor extractor; private static StreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = MediaCCC.getStreamExtractor(URL); extractor = MediaCCC.getStreamExtractor(URL);
@ -62,7 +61,8 @@ public class MediaCCCStreamExtractorTest {
@Override public Locale expectedLanguageInfo() { return new Locale("de"); } @Override public Locale expectedLanguageInfo() { return new Locale("de"); }
@Override @Override
@Test public void testThumbnailUrl() throws Exception { @Test
public void testThumbnailUrl() throws Exception {
super.testThumbnailUrl(); super.testThumbnailUrl();
assertEquals("https://static.media.ccc.de/media/events/gpn/gpn18/105-hd.jpg", extractor.getThumbnailUrl()); assertEquals("https://static.media.ccc.de/media/events/gpn/gpn18/105-hd.jpg", extractor.getThumbnailUrl());
} }
@ -94,7 +94,7 @@ public class MediaCCCStreamExtractorTest {
private static final String URL = BASE_URL + ID; private static final String URL = BASE_URL + ID;
private static StreamExtractor extractor; private static StreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = MediaCCC.getStreamExtractor(URL); extractor = MediaCCC.getStreamExtractor(URL);
@ -131,7 +131,8 @@ public class MediaCCCStreamExtractorTest {
@Override public List<String> expectedTags() { return Arrays.asList("36c3", "10565", "2019", "Security", "Main"); } @Override public List<String> expectedTags() { return Arrays.asList("36c3", "10565", "2019", "Security", "Main"); }
@Override @Override
@Test public void testThumbnailUrl() throws Exception { @Test
public void testThumbnailUrl() throws Exception {
super.testThumbnailUrl(); super.testThumbnailUrl();
assertEquals("https://static.media.ccc.de/media/congress/2019/10565-hd.jpg", extractor.getThumbnailUrl()); assertEquals("https://static.media.ccc.de/media/congress/2019/10565-hd.jpg", extractor.getThumbnailUrl());
} }

View File

@ -1,18 +1,18 @@
package org.schabi.newpipe.extractor.services.media_ccc; package org.schabi.newpipe.extractor.services.media_ccc;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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.media_ccc.linkHandler.MediaCCCStreamLinkHandlerFactory; import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCStreamLinkHandlerFactory;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
public class MediaCCCStreamLinkHandlerFactoryTest { public class MediaCCCStreamLinkHandlerFactoryTest {
private static MediaCCCStreamLinkHandlerFactory linkHandler; private static MediaCCCStreamLinkHandlerFactory linkHandler;
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
linkHandler = new MediaCCCStreamLinkHandlerFactory(); linkHandler = new MediaCCCStreamLinkHandlerFactory();
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());

View File

@ -1,6 +1,6 @@
package org.schabi.newpipe.extractor.services.media_ccc.search; package org.schabi.newpipe.extractor.services.media_ccc.search;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.schabi.newpipe.downloader.DownloaderTestImpl; 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;
@ -20,7 +20,7 @@ public class MediaCCCSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "kde"; private static final String QUERY = "kde";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = MediaCCC.getSearchExtractor(QUERY); extractor = MediaCCC.getSearchExtractor(QUERY);
@ -43,7 +43,7 @@ public class MediaCCCSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "c3"; private static final String QUERY = "c3";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = MediaCCC.getSearchExtractor(QUERY, singletonList(CONFERENCES), ""); extractor = MediaCCC.getSearchExtractor(QUERY, singletonList(CONFERENCES), "");
@ -67,7 +67,7 @@ public class MediaCCCSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "linux"; private static final String QUERY = "linux";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = MediaCCC.getSearchExtractor(QUERY, singletonList(EVENTS), ""); extractor = MediaCCC.getSearchExtractor(QUERY, singletonList(EVENTS), "");

View File

@ -1,16 +1,16 @@
package org.schabi.newpipe.extractor.services.peertube; package org.schabi.newpipe.extractor.services.peertube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Ignore; import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.ExtractorAsserts;
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.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest; import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeAccountExtractor; import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeAccountExtractor;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
import static org.schabi.newpipe.extractor.ServiceList.PeerTube; import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
import static org.schabi.newpipe.extractor.services.DefaultTests.*; import static org.schabi.newpipe.extractor.services.DefaultTests.*;
@ -23,7 +23,7 @@ public class PeertubeAccountExtractorTest {
public static class Framasoft implements BaseChannelExtractorTest { public static class Framasoft implements BaseChannelExtractorTest {
private static PeertubeAccountExtractor extractor; private static PeertubeAccountExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
// setting instance might break test when running in parallel // setting instance might break test when running in parallel
@ -102,7 +102,7 @@ public class PeertubeAccountExtractorTest {
@Test @Test
public void testSubscriberCount() throws ParsingException { public void testSubscriberCount() throws ParsingException {
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 700); ExtractorAsserts.assertGreaterOrEqual(700, extractor.getSubscriberCount());
} }
@Override @Override
@ -114,7 +114,7 @@ public class PeertubeAccountExtractorTest {
public static class FreeSoftwareFoundation implements BaseChannelExtractorTest { public static class FreeSoftwareFoundation implements BaseChannelExtractorTest {
private static PeertubeAccountExtractor extractor; private static PeertubeAccountExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
// setting instance might break test when running in parallel // setting instance might break test when running in parallel
@ -203,7 +203,7 @@ public class PeertubeAccountExtractorTest {
@Test @Test
public void testSubscriberCount() throws ParsingException { public void testSubscriberCount() throws ParsingException {
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 100); ExtractorAsserts.assertGreaterOrEqual(100, extractor.getSubscriberCount());
} }
@Override @Override

View File

@ -1,15 +1,16 @@
package org.schabi.newpipe.extractor.services.peertube; package org.schabi.newpipe.extractor.services.peertube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.ExtractorAsserts;
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.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest; import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeChannelExtractor; import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeChannelExtractor;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
import static org.schabi.newpipe.extractor.ServiceList.PeerTube; import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
import static org.schabi.newpipe.extractor.services.DefaultTests.*; import static org.schabi.newpipe.extractor.services.DefaultTests.*;
@ -22,7 +23,7 @@ public class PeertubeChannelExtractorTest {
public static class LaQuadratureDuNet implements BaseChannelExtractorTest { public static class LaQuadratureDuNet implements BaseChannelExtractorTest {
private static PeertubeChannelExtractor extractor; private static PeertubeChannelExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
// setting instance might break test when running in parallel // setting instance might break test when running in parallel
@ -116,7 +117,7 @@ public class PeertubeChannelExtractorTest {
@Test @Test
public void testSubscriberCount() throws ParsingException { public void testSubscriberCount() throws ParsingException {
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 230); ExtractorAsserts.assertGreaterOrEqual(230, extractor.getSubscriberCount());
} }
@Override @Override
@ -129,7 +130,7 @@ public class PeertubeChannelExtractorTest {
private static PeertubeChannelExtractor extractor; private static PeertubeChannelExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
// setting instance might break test when running in parallel // setting instance might break test when running in parallel
@ -233,7 +234,7 @@ public class PeertubeChannelExtractorTest {
@Test @Test
public void testSubscriberCount() throws ParsingException { public void testSubscriberCount() throws ParsingException {
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 700); ExtractorAsserts.assertGreaterOrEqual(700, extractor.getSubscriberCount());
} }
@Override @Override

View File

@ -1,14 +1,14 @@
package org.schabi.newpipe.extractor.services.peertube; package org.schabi.newpipe.extractor.services.peertube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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.peertube.linkHandler.PeertubeChannelLinkHandlerFactory; import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeChannelLinkHandlerFactory;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.PeerTube; import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
/** /**
@ -18,7 +18,7 @@ public class PeertubeChannelLinkHandlerFactoryTest {
private static PeertubeChannelLinkHandlerFactory linkHandler; private static PeertubeChannelLinkHandlerFactory linkHandler;
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
PeerTube.setInstance(new PeertubeInstance("https://peertube.stream", "PeerTube on peertube.stream")); PeerTube.setInstance(new PeertubeInstance("https://peertube.stream", "PeerTube on peertube.stream"));
linkHandler = PeertubeChannelLinkHandlerFactory.getInstance(); linkHandler = PeertubeChannelLinkHandlerFactory.getInstance();

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.peertube; package org.schabi.newpipe.extractor.services.peertube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage; import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
@ -15,16 +15,16 @@ import org.schabi.newpipe.extractor.utils.Utils;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.PeerTube; import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
public class PeertubeCommentsExtractorTest { public class PeertubeCommentsExtractorTest {
public static class Default { public static class Default {
private static PeertubeCommentsExtractor extractor; private static PeertubeCommentsExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (PeertubeCommentsExtractor) PeerTube extractor = (PeertubeCommentsExtractor) PeerTube
@ -97,7 +97,7 @@ public class PeertubeCommentsExtractorTest {
public static class DeletedComments { public static class DeletedComments {
private static PeertubeCommentsExtractor extractor; private static PeertubeCommentsExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (PeertubeCommentsExtractor) PeerTube extractor = (PeertubeCommentsExtractor) PeerTube

View File

@ -1,14 +1,14 @@
package org.schabi.newpipe.extractor.services.peertube; package org.schabi.newpipe.extractor.services.peertube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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.peertube.linkHandler.PeertubeCommentsLinkHandlerFactory; import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeCommentsLinkHandlerFactory;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
/** /**
* Test for {@link PeertubeCommentsLinkHandlerFactory} * Test for {@link PeertubeCommentsLinkHandlerFactory}
@ -17,7 +17,7 @@ public class PeertubeCommentsLinkHandlerFactoryTest {
private static PeertubeCommentsLinkHandlerFactory linkHandler; private static PeertubeCommentsLinkHandlerFactory linkHandler;
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
linkHandler = PeertubeCommentsLinkHandlerFactory.getInstance(); linkHandler = PeertubeCommentsLinkHandlerFactory.getInstance();
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());

View File

@ -1,15 +1,15 @@
package org.schabi.newpipe.extractor.services.peertube; package org.schabi.newpipe.extractor.services.peertube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubePlaylistExtractor; import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubePlaylistExtractor;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.schabi.newpipe.extractor.ServiceList.PeerTube; import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
public class PeertubePlaylistExtractorTest { public class PeertubePlaylistExtractorTest {
@ -17,7 +17,7 @@ public class PeertubePlaylistExtractorTest {
public static class Shocking { public static class Shocking {
private static PeertubePlaylistExtractor extractor; private static PeertubePlaylistExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (PeertubePlaylistExtractor) PeerTube extractor = (PeertubePlaylistExtractor) PeerTube
@ -31,7 +31,7 @@ public class PeertubePlaylistExtractorTest {
} }
@Test @Test
@Ignore("URL changes with every request") @Disabled("URL changes with every request")
public void testGetThumbnailUrl() throws ParsingException { public void testGetThumbnailUrl() throws ParsingException {
assertEquals("https://framatube.org/static/thumbnails/playlist-96b0ee2b-a5a7-4794-8769-58d8ccb79ab7.jpg", extractor.getThumbnailUrl()); assertEquals("https://framatube.org/static/thumbnails/playlist-96b0ee2b-a5a7-4794-8769-58d8ccb79ab7.jpg", extractor.getThumbnailUrl());
} }
@ -53,7 +53,7 @@ public class PeertubePlaylistExtractorTest {
@Test @Test
public void testGetStreamCount() throws ParsingException { public void testGetStreamCount() throws ParsingException {
ExtractorAsserts.assertAtLeast(39, extractor.getStreamCount()); ExtractorAsserts.assertGreaterOrEqual(39, extractor.getStreamCount());
} }
@Test @Test

View File

@ -1,14 +1,14 @@
package org.schabi.newpipe.extractor.services.peertube; package org.schabi.newpipe.extractor.services.peertube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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.peertube.linkHandler.PeertubePlaylistLinkHandlerFactory; import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubePlaylistLinkHandlerFactory;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
/** /**
* Test for {@link PeertubePlaylistLinkHandlerFactory} * Test for {@link PeertubePlaylistLinkHandlerFactory}
@ -17,7 +17,7 @@ public class PeertubePlaylistLinkHandlerFactoryTest {
private static PeertubePlaylistLinkHandlerFactory linkHandler; private static PeertubePlaylistLinkHandlerFactory linkHandler;
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
linkHandler = PeertubePlaylistLinkHandlerFactory.getInstance(); linkHandler = PeertubePlaylistLinkHandlerFactory.getInstance();
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());

View File

@ -1,8 +1,8 @@
package org.schabi.newpipe.extractor.services.peertube; package org.schabi.newpipe.extractor.services.peertube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
@ -19,7 +19,7 @@ import java.util.Locale;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.schabi.newpipe.extractor.ServiceList.PeerTube; import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
public abstract class PeertubeStreamExtractorTest extends DefaultStreamExtractorTest { public abstract class PeertubeStreamExtractorTest extends DefaultStreamExtractorTest {
@ -36,7 +36,7 @@ public abstract class PeertubeStreamExtractorTest extends DefaultStreamExtractor
private static final String URL = INSTANCE + BASE_URL + ID + "?start=" + TIMESTAMP_MINUTE + "m" + TIMESTAMP_SECOND + "s"; private static final String URL = INSTANCE + BASE_URL + ID + "?start=" + TIMESTAMP_MINUTE + "m" + TIMESTAMP_SECOND + "s";
private static StreamExtractor extractor; private static StreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
// setting instance might break test when running in parallel (!) // setting instance might break test when running in parallel (!)
@ -102,7 +102,7 @@ public abstract class PeertubeStreamExtractorTest extends DefaultStreamExtractor
private static final String URL = INSTANCE + BASE_URL + ID; private static final String URL = INSTANCE + BASE_URL + ID;
private static StreamExtractor extractor; private static StreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
// setting instance might break test when running in parallel (!) // setting instance might break test when running in parallel (!)
@ -140,14 +140,14 @@ public abstract class PeertubeStreamExtractorTest extends DefaultStreamExtractor
@Override public List<String> expectedTags() { return Arrays.asList("Marinauts", "adobe flash", "adobe flash player", "flash games", "the marinauts"); } @Override public List<String> expectedTags() { return Arrays.asList("Marinauts", "adobe flash", "adobe flash player", "flash games", "the marinauts"); }
} }
@Ignore("Test broken, SSL problem") @Disabled("Test broken, SSL problem")
public static class AgeRestricted extends PeertubeStreamExtractorTest { public static class AgeRestricted extends PeertubeStreamExtractorTest {
private static final String ID = "dbd8e5e1-c527-49b6-b70c-89101dbb9c08"; private static final String ID = "dbd8e5e1-c527-49b6-b70c-89101dbb9c08";
private static final String INSTANCE = "https://nocensoring.net"; private static final String INSTANCE = "https://nocensoring.net";
private static final String URL = INSTANCE + "/videos/embed/" + ID; private static final String URL = INSTANCE + "/videos/embed/" + ID;
private static StreamExtractor extractor; private static StreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());; NewPipe.init(DownloaderTestImpl.getInstance());;
// setting instance might break test when running in parallel (!) // setting instance might break test when running in parallel (!)
@ -186,7 +186,7 @@ public abstract class PeertubeStreamExtractorTest extends DefaultStreamExtractor
} }
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
PeerTube.setInstance(new PeertubeInstance("https://peertube.cpy.re", "PeerTube test server")); PeerTube.setInstance(new PeertubeInstance("https://peertube.cpy.re", "PeerTube test server"));

View File

@ -1,13 +1,13 @@
package org.schabi.newpipe.extractor.services.peertube; package org.schabi.newpipe.extractor.services.peertube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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.peertube.linkHandler.PeertubeStreamLinkHandlerFactory; import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeStreamLinkHandlerFactory;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import static org.schabi.newpipe.extractor.ServiceList.PeerTube; import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
/** /**
@ -17,7 +17,7 @@ public class PeertubeStreamLinkHandlerFactoryTest {
private static PeertubeStreamLinkHandlerFactory linkHandler; private static PeertubeStreamLinkHandlerFactory linkHandler;
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube")); PeerTube.setInstance(new PeertubeInstance("https://framatube.org", "Framatube"));
linkHandler = PeertubeStreamLinkHandlerFactory.getInstance(); linkHandler = PeertubeStreamLinkHandlerFactory.getInstance();

View File

@ -1,14 +1,14 @@
package org.schabi.newpipe.extractor.services.peertube; package org.schabi.newpipe.extractor.services.peertube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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.BaseListExtractorTest; import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeTrendingExtractor; import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeTrendingExtractor;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.schabi.newpipe.extractor.ServiceList.PeerTube; import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
import static org.schabi.newpipe.extractor.services.DefaultTests.*; import static org.schabi.newpipe.extractor.services.DefaultTests.*;
@ -17,7 +17,7 @@ public class PeertubeTrendingExtractorTest {
public static class Trending implements BaseListExtractorTest { public static class Trending implements BaseListExtractorTest {
private static PeertubeTrendingExtractor extractor; private static PeertubeTrendingExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
// setting instance might break test when running in parallel // setting instance might break test when running in parallel

View File

@ -1,15 +1,15 @@
package org.schabi.newpipe.extractor.services.peertube; package org.schabi.newpipe.extractor.services.peertube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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.linkhandler.LinkHandlerFactory; import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeTrendingLinkHandlerFactory; import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeTrendingLinkHandlerFactory;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.PeerTube; import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
/** /**
@ -18,7 +18,7 @@ import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
public class PeertubeTrendingLinkHandlerFactoryTest { public class PeertubeTrendingLinkHandlerFactoryTest {
private static LinkHandlerFactory LinkHandlerFactory; private static LinkHandlerFactory LinkHandlerFactory;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
// setting instance might break test when running in parallel // setting instance might break test when running in parallel
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host")); PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host"));

View File

@ -1,8 +1,8 @@
package org.schabi.newpipe.extractor.services.peertube.search; package org.schabi.newpipe.extractor.services.peertube.search;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage; import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
@ -26,7 +26,7 @@ public class PeertubeSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "fsf"; private static final String QUERY = "fsf";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
// setting instance might break test when running in parallel // setting instance might break test when running in parallel
@ -49,7 +49,7 @@ public class PeertubeSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "kde"; private static final String QUERY = "kde";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
// setting instance might break test when running in parallel // setting instance might break test when running in parallel
@ -70,7 +70,7 @@ public class PeertubeSearchExtractorTest {
public static class PagingTest { public static class PagingTest {
@Test @Test
@Ignore("Exception in CI: javax.net.ssl.SSLHandshakeException: PKIX path validation failed: java.security.cert.CertPathValidatorException: validity check failed") @Disabled("Exception in CI: javax.net.ssl.SSLHandshakeException: PKIX path validation failed: java.security.cert.CertPathValidatorException: validity check failed")
public void duplicatedItemsCheck() throws Exception { public void duplicatedItemsCheck() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
final SearchExtractor extractor = PeerTube.getSearchExtractor("internet", singletonList(VIDEOS), ""); final SearchExtractor extractor = PeerTube.getSearchExtractor("internet", singletonList(VIDEOS), "");

View File

@ -1,17 +1,17 @@
package org.schabi.newpipe.extractor.services.peertube.search; package org.schabi.newpipe.extractor.services.peertube.search;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.extractor.services.peertube.PeertubeInstance; import org.schabi.newpipe.extractor.services.peertube.PeertubeInstance;
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeSearchQueryHandlerFactory; import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeSearchQueryHandlerFactory;
import static java.util.Collections.singletonList; import static java.util.Collections.singletonList;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.schabi.newpipe.extractor.ServiceList.PeerTube; import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
public class PeertubeSearchQHTest { public class PeertubeSearchQHTest {
@BeforeClass @BeforeAll
public static void setUpClass() throws Exception { public static void setUpClass() throws Exception {
// setting instance might break test when running in parallel // setting instance might break test when running in parallel
PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host")); PeerTube.setInstance(new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host"));

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.soundcloud; package org.schabi.newpipe.extractor.services.soundcloud;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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;
@ -9,7 +9,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest; import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudChannelExtractor; import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudChannelExtractor;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
@ -22,7 +22,7 @@ public class SoundcloudChannelExtractorTest {
public static class LilUzi implements BaseChannelExtractorTest { public static class LilUzi implements BaseChannelExtractorTest {
private static SoundcloudChannelExtractor extractor; private static SoundcloudChannelExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (SoundcloudChannelExtractor) SoundCloud extractor = (SoundcloudChannelExtractor) SoundCloud
@ -99,7 +99,7 @@ public class SoundcloudChannelExtractorTest {
@Test @Test
public void testSubscriberCount() { public void testSubscriberCount() {
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 1e6); assertTrue(extractor.getSubscriberCount() >= 1e6, "Wrong subscriber count");
} }
@Override @Override
@ -111,7 +111,7 @@ public class SoundcloudChannelExtractorTest {
public static class DubMatix implements BaseChannelExtractorTest { public static class DubMatix implements BaseChannelExtractorTest {
private static SoundcloudChannelExtractor extractor; private static SoundcloudChannelExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (SoundcloudChannelExtractor) SoundCloud extractor = (SoundcloudChannelExtractor) SoundCloud
@ -198,7 +198,7 @@ public class SoundcloudChannelExtractorTest {
@Test @Test
public void testSubscriberCount() { public void testSubscriberCount() {
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 2e6); assertTrue(extractor.getSubscriberCount() >= 2e6, "Wrong subscriber count");
} }
@Override @Override

View File

@ -1,14 +1,14 @@
package org.schabi.newpipe.extractor.services.soundcloud; package org.schabi.newpipe.extractor.services.soundcloud;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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.BaseListExtractorTest; import org.schabi.newpipe.extractor.services.BaseListExtractorTest;
import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudChartsExtractor; import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudChartsExtractor;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
import static org.schabi.newpipe.extractor.services.DefaultTests.*; import static org.schabi.newpipe.extractor.services.DefaultTests.*;
@ -16,7 +16,7 @@ public class SoundcloudChartsExtractorTest {
public static class NewAndHot implements BaseListExtractorTest { public static class NewAndHot implements BaseListExtractorTest {
private static SoundcloudChartsExtractor extractor; private static SoundcloudChartsExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (SoundcloudChartsExtractor) SoundCloud.getKioskList() extractor = (SoundcloudChartsExtractor) SoundCloud.getKioskList()
@ -71,7 +71,7 @@ public class SoundcloudChartsExtractorTest {
public static class Top50Charts implements BaseListExtractorTest { public static class Top50Charts implements BaseListExtractorTest {
private static SoundcloudChartsExtractor extractor; private static SoundcloudChartsExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (SoundcloudChartsExtractor) SoundCloud.getKioskList() extractor = (SoundcloudChartsExtractor) SoundCloud.getKioskList()

View File

@ -1,15 +1,15 @@
package org.schabi.newpipe.extractor.services.soundcloud; package org.schabi.newpipe.extractor.services.soundcloud;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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.soundcloud.linkHandler.SoundcloudChartsLinkHandlerFactory; import org.schabi.newpipe.extractor.services.soundcloud.linkHandler.SoundcloudChartsLinkHandlerFactory;
import static junit.framework.TestCase.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
/** /**
* Test for {@link SoundcloudChartsLinkHandlerFactory} * Test for {@link SoundcloudChartsLinkHandlerFactory}
@ -17,7 +17,7 @@ import static org.junit.Assert.assertTrue;
public class SoundcloudChartsLinkHandlerFactoryTest { public class SoundcloudChartsLinkHandlerFactoryTest {
private static SoundcloudChartsLinkHandlerFactory linkHandler; private static SoundcloudChartsLinkHandlerFactory linkHandler;
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
linkHandler = new SoundcloudChartsLinkHandlerFactory(); linkHandler = new SoundcloudChartsLinkHandlerFactory();
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());

View File

@ -1,50 +1,49 @@
package org.schabi.newpipe.extractor.services.soundcloud; package org.schabi.newpipe.extractor.services.soundcloud;
import org.junit.Assert; import org.junit.jupiter.api.Assertions;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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 static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException; import java.io.IOException;
public class SoundcloudParsingHelperTest { public class SoundcloudParsingHelperTest {
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
} }
@Test @Test
public void assertThatHardcodedClientIdIsValid() throws Exception { public void assertThatHardcodedClientIdIsValid() throws Exception {
assertTrue("Hardcoded client id is not valid anymore", assertTrue(SoundcloudParsingHelper.checkIfHardcodedClientIdIsValid(),
SoundcloudParsingHelper.checkIfHardcodedClientIdIsValid()); "Hardcoded client id is not valid anymore");
} }
@Test @Test
public void assertHardCodedClientIdMatchesCurrentClientId() throws IOException, ExtractionException { public void assertHardCodedClientIdMatchesCurrentClientId() throws IOException, ExtractionException {
assertEquals( assertEquals(
"Hardcoded client doesn't match extracted clientId",
SoundcloudParsingHelper.HARDCODED_CLIENT_ID, SoundcloudParsingHelper.HARDCODED_CLIENT_ID,
SoundcloudParsingHelper.clientId()); SoundcloudParsingHelper.clientId(),
"Hardcoded client doesn't match extracted clientId");
} }
@Test @Test
public void resolveUrlWithEmbedPlayerTest() throws Exception { public void resolveUrlWithEmbedPlayerTest() throws Exception {
Assert.assertEquals("https://soundcloud.com/trapcity", SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/users/26057743")); assertEquals("https://soundcloud.com/trapcity", SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/users/26057743"));
Assert.assertEquals("https://soundcloud.com/nocopyrightsounds", SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/users/16069159")); assertEquals("https://soundcloud.com/nocopyrightsounds", SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/users/16069159"));
Assert.assertEquals("https://soundcloud.com/trapcity", SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api-v2.soundcloud.com/users/26057743")); assertEquals("https://soundcloud.com/trapcity", SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api-v2.soundcloud.com/users/26057743"));
Assert.assertEquals("https://soundcloud.com/nocopyrightsounds", SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api-v2.soundcloud.com/users/16069159")); assertEquals("https://soundcloud.com/nocopyrightsounds", SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api-v2.soundcloud.com/users/16069159"));
} }
@Test @Test
public void resolveIdWithWidgetApiTest() throws Exception { public void resolveIdWithWidgetApiTest() throws Exception {
Assert.assertEquals("26057743", SoundcloudParsingHelper.resolveIdWithWidgetApi("https://soundcloud.com/trapcity")); assertEquals("26057743", SoundcloudParsingHelper.resolveIdWithWidgetApi("https://soundcloud.com/trapcity"));
Assert.assertEquals("16069159", SoundcloudParsingHelper.resolveIdWithWidgetApi("https://soundcloud.com/nocopyrightsounds")); assertEquals("16069159", SoundcloudParsingHelper.resolveIdWithWidgetApi("https://soundcloud.com/nocopyrightsounds"));
} }
} }

View File

@ -1,9 +1,10 @@
package org.schabi.newpipe.extractor.services.soundcloud; package org.schabi.newpipe.extractor.services.soundcloud;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.ExtractorAsserts;
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.playlist.PlaylistExtractor; import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
@ -11,8 +12,7 @@ import org.schabi.newpipe.extractor.services.BasePlaylistExtractorTest;
import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudPlaylistExtractor; import org.schabi.newpipe.extractor.services.soundcloud.extractors.SoundcloudPlaylistExtractor;
import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import static org.hamcrest.CoreMatchers.*; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.Assert.*;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
import static org.schabi.newpipe.extractor.services.DefaultTests.*; import static org.schabi.newpipe.extractor.services.DefaultTests.*;
@ -24,7 +24,7 @@ public class SoundcloudPlaylistExtractorTest {
public static class LuvTape implements BasePlaylistExtractorTest { public static class LuvTape implements BasePlaylistExtractorTest {
private static SoundcloudPlaylistExtractor extractor; private static SoundcloudPlaylistExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (SoundcloudPlaylistExtractor) SoundCloud extractor = (SoundcloudPlaylistExtractor) SoundCloud
@ -91,10 +91,10 @@ public class SoundcloudPlaylistExtractorTest {
} }
@Test @Test
public void testUploaderUrl() { void testUploaderUrl() {
final String uploaderUrl = extractor.getUploaderUrl(); final String uploaderUrl = extractor.getUploaderUrl();
assertIsSecureUrl(uploaderUrl); assertIsSecureUrl(uploaderUrl);
assertThat(uploaderUrl, containsString("liluzivert")); ExtractorAsserts.assertContains("liluzivert", uploaderUrl);
} }
@Test @Test
@ -109,10 +109,10 @@ public class SoundcloudPlaylistExtractorTest {
@Test @Test
public void testStreamCount() { public void testStreamCount() {
assertTrue("Stream count does not fit: " + extractor.getStreamCount(), extractor.getStreamCount() >= 10); ExtractorAsserts.assertGreaterOrEqual(10, extractor.getStreamCount());
} }
@Override @Test
public void testUploaderVerified() throws Exception { public void testUploaderVerified() throws Exception {
assertTrue(extractor.isUploaderVerified()); assertTrue(extractor.isUploaderVerified());
} }
@ -121,7 +121,7 @@ public class SoundcloudPlaylistExtractorTest {
public static class RandomHouseMusic implements BasePlaylistExtractorTest { public static class RandomHouseMusic implements BasePlaylistExtractorTest {
private static SoundcloudPlaylistExtractor extractor; private static SoundcloudPlaylistExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (SoundcloudPlaylistExtractor) SoundCloud extractor = (SoundcloudPlaylistExtractor) SoundCloud
@ -188,10 +188,10 @@ public class SoundcloudPlaylistExtractorTest {
} }
@Test @Test
public void testUploaderUrl() { void testUploaderUrl() {
final String uploaderUrl = extractor.getUploaderUrl(); final String uploaderUrl = extractor.getUploaderUrl();
assertIsSecureUrl(uploaderUrl); assertIsSecureUrl(uploaderUrl);
assertThat(uploaderUrl, containsString("micky96")); ExtractorAsserts.assertContains("micky96", uploaderUrl);
} }
@Test @Test
@ -206,10 +206,10 @@ public class SoundcloudPlaylistExtractorTest {
@Test @Test
public void testStreamCount() { public void testStreamCount() {
assertTrue("Stream count does not fit: " + extractor.getStreamCount(), extractor.getStreamCount() >= 10); ExtractorAsserts.assertGreaterOrEqual(10, extractor.getStreamCount());
} }
@Override @Test
public void testUploaderVerified() throws Exception { public void testUploaderVerified() throws Exception {
assertFalse(extractor.isUploaderVerified()); assertFalse(extractor.isUploaderVerified());
} }
@ -218,7 +218,7 @@ public class SoundcloudPlaylistExtractorTest {
public static class EDMxxx implements BasePlaylistExtractorTest { public static class EDMxxx implements BasePlaylistExtractorTest {
private static SoundcloudPlaylistExtractor extractor; private static SoundcloudPlaylistExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (SoundcloudPlaylistExtractor) SoundCloud extractor = (SoundcloudPlaylistExtractor) SoundCloud
@ -231,7 +231,7 @@ public class SoundcloudPlaylistExtractorTest {
//////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////*/
@Test @Test
public void testGetPageInNewExtractor() throws Exception { void testGetPageInNewExtractor() throws Exception {
PlaylistExtractor newExtractor = SoundCloud.getPlaylistExtractor(extractor.getUrl()); PlaylistExtractor newExtractor = SoundCloud.getPlaylistExtractor(extractor.getUrl());
defaultTestGetPageInNewExtractor(extractor, newExtractor); defaultTestGetPageInNewExtractor(extractor, newExtractor);
} }
@ -300,10 +300,10 @@ public class SoundcloudPlaylistExtractorTest {
} }
@Test @Test
public void testUploaderUrl() { void testUploaderUrl() {
final String uploaderUrl = extractor.getUploaderUrl(); final String uploaderUrl = extractor.getUploaderUrl();
assertIsSecureUrl(uploaderUrl); assertIsSecureUrl(uploaderUrl);
assertTrue(uploaderUrl, uploaderUrl.contains("user350509423")); ExtractorAsserts.assertContains("user350509423", uploaderUrl);
} }
@Test @Test
@ -318,10 +318,10 @@ public class SoundcloudPlaylistExtractorTest {
@Test @Test
public void testStreamCount() { public void testStreamCount() {
assertTrue("Stream count does not fit: " + extractor.getStreamCount(), extractor.getStreamCount() >= 370); ExtractorAsserts.assertGreaterOrEqual(370, extractor.getStreamCount());
} }
@Override @Test
public void testUploaderVerified() throws Exception { public void testUploaderVerified() throws Exception {
assertFalse(extractor.isUploaderVerified()); assertFalse(extractor.isUploaderVerified());
} }
@ -330,7 +330,7 @@ public class SoundcloudPlaylistExtractorTest {
public static class SmallPlaylist implements BasePlaylistExtractorTest { public static class SmallPlaylist implements BasePlaylistExtractorTest {
private static SoundcloudPlaylistExtractor extractor; private static SoundcloudPlaylistExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (SoundcloudPlaylistExtractor) SoundCloud extractor = (SoundcloudPlaylistExtractor) SoundCloud
@ -377,7 +377,7 @@ public class SoundcloudPlaylistExtractorTest {
} }
@Test @Test
@Ignore("Test broken? Playlist has 2 entries, each page has 1 entry meaning it has 2 pages.") @Disabled("Test broken? Playlist has 2 entries, each page has 1 entry meaning it has 2 pages.")
public void testMoreRelatedItems() throws Exception { public void testMoreRelatedItems() throws Exception {
try { try {
defaultTestMoreItems(extractor); defaultTestMoreItems(extractor);
@ -404,10 +404,10 @@ public class SoundcloudPlaylistExtractorTest {
} }
@Test @Test
public void testUploaderUrl() { void testUploaderUrl() {
final String uploaderUrl = extractor.getUploaderUrl(); final String uploaderUrl = extractor.getUploaderUrl();
assertIsSecureUrl(uploaderUrl); assertIsSecureUrl(uploaderUrl);
assertThat(uploaderUrl, containsString("breezy-123")); ExtractorAsserts.assertContains("breezy-123", uploaderUrl);
} }
@Test @Test
@ -425,7 +425,7 @@ public class SoundcloudPlaylistExtractorTest {
assertEquals(2, extractor.getStreamCount()); assertEquals(2, extractor.getStreamCount());
} }
@Override @Test
public void testUploaderVerified() throws Exception { public void testUploaderVerified() throws Exception {
assertFalse(extractor.isUploaderVerified()); assertFalse(extractor.isUploaderVerified());
} }

View File

@ -1,9 +1,10 @@
package org.schabi.newpipe.extractor.services.soundcloud; package org.schabi.newpipe.extractor.services.soundcloud;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.ExtractorAsserts;
import org.schabi.newpipe.extractor.MediaFormat; import org.schabi.newpipe.extractor.MediaFormat;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
@ -20,9 +21,7 @@ import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import static junit.framework.TestCase.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
public class SoundcloudStreamExtractorTest { public class SoundcloudStreamExtractorTest {
@ -35,7 +34,7 @@ public class SoundcloudStreamExtractorTest {
private static final String URL = UPLOADER + "/" + ID + "#t=" + TIMESTAMP; private static final String URL = UPLOADER + "/" + ID + "#t=" + TIMESTAMP;
private static StreamExtractor extractor; private static StreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = SoundCloud.getStreamExtractor(URL); extractor = SoundCloud.getStreamExtractor(URL);
@ -76,7 +75,7 @@ public class SoundcloudStreamExtractorTest {
@Test @Test
@Override @Override
@Ignore("Unreliable, sometimes it has related items, sometimes it does not") @Disabled("Unreliable, sometimes it has related items, sometimes it does not")
public void testRelatedItems() throws Exception { public void testRelatedItems() throws Exception {
super.testRelatedItems(); super.testRelatedItems();
} }
@ -89,7 +88,7 @@ public class SoundcloudStreamExtractorTest {
private static final String URL = UPLOADER + "/" + ID + "#t=" + TIMESTAMP; private static final String URL = UPLOADER + "/" + ID + "#t=" + TIMESTAMP;
private static StreamExtractor extractor; private static StreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = SoundCloud.getStreamExtractor(URL); extractor = SoundCloud.getStreamExtractor(URL);
@ -102,7 +101,7 @@ public class SoundcloudStreamExtractorTest {
@Override @Override
@Test @Test
@Ignore("Unreliable, sometimes it has related items, sometimes it does not. See " + @Disabled("Unreliable, sometimes it has related items, sometimes it does not. See " +
"https://github.com/TeamNewPipe/NewPipeExtractor/runs/2280013723#step:5:263 " + "https://github.com/TeamNewPipe/NewPipeExtractor/runs/2280013723#step:5:263 " +
"https://github.com/TeamNewPipe/NewPipeExtractor/pull/601") "https://github.com/TeamNewPipe/NewPipeExtractor/pull/601")
public void testRelatedItems() throws Exception { public void testRelatedItems() throws Exception {
@ -146,7 +145,7 @@ public class SoundcloudStreamExtractorTest {
private static final String URL = UPLOADER + "/" + ID + "#t=" + TIMESTAMP; private static final String URL = UPLOADER + "/" + ID + "#t=" + TIMESTAMP;
private static StreamExtractor extractor; private static StreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = SoundCloud.getStreamExtractor(URL); extractor = SoundCloud.getStreamExtractor(URL);
@ -192,12 +191,12 @@ public class SoundcloudStreamExtractorTest {
final String mediaUrl = audioStream.getUrl(); final String mediaUrl = audioStream.getUrl();
if (audioStream.getFormat() == MediaFormat.OPUS) { if (audioStream.getFormat() == MediaFormat.OPUS) {
// assert that it's an OPUS 64 kbps media URL with a single range which comes from an HLS SoundCloud CDN // assert that it's an OPUS 64 kbps media URL with a single range which comes from an HLS SoundCloud CDN
assertThat(mediaUrl, containsString("-hls-opus-media.sndcdn.com")); ExtractorAsserts.assertContains("-hls-opus-media.sndcdn.com", mediaUrl);
assertThat(mediaUrl, containsString(".64.opus")); ExtractorAsserts.assertContains(".64.opus", mediaUrl);
} }
if (audioStream.getFormat() == MediaFormat.MP3) { if (audioStream.getFormat() == MediaFormat.MP3) {
// assert that it's a MP3 128 kbps media URL which comes from a progressive SoundCloud CDN // assert that it's a MP3 128 kbps media URL which comes from a progressive SoundCloud CDN
assertThat(mediaUrl, containsString("-media.sndcdn.com/bKOA7Pwbut93.128.mp3")); ExtractorAsserts.assertContains("-media.sndcdn.com/bKOA7Pwbut93.128.mp3", mediaUrl);
} }
} }
} }

View File

@ -1,8 +1,7 @@
package org.schabi.newpipe.extractor.services.soundcloud; package org.schabi.newpipe.extractor.services.soundcloud;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Ignore; import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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;
@ -11,7 +10,7 @@ import org.schabi.newpipe.extractor.services.soundcloud.linkHandler.SoundcloudSt
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
/** /**
* Test for {@link SoundcloudStreamLinkHandlerFactory} * Test for {@link SoundcloudStreamLinkHandlerFactory}
@ -19,15 +18,15 @@ import static org.junit.Assert.*;
public class SoundcloudStreamLinkHandlerFactoryTest { public class SoundcloudStreamLinkHandlerFactoryTest {
private static SoundcloudStreamLinkHandlerFactory linkHandler; private static SoundcloudStreamLinkHandlerFactory linkHandler;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
linkHandler = SoundcloudStreamLinkHandlerFactory.getInstance(); linkHandler = SoundcloudStreamLinkHandlerFactory.getInstance();
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
} }
@Test(expected = IllegalArgumentException.class) @Test
public void getIdWithNullAsUrl() throws ParsingException { public void getIdWithNullAsUrl() {
linkHandler.fromUrl(null).getId(); assertThrows(IllegalArgumentException.class, () -> linkHandler.fromUrl(null));
} }
@Test @Test

View File

@ -1,7 +1,9 @@
package org.schabi.newpipe.extractor.services.soundcloud; package org.schabi.newpipe.extractor.services.soundcloud;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.ServiceList; import org.schabi.newpipe.extractor.ServiceList;
@ -15,7 +17,7 @@ import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
/** /**
* Test for {@link SoundcloudSubscriptionExtractor} * Test for {@link SoundcloudSubscriptionExtractor}
@ -24,54 +26,49 @@ public class SoundcloudSubscriptionExtractorTest {
private static SoundcloudSubscriptionExtractor subscriptionExtractor; private static SoundcloudSubscriptionExtractor subscriptionExtractor;
private static LinkHandlerFactory urlHandler; private static LinkHandlerFactory urlHandler;
@BeforeClass @BeforeAll
public static void setupClass() { public static void setupClass() {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
subscriptionExtractor = new SoundcloudSubscriptionExtractor(ServiceList.SoundCloud); subscriptionExtractor = new SoundcloudSubscriptionExtractor(ServiceList.SoundCloud);
urlHandler = ServiceList.SoundCloud.getChannelLHFactory(); urlHandler = ServiceList.SoundCloud.getChannelLHFactory();
} }
@Test @ParameterizedTest
public void testFromChannelUrl() throws Exception { @ValueSource(strings = {
testList(subscriptionExtractor.fromChannelUrl("https://soundcloud.com/monstercat")); "https://soundcloud.com/monstercat",
testList(subscriptionExtractor.fromChannelUrl("http://soundcloud.com/monstercat")); "http://soundcloud.com/monstercat",
testList(subscriptionExtractor.fromChannelUrl("soundcloud.com/monstercat")); "soundcloud.com/monstercat",
testList(subscriptionExtractor.fromChannelUrl("monstercat")); "monstercat",
// Empty followings user
//Empty followings user "some-random-user-184047028"
testList(subscriptionExtractor.fromChannelUrl("some-random-user-184047028")); })
} void testFromChannelUrl(final String channelUrl) throws Exception {
for (SubscriptionItem item : subscriptionExtractor.fromChannelUrl(channelUrl)) {
@Test
public void testInvalidSourceException() {
List<String> invalidList = Arrays.asList(
"httttps://invalid.com/user",
".com/monstercat",
"ithinkthatthisuserdontexist",
"",
null
);
for (String invalidUser : invalidList) {
try {
subscriptionExtractor.fromChannelUrl(invalidUser);
fail("didn't throw exception");
} catch (IOException e) {
// Ignore it, could be an unstable network on the CI server
} catch (Exception e) {
boolean isExpectedException = e instanceof SubscriptionExtractor.InvalidSourceException;
assertTrue(e.getClass().getSimpleName() + " is not the expected exception", isExpectedException);
}
}
}
private void testList(List<SubscriptionItem> subscriptionItems) throws ParsingException {
for (SubscriptionItem item : subscriptionItems) {
assertNotNull(item.getName()); assertNotNull(item.getName());
assertNotNull(item.getUrl()); assertNotNull(item.getUrl());
assertTrue(urlHandler.acceptUrl(item.getUrl())); assertTrue(urlHandler.acceptUrl(item.getUrl()));
assertFalse(item.getServiceId() == -1); assertNotEquals(-1, item.getServiceId());
} }
} }
@ParameterizedTest
@ValueSource(strings = {
"httttps://invalid.com/user",
".com/monstercat",
"ithinkthatthisuserdontexist",
""
})
void testInvalidSourceException(final String invalidUser) {
assertThrows(
SubscriptionExtractor.InvalidSourceException.class,
() -> subscriptionExtractor.fromChannelUrl(invalidUser));
}
// null can't be added to the above value source because it's not a constant
@Test
void testInvalidSourceExceptionWhenUrlIsNull() {
assertThrows(
SubscriptionExtractor.InvalidSourceException.class,
() -> subscriptionExtractor.fromChannelUrl(null));
}
} }

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.soundcloud; package org.schabi.newpipe.extractor.services.soundcloud;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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;
@ -9,7 +9,7 @@ import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;
import java.io.IOException; import java.io.IOException;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
/** /**
@ -18,7 +18,7 @@ import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
public class SoundcloudSuggestionExtractorTest { public class SoundcloudSuggestionExtractorTest {
private static SuggestionExtractor suggestionExtractor; private static SuggestionExtractor suggestionExtractor;
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
suggestionExtractor = SoundCloud.getSuggestionExtractor(); suggestionExtractor = SoundCloud.getSuggestionExtractor();

View File

@ -1,8 +1,7 @@
package org.schabi.newpipe.extractor.services.soundcloud.search; package org.schabi.newpipe.extractor.services.soundcloud.search;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Ignore; import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage; import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
@ -20,7 +19,7 @@ import java.net.URLEncoder;
import java.util.List; import java.util.List;
import static java.util.Collections.singletonList; import static java.util.Collections.singletonList;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
import static org.schabi.newpipe.extractor.services.DefaultTests.assertNoDuplicatedItems; import static org.schabi.newpipe.extractor.services.DefaultTests.assertNoDuplicatedItems;
import static org.schabi.newpipe.extractor.services.soundcloud.linkHandler.SoundcloudSearchQueryHandlerFactory.*; import static org.schabi.newpipe.extractor.services.soundcloud.linkHandler.SoundcloudSearchQueryHandlerFactory.*;
@ -32,7 +31,7 @@ public class SoundcloudSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "lill uzi vert"; private static final String QUERY = "lill uzi vert";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = SoundCloud.getSearchExtractor(QUERY); extractor = SoundCloud.getSearchExtractor(QUERY);
@ -55,7 +54,7 @@ public class SoundcloudSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "lill uzi vert"; private static final String QUERY = "lill uzi vert";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = SoundCloud.getSearchExtractor(QUERY, singletonList(TRACKS), ""); extractor = SoundCloud.getSearchExtractor(QUERY, singletonList(TRACKS), "");
@ -79,7 +78,7 @@ public class SoundcloudSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "lill uzi vert"; private static final String QUERY = "lill uzi vert";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = SoundCloud.getSearchExtractor(QUERY, singletonList(USERS), ""); extractor = SoundCloud.getSearchExtractor(QUERY, singletonList(USERS), "");
@ -103,7 +102,7 @@ public class SoundcloudSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "lill uzi vert"; private static final String QUERY = "lill uzi vert";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = SoundCloud.getSearchExtractor(QUERY, singletonList(PLAYLISTS), ""); extractor = SoundCloud.getSearchExtractor(QUERY, singletonList(PLAYLISTS), "");
@ -149,7 +148,7 @@ public class SoundcloudSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "David Guetta"; private static final String QUERY = "David Guetta";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = SoundCloud.getSearchExtractor(QUERY, singletonList(USERS), ""); extractor = SoundCloud.getSearchExtractor(QUERY, singletonList(USERS), "");
@ -168,7 +167,7 @@ public class SoundcloudSearchExtractorTest {
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.CHANNEL; } @Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.CHANNEL; }
@Test @Test
public void testIsVerified() throws IOException, ExtractionException { void testIsVerified() throws IOException, ExtractionException {
final List<InfoItem> items = extractor.getInitialPage().getItems(); final List<InfoItem> items = extractor.getInitialPage().getItems();
boolean verified = false; boolean verified = false;
for (InfoItem item : items) { for (InfoItem item : items) {

View File

@ -1,19 +1,18 @@
package org.schabi.newpipe.extractor.services.soundcloud.search; package org.schabi.newpipe.extractor.services.soundcloud.search;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Ignore; import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
import static org.schabi.newpipe.extractor.services.soundcloud.linkHandler.SoundcloudSearchQueryHandlerFactory.*; import static org.schabi.newpipe.extractor.services.soundcloud.linkHandler.SoundcloudSearchQueryHandlerFactory.*;
public class SoundcloudSearchQHTest { public class SoundcloudSearchQHTest {
@BeforeClass @BeforeAll
public static void setUpClass() throws Exception { public static void setUpClass() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
} }

View File

@ -1,9 +1,10 @@
package org.schabi.newpipe.extractor.services.youtube; package org.schabi.newpipe.extractor.services.youtube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderFactory; import org.schabi.newpipe.downloader.DownloaderFactory;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.ExtractorAsserts;
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.exceptions.AccountTerminatedException; import org.schabi.newpipe.extractor.exceptions.AccountTerminatedException;
@ -16,9 +17,8 @@ import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeChannelEx
import java.io.IOException; import java.io.IOException;
import java.util.Random; import java.util.Random;
import static org.hamcrest.CoreMatchers.containsString; import static org.junit.jupiter.api.Assertions.*;
import static org.hamcrest.MatcherAssert.assertThat; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertContains;
import static org.junit.Assert.*;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.ServiceList.YouTube;
import static org.schabi.newpipe.extractor.services.DefaultTests.*; import static org.schabi.newpipe.extractor.services.DefaultTests.*;
@ -31,132 +31,123 @@ public class YoutubeChannelExtractorTest {
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/youtube/extractor/channel/"; private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/youtube/extractor/channel/";
public static class NotAvailable { public static class NotAvailable {
@BeforeClass @BeforeAll
public static void setUp() throws IOException { public static void setUp() throws IOException {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "notAvailable")); NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "notAvailable"));
} }
@Test(expected = ContentNotAvailableException.class) @Test
public void deletedFetch() throws Exception { public void deletedFetch() throws Exception {
final ChannelExtractor extractor = final ChannelExtractor extractor =
YouTube.getChannelExtractor("https://www.youtube.com/channel/UCAUc4iz6edWerIjlnL8OSSw"); YouTube.getChannelExtractor("https://www.youtube.com/channel/UCAUc4iz6edWerIjlnL8OSSw");
extractor.fetchPage();
assertThrows(ContentNotAvailableException.class, extractor::fetchPage);
} }
@Test(expected = ContentNotAvailableException.class) @Test
public void nonExistentFetch() throws Exception { public void nonExistentFetch() throws Exception {
final ChannelExtractor extractor = final ChannelExtractor extractor =
YouTube.getChannelExtractor("https://www.youtube.com/channel/DOESNT-EXIST"); YouTube.getChannelExtractor("https://www.youtube.com/channel/DOESNT-EXIST");
extractor.fetchPage();
assertThrows(ContentNotAvailableException.class, extractor::fetchPage);
} }
@Test(expected = AccountTerminatedException.class) @Test
public void accountTerminatedTOSFetch() throws Exception { public void accountTerminatedTOSFetch() throws Exception {
// "This account has been terminated for a violation of YouTube's Terms of Service." // "This account has been terminated for a violation of YouTube's Terms of Service."
final ChannelExtractor extractor = final ChannelExtractor extractor =
YouTube.getChannelExtractor("https://www.youtube.com/channel/UCTGjY2I-ZUGnwVoWAGRd7XQ"); YouTube.getChannelExtractor("https://www.youtube.com/channel/UCTGjY2I-ZUGnwVoWAGRd7XQ");
try {
extractor.fetchPage(); AccountTerminatedException ex =
} catch (final AccountTerminatedException e) { assertThrows(AccountTerminatedException.class, extractor::fetchPage);
assertEquals(e.getReason(), AccountTerminatedException.Reason.VIOLATION); assertEquals(AccountTerminatedException.Reason.VIOLATION, ex.getReason());
throw e;
}
} }
@Test(expected = AccountTerminatedException.class) @Test
public void accountTerminatedCommunityFetch() throws Exception { public void accountTerminatedCommunityFetch() throws Exception {
// "This account has been terminated for violating YouTube's Community Guidelines." // "This account has been terminated for violating YouTube's Community Guidelines."
final ChannelExtractor extractor = final ChannelExtractor extractor =
YouTube.getChannelExtractor("https://www.youtube.com/channel/UC0AuOxCr9TZ0TtEgL1zpIgA"); YouTube.getChannelExtractor("https://www.youtube.com/channel/UC0AuOxCr9TZ0TtEgL1zpIgA");
try {
extractor.fetchPage(); AccountTerminatedException ex =
} catch (final AccountTerminatedException e) { assertThrows(AccountTerminatedException.class, extractor::fetchPage);
assertEquals(e.getReason(), AccountTerminatedException.Reason.VIOLATION); assertEquals(AccountTerminatedException.Reason.VIOLATION, ex.getReason());
throw e;
}
} }
@Test(expected = AccountTerminatedException.class) @Test
public void accountTerminatedHateFetch() throws Exception { public void accountTerminatedHateFetch() throws Exception {
// "This account has been terminated due to multiple or severe violations // "This account has been terminated due to multiple or severe violations
// of YouTube's policy prohibiting hate speech." // of YouTube's policy prohibiting hate speech."
final ChannelExtractor extractor = final ChannelExtractor extractor =
YouTube.getChannelExtractor("https://www.youtube.com/channel/UCPWXIOPK-9myzek6jHR5yrg"); YouTube.getChannelExtractor("https://www.youtube.com/channel/UCPWXIOPK-9myzek6jHR5yrg");
try {
extractor.fetchPage(); AccountTerminatedException ex =
} catch (final AccountTerminatedException e) { assertThrows(AccountTerminatedException.class, extractor::fetchPage);
assertEquals(e.getReason(), AccountTerminatedException.Reason.VIOLATION); assertEquals(AccountTerminatedException.Reason.VIOLATION, ex.getReason());
throw e;
}
} }
@Test(expected = AccountTerminatedException.class) @Test
public void accountTerminatedBullyFetch() throws Exception { public void accountTerminatedBullyFetch() throws Exception {
// "This account has been terminated due to multiple or severe violations // "This account has been terminated due to multiple or severe violations
// of YouTube's policy prohibiting content designed to harass, bully or threaten." // of YouTube's policy prohibiting content designed to harass, bully or threaten."
final ChannelExtractor extractor = final ChannelExtractor extractor =
YouTube.getChannelExtractor("https://youtube.com/channel/UCB1o7_gbFp2PLsamWxFenBg"); YouTube.getChannelExtractor("https://youtube.com/channel/UCB1o7_gbFp2PLsamWxFenBg");
try {
extractor.fetchPage(); AccountTerminatedException ex =
} catch (final AccountTerminatedException e) { assertThrows(AccountTerminatedException.class, extractor::fetchPage);
assertEquals(e.getReason(), AccountTerminatedException.Reason.VIOLATION); assertEquals(AccountTerminatedException.Reason.VIOLATION, ex.getReason());
throw e;
}
} }
@Test(expected = AccountTerminatedException.class) @Test
public void accountTerminatedSpamFetch() throws Exception { public void accountTerminatedSpamFetch() throws Exception {
// "This account has been terminated due to multiple or severe violations // "This account has been terminated due to multiple or severe violations
// of YouTube's policy against spam, deceptive practices and misleading content // of YouTube's policy against spam, deceptive practices and misleading content
// or other Terms of Service violations." // or other Terms of Service violations."
final ChannelExtractor extractor = final ChannelExtractor extractor =
YouTube.getChannelExtractor("https://www.youtube.com/channel/UCoaO4U_p7G7AwalqSbGCZOA"); YouTube.getChannelExtractor("https://www.youtube.com/channel/UCoaO4U_p7G7AwalqSbGCZOA");
try {
extractor.fetchPage(); AccountTerminatedException ex =
} catch (final AccountTerminatedException e) { assertThrows(AccountTerminatedException.class, extractor::fetchPage);
assertEquals(e.getReason(), AccountTerminatedException.Reason.VIOLATION); assertEquals(AccountTerminatedException.Reason.VIOLATION, ex.getReason());
throw e;
}
} }
@Test(expected = AccountTerminatedException.class) @Test
public void accountTerminatedCopyrightFetch() throws Exception { public void accountTerminatedCopyrightFetch() throws Exception {
// "This account has been terminated because we received multiple third-party claims // "This account has been terminated because we received multiple third-party claims
// of copyright infringement regarding material that the user posted." // of copyright infringement regarding material that the user posted."
final ChannelExtractor extractor = final ChannelExtractor extractor =
YouTube.getChannelExtractor("https://www.youtube.com/channel/UCI4i4RgFT5ilfMpna4Z_Y8w"); YouTube.getChannelExtractor("https://www.youtube.com/channel/UCI4i4RgFT5ilfMpna4Z_Y8w");
try {
extractor.fetchPage(); AccountTerminatedException ex =
} catch (final AccountTerminatedException e) { assertThrows(AccountTerminatedException.class, extractor::fetchPage);
assertEquals(e.getReason(), AccountTerminatedException.Reason.VIOLATION); assertEquals(AccountTerminatedException.Reason.VIOLATION, ex.getReason());
throw e;
}
} }
} }
public static class NotSupported { public static class NotSupported {
@BeforeClass @BeforeAll
public static void setUp() throws IOException { public static void setUp() throws IOException {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "notSupported")); NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "notSupported"));
} }
@Test(expected = ContentNotSupportedException.class) @Test
public void noVideoTab() throws Exception { void noVideoTab() throws Exception {
final ChannelExtractor extractor = YouTube.getChannelExtractor("https://invidio.us/channel/UC-9-kyTW8ZkZNDHQJ6FgpwQ"); final ChannelExtractor extractor = YouTube.getChannelExtractor("https://invidio.us/channel/UC-9-kyTW8ZkZNDHQJ6FgpwQ");
extractor.fetchPage(); extractor.fetchPage();
extractor.getInitialPage(); assertThrows(ContentNotSupportedException.class, extractor::getInitialPage);
} }
} }
public static class Gronkh implements BaseChannelExtractorTest { public static class Gronkh implements BaseChannelExtractorTest {
private static YoutubeChannelExtractor extractor; private static YoutubeChannelExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -215,21 +206,21 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testDescription() throws Exception { public void testDescription() throws Exception {
assertThat(extractor.getDescription(), containsString("Ungebremster Spieltrieb seit 1896.")); assertContains("Ungebremster Spieltrieb seit 1896.", extractor.getDescription());
} }
@Test @Test
public void testAvatarUrl() throws Exception { public void testAvatarUrl() throws Exception {
String avatarUrl = extractor.getAvatarUrl(); String avatarUrl = extractor.getAvatarUrl();
assertIsSecureUrl(avatarUrl); assertIsSecureUrl(avatarUrl);
assertTrue(avatarUrl, avatarUrl.contains("yt3")); ExtractorAsserts.assertContains("yt3", avatarUrl);
} }
@Test @Test
public void testBannerUrl() throws Exception { public void testBannerUrl() throws Exception {
String bannerUrl = extractor.getBannerUrl(); String bannerUrl = extractor.getBannerUrl();
assertIsSecureUrl(bannerUrl); assertIsSecureUrl(bannerUrl);
assertTrue(bannerUrl, bannerUrl.contains("yt3")); ExtractorAsserts.assertContains("yt3", bannerUrl);
} }
@Test @Test
@ -239,8 +230,7 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testSubscriberCount() throws Exception { public void testSubscriberCount() throws Exception {
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 0); ExtractorAsserts.assertGreaterOrEqual(4_900_000, extractor.getSubscriberCount());
assertTrue("Subscriber count too small", extractor.getSubscriberCount() >= 4e6);
} }
@Override @Override
@ -254,7 +244,7 @@ public class YoutubeChannelExtractorTest {
public static class VSauce implements BaseChannelExtractorTest { public static class VSauce implements BaseChannelExtractorTest {
private static YoutubeChannelExtractor extractor; private static YoutubeChannelExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -313,22 +303,21 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testDescription() throws Exception { public void testDescription() throws Exception {
assertTrue("What it actually was: " + extractor.getDescription(), assertContains("Our World is Amazing. \n\nQuestions? Ideas? Tweet me:", extractor.getDescription());
extractor.getDescription().contains("Our World is Amazing. \n\nQuestions? Ideas? Tweet me:"));
} }
@Test @Test
public void testAvatarUrl() throws Exception { public void testAvatarUrl() throws Exception {
String avatarUrl = extractor.getAvatarUrl(); String avatarUrl = extractor.getAvatarUrl();
assertIsSecureUrl(avatarUrl); assertIsSecureUrl(avatarUrl);
assertTrue(avatarUrl, avatarUrl.contains("yt3")); ExtractorAsserts.assertContains("yt3", avatarUrl);
} }
@Test @Test
public void testBannerUrl() throws Exception { public void testBannerUrl() throws Exception {
String bannerUrl = extractor.getBannerUrl(); String bannerUrl = extractor.getBannerUrl();
assertIsSecureUrl(bannerUrl); assertIsSecureUrl(bannerUrl);
assertTrue(bannerUrl, bannerUrl.contains("yt3")); ExtractorAsserts.assertContains("yt3", bannerUrl);
} }
@Test @Test
@ -338,11 +327,10 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testSubscriberCount() throws Exception { public void testSubscriberCount() throws Exception {
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 0); ExtractorAsserts.assertGreaterOrEqual(17_000_000, extractor.getSubscriberCount());
assertTrue("Subscriber count too small", extractor.getSubscriberCount() >= 10e6);
} }
@Override @Test
public void testVerified() throws Exception { public void testVerified() throws Exception {
assertTrue(extractor.isVerified()); assertTrue(extractor.isVerified());
} }
@ -352,7 +340,7 @@ public class YoutubeChannelExtractorTest {
public static class Kurzgesagt implements BaseChannelExtractorTest { public static class Kurzgesagt implements BaseChannelExtractorTest {
private static YoutubeChannelExtractor extractor; private static YoutubeChannelExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -373,8 +361,7 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testName() throws Exception { public void testName() throws Exception {
String name = extractor.getName(); assertTrue(extractor.getName().startsWith("Kurzgesagt"));
assertTrue(name, name.startsWith("Kurzgesagt"));
} }
@Test @Test
@ -412,8 +399,7 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testDescription() throws Exception { public void testDescription() throws Exception {
final String description = extractor.getDescription(); ExtractorAsserts.assertContains("small team who want to make science look beautiful", extractor.getDescription());
assertTrue(description, description.contains("small team who want to make science look beautiful"));
//TODO: Description get cuts out, because the og:description is optimized and don't have all the content //TODO: Description get cuts out, because the og:description is optimized and don't have all the content
//assertTrue(description, description.contains("Currently we make one animation video per month")); //assertTrue(description, description.contains("Currently we make one animation video per month"));
} }
@ -422,14 +408,14 @@ public class YoutubeChannelExtractorTest {
public void testAvatarUrl() throws Exception { public void testAvatarUrl() throws Exception {
String avatarUrl = extractor.getAvatarUrl(); String avatarUrl = extractor.getAvatarUrl();
assertIsSecureUrl(avatarUrl); assertIsSecureUrl(avatarUrl);
assertTrue(avatarUrl, avatarUrl.contains("yt3")); ExtractorAsserts.assertContains("yt3", avatarUrl);
} }
@Test @Test
public void testBannerUrl() throws Exception { public void testBannerUrl() throws Exception {
String bannerUrl = extractor.getBannerUrl(); String bannerUrl = extractor.getBannerUrl();
assertIsSecureUrl(bannerUrl); assertIsSecureUrl(bannerUrl);
assertTrue(bannerUrl, bannerUrl.contains("yt3")); ExtractorAsserts.assertContains("yt3", bannerUrl);
} }
@Test @Test
@ -439,10 +425,10 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testSubscriberCount() throws Exception { public void testSubscriberCount() throws Exception {
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 5e6); ExtractorAsserts.assertGreaterOrEqual(17_000_000, extractor.getSubscriberCount());
} }
@Override @Test
public void testVerified() throws Exception { public void testVerified() throws Exception {
assertTrue(extractor.isVerified()); assertTrue(extractor.isVerified());
} }
@ -452,7 +438,7 @@ public class YoutubeChannelExtractorTest {
private static YoutubeChannelExtractor extractor; private static YoutubeChannelExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
// Test is not deterministic, mocks can't be used // Test is not deterministic, mocks can't be used
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
@ -471,7 +457,7 @@ public class YoutubeChannelExtractorTest {
public static class CaptainDisillusion implements BaseChannelExtractorTest { public static class CaptainDisillusion implements BaseChannelExtractorTest {
private static YoutubeChannelExtractor extractor; private static YoutubeChannelExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -530,22 +516,21 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testDescription() throws Exception { public void testDescription() throws Exception {
final String description = extractor.getDescription(); ExtractorAsserts.assertContains("In a world where", extractor.getDescription());
assertTrue(description, description.contains("In a world where"));
} }
@Test @Test
public void testAvatarUrl() throws Exception { public void testAvatarUrl() throws Exception {
String avatarUrl = extractor.getAvatarUrl(); String avatarUrl = extractor.getAvatarUrl();
assertIsSecureUrl(avatarUrl); assertIsSecureUrl(avatarUrl);
assertTrue(avatarUrl, avatarUrl.contains("yt3")); ExtractorAsserts.assertContains("yt3", avatarUrl);
} }
@Test @Test
public void testBannerUrl() throws Exception { public void testBannerUrl() throws Exception {
String bannerUrl = extractor.getBannerUrl(); String bannerUrl = extractor.getBannerUrl();
assertIsSecureUrl(bannerUrl); assertIsSecureUrl(bannerUrl);
assertTrue(bannerUrl, bannerUrl.contains("yt3")); ExtractorAsserts.assertContains("yt3", bannerUrl);
} }
@Test @Test
@ -555,10 +540,10 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testSubscriberCount() throws Exception { public void testSubscriberCount() throws Exception {
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 5e5); ExtractorAsserts.assertGreaterOrEqual(2_000_000, extractor.getSubscriberCount());
} }
@Override @Test
public void testVerified() throws Exception { public void testVerified() throws Exception {
assertTrue(extractor.isVerified()); assertTrue(extractor.isVerified());
} }
@ -567,7 +552,7 @@ public class YoutubeChannelExtractorTest {
public static class RandomChannel implements BaseChannelExtractorTest { public static class RandomChannel implements BaseChannelExtractorTest {
private static YoutubeChannelExtractor extractor; private static YoutubeChannelExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -632,22 +617,21 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testDescription() throws Exception { public void testDescription() throws Exception {
final String description = extractor.getDescription(); ExtractorAsserts.assertContains("Hey there iu will upoload a load of pranks onto this channel", extractor.getDescription());
assertTrue(description, description.contains("Hey there iu will upoload a load of pranks onto this channel"));
} }
@Test @Test
public void testAvatarUrl() throws Exception { public void testAvatarUrl() throws Exception {
String avatarUrl = extractor.getAvatarUrl(); String avatarUrl = extractor.getAvatarUrl();
assertIsSecureUrl(avatarUrl); assertIsSecureUrl(avatarUrl);
assertTrue(avatarUrl, avatarUrl.contains("yt3")); ExtractorAsserts.assertContains("yt3", avatarUrl);
} }
@Test @Test
public void testBannerUrl() throws Exception { public void testBannerUrl() throws Exception {
String bannerUrl = extractor.getBannerUrl(); String bannerUrl = extractor.getBannerUrl();
assertIsSecureUrl(bannerUrl); assertIsSecureUrl(bannerUrl);
assertTrue(bannerUrl, bannerUrl.contains("yt3")); ExtractorAsserts.assertContains("yt3", bannerUrl);
} }
@Test @Test
@ -657,11 +641,10 @@ public class YoutubeChannelExtractorTest {
@Test @Test
public void testSubscriberCount() throws Exception { public void testSubscriberCount() throws Exception {
long subscribers = extractor.getSubscriberCount(); ExtractorAsserts.assertGreaterOrEqual(50, extractor.getSubscriberCount());
assertTrue("Wrong subscriber count: " + subscribers, subscribers >= 50);
} }
@Override @Test
public void testVerified() throws Exception { public void testVerified() throws Exception {
assertFalse(extractor.isVerified()); assertFalse(extractor.isVerified());
} }

View File

@ -1,15 +1,15 @@
package org.schabi.newpipe.extractor.services.youtube; package org.schabi.newpipe.extractor.services.youtube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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.youtube.linkHandler.YoutubeChannelLinkHandlerFactory; import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelLinkHandlerFactory;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
/** /**
* Test for {@link YoutubeChannelLinkHandlerFactory} * Test for {@link YoutubeChannelLinkHandlerFactory}
@ -18,7 +18,7 @@ public class YoutubeChannelLinkHandlerFactoryTest {
private static YoutubeChannelLinkHandlerFactory linkHandler; private static YoutubeChannelLinkHandlerFactory linkHandler;
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
linkHandler = YoutubeChannelLinkHandlerFactory.getInstance(); linkHandler = YoutubeChannelLinkHandlerFactory.getInstance();
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());

View File

@ -1,6 +1,6 @@
package org.schabi.newpipe.extractor.services.youtube; package org.schabi.newpipe.extractor.services.youtube;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderFactory; 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;
@ -16,7 +16,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import static org.junit.Assert.fail; import static org.junit.jupiter.api.Assertions.fail;
import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.ServiceList.YouTube;
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems; import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems;

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.youtube; package org.schabi.newpipe.extractor.services.youtube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderFactory; import org.schabi.newpipe.downloader.DownloaderFactory;
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage; import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
@ -19,10 +19,10 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Random; import java.util.Random;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.ServiceList.YouTube;
public class YoutubeCommentsExtractorTest { public class YoutubeCommentsExtractorTest {
@ -36,7 +36,7 @@ public class YoutubeCommentsExtractorTest {
private static final String commentContent = "Category: Education"; private static final String commentContent = "Category: Education";
private static YoutubeCommentsExtractor extractor; private static YoutubeCommentsExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -125,7 +125,7 @@ public class YoutubeCommentsExtractorTest {
private final static String url = "https://www.youtube.com/watch?v=VM_6n762j6M"; private final static String url = "https://www.youtube.com/watch?v=VM_6n762j6M";
private static YoutubeCommentsExtractor extractor; private static YoutubeCommentsExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -165,7 +165,7 @@ public class YoutubeCommentsExtractorTest {
private final static String url = "https://www.youtube.com/watch?v=tR11b7uh17Y"; private final static String url = "https://www.youtube.com/watch?v=tR11b7uh17Y";
private static YoutubeCommentsExtractor extractor; private static YoutubeCommentsExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -199,7 +199,7 @@ public class YoutubeCommentsExtractorTest {
heartedByUploader = true; heartedByUploader = true;
} }
} }
assertTrue("No comments was hearted by uploader", heartedByUploader); assertTrue(heartedByUploader, "No comments was hearted by uploader");
} }
} }
@ -208,7 +208,7 @@ public class YoutubeCommentsExtractorTest {
private final static String url = "https://www.youtube.com/watch?v=bjFtFMilb34"; private final static String url = "https://www.youtube.com/watch?v=bjFtFMilb34";
private static YoutubeCommentsExtractor extractor; private static YoutubeCommentsExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -238,7 +238,7 @@ public class YoutubeCommentsExtractorTest {
assertFalse(Utils.isBlank(c.getCommentText())); assertFalse(Utils.isBlank(c.getCommentText()));
} }
assertTrue("First comment isn't pinned", comments.getItems().get(0).isPinned()); assertTrue(comments.getItems().get(0).isPinned(), "First comment isn't pinned");
} }
} }
@ -250,7 +250,7 @@ public class YoutubeCommentsExtractorTest {
private final static String url = "https://www.youtube.com/watch?v=QqsLTNkzvaY"; private final static String url = "https://www.youtube.com/watch?v=QqsLTNkzvaY";
private static YoutubeCommentsExtractor extractor; private static YoutubeCommentsExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -268,9 +268,9 @@ public class YoutubeCommentsExtractorTest {
CommentsInfoItem pinnedComment = comments.getItems().get(0); CommentsInfoItem pinnedComment = comments.getItems().get(0);
assertTrue("First comment isn't pinned", pinnedComment.isPinned()); assertTrue(pinnedComment.isPinned(), "First comment isn't pinned");
assertTrue("The first pinned comment has no likes", pinnedComment.getLikeCount() > 0); assertTrue(pinnedComment.getLikeCount() > 0, "The first pinned comment has no likes");
assertTrue("The first pinned comment has no vote count", !Utils.isBlank(pinnedComment.getTextualLikeCount())); assertFalse(Utils.isBlank(pinnedComment.getTextualLikeCount()), "The first pinned comment has no vote count");
} }
} }
@ -282,7 +282,7 @@ public class YoutubeCommentsExtractorTest {
private final static String url = "https://www.youtube.com/watch?v=QqsLTNkzvaY"; private final static String url = "https://www.youtube.com/watch?v=QqsLTNkzvaY";
private static YoutubeCommentsExtractor extractor; private static YoutubeCommentsExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -302,8 +302,8 @@ public class YoutubeCommentsExtractorTest {
CommentsInfoItem pinnedComment = comments.getItems().get(0); CommentsInfoItem pinnedComment = comments.getItems().get(0);
assertTrue("First comment isn't pinned", pinnedComment.isPinned()); assertTrue(pinnedComment.isPinned(), "First comment isn't pinned");
assertTrue("The first pinned comment has no vote count", !Utils.isBlank(pinnedComment.getTextualLikeCount())); assertFalse(Utils.isBlank(pinnedComment.getTextualLikeCount()), "The first pinned comment has no vote count");
} }
} }
@ -311,7 +311,7 @@ public class YoutubeCommentsExtractorTest {
private final static String url = "https://www.youtube.com/watch?v=xaQJbozY_Is"; private final static String url = "https://www.youtube.com/watch?v=xaQJbozY_Is";
private static YoutubeCommentsExtractor extractor; private static YoutubeCommentsExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -329,11 +329,12 @@ public class YoutubeCommentsExtractorTest {
CommentsInfoItem firstComment = comments.getItems().get(0); CommentsInfoItem firstComment = comments.getItems().get(0);
assertTrue("First comment isn't pinned", firstComment.isPinned()); assertTrue(firstComment.isPinned(), "First comment isn't pinned");
InfoItemsPage<CommentsInfoItem> replies = extractor.getPage(firstComment.getReplies()); InfoItemsPage<CommentsInfoItem> replies = extractor.getPage(firstComment.getReplies());
assertEquals("First reply comment did not match", "First", replies.getItems().get(0).getCommentText()); assertEquals("First", replies.getItems().get(0).getCommentText(),
"First reply comment did not match");
} }
} }
} }

View File

@ -1,29 +1,30 @@
package org.schabi.newpipe.extractor.services.youtube; package org.schabi.newpipe.extractor.services.youtube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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.youtube.linkHandler.YoutubeCommentsLinkHandlerFactory; import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeCommentsLinkHandlerFactory;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class YoutubeCommentsLinkHandlerFactoryTest { public class YoutubeCommentsLinkHandlerFactoryTest {
private static YoutubeCommentsLinkHandlerFactory linkHandler; private static YoutubeCommentsLinkHandlerFactory linkHandler;
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
linkHandler = YoutubeCommentsLinkHandlerFactory.getInstance(); linkHandler = YoutubeCommentsLinkHandlerFactory.getInstance();
} }
@Test(expected = IllegalArgumentException.class) @Test
public void getIdWithNullAsUrl() throws ParsingException { public void getIdWithNullAsUrl() {
linkHandler.fromId(null); assertThrows(IllegalArgumentException.class, () -> linkHandler.fromId(null));
} }
@Test @Test

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.youtube; package org.schabi.newpipe.extractor.services.youtube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderFactory; 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;
@ -12,8 +12,9 @@ import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeFeedExtra
import java.io.IOException; import java.io.IOException;
import java.util.Random; import java.util.Random;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.ServiceList.YouTube;
import static org.schabi.newpipe.extractor.services.DefaultTests.assertNoMoreItems; import static org.schabi.newpipe.extractor.services.DefaultTests.assertNoMoreItems;
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems; import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems;
@ -25,7 +26,7 @@ public class YoutubeFeedExtractorTest {
public static class Kurzgesagt implements BaseListExtractorTest { public static class Kurzgesagt implements BaseListExtractorTest {
private static YoutubeFeedExtractor extractor; private static YoutubeFeedExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -46,8 +47,7 @@ public class YoutubeFeedExtractorTest {
@Test @Test
public void testName() { public void testName() {
String name = extractor.getName(); assertTrue(extractor.getName().startsWith("Kurzgesagt"));
assertTrue(name, name.startsWith("Kurzgesagt"));
} }
@Test @Test
@ -82,16 +82,16 @@ public class YoutubeFeedExtractorTest {
public static class NotAvailable { public static class NotAvailable {
@BeforeClass @BeforeAll
public static void setUp() throws IOException { public static void setUp() throws IOException {
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "notAvailable/")); NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "notAvailable/"));
} }
@Test(expected = ContentNotAvailableException.class) @Test
public void AccountTerminatedFetch() throws Exception { void AccountTerminatedFetch() throws Exception {
YoutubeFeedExtractor extractor = (YoutubeFeedExtractor) YouTube YoutubeFeedExtractor extractor = (YoutubeFeedExtractor) YouTube
.getFeedExtractor("https://www.youtube.com/channel/UCTGjY2I-ZUGnwVoWAGRd7XQ"); .getFeedExtractor("https://www.youtube.com/channel/UCTGjY2I-ZUGnwVoWAGRd7XQ");
extractor.fetchPage(); assertThrows(ContentNotAvailableException.class, extractor::fetchPage);
} }
} }
} }

View File

@ -1,31 +1,31 @@
package org.schabi.newpipe.extractor.services.youtube; package org.schabi.newpipe.extractor.services.youtube;
import org.junit.Before; import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.ExtractorAsserts;
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 java.io.IOException; import java.io.IOException;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
public class YoutubeJavaScriptExtractorTest { public class YoutubeJavaScriptExtractorTest {
@Before @BeforeEach
public void setup() throws IOException { public void setup() throws IOException {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
} }
@Test @Test
public void testExtractJavaScriptUrlIframe() throws ParsingException { public void testExtractJavaScriptUrlIframe() throws ParsingException {
assertThat(YoutubeJavaScriptExtractor.extractJavaScriptUrl(), endsWith("base.js")); assertTrue(YoutubeJavaScriptExtractor.extractJavaScriptUrl().endsWith("base.js"));
} }
@Test @Test
public void testExtractJavaScriptUrlEmbed() throws ParsingException { public void testExtractJavaScriptUrlEmbed() throws ParsingException {
assertThat(YoutubeJavaScriptExtractor.extractJavaScriptUrl("d4IGg5dqeO8"), endsWith("base.js")); assertTrue(YoutubeJavaScriptExtractor.extractJavaScriptUrl("d4IGg5dqeO8").endsWith("base.js"));
} }
@Test @Test
@ -48,9 +48,8 @@ public class YoutubeJavaScriptExtractorTest {
} }
private void assertPlayerJsCode(final String playerJsCode) { private void assertPlayerJsCode(final String playerJsCode) {
assertThat(playerJsCode, allOf( ExtractorAsserts.assertContains(" Copyright The Closure Library Authors.\n"
containsString(" Copyright The Closure Library Authors.\n" + " SPDX-License-Identifier: Apache-2.0", playerJsCode);
+ " SPDX-License-Identifier: Apache-2.0"), ExtractorAsserts.assertContains("var _yt_player", playerJsCode);
containsString("var _yt_player")));
} }
} }

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.youtube; package org.schabi.newpipe.extractor.services.youtube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderFactory; 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;
@ -10,7 +10,7 @@ import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeTrendingE
import java.util.Random; import java.util.Random;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.ServiceList.YouTube;
import static org.schabi.newpipe.extractor.services.DefaultTests.assertNoMoreItems; import static org.schabi.newpipe.extractor.services.DefaultTests.assertNoMoreItems;
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems; import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems;
@ -22,7 +22,7 @@ public class YoutubeKioskExtractorTest {
public static class Trending implements BaseListExtractorTest { public static class Trending implements BaseListExtractorTest {
private static YoutubeTrendingExtractor extractor; private static YoutubeTrendingExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));

View File

@ -1,11 +1,11 @@
package org.schabi.newpipe.extractor.services.youtube; package org.schabi.newpipe.extractor.services.youtube;
import com.grack.nanojson.JsonWriter; import com.grack.nanojson.JsonWriter;
import org.hamcrest.MatcherAssert; import org.junit.jupiter.api.BeforeAll;
import org.junit.BeforeClass; import org.junit.jupiter.api.Disabled;
import org.junit.Ignore; import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.schabi.newpipe.downloader.DownloaderFactory; import org.schabi.newpipe.downloader.DownloaderFactory;
import org.schabi.newpipe.extractor.ExtractorAsserts;
import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage; import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
@ -15,33 +15,29 @@ import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeMixPlayli
import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import static org.hamcrest.CoreMatchers.containsString; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.hamcrest.CoreMatchers.startsWith; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.ServiceList.YouTube;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.*; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.*;
import static org.schabi.newpipe.extractor.utils.Utils.UTF_8;
public class YoutubeMixPlaylistExtractorTest { public class YoutubeMixPlaylistExtractorTest {
private static final String VIDEO_ID = "_AzeUSL9lZc";
private static final String VIDEO_TITLE =
"Most Beautiful And Emotional Piano: Anime Music Shigatsu wa Kimi no Uso OST IMO";
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/youtube/extractor/mix/"; private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/youtube/extractor/mix/";
private static final Map<String, String> dummyCookie = new HashMap<>(); private static final Map<String, String> dummyCookie = new HashMap<>();
private static YoutubeMixPlaylistExtractor extractor; private static YoutubeMixPlaylistExtractor extractor;
@Ignore("Test broken, video was blocked by SME and is only available in Japan")
public static class Mix { public static class Mix {
private static final String VIDEO_ID = "QMVCAPd5cwBcg";
private static final String VIDEO_TITLE = "Mix ";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -54,41 +50,41 @@ public class YoutubeMixPlaylistExtractorTest {
} }
@Test @Test
public void getServiceId() { void getServiceId() {
assertEquals(YouTube.getServiceId(), extractor.getServiceId()); assertEquals(YouTube.getServiceId(), extractor.getServiceId());
} }
@Test @Test
public void getName() throws Exception { void getName() throws Exception {
final String name = extractor.getName(); final String name = extractor.getName();
assertThat(name, startsWith("Mix")); ExtractorAsserts.assertContains("Mix", name);
assertThat(name, containsString(VIDEO_TITLE)); ExtractorAsserts.assertContains(VIDEO_TITLE, name);
} }
@Test @Test
public void getThumbnailUrl() throws Exception { void getThumbnailUrl() throws Exception {
final String thumbnailUrl = extractor.getThumbnailUrl(); final String thumbnailUrl = extractor.getThumbnailUrl();
assertIsSecureUrl(thumbnailUrl); assertIsSecureUrl(thumbnailUrl);
MatcherAssert.assertThat(thumbnailUrl, containsString("yt")); ExtractorAsserts.assertContains("yt", thumbnailUrl);
assertThat(thumbnailUrl, containsString(VIDEO_ID)); ExtractorAsserts.assertContains(VIDEO_ID, thumbnailUrl);
} }
@Test @Test
public void getInitialPage() throws Exception { void getInitialPage() throws Exception {
final InfoItemsPage<StreamInfoItem> streams = extractor.getInitialPage(); final InfoItemsPage<StreamInfoItem> streams = extractor.getInitialPage();
assertFalse(streams.getItems().isEmpty()); assertFalse(streams.getItems().isEmpty());
assertTrue(streams.hasNextPage()); assertTrue(streams.hasNextPage());
} }
@Test @Test
public void getPage() throws Exception { void getPage() throws Exception {
final byte[] body = JsonWriter.string(prepareDesktopJsonBuilder( final byte[] body = JsonWriter.string(prepareDesktopJsonBuilder(
NewPipe.getPreferredLocalization(), NewPipe.getPreferredContentCountry()) NewPipe.getPreferredLocalization(), NewPipe.getPreferredContentCountry())
.value("videoId", VIDEO_ID) .value("videoId", VIDEO_ID)
.value("playlistId", "RD" + VIDEO_ID) .value("playlistId", "RD" + VIDEO_ID)
.value("params", "OAE%3D") .value("params", "OAE%3D")
.done()) .done())
.getBytes(UTF_8); .getBytes(StandardCharsets.UTF_8);
final InfoItemsPage<StreamInfoItem> streams = extractor.getPage(new Page( final InfoItemsPage<StreamInfoItem> streams = extractor.getPage(new Page(
YOUTUBEI_V1_URL + "next?key=" + getKey(), null, null, dummyCookie, body)); YOUTUBEI_V1_URL + "next?key=" + getKey(), null, null, dummyCookie, body));
@ -97,7 +93,7 @@ public class YoutubeMixPlaylistExtractorTest {
} }
@Test @Test
public void getContinuations() throws Exception { void getContinuations() throws Exception {
InfoItemsPage<StreamInfoItem> streams = extractor.getInitialPage(); InfoItemsPage<StreamInfoItem> streams = extractor.getInitialPage();
final Set<String> urls = new HashSet<>(); final Set<String> urls = new HashSet<>();
@ -119,53 +115,54 @@ public class YoutubeMixPlaylistExtractorTest {
} }
@Test @Test
public void getStreamCount() { void getStreamCount() {
assertEquals(ListExtractor.ITEM_COUNT_INFINITE, extractor.getStreamCount()); assertEquals(ListExtractor.ITEM_COUNT_INFINITE, extractor.getStreamCount());
} }
} }
@Ignore("Test broken, video was removed by the uploader")
public static class MixWithIndex { public static class MixWithIndex {
private static final int INDEX = 13; private static final String VIDEO_ID = "QMVCAPd5cwBcg";
private static final String VIDEO_ID_NUMBER_13 = "qHtzO49SDmk"; private static final String VIDEO_TITLE = "Mix ";
private static final int INDEX = 4;
private static final String VIDEO_ID_NUMBER_4 = "lWA2pjMjpBs";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "mixWithIndex")); NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "mixWithIndex"));
dummyCookie.put(YoutubeMixPlaylistExtractor.COOKIE_NAME, "whatever"); dummyCookie.put(YoutubeMixPlaylistExtractor.COOKIE_NAME, "whatever");
extractor = (YoutubeMixPlaylistExtractor) YouTube extractor = (YoutubeMixPlaylistExtractor) YouTube
.getPlaylistExtractor("https://www.youtube.com/watch?v=" + VIDEO_ID_NUMBER_13 .getPlaylistExtractor("https://www.youtube.com/watch?v=" + VIDEO_ID_NUMBER_4
+ "&list=RD" + VIDEO_ID + "&index=" + INDEX); + "&list=RD" + VIDEO_ID + "&index=" + INDEX);
extractor.fetchPage(); extractor.fetchPage();
} }
@Test @Test
public void getName() throws Exception { void getName() throws Exception {
final String name = extractor.getName(); final String name = extractor.getName();
assertThat(name, startsWith("Mix")); ExtractorAsserts.assertContains("Mix", name);
assertThat(name, containsString(VIDEO_TITLE)); ExtractorAsserts.assertContains(VIDEO_TITLE, name);
} }
@Test @Test
public void getThumbnailUrl() throws Exception { void getThumbnailUrl() throws Exception {
final String thumbnailUrl = extractor.getThumbnailUrl(); final String thumbnailUrl = extractor.getThumbnailUrl();
assertIsSecureUrl(thumbnailUrl); assertIsSecureUrl(thumbnailUrl);
assertThat(thumbnailUrl, containsString("yt")); ExtractorAsserts.assertContains("yt", thumbnailUrl);
assertThat(thumbnailUrl, containsString(VIDEO_ID)); ExtractorAsserts.assertContains(VIDEO_ID, thumbnailUrl);
} }
@Test @Test
public void getInitialPage() throws Exception { void getInitialPage() throws Exception {
final InfoItemsPage<StreamInfoItem> streams = extractor.getInitialPage(); final InfoItemsPage<StreamInfoItem> streams = extractor.getInitialPage();
assertFalse(streams.getItems().isEmpty()); assertFalse(streams.getItems().isEmpty());
assertTrue(streams.hasNextPage()); assertTrue(streams.hasNextPage());
} }
@Test @Test
public void getPage() throws Exception { void getPage() throws Exception {
final byte[] body = JsonWriter.string(prepareDesktopJsonBuilder( final byte[] body = JsonWriter.string(prepareDesktopJsonBuilder(
NewPipe.getPreferredLocalization(), NewPipe.getPreferredContentCountry()) NewPipe.getPreferredLocalization(), NewPipe.getPreferredContentCountry())
.value("videoId", VIDEO_ID) .value("videoId", VIDEO_ID)
@ -173,7 +170,7 @@ public class YoutubeMixPlaylistExtractorTest {
.value("playlistIndex", INDEX) .value("playlistIndex", INDEX)
.value("params", "OAE%3D") .value("params", "OAE%3D")
.done()) .done())
.getBytes(UTF_8); .getBytes(StandardCharsets.UTF_8);
final InfoItemsPage<StreamInfoItem> streams = extractor.getPage(new Page( final InfoItemsPage<StreamInfoItem> streams = extractor.getPage(new Page(
YOUTUBEI_V1_URL + "next?key=" + getKey(), null, null, dummyCookie, body)); YOUTUBEI_V1_URL + "next?key=" + getKey(), null, null, dummyCookie, body));
@ -182,7 +179,7 @@ public class YoutubeMixPlaylistExtractorTest {
} }
@Test @Test
public void getContinuations() throws Exception { void getContinuations() throws Exception {
InfoItemsPage<StreamInfoItem> streams = extractor.getInitialPage(); InfoItemsPage<StreamInfoItem> streams = extractor.getInitialPage();
final Set<String> urls = new HashSet<>(); final Set<String> urls = new HashSet<>();
@ -203,15 +200,15 @@ public class YoutubeMixPlaylistExtractorTest {
} }
@Test @Test
public void getStreamCount() { void getStreamCount() {
assertEquals(ListExtractor.ITEM_COUNT_INFINITE, extractor.getStreamCount()); assertEquals(ListExtractor.ITEM_COUNT_INFINITE, extractor.getStreamCount());
} }
} }
@Ignore("Test broken")
public static class MyMix { public static class MyMix {
private static final String VIDEO_ID = "_AzeUSL9lZc";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -224,39 +221,39 @@ public class YoutubeMixPlaylistExtractorTest {
} }
@Test @Test
public void getServiceId() { void getServiceId() {
assertEquals(YouTube.getServiceId(), extractor.getServiceId()); assertEquals(YouTube.getServiceId(), extractor.getServiceId());
} }
@Test @Test
public void getName() throws Exception { void getName() throws Exception {
final String name = extractor.getName(); final String name = extractor.getName();
assertEquals("My Mix", name); assertEquals("My Mix", name);
} }
@Test @Test
public void getThumbnailUrl() throws Exception { void getThumbnailUrl() throws Exception {
final String thumbnailUrl = extractor.getThumbnailUrl(); final String thumbnailUrl = extractor.getThumbnailUrl();
assertIsSecureUrl(thumbnailUrl); assertIsSecureUrl(thumbnailUrl);
assertThat(thumbnailUrl, startsWith("https://i.ytimg.com/vi/_AzeUSL9lZc")); assertTrue(thumbnailUrl.startsWith("https://i.ytimg.com/vi/_AzeUSL9lZc"));
} }
@Test @Test
public void getInitialPage() throws Exception { void getInitialPage() throws Exception {
final InfoItemsPage<StreamInfoItem> streams = extractor.getInitialPage(); final InfoItemsPage<StreamInfoItem> streams = extractor.getInitialPage();
assertFalse(streams.getItems().isEmpty()); assertFalse(streams.getItems().isEmpty());
assertTrue(streams.hasNextPage()); assertTrue(streams.hasNextPage());
} }
@Test @Test
public void getPage() throws Exception { void getPage() throws Exception {
final byte[] body = JsonWriter.string(prepareDesktopJsonBuilder( final byte[] body = JsonWriter.string(prepareDesktopJsonBuilder(
NewPipe.getPreferredLocalization(), NewPipe.getPreferredContentCountry()) NewPipe.getPreferredLocalization(), NewPipe.getPreferredContentCountry())
.value("videoId", VIDEO_ID) .value("videoId", VIDEO_ID)
.value("playlistId", "RDMM" + VIDEO_ID) .value("playlistId", "RDMM" + VIDEO_ID)
.value("params", "OAE%3D") .value("params", "OAE%3D")
.done()) .done())
.getBytes(UTF_8); .getBytes(StandardCharsets.UTF_8);
final InfoItemsPage<StreamInfoItem> streams = extractor.getPage(new Page( final InfoItemsPage<StreamInfoItem> streams = extractor.getPage(new Page(
YOUTUBEI_V1_URL + "next?key=" + getKey(), null, null, dummyCookie, body)); YOUTUBEI_V1_URL + "next?key=" + getKey(), null, null, dummyCookie, body));
@ -265,7 +262,7 @@ public class YoutubeMixPlaylistExtractorTest {
} }
@Test @Test
public void getContinuations() throws Exception { void getContinuations() throws Exception {
InfoItemsPage<StreamInfoItem> streams = extractor.getInitialPage(); InfoItemsPage<StreamInfoItem> streams = extractor.getInitialPage();
final Set<String> urls = new HashSet<>(); final Set<String> urls = new HashSet<>();
@ -287,14 +284,16 @@ public class YoutubeMixPlaylistExtractorTest {
} }
@Test @Test
public void getStreamCount() { void getStreamCount() {
assertEquals(ListExtractor.ITEM_COUNT_INFINITE, extractor.getStreamCount()); assertEquals(ListExtractor.ITEM_COUNT_INFINITE, extractor.getStreamCount());
} }
} }
public static class Invalid { public static class Invalid {
@BeforeClass private static final String VIDEO_ID = "QMVCAPd5cwBcg";
@BeforeAll
public static void setUp() throws IOException { public static void setUp() throws IOException {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -302,23 +301,23 @@ public class YoutubeMixPlaylistExtractorTest {
dummyCookie.put(YoutubeMixPlaylistExtractor.COOKIE_NAME, "whatever"); dummyCookie.put(YoutubeMixPlaylistExtractor.COOKIE_NAME, "whatever");
} }
@Ignore @Test
@Test(expected = IllegalArgumentException.class) void getPageEmptyUrl() throws Exception {
public void getPageEmptyUrl() throws Exception {
extractor = (YoutubeMixPlaylistExtractor) YouTube extractor = (YoutubeMixPlaylistExtractor) YouTube
.getPlaylistExtractor("https://www.youtube.com/watch?v=" + VIDEO_ID .getPlaylistExtractor("https://www.youtube.com/watch?v=" + VIDEO_ID
+ "&list=RD" + VIDEO_ID); + "&list=RD" + VIDEO_ID);
extractor.fetchPage(); extractor.fetchPage();
extractor.getPage(new Page("")); assertThrows(IllegalArgumentException.class, () -> extractor.getPage(new Page("")));
} }
@Test(expected = ExtractionException.class) @Test
public void invalidVideoId() throws Exception { void invalidVideoId() throws Exception {
extractor = (YoutubeMixPlaylistExtractor) YouTube extractor = (YoutubeMixPlaylistExtractor) YouTube
.getPlaylistExtractor("https://www.youtube.com/watch?v=" + "abcde" .getPlaylistExtractor("https://www.youtube.com/watch?v=" + "abcde"
+ "&list=RD" + "abcde"); + "&list=RD" + "abcde");
extractor.fetchPage();
extractor.getName(); assertThrows(ExtractionException.class, extractor::fetchPage);
} }
} }
@ -329,7 +328,7 @@ public class YoutubeMixPlaylistExtractorTest {
private static final String CHANNEL_TITLE = "Linus Tech Tips"; private static final String CHANNEL_TITLE = "Linus Tech Tips";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -342,35 +341,35 @@ public class YoutubeMixPlaylistExtractorTest {
} }
@Test @Test
public void getName() throws Exception { void getName() throws Exception {
final String name = extractor.getName(); final String name = extractor.getName();
assertThat(name, startsWith("Mix")); ExtractorAsserts.assertContains("Mix", name);
assertThat(name, containsString(CHANNEL_TITLE)); ExtractorAsserts.assertContains(CHANNEL_TITLE, name);
} }
@Test @Test
public void getThumbnailUrl() throws Exception { void getThumbnailUrl() throws Exception {
final String thumbnailUrl = extractor.getThumbnailUrl(); final String thumbnailUrl = extractor.getThumbnailUrl();
assertIsSecureUrl(thumbnailUrl); assertIsSecureUrl(thumbnailUrl);
assertThat(thumbnailUrl, containsString("yt")); ExtractorAsserts.assertContains("yt", thumbnailUrl);
} }
@Test @Test
public void getInitialPage() throws Exception { void getInitialPage() throws Exception {
final InfoItemsPage<StreamInfoItem> streams = extractor.getInitialPage(); final InfoItemsPage<StreamInfoItem> streams = extractor.getInitialPage();
assertFalse(streams.getItems().isEmpty()); assertFalse(streams.getItems().isEmpty());
assertTrue(streams.hasNextPage()); assertTrue(streams.hasNextPage());
} }
@Test @Test
public void getPage() throws Exception { void getPage() throws Exception {
final byte[] body = JsonWriter.string(prepareDesktopJsonBuilder( final byte[] body = JsonWriter.string(prepareDesktopJsonBuilder(
NewPipe.getPreferredLocalization(), NewPipe.getPreferredContentCountry()) NewPipe.getPreferredLocalization(), NewPipe.getPreferredContentCountry())
.value("videoId", VIDEO_ID_OF_CHANNEL) .value("videoId", VIDEO_ID_OF_CHANNEL)
.value("playlistId", "RDCM" + CHANNEL_ID) .value("playlistId", "RDCM" + CHANNEL_ID)
.value("params", "OAE%3D") .value("params", "OAE%3D")
.done()) .done())
.getBytes(UTF_8); .getBytes(StandardCharsets.UTF_8);
final InfoItemsPage<StreamInfoItem> streams = extractor.getPage(new Page( final InfoItemsPage<StreamInfoItem> streams = extractor.getPage(new Page(
YOUTUBEI_V1_URL + "next?key=" + getKey(), null, null, dummyCookie, body)); YOUTUBEI_V1_URL + "next?key=" + getKey(), null, null, dummyCookie, body));
@ -379,7 +378,7 @@ public class YoutubeMixPlaylistExtractorTest {
} }
@Test @Test
public void getStreamCount() { void getStreamCount() {
assertEquals(ListExtractor.ITEM_COUNT_INFINITE, extractor.getStreamCount()); assertEquals(ListExtractor.ITEM_COUNT_INFINITE, extractor.getStreamCount());
} }
} }

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.youtube; package org.schabi.newpipe.extractor.services.youtube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderFactory; 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;
@ -10,14 +10,14 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
import java.io.IOException; import java.io.IOException;
import java.util.Random; import java.util.Random;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
public class YoutubeParsingHelperTest { public class YoutubeParsingHelperTest {
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/youtube/"; private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/youtube/";
@BeforeClass @BeforeAll
public static void setUp() throws IOException { public static void setUp() throws IOException {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -26,14 +26,14 @@ public class YoutubeParsingHelperTest {
@Test @Test
public void testAreHardcodedClientVersionAndKeyValid() throws IOException, ExtractionException { public void testAreHardcodedClientVersionAndKeyValid() throws IOException, ExtractionException {
assertTrue("Hardcoded client version and key are not valid anymore", assertTrue(YoutubeParsingHelper.areHardcodedClientVersionAndKeyValid(),
YoutubeParsingHelper.areHardcodedClientVersionAndKeyValid()); "Hardcoded client version and key are not valid anymore");
} }
@Test @Test
public void testAreHardcodedYoutubeMusicKeysValid() throws IOException, ExtractionException { public void testAreHardcodedYoutubeMusicKeysValid() throws IOException, ExtractionException {
assertTrue("Hardcoded YouTube Music keys are not valid anymore", assertTrue(YoutubeParsingHelper.isHardcodedYoutubeMusicKeyValid(),
YoutubeParsingHelper.isHardcodedYoutubeMusicKeyValid()); "Hardcoded YouTube Music keys are not valid anymore");
} }
@Test @Test

View File

@ -1,12 +1,14 @@
package org.schabi.newpipe.extractor.services.youtube; package org.schabi.newpipe.extractor.services.youtube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderFactory; import org.schabi.newpipe.downloader.DownloaderFactory;
import org.schabi.newpipe.extractor.ExtractorAsserts;
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.exceptions.ContentNotAvailableException; import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
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.playlist.PlaylistExtractor; import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
import org.schabi.newpipe.extractor.services.BasePlaylistExtractorTest; import org.schabi.newpipe.extractor.services.BasePlaylistExtractorTest;
@ -16,9 +18,10 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import java.io.IOException; import java.io.IOException;
import java.util.Random; import java.util.Random;
import static junit.framework.TestCase.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.ServiceList.YouTube;
import static org.schabi.newpipe.extractor.services.DefaultTests.assertNoMoreItems; import static org.schabi.newpipe.extractor.services.DefaultTests.assertNoMoreItems;
@ -35,32 +38,32 @@ public class YoutubePlaylistExtractorTest {
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/youtube/extractor/playlist/"; private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/youtube/extractor/playlist/";
public static class NotAvailable { public static class NotAvailable {
@BeforeClass @BeforeAll
public static void setUp() throws IOException { public static void setUp() throws IOException {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "notAvailable")); NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "notAvailable"));
} }
@Test(expected = ContentNotAvailableException.class) @Test
public void nonExistentFetch() throws Exception { void nonExistentFetch() throws Exception {
final PlaylistExtractor extractor = final PlaylistExtractor extractor =
YouTube.getPlaylistExtractor("https://www.youtube.com/playlist?list=PL11111111111111111111111111111111"); YouTube.getPlaylistExtractor("https://www.youtube.com/playlist?list=PL11111111111111111111111111111111");
extractor.fetchPage(); assertThrows(ContentNotAvailableException.class, extractor::fetchPage);
} }
@Test(expected = ContentNotAvailableException.class) @Test
public void invalidId() throws Exception { void invalidId() throws Exception {
final PlaylistExtractor extractor = final PlaylistExtractor extractor =
YouTube.getPlaylistExtractor("https://www.youtube.com/playlist?list=INVALID_ID"); YouTube.getPlaylistExtractor("https://www.youtube.com/playlist?list=INVALID_ID");
extractor.fetchPage(); assertThrows(ContentNotAvailableException.class, extractor::fetchPage);
} }
} }
public static class TimelessPopHits implements BasePlaylistExtractorTest { public static class TimelessPopHits implements BasePlaylistExtractorTest {
private static YoutubePlaylistExtractor extractor; private static YoutubePlaylistExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -81,8 +84,7 @@ public class YoutubePlaylistExtractorTest {
@Test @Test
public void testName() throws Exception { public void testName() throws Exception {
String name = extractor.getName(); assertTrue(extractor.getName().startsWith("Pop Music Playlist"));
assertTrue(name, name.startsWith("Pop Music Playlist"));
} }
@Test @Test
@ -122,15 +124,15 @@ public class YoutubePlaylistExtractorTest {
public void testThumbnailUrl() throws Exception { public void testThumbnailUrl() throws Exception {
final String thumbnailUrl = extractor.getThumbnailUrl(); final String thumbnailUrl = extractor.getThumbnailUrl();
assertIsSecureUrl(thumbnailUrl); assertIsSecureUrl(thumbnailUrl);
assertTrue(thumbnailUrl, thumbnailUrl.contains("yt")); ExtractorAsserts.assertContains("yt", thumbnailUrl);
} }
@Ignore @Disabled
@Test @Test
public void testBannerUrl() { public void testBannerUrl() {
final String bannerUrl = extractor.getBannerUrl(); final String bannerUrl = extractor.getBannerUrl();
assertIsSecureUrl(bannerUrl); assertIsSecureUrl(bannerUrl);
assertTrue(bannerUrl, bannerUrl.contains("yt")); ExtractorAsserts.assertContains("yt", bannerUrl);
} }
@Test @Test
@ -141,18 +143,18 @@ public class YoutubePlaylistExtractorTest {
@Test @Test
public void testUploaderName() throws Exception { public void testUploaderName() throws Exception {
final String uploaderName = extractor.getUploaderName(); final String uploaderName = extractor.getUploaderName();
assertTrue(uploaderName, uploaderName.contains("Just Hits")); ExtractorAsserts.assertContains("Just Hits", uploaderName);
} }
@Test @Test
public void testUploaderAvatarUrl() throws Exception { public void testUploaderAvatarUrl() throws Exception {
final String uploaderAvatarUrl = extractor.getUploaderAvatarUrl(); final String uploaderAvatarUrl = extractor.getUploaderAvatarUrl();
assertTrue(uploaderAvatarUrl, uploaderAvatarUrl.contains("yt")); ExtractorAsserts.assertContains("yt", uploaderAvatarUrl);
} }
@Test @Test
public void testStreamCount() throws Exception { public void testStreamCount() throws Exception {
assertTrue("Error in the streams count", extractor.getStreamCount() > 100); ExtractorAsserts.assertGreater(100, extractor.getStreamCount());
} }
@Override @Override
@ -164,7 +166,7 @@ public class YoutubePlaylistExtractorTest {
public static class HugePlaylist implements BasePlaylistExtractorTest { public static class HugePlaylist implements BasePlaylistExtractorTest {
private static YoutubePlaylistExtractor extractor; private static YoutubePlaylistExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -242,15 +244,15 @@ public class YoutubePlaylistExtractorTest {
public void testThumbnailUrl() throws Exception { public void testThumbnailUrl() throws Exception {
final String thumbnailUrl = extractor.getThumbnailUrl(); final String thumbnailUrl = extractor.getThumbnailUrl();
assertIsSecureUrl(thumbnailUrl); assertIsSecureUrl(thumbnailUrl);
assertTrue(thumbnailUrl, thumbnailUrl.contains("yt")); ExtractorAsserts.assertContains("yt", thumbnailUrl);
} }
@Ignore @Disabled
@Test @Test
public void testBannerUrl() { public void testBannerUrl() {
final String bannerUrl = extractor.getBannerUrl(); final String bannerUrl = extractor.getBannerUrl();
assertIsSecureUrl(bannerUrl); assertIsSecureUrl(bannerUrl);
assertTrue(bannerUrl, bannerUrl.contains("yt")); ExtractorAsserts.assertContains("yt", bannerUrl);
} }
@Test @Test
@ -266,12 +268,12 @@ public class YoutubePlaylistExtractorTest {
@Test @Test
public void testUploaderAvatarUrl() throws Exception { public void testUploaderAvatarUrl() throws Exception {
final String uploaderAvatarUrl = extractor.getUploaderAvatarUrl(); final String uploaderAvatarUrl = extractor.getUploaderAvatarUrl();
assertTrue(uploaderAvatarUrl, uploaderAvatarUrl.contains("yt")); ExtractorAsserts.assertContains("yt", uploaderAvatarUrl);
} }
@Test @Test
public void testStreamCount() throws Exception { public void testStreamCount() throws Exception {
assertTrue("Error in the streams count", extractor.getStreamCount() > 100); ExtractorAsserts.assertGreater(100, extractor.getStreamCount());
} }
@Override @Override
@ -283,7 +285,7 @@ public class YoutubePlaylistExtractorTest {
public static class LearningPlaylist implements BasePlaylistExtractorTest { public static class LearningPlaylist implements BasePlaylistExtractorTest {
private static YoutubePlaylistExtractor extractor; private static YoutubePlaylistExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -304,8 +306,7 @@ public class YoutubePlaylistExtractorTest {
@Test @Test
public void testName() throws Exception { public void testName() throws Exception {
String name = extractor.getName(); assertTrue(extractor.getName().startsWith("Anatomy & Physiology"));
assertTrue(name, name.startsWith("Anatomy & Physiology"));
} }
@Test @Test
@ -332,7 +333,7 @@ public class YoutubePlaylistExtractorTest {
defaultTestRelatedItems(extractor); defaultTestRelatedItems(extractor);
} }
@Ignore @Disabled
@Test @Test
public void testMoreRelatedItems() throws Exception { public void testMoreRelatedItems() throws Exception {
defaultTestMoreItems(extractor); defaultTestMoreItems(extractor);
@ -346,15 +347,15 @@ public class YoutubePlaylistExtractorTest {
public void testThumbnailUrl() throws Exception { public void testThumbnailUrl() throws Exception {
final String thumbnailUrl = extractor.getThumbnailUrl(); final String thumbnailUrl = extractor.getThumbnailUrl();
assertIsSecureUrl(thumbnailUrl); assertIsSecureUrl(thumbnailUrl);
assertTrue(thumbnailUrl, thumbnailUrl.contains("yt")); ExtractorAsserts.assertContains("yt", thumbnailUrl);
} }
@Ignore @Disabled
@Test @Test
public void testBannerUrl() { public void testBannerUrl() {
final String bannerUrl = extractor.getBannerUrl(); final String bannerUrl = extractor.getBannerUrl();
assertIsSecureUrl(bannerUrl); assertIsSecureUrl(bannerUrl);
assertTrue(bannerUrl, bannerUrl.contains("yt")); ExtractorAsserts.assertContains("yt", bannerUrl);
} }
@Test @Test
@ -365,18 +366,18 @@ public class YoutubePlaylistExtractorTest {
@Test @Test
public void testUploaderName() throws Exception { public void testUploaderName() throws Exception {
final String uploaderName = extractor.getUploaderName(); final String uploaderName = extractor.getUploaderName();
assertTrue(uploaderName, uploaderName.contains("CrashCourse")); ExtractorAsserts.assertContains("CrashCourse", uploaderName);
} }
@Test @Test
public void testUploaderAvatarUrl() throws Exception { public void testUploaderAvatarUrl() throws Exception {
final String uploaderAvatarUrl = extractor.getUploaderAvatarUrl(); final String uploaderAvatarUrl = extractor.getUploaderAvatarUrl();
assertTrue(uploaderAvatarUrl, uploaderAvatarUrl.contains("yt")); ExtractorAsserts.assertContains("yt", uploaderAvatarUrl);
} }
@Test @Test
public void testStreamCount() throws Exception { public void testStreamCount() throws Exception {
assertTrue("Error in the streams count", extractor.getStreamCount() > 40); ExtractorAsserts.assertGreater(40, extractor.getStreamCount());
} }
@Override @Override
@ -387,7 +388,7 @@ public class YoutubePlaylistExtractorTest {
public static class ContinuationsTests { public static class ContinuationsTests {
@BeforeClass @BeforeAll
public static void setUp() throws IOException { public static void setUp() throws IOException {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -413,7 +414,7 @@ public class YoutubePlaylistExtractorTest {
final ListExtractor.InfoItemsPage<StreamInfoItem> page = defaultTestMoreItems( final ListExtractor.InfoItemsPage<StreamInfoItem> page = defaultTestMoreItems(
extractor); extractor);
assertFalse("More items available when it shouldn't", page.hasNextPage()); assertFalse(page.hasNextPage(), "More items available when it shouldn't");
} }
} }
} }

View File

@ -1,13 +1,13 @@
package org.schabi.newpipe.extractor.services.youtube; package org.schabi.newpipe.extractor.services.youtube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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.youtube.linkHandler.YoutubePlaylistLinkHandlerFactory; import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubePlaylistLinkHandlerFactory;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
/** /**
* Test for {@link YoutubePlaylistLinkHandlerFactory} * Test for {@link YoutubePlaylistLinkHandlerFactory}
@ -15,15 +15,15 @@ import static org.junit.Assert.*;
public class YoutubePlaylistLinkHandlerFactoryTest { public class YoutubePlaylistLinkHandlerFactoryTest {
private static YoutubePlaylistLinkHandlerFactory linkHandler; private static YoutubePlaylistLinkHandlerFactory linkHandler;
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
linkHandler = YoutubePlaylistLinkHandlerFactory.getInstance(); linkHandler = YoutubePlaylistLinkHandlerFactory.getInstance();
} }
@Test(expected = IllegalArgumentException.class) @Test
public void getIdWithNullAsUrl() throws ParsingException { public void getIdWithNullAsUrl() {
linkHandler.fromId(null); assertThrows(IllegalArgumentException.class, () -> linkHandler.fromId(null));
} }
@Test @Test

View File

@ -20,8 +20,8 @@ package org.schabi.newpipe.extractor.services.youtube;
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>. * along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/ */
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService;
@ -30,9 +30,9 @@ import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeMixPlaylistExtractor; import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeMixPlaylistExtractor;
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubePlaylistExtractor; import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubePlaylistExtractor;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.ServiceList.YouTube;
/** /**
@ -42,7 +42,7 @@ public class YoutubeServiceTest {
static StreamingService service; static StreamingService service;
static KioskList kioskList; static KioskList kioskList;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
service = YouTube; service = YouTube;
@ -50,25 +50,25 @@ public class YoutubeServiceTest {
} }
@Test @Test
public void testGetKioskAvailableKiosks() throws Exception { void testGetKioskAvailableKiosks() {
assertFalse("No kiosk got returned", kioskList.getAvailableKiosks().isEmpty()); assertFalse(kioskList.getAvailableKiosks().isEmpty(), "No kiosk got returned");
} }
@Test @Test
public void testGetDefaultKiosk() throws Exception { void testGetDefaultKiosk() throws Exception {
assertEquals(kioskList.getDefaultKioskExtractor(null).getId(), "Trending"); assertEquals(kioskList.getDefaultKioskExtractor(null).getId(), "Trending");
} }
@Test @Test
public void getPlayListExtractorIsNormalPlaylist() throws Exception { void getPlayListExtractorIsNormalPlaylist() throws Exception {
final PlaylistExtractor extractor = service.getPlaylistExtractor( final PlaylistExtractor extractor = service.getPlaylistExtractor(
"https://www.youtube.com/watch?v=JhqtYOnNrTs&list=PL-EkZZikQIQVqk9rBWzEo5b-2GeozElS"); "https://www.youtube.com/watch?v=JhqtYOnNrTs&list=PL-EkZZikQIQVqk9rBWzEo5b-2GeozElS");
assertTrue(extractor instanceof YoutubePlaylistExtractor); assertTrue(extractor instanceof YoutubePlaylistExtractor);
} }
@Test @Test
public void getPlaylistExtractorIsMix() throws Exception { void getPlaylistExtractorIsMix() throws Exception {
final String videoId = "_AzeUSL9lZc"; final String videoId = "_AzeUSL9lZc";
PlaylistExtractor extractor = YouTube.getPlaylistExtractor( PlaylistExtractor extractor = YouTube.getPlaylistExtractor(
"https://www.youtube.com/watch?v=" + videoId + "&list=RD" + videoId); "https://www.youtube.com/watch?v=" + videoId + "&list=RD" + videoId);

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.youtube; package org.schabi.newpipe.extractor.services.youtube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.FoundAdException; import org.schabi.newpipe.extractor.exceptions.FoundAdException;
@ -11,7 +11,7 @@ import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeStreamLi
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
/** /**
* Test for {@link YoutubeStreamLinkHandlerFactory} * Test for {@link YoutubeStreamLinkHandlerFactory}
@ -20,20 +20,20 @@ public class YoutubeStreamLinkHandlerFactoryTest {
private static String AD_URL = "https://googleads.g.doubleclick.net/aclk?sa=l&ai=C-2IPgeVTWPf4GcOStgfOnIOADf78n61GvKmmobYDrgIQASDj-5MDKAJg9ZXOgeAEoAGgy_T-A8gBAakC2gkpmquIsT6oAwGqBJMBT9BgD5kVgbN0dX602bFFaDw9vsxq-We-S8VkrXVBi6W_e7brZ36GCz1WO3EPEeklYuJjXLUowwCOKsd-8xr1UlS_tusuFJv9iX35xoBHKTRvs8-0aDbfEIm6in37QDfFuZjqgEMB8-tg0Jn_Pf1RU5OzbuU40B4Gy25NUTnOxhDKthOhKBUSZEksCEerUV8GMu10iAXCxquwApIFBggDEAEYAaAGGsgGlIjthrUDgAfItIsBqAemvhvYBwHSCAUIgGEQAbgT6AE&num=1&sig=AOD64_1DybDd4qAm5O7o9UAbTNRdqXXHFQ&ctype=21&video_id=dMO_IXYPZew&client=ca-pub-6219811747049371&adurl=http://www.youtube.com/watch%3Fv%3DdMO_IXYPZew"; private static String AD_URL = "https://googleads.g.doubleclick.net/aclk?sa=l&ai=C-2IPgeVTWPf4GcOStgfOnIOADf78n61GvKmmobYDrgIQASDj-5MDKAJg9ZXOgeAEoAGgy_T-A8gBAakC2gkpmquIsT6oAwGqBJMBT9BgD5kVgbN0dX602bFFaDw9vsxq-We-S8VkrXVBi6W_e7brZ36GCz1WO3EPEeklYuJjXLUowwCOKsd-8xr1UlS_tusuFJv9iX35xoBHKTRvs8-0aDbfEIm6in37QDfFuZjqgEMB8-tg0Jn_Pf1RU5OzbuU40B4Gy25NUTnOxhDKthOhKBUSZEksCEerUV8GMu10iAXCxquwApIFBggDEAEYAaAGGsgGlIjthrUDgAfItIsBqAemvhvYBwHSCAUIgGEQAbgT6AE&num=1&sig=AOD64_1DybDd4qAm5O7o9UAbTNRdqXXHFQ&ctype=21&video_id=dMO_IXYPZew&client=ca-pub-6219811747049371&adurl=http://www.youtube.com/watch%3Fv%3DdMO_IXYPZew";
private static YoutubeStreamLinkHandlerFactory linkHandler; private static YoutubeStreamLinkHandlerFactory linkHandler;
@BeforeClass @BeforeAll
public static void setUp() { public static void setUp() {
linkHandler = YoutubeStreamLinkHandlerFactory.getInstance(); linkHandler = YoutubeStreamLinkHandlerFactory.getInstance();
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
} }
@Test(expected = IllegalArgumentException.class) @Test
public void getIdWithNullAsUrl() throws ParsingException { public void getIdWithNullAsUrl() {
linkHandler.fromId(null); assertThrows(IllegalArgumentException.class, () -> linkHandler.fromId(null));
} }
@Test(expected = FoundAdException.class) @Test
public void getIdForAd() throws ParsingException { public void getIdForAd() throws ParsingException {
linkHandler.fromUrl(AD_URL).getId(); assertThrows(FoundAdException.class, () -> linkHandler.fromUrl(AD_URL));
} }
@Test @Test

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.youtube; package org.schabi.newpipe.extractor.services.youtube;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.ServiceList; import org.schabi.newpipe.extractor.ServiceList;
@ -16,7 +16,7 @@ import java.io.FileInputStream;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import static org.schabi.newpipe.FileUtils.resolveTestResource; import static org.schabi.newpipe.FileUtils.resolveTestResource;
import static org.schabi.newpipe.extractor.utils.Utils.UTF_8; import static org.schabi.newpipe.extractor.utils.Utils.UTF_8;
@ -29,7 +29,7 @@ public class YoutubeSubscriptionExtractorTest {
private static YoutubeSubscriptionExtractor subscriptionExtractor; private static YoutubeSubscriptionExtractor subscriptionExtractor;
private static LinkHandlerFactory urlHandler; private static LinkHandlerFactory urlHandler;
@BeforeClass @BeforeAll
public static void setupClass() { public static void setupClass() {
//Doesn't make network requests //Doesn't make network requests
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
@ -107,7 +107,7 @@ public class YoutubeSubscriptionExtractorTest {
if (!correctType) { if (!correctType) {
e.printStackTrace(); e.printStackTrace();
} }
assertTrue(e.getClass().getSimpleName() + " is not InvalidSourceException", correctType); assertTrue(correctType, e.getClass().getSimpleName() + " is not InvalidSourceException");
} }
} }
} }

View File

@ -20,8 +20,8 @@ package org.schabi.newpipe.extractor.services.youtube;
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>. * along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/ */
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderFactory; 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;
@ -31,7 +31,7 @@ import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;
import java.io.IOException; import java.io.IOException;
import java.util.Random; import java.util.Random;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.ServiceList.YouTube;
/** /**
@ -43,7 +43,7 @@ public class YoutubeSuggestionExtractorTest {
private static SuggestionExtractor suggestionExtractor; private static SuggestionExtractor suggestionExtractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.youtube; package org.schabi.newpipe.extractor.services.youtube;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.mozilla.javascript.EvaluatorException; import org.mozilla.javascript.EvaluatorException;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
@ -9,14 +9,13 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
import java.io.IOException; import java.io.IOException;
import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.Assert.assertNotEquals; import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.Assert.fail;
public class YoutubeThrottlingDecrypterTest { public class YoutubeThrottlingDecrypterTest {
@Before @BeforeEach
public void setup() throws IOException { public void setup() throws IOException {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
} }
@ -49,9 +48,9 @@ public class YoutubeThrottlingDecrypterTest {
@Test @Test
public void testDecode__noNParam__success() throws ParsingException { public void testDecode__noNParam__success() throws ParsingException {
final String noNParamUrl = "https://r5---sn-4g5ednsz.googlevideo.com/videoplayback?expire=1626553257&ei=SefyYPmIFoKT1wLtqbjgCQ&ip=127.0.0.1&id=o-AIT5xGifsaEAdEOAb5vd06J9VNtm-KHHolnaZRGPjHZi&itag=140&source=youtube&requiressl=yes&mh=xO&mm=31%2C29&mn=sn-4g5ednsz%2Csn-4g5e6nsr&ms=au%2Crdu&mv=m&mvi=5&pl=24&initcwndbps=1322500&vprv=1&mime=audio%2Fmp4&ns=cA2SS5atEe0mH8tMwGTO4RIG&gir=yes&clen=3009275&dur=185.898&lmt=1626356984653961&mt=1626531173&fvip=5&keepalive=yes&fexp=24001373%2C24007246&beids=23886212&c=WEB&txp=6411222&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhAPueRlTutSlzPafxrqBmgZz5m7-Zfbw3QweDp3j4XO9SAiEA5tF7_ZCJFKmS-D6I1jlUURjpjoiTbsYyKuarV4u6E8Y%3D&sig=AOq0QJ8wRQIgRD_4WwkPeTEKGVSQqPsznMJGqq4nVJ8o1ChGBCgi4Y0CIQCZT3tI40YLKBWJCh2Q7AlvuUIpN0ficzdSElLeQpJdrw=="; final String noNParamUrl = "https://r5---sn-4g5ednsz.googlevideo.com/videoplayback?expire=1626553257&ei=SefyYPmIFoKT1wLtqbjgCQ&ip=127.0.0.1&id=o-AIT5xGifsaEAdEOAb5vd06J9VNtm-KHHolnaZRGPjHZi&itag=140&source=youtube&requiressl=yes&mh=xO&mm=31%2C29&mn=sn-4g5ednsz%2Csn-4g5e6nsr&ms=au%2Crdu&mv=m&mvi=5&pl=24&initcwndbps=1322500&vprv=1&mime=audio%2Fmp4&ns=cA2SS5atEe0mH8tMwGTO4RIG&gir=yes&clen=3009275&dur=185.898&lmt=1626356984653961&mt=1626531173&fvip=5&keepalive=yes&fexp=24001373%2C24007246&beids=23886212&c=WEB&txp=6411222&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhAPueRlTutSlzPafxrqBmgZz5m7-Zfbw3QweDp3j4XO9SAiEA5tF7_ZCJFKmS-D6I1jlUURjpjoiTbsYyKuarV4u6E8Y%3D&sig=AOq0QJ8wRQIgRD_4WwkPeTEKGVSQqPsznMJGqq4nVJ8o1ChGBCgi4Y0CIQCZT3tI40YLKBWJCh2Q7AlvuUIpN0ficzdSElLeQpJdrw==";
String decrypted = new YoutubeThrottlingDecrypter().apply(noNParamUrl); final String decrypted = new YoutubeThrottlingDecrypter().apply(noNParamUrl);
assertThat(decrypted, equalTo(noNParamUrl)); assertEquals(noNParamUrl, decrypted);
} }
} }

View File

@ -20,8 +20,8 @@ package org.schabi.newpipe.extractor.services.youtube;
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>. * along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/ */
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderFactory; 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;
@ -30,8 +30,8 @@ import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
import java.util.Random; import java.util.Random;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.ServiceList.YouTube;
/** /**
@ -43,7 +43,7 @@ public class YoutubeTrendingKioskInfoTest {
static KioskInfo kioskInfo; static KioskInfo kioskInfo;
@BeforeClass @BeforeAll
public static void setUp() public static void setUp()
throws Exception { throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();

View File

@ -20,17 +20,17 @@ package org.schabi.newpipe.extractor.services.youtube;
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>. * along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/ */
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
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.linkhandler.LinkHandlerFactory; import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeTrendingLinkHandlerFactory; import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeTrendingLinkHandlerFactory;
import static junit.framework.TestCase.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.ServiceList.YouTube;
/** /**
@ -39,7 +39,7 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube;
public class YoutubeTrendingLinkHandlerFactoryTest { public class YoutubeTrendingLinkHandlerFactoryTest {
private static LinkHandlerFactory LinkHandlerFactory; private static LinkHandlerFactory LinkHandlerFactory;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
LinkHandlerFactory = YouTube.getKioskList().getListLinkHandlerFactoryByType("Trending"); LinkHandlerFactory = YouTube.getKioskList().getListLinkHandlerFactoryByType("Trending");
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.youtube.search; package org.schabi.newpipe.extractor.services.youtube.search;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.schabi.newpipe.downloader.DownloaderTestImpl; 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;
@ -23,7 +23,7 @@ public class YoutubeMusicSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "mocromaniac"; private static final String QUERY = "mocromaniac";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_SONGS), ""); extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_SONGS), "");
@ -45,7 +45,7 @@ public class YoutubeMusicSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "fresku"; private static final String QUERY = "fresku";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_VIDEOS), ""); extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_VIDEOS), "");
@ -67,7 +67,7 @@ public class YoutubeMusicSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "johnny sellah"; private static final String QUERY = "johnny sellah";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_ALBUMS), ""); extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_ALBUMS), "");
@ -89,7 +89,7 @@ public class YoutubeMusicSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "louivos"; private static final String QUERY = "louivos";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_PLAYLISTS), ""); extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_PLAYLISTS), "");
@ -107,12 +107,12 @@ public class YoutubeMusicSearchExtractorTest {
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.PLAYLIST; } @Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.PLAYLIST; }
} }
@Ignore @Disabled
public static class MusicArtists extends DefaultSearchExtractorTest { public static class MusicArtists extends DefaultSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "kevin"; private static final String QUERY = "kevin";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_ARTISTS), ""); extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_ARTISTS), "");
@ -135,7 +135,7 @@ public class YoutubeMusicSearchExtractorTest {
private static final String QUERY = "megaman x3"; private static final String QUERY = "megaman x3";
private static final boolean CORRECTED = true; private static final boolean CORRECTED = true;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_SONGS), ""); extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_SONGS), "");
@ -159,7 +159,7 @@ public class YoutubeMusicSearchExtractorTest {
private static final String QUERY = "nocopyrigh sounds"; private static final String QUERY = "nocopyrigh sounds";
private static final String EXPECTED_SUGGESTION = "nocopyrightsounds"; private static final String EXPECTED_SUGGESTION = "nocopyrightsounds";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_SONGS), ""); extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_SONGS), "");

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.youtube.search; package org.schabi.newpipe.extractor.services.youtube.search;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderFactory; import org.schabi.newpipe.downloader.DownloaderFactory;
import org.schabi.newpipe.extractor.*; import org.schabi.newpipe.extractor.*;
import org.schabi.newpipe.extractor.channel.ChannelInfoItem; import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
@ -22,8 +22,8 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import static java.util.Collections.singletonList; import static java.util.Collections.singletonList;
import static junit.framework.TestCase.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmptyErrors; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmptyErrors;
import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.ServiceList.YouTube;
import static org.schabi.newpipe.extractor.services.DefaultTests.assertNoDuplicatedItems; import static org.schabi.newpipe.extractor.services.DefaultTests.assertNoDuplicatedItems;
@ -37,7 +37,7 @@ public class YoutubeSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "test"; private static final String QUERY = "test";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -60,7 +60,7 @@ public class YoutubeSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "test"; private static final String QUERY = "test";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -85,7 +85,7 @@ public class YoutubeSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "test"; private static final String QUERY = "test";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -110,7 +110,7 @@ public class YoutubeSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "test"; private static final String QUERY = "test";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -136,7 +136,7 @@ public class YoutubeSearchExtractorTest {
private static final String QUERY = "newpip"; private static final String QUERY = "newpip";
private static final String EXPECTED_SUGGESTION = "newpipe"; private static final String EXPECTED_SUGGESTION = "newpipe";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -161,7 +161,7 @@ public class YoutubeSearchExtractorTest {
private static final String QUERY = "pewdeipie"; private static final String QUERY = "pewdeipie";
private static final String EXPECTED_SUGGESTION = "pewdiepie"; private static final String EXPECTED_SUGGESTION = "pewdiepie";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -186,7 +186,7 @@ public class YoutubeSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "UCO6AK"; private static final String QUERY = "UCO6AK";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -217,7 +217,7 @@ public class YoutubeSearchExtractorTest {
assertEquals(0, nextEmptyPage.getItems().size()); assertEquals(0, nextEmptyPage.getItems().size());
assertEmptyErrors("Empty page has errors", nextEmptyPage.getErrors()); assertEmptyErrors("Empty page has errors", nextEmptyPage.getErrors());
assertFalse("More items available when it shouldn't", nextEmptyPage.hasNextPage()); assertFalse(nextEmptyPage.hasNextPage(), "More items available when it shouldn't");
} }
} }
@ -241,8 +241,8 @@ public class YoutubeSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "Covid"; private static final String QUERY = "Covid";
@Test @BeforeAll
public void clarificationTest() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "metaInfo")); NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "metaInfo"));
@ -278,7 +278,7 @@ public class YoutubeSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "bbc"; private static final String QUERY = "bbc";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -316,7 +316,7 @@ public class YoutubeSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "sidemen"; private static final String QUERY = "sidemen";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -348,7 +348,7 @@ public class YoutubeSearchExtractorTest {
private static SearchExtractor extractor; private static SearchExtractor extractor;
private static final String QUERY = "44wLAzydRFU"; private static final String QUERY = "44wLAzydRFU";
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));

View File

@ -1,9 +1,9 @@
package org.schabi.newpipe.extractor.services.youtube.search; package org.schabi.newpipe.extractor.services.youtube.search;
import org.junit.Test; import org.junit.jupiter.api.Test;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.ServiceList.YouTube;
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.CHANNELS; import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.CHANNELS;
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.MUSIC_SONGS; import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.MUSIC_SONGS;

View File

@ -1,6 +1,6 @@
package org.schabi.newpipe.extractor.services.youtube.stream; package org.schabi.newpipe.extractor.services.youtube.stream;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.schabi.newpipe.downloader.DownloaderFactory; 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;
@ -10,7 +10,6 @@ import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExt
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;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
@ -26,7 +25,7 @@ public class YoutubeStreamExtractorAgeRestrictedTest extends DefaultStreamExtrac
private static final String URL = YoutubeStreamExtractorDefaultTest.BASE_URL + ID + "&t=" + TIMESTAMP; private static final String URL = YoutubeStreamExtractorDefaultTest.BASE_URL + ID + "&t=" + TIMESTAMP;
private static StreamExtractor extractor; private static StreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));

View File

@ -1,6 +1,6 @@
package org.schabi.newpipe.extractor.services.youtube.stream; package org.schabi.newpipe.extractor.services.youtube.stream;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.schabi.newpipe.downloader.DownloaderFactory; 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;
@ -29,7 +29,7 @@ public class YoutubeStreamExtractorControversialTest extends DefaultStreamExtrac
private static final String URL = YoutubeStreamExtractorDefaultTest.BASE_URL + ID; private static final String URL = YoutubeStreamExtractorDefaultTest.BASE_URL + ID;
private static StreamExtractor extractor; private static StreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));

View File

@ -1,8 +1,8 @@
package org.schabi.newpipe.extractor.services.youtube.stream; package org.schabi.newpipe.extractor.services.youtube.stream;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderFactory; import org.schabi.newpipe.downloader.DownloaderFactory;
import org.schabi.newpipe.downloader.DownloaderTestImpl; import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.MetaInfo; import org.schabi.newpipe.extractor.MetaInfo;
@ -29,8 +29,9 @@ import java.util.Random;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.schabi.newpipe.extractor.ServiceList.YouTube; import static org.schabi.newpipe.extractor.ServiceList.YouTube;
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING; import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
@ -59,7 +60,7 @@ public class YoutubeStreamExtractorDefaultTest {
public static final String YOUTUBE_LICENCE = "YouTube licence"; public static final String YOUTUBE_LICENCE = "YouTube licence";
public static class NotAvailable { public static class NotAvailable {
@BeforeClass @BeforeAll
public static void setUp() throws IOException { public static void setUp() throws IOException {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -67,46 +68,46 @@ public class YoutubeStreamExtractorDefaultTest {
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "notAvailable")); NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "notAvailable"));
} }
@Test(expected = GeographicRestrictionException.class) @Test
public void geoRestrictedContent() throws Exception { void geoRestrictedContent() throws Exception {
final StreamExtractor extractor = final StreamExtractor extractor =
YouTube.getStreamExtractor(BASE_URL + "_PL2HJKxnOM"); YouTube.getStreamExtractor(BASE_URL + "_PL2HJKxnOM");
extractor.fetchPage(); assertThrows(GeographicRestrictionException.class, extractor::fetchPage);
} }
@Test(expected = ContentNotAvailableException.class) @Test
public void nonExistentFetch() throws Exception { void nonExistentFetch() throws Exception {
final StreamExtractor extractor = final StreamExtractor extractor =
YouTube.getStreamExtractor(BASE_URL + "don-t-exist"); YouTube.getStreamExtractor(BASE_URL + "don-t-exist");
extractor.fetchPage(); assertThrows(ContentNotAvailableException.class, extractor::fetchPage);
} }
@Test(expected = ParsingException.class) @Test
public void invalidId() throws Exception { void invalidId() throws Exception {
final StreamExtractor extractor = final StreamExtractor extractor =
YouTube.getStreamExtractor(BASE_URL + "INVALID_ID_INVALID_ID"); YouTube.getStreamExtractor(BASE_URL + "INVALID_ID_INVALID_ID");
extractor.fetchPage(); assertThrows(ParsingException.class, extractor::fetchPage);
} }
@Test(expected = PaidContentException.class) @Test
public void paidContent() throws Exception { void paidContent() throws Exception {
final StreamExtractor extractor = final StreamExtractor extractor =
YouTube.getStreamExtractor(BASE_URL + "ayI2iBwGdxw"); YouTube.getStreamExtractor(BASE_URL + "ayI2iBwGdxw");
extractor.fetchPage(); assertThrows(PaidContentException.class, extractor::fetchPage);
} }
@Test(expected = PrivateContentException.class) @Test
public void privateContent() throws Exception { void privateContent() throws Exception {
final StreamExtractor extractor = final StreamExtractor extractor =
YouTube.getStreamExtractor(BASE_URL + "8VajtrESJzA"); YouTube.getStreamExtractor(BASE_URL + "8VajtrESJzA");
extractor.fetchPage(); assertThrows(PrivateContentException.class, extractor::fetchPage);
} }
@Test(expected = YoutubeMusicPremiumContentException.class) @Test
public void youtubeMusicPremiumContent() throws Exception { void youtubeMusicPremiumContent() throws Exception {
final StreamExtractor extractor = final StreamExtractor extractor =
YouTube.getStreamExtractor(BASE_URL + "sMJ8bRN2dak"); YouTube.getStreamExtractor(BASE_URL + "sMJ8bRN2dak");
extractor.fetchPage(); assertThrows(YoutubeMusicPremiumContentException.class, extractor::fetchPage);
} }
} }
@ -116,7 +117,7 @@ public class YoutubeStreamExtractorDefaultTest {
private static final String URL = BASE_URL + ID + "&t=" + TIMESTAMP + "s"; private static final String URL = BASE_URL + ID + "&t=" + TIMESTAMP + "s";
private static StreamExtractor extractor; private static StreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -160,7 +161,7 @@ public class YoutubeStreamExtractorDefaultTest {
private static final String URL = BASE_URL + ID; private static final String URL = BASE_URL + ID;
private static StreamExtractor extractor; private static StreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -207,14 +208,14 @@ public class YoutubeStreamExtractorDefaultTest {
// @formatter:on // @formatter:on
} }
@Ignore("Test broken, video was made private") @Disabled("Test broken, video was made private")
public static class RatingsDisabledTest extends DefaultStreamExtractorTest { public static class RatingsDisabledTest extends DefaultStreamExtractorTest {
private static final String ID = "HRKu0cvrr_o"; private static final String ID = "HRKu0cvrr_o";
private static final int TIMESTAMP = 17; private static final int TIMESTAMP = 17;
private static final String URL = BASE_URL + ID + "&t=" + TIMESTAMP; private static final String URL = BASE_URL + ID + "&t=" + TIMESTAMP;
private static StreamExtractor extractor; private static StreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -252,7 +253,7 @@ public class YoutubeStreamExtractorDefaultTest {
private static final String URL = BASE_URL + ID; private static final String URL = BASE_URL + ID;
private static StreamExtractor extractor; private static StreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -314,7 +315,7 @@ public class YoutubeStreamExtractorDefaultTest {
private static final String URL = BASE_URL + ID; private static final String URL = BASE_URL + ID;
private static StreamExtractor extractor; private static StreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -368,12 +369,12 @@ public class YoutubeStreamExtractorDefaultTest {
@Override @Override
@Test @Test
@Ignore("encoding problem") @Disabled("encoding problem")
public void testName() {} public void testName() {}
@Override @Override
@Test @Test
@Ignore("encoding problem") @Disabled("encoding problem")
public void testTags() {} public void testTags() {}
} }
@ -383,7 +384,7 @@ public class YoutubeStreamExtractorDefaultTest {
private static final String URL = BASE_URL + ID; private static final String URL = BASE_URL + ID;
private static StreamExtractor extractor; private static StreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -437,7 +438,7 @@ public class YoutubeStreamExtractorDefaultTest {
public static class UnlistedTest { public static class UnlistedTest {
private static YoutubeStreamExtractor extractor; private static YoutubeStreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeStreamExtractor.resetDeobfuscationCode(); YoutubeStreamExtractor.resetDeobfuscationCode();
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());
@ -457,7 +458,7 @@ public class YoutubeStreamExtractorDefaultTest {
private static final String URL = BASE_URL + ID; private static final String URL = BASE_URL + ID;
private static StreamExtractor extractor; private static StreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeStreamExtractor.resetDeobfuscationCode(); YoutubeStreamExtractor.resetDeobfuscationCode();
NewPipe.init(DownloaderTestImpl.getInstance()); NewPipe.init(DownloaderTestImpl.getInstance());

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.youtube.stream; package org.schabi.newpipe.extractor.services.youtube.stream;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderFactory; 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;
@ -26,7 +26,7 @@ public class YoutubeStreamExtractorLivestreamTest extends DefaultStreamExtractor
private static final String URL = YoutubeStreamExtractorDefaultTest.BASE_URL + ID + "&t=" + TIMESTAMP; private static final String URL = YoutubeStreamExtractorDefaultTest.BASE_URL + ID + "&t=" + TIMESTAMP;
private static StreamExtractor extractor; private static StreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));

View File

@ -1,6 +1,6 @@
package org.schabi.newpipe.extractor.services.youtube.stream; package org.schabi.newpipe.extractor.services.youtube.stream;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeAll;
import org.schabi.newpipe.downloader.DownloaderFactory; 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;
@ -25,7 +25,7 @@ public class YoutubeStreamExtractorUnlistedTest extends DefaultStreamExtractorTe
static final String URL = YoutubeStreamExtractorDefaultTest.BASE_URL + ID; static final String URL = YoutubeStreamExtractorDefaultTest.BASE_URL + ID;
private static StreamExtractor extractor; private static StreamExtractor extractor;
@BeforeClass @BeforeAll
public static void setUp() throws Exception { public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeParsingHelper.setNumberGenerator(new Random(1));

View File

@ -5,12 +5,12 @@ import com.grack.nanojson.JsonArray;
import com.grack.nanojson.JsonObject; import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParser; import com.grack.nanojson.JsonParser;
import com.grack.nanojson.JsonParserException; import com.grack.nanojson.JsonParserException;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import java.util.List; import java.util.List;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
public class JsonUtilsTest { public class JsonUtilsTest {

View File

@ -1,9 +1,9 @@
package org.schabi.newpipe.extractor.utils; package org.schabi.newpipe.extractor.utils;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.schabi.newpipe.extractor.utils.StringUtils.matchToClosingParenthesis; import static org.schabi.newpipe.extractor.utils.StringUtils.matchToClosingParenthesis;
public class StringUtilsTest { public class StringUtilsTest {
@ -48,7 +48,7 @@ public class StringUtilsTest {
assertEquals(expected, substring); assertEquals(expected, substring);
} }
@Ignore("Functionality currently not needed") @Disabled("Functionality currently not needed")
@Test @Test
public void lessClosing__success() { public void lessClosing__success() {
String expected = "{{{}}}"; String expected = "{{{}}}";

View File

@ -1,11 +1,11 @@
package org.schabi.newpipe.extractor.utils; package org.schabi.newpipe.extractor.utils;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import java.util.Arrays; import java.util.Arrays;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
public class UtilsTest { public class UtilsTest {
@Test @Test

Some files were not shown because too many files have changed in this diff Show More