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 {
nanojsonVersion = "1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751"
spotbugsVersion = "4.5.2"
junitVersion = "4.13.2"
junitVersion = "5.8.2"
}
}

View File

@ -3,6 +3,7 @@ test {
if (System.properties.containsKey('downloader')) {
systemProperty('downloader', System.getProperty('downloader'))
}
useJUnitPlatform()
}
dependencies {
@ -14,7 +15,11 @@ dependencies {
implementation "com.github.spotbugs:spotbugs-annotations:$spotbugsVersion"
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.google.code.gson:gson:2.8.9'
}

View File

@ -41,7 +41,7 @@ import static org.schabi.newpipe.extractor.utils.Utils.*;
public class SoundcloudParsingHelper {
static final String HARDCODED_CLIENT_ID =
"1NKODbzHzEpoowFHxTAmS7oB08DObPuK"; // Updated on 08/12/21
"JpcTFmpEz9lMPDrM6TDAC9izag7Be06D"; // Updated on 2022-01-07
private static String clientId;
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.util.Collections;
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.utils.Utils.EMPTY_STRING;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
public class SoundcloudSearchExtractor extends SearchExtractor {
private JsonArray searchCollection;
private JsonArray initialSearchCollection;
public SoundcloudSearchExtractor(final StreamingService service,
final SearchQueryHandler linkHandler) {
@ -53,8 +54,9 @@ public class SoundcloudSearchExtractor extends SearchExtractor {
@Nonnull
@Override
public InfoItemsPage<InfoItem> getInitialPage() throws IOException, ExtractionException {
return new InfoItemsPage<>(collectItems(searchCollection), getNextPageFromCurrentUrl(
getUrl()));
return new InfoItemsPage<>(
collectItems(initialSearchCollection),
getNextPageFromCurrentUrl(getUrl(), currentOffset -> ITEMS_PER_PAGE));
}
@Override
@ -65,6 +67,7 @@ public class SoundcloudSearchExtractor extends SearchExtractor {
}
final Downloader dl = getDownloader();
final JsonArray searchCollection;
try {
final String response = dl.get(page.getUrl(), getExtractorLocalization())
.responseBody();
@ -73,8 +76,9 @@ public class SoundcloudSearchExtractor extends SearchExtractor {
throw new ParsingException("Could not parse json response", e);
}
return new InfoItemsPage<>(collectItems(searchCollection), getNextPageFromCurrentUrl(page
.getUrl()));
return new InfoItemsPage<>(
collectItems(searchCollection),
getNextPageFromCurrentUrl(page.getUrl(), currentOffset -> currentOffset + ITEMS_PER_PAGE));
}
@Override
@ -84,12 +88,12 @@ public class SoundcloudSearchExtractor extends SearchExtractor {
final String url = getUrl();
try {
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) {
throw new ParsingException("Could not parse json response", e);
}
if (searchCollection.isEmpty()) {
if (initialSearchCollection.isEmpty()) {
throw new SearchExtractor.NothingFoundException("Nothing found");
}
}
@ -118,12 +122,14 @@ public class SoundcloudSearchExtractor extends SearchExtractor {
return collector;
}
private Page getNextPageFromCurrentUrl(final String currentUrl)
private Page getNextPageFromCurrentUrl(final String currentUrl, final IntUnaryOperator newPageOffsetCalculator)
throws MalformedURLException, UnsupportedEncodingException {
final int pageOffset = Integer.parseInt(
Parser.compatParseMap(new URL(currentUrl).getQuery()).get("offset"));
final int currentPageOffset = Integer.parseInt(
Parser.compatParseMap(new URL(currentUrl).getQuery()).get("offset"));
return new Page(currentUrl.replace("&offset=" + pageOffset, "&offset="
+ (pageOffset + ITEMS_PER_PAGE)));
return new 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.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ExtractorAsserts {
public static void assertEmptyErrors(String message, List<Throwable> errors) {
@ -44,7 +42,7 @@ public class ExtractorAsserts {
public static void assertIsSecureUrl(String 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) {
@ -53,7 +51,7 @@ public class ExtractorAsserts {
public static void assertNotEmpty(@Nullable String message, String stringToCheck) {
assertNotNull(message, stringToCheck);
assertFalse(message, stringToCheck.isEmpty());
assertFalse(stringToCheck.isEmpty(), message);
}
public static void assertEmpty(String stringToCheck) {
@ -62,12 +60,56 @@ public class ExtractorAsserts {
public static void assertEmpty(@Nullable String message, String stringToCheck) {
if (stringToCheck != null) {
assertTrue(message, stringToCheck.isEmpty());
assertTrue(stringToCheck.isEmpty(), message);
}
}
public static void assertAtLeast(long expected, long actual) {
assertTrue(actual + " is not at least " + expected, actual >= expected);
public static void assertGreater(final long expected, final long actual) {
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
@ -85,4 +127,13 @@ public class ExtractorAsserts {
// using new ArrayList<> to make sure the type is the same
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;
import org.junit.Test;
import org.junit.jupiter.api.Test;
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.ServiceList.SoundCloud;
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
@ -19,9 +19,11 @@ public class NewPipeTest {
public void testAllServicesHaveDifferentId() throws Exception {
HashSet<Integer> servicesId = new HashSet<>();
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;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.extractor.Extractor;
import org.schabi.newpipe.extractor.ExtractorAsserts;
import org.schabi.newpipe.extractor.StreamingService;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
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 {
final String url = extractor().getUrl();
assertIsSecureUrl(url);
assertThat(url, containsString(expectedUrlContains()));
ExtractorAsserts.assertContains(expectedUrlContains(), url);
}
@Test
@ -48,6 +48,6 @@ public abstract class DefaultExtractorTest<T extends Extractor> implements BaseE
public void testOriginalUrl() throws Exception {
final String originalUrl = extractor().getOriginalUrl();
assertIsSecureUrl(originalUrl);
assertThat(originalUrl, containsString(expectedOriginalUrlContains()));
ExtractorAsserts.assertContains(expectedOriginalUrlContains(), originalUrl);
}
}

View File

@ -1,6 +1,6 @@
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.ListExtractor;

View File

@ -1,6 +1,6 @@
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.search.SearchExtractor;
@ -13,8 +13,8 @@ import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;

View File

@ -1,6 +1,7 @@
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.MediaFormat;
import org.schabi.newpipe.extractor.MetaInfo;
@ -23,14 +24,12 @@ import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertAtLeast;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertGreaterOrEqual;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEqualsOrderIndependent;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsValidUrl;
@ -149,13 +148,13 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
assertNotNull(description);
if (expectedDescriptionIsEmpty()) {
assertTrue("description is not empty", description.getContent().isEmpty());
assertTrue(description.getContent().isEmpty(), "description is not empty");
} else {
assertFalse("description is empty", description.getContent().isEmpty());
assertFalse(description.getContent().isEmpty(), "description is empty");
}
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
@Override
public void testViewCount() throws Exception {
assertAtLeast(expectedViewCountAtLeast(), extractor().getViewCount());
assertGreaterOrEqual(expectedViewCountAtLeast(), extractor().getViewCount());
}
@Test
@ -207,7 +206,7 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
if (expectedLikeCountAtLeast() == -1) {
assertEquals(-1, extractor().getLikeCount());
} else {
assertAtLeast(expectedLikeCountAtLeast(), extractor().getLikeCount());
assertGreaterOrEqual(expectedLikeCountAtLeast(), extractor().getLikeCount());
}
}
@ -217,7 +216,7 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
if (expectedDislikeCountAtLeast() == -1) {
assertEquals(-1, extractor().getDislikeCount());
} 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();
// see MediaFormat: video stream formats range from 0 to 0x100
assertTrue("format id does not fit a video stream: " + formatId,
0 <= formatId && formatId < 0x100);
assertTrue(0 <= formatId && formatId < 0x100,
"format id does not fit a video stream: " + formatId);
}
} else {
assertTrue(videoStreams.isEmpty());
@ -287,8 +286,8 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
final int formatId = stream.getFormatId();
// see MediaFormat: video stream formats range from 0x100 to 0x1000
assertTrue("format id does not fit an audio stream: " + formatId,
0x100 <= formatId && formatId < 0x1000);
assertTrue(0x100 <= formatId && formatId < 0x1000,
"format id does not fit an audio stream: " + formatId);
}
} else {
assertTrue(audioStreams.isEmpty());
@ -309,8 +308,8 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
final int formatId = stream.getFormatId();
// see MediaFormat: video stream formats range from 0x1000 to 0x10000
assertTrue("format id does not fit a subtitles stream: " + formatId,
0x1000 <= formatId && formatId < 0x10000);
assertTrue(0x1000 <= formatId && formatId < 0x10000,
"format id does not fit a subtitles stream: " + formatId);
}
} else {
assertTrue(subtitles.isEmpty());
@ -333,7 +332,7 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
assertTrue(dashMpdUrl.isEmpty());
} else {
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.Set;
import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.schabi.newpipe.extractor.ExtractorAsserts.*;
import static org.schabi.newpipe.extractor.StreamingService.LinkType;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
public final class DefaultTests {
public static void defaultTestListOfItems(StreamingService expectedService, List<? extends InfoItem> itemsList, List<Throwable> errors) throws ParsingException {
assertFalse("List of items is empty", itemsList.isEmpty());
assertFalse("List of items contains a null element", itemsList.contains(null));
assertFalse(itemsList.isEmpty(), "List of items is empty");
assertFalse(itemsList.contains(null), "List of items contains a null element");
assertEmptyErrors("Errors during extraction", errors);
for (InfoItem item : itemsList) {
@ -33,8 +32,8 @@ public final class DefaultTests {
if (!isNullOrEmpty(thumbnailUrl)) {
assertIsSecureUrl(thumbnailUrl);
}
assertNotNull("InfoItem type not set: " + item, item.getInfoType());
assertEquals("Unexpected item service id", expectedService.getServiceId(), item.getServiceId());
assertNotNull(item.getInfoType(), "InfoItem type not set: " + item);
assertEquals(expectedService.getServiceId(), item.getServiceId(), "Unexpected item service id");
assertNotEmpty("Item name not set: " + item, item.getName());
if (item instanceof StreamInfoItem) {
@ -57,7 +56,7 @@ public final class DefaultTests {
if (!isNullOrEmpty(streamInfoItem.getTextualUploadDate())) {
final DateWrapper uploadDate = streamInfoItem.getUploadDate();
assertNotNull("No parsed upload date", uploadDate);
assertNotNull(uploadDate,"No parsed upload date");
}
} 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 {
final LinkType linkTypeByUrl = expectedService.getLinkTypeByUrl(url);
assertNotEquals("Url is not recognized by its own service: \"" + url + "\"",
LinkType.NONE, linkTypeByUrl);
assertEquals("Service returned wrong link type for: \"" + url + "\"",
expectedLinkType, linkTypeByUrl);
assertNotEquals(LinkType.NONE, linkTypeByUrl,
"Url is not recognized by its own service: \"" + url + "\"");
assertEquals(expectedLinkType, linkTypeByUrl,
"Service returned wrong link type for: \"" + url + "\"");
}
public static void assertOnlyContainsType(ListExtractor.InfoItemsPage<? extends InfoItem> items, InfoItem.InfoType expectedType) {
for (InfoItem item : items.getItems()) {
assertEquals("Item list contains unexpected info types",
expectedType, item.getInfoType());
assertEquals(expectedType, item.getInfoType(),
"Item list contains unexpected info types");
}
}
public static <T extends InfoItem> void assertNoMoreItems(ListExtractor<T> extractor) throws Exception {
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,
@ -122,10 +121,10 @@ public final class DefaultTests {
public static <T extends InfoItem> ListExtractor.InfoItemsPage<T> defaultTestMoreItems(ListExtractor<T> extractor) throws Exception {
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());
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());
defaultTestListOfItems(extractor.getService(), nextPage.getItems(), nextPage.getErrors());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,12 +2,12 @@
package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
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}
@ -16,7 +16,7 @@ public class BandcampFeaturedLinkHandlerFactoryTest {
private static BandcampFeaturedLinkHandlerFactory linkHandler;
@BeforeClass
@BeforeAll
public static void setUp() {
linkHandler = new BandcampFeaturedLinkHandlerFactory();
}

View File

@ -2,8 +2,9 @@
package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
@ -17,7 +18,7 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import java.io.IOException;
import java.util.List;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
/**
@ -25,7 +26,7 @@ import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
*/
public class BandcampPlaylistExtractorTest {
@BeforeClass
@BeforeAll
public static void setUp() {
NewPipe.init(DownloaderTestImpl.getInstance());
}
@ -57,7 +58,8 @@ public class BandcampPlaylistExtractorTest {
/**
* 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 {
final PlaylistExtractor extractor = Bandcamp.getPlaylistExtractor("https://infiniteammo.bandcamp.com/album/night-in-the-woods-vol-1-at-the-end-of-everything");
extractor.fetchPage();
@ -73,10 +75,11 @@ public class BandcampPlaylistExtractorTest {
/**
* Test playlists with locked content
*/
@Test(expected = ContentNotAvailableException.class)
@Test
public void testLockedContent() throws ExtractionException, IOException {
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;
@BeforeClass
@BeforeAll
public static void setUp() throws ExtractionException, IOException {
NewPipe.init(DownloaderTestImpl.getInstance());
extractor = Bandcamp.getPlaylistExtractor("https://macbenson.bandcamp.com/album/coming-of-age");

View File

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

View File

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

View File

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

View File

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

View File

@ -2,21 +2,21 @@
package org.schabi.newpipe.extractor.services.bandcamp;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampSearchQueryHandlerFactory;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
public class BandcampSearchQueryHandlerFactoryTest {
static BandcampSearchQueryHandlerFactory searchQuery;
@BeforeClass
@BeforeAll
public static void setUp() {
NewPipe.init(DownloaderTestImpl.getInstance());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,23 +1,22 @@
package org.schabi.newpipe.extractor.services.media_ccc;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest;
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCStreamExtractor;
import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.stream.StreamType;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
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;
/**
@ -31,7 +30,7 @@ public class MediaCCCStreamExtractorTest {
private static final String URL = BASE_URL + ID;
private static StreamExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
extractor = MediaCCC.getStreamExtractor(URL);
@ -62,7 +61,8 @@ public class MediaCCCStreamExtractorTest {
@Override public Locale expectedLanguageInfo() { return new Locale("de"); }
@Override
@Test public void testThumbnailUrl() throws Exception {
@Test
public void testThumbnailUrl() throws Exception {
super.testThumbnailUrl();
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 StreamExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
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
@Test public void testThumbnailUrl() throws Exception {
@Test
public void testThumbnailUrl() throws Exception {
super.testThumbnailUrl();
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;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCStreamLinkHandlerFactory;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class MediaCCCStreamLinkHandlerFactoryTest {
private static MediaCCCStreamLinkHandlerFactory linkHandler;
@BeforeClass
@BeforeAll
public static void setUp() {
linkHandler = new MediaCCCStreamLinkHandlerFactory();
NewPipe.init(DownloaderTestImpl.getInstance());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,8 +1,8 @@
package org.schabi.newpipe.extractor.services.peertube;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService;
@ -19,7 +19,7 @@ import java.util.Locale;
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;
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 StreamExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
// 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 StreamExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
// 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"); }
}
@Ignore("Test broken, SSL problem")
@Disabled("Test broken, SSL problem")
public static class AgeRestricted extends PeertubeStreamExtractorTest {
private static final String ID = "dbd8e5e1-c527-49b6-b70c-89101dbb9c08";
private static final String INSTANCE = "https://nocensoring.net";
private static final String URL = INSTANCE + "/videos/embed/" + ID;
private static StreamExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());;
// 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 {
NewPipe.init(DownloaderTestImpl.getInstance());
PeerTube.setInstance(new PeertubeInstance("https://peertube.cpy.re", "PeerTube test server"));

View File

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

View File

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

View File

@ -1,15 +1,15 @@
package org.schabi.newpipe.extractor.services.peertube;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeTrendingLinkHandlerFactory;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
/**
@ -18,7 +18,7 @@ import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
public class PeertubeTrendingLinkHandlerFactoryTest {
private static LinkHandlerFactory LinkHandlerFactory;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
// setting instance might break test when running in parallel
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;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
@ -26,7 +26,7 @@ public class PeertubeSearchExtractorTest {
private static SearchExtractor extractor;
private static final String QUERY = "fsf";
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
// setting instance might break test when running in parallel
@ -49,7 +49,7 @@ public class PeertubeSearchExtractorTest {
private static SearchExtractor extractor;
private static final String QUERY = "kde";
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
// setting instance might break test when running in parallel
@ -70,7 +70,7 @@ public class PeertubeSearchExtractorTest {
public static class PagingTest {
@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 {
NewPipe.init(DownloaderTestImpl.getInstance());
final SearchExtractor extractor = PeerTube.getSearchExtractor("internet", singletonList(VIDEOS), "");

View File

@ -1,17 +1,17 @@
package org.schabi.newpipe.extractor.services.peertube.search;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.extractor.services.peertube.PeertubeInstance;
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeSearchQueryHandlerFactory;
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;
public class PeertubeSearchQHTest {
@BeforeClass
@BeforeAll
public static void setUpClass() throws Exception {
// setting instance might break test when running in parallel
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;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.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.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.assertIsSecureUrl;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
@ -22,7 +22,7 @@ public class SoundcloudChannelExtractorTest {
public static class LilUzi implements BaseChannelExtractorTest {
private static SoundcloudChannelExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (SoundcloudChannelExtractor) SoundCloud
@ -99,7 +99,7 @@ public class SoundcloudChannelExtractorTest {
@Test
public void testSubscriberCount() {
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 1e6);
assertTrue(extractor.getSubscriberCount() >= 1e6, "Wrong subscriber count");
}
@Override
@ -111,7 +111,7 @@ public class SoundcloudChannelExtractorTest {
public static class DubMatix implements BaseChannelExtractorTest {
private static SoundcloudChannelExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (SoundcloudChannelExtractor) SoundCloud
@ -198,7 +198,7 @@ public class SoundcloudChannelExtractorTest {
@Test
public void testSubscriberCount() {
assertTrue("Wrong subscriber count", extractor.getSubscriberCount() >= 2e6);
assertTrue(extractor.getSubscriberCount() >= 2e6, "Wrong subscriber count");
}
@Override

View File

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

View File

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

View File

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

View File

@ -1,9 +1,10 @@
package org.schabi.newpipe.extractor.services.soundcloud;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.ExtractorAsserts;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.NewPipe;
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.stream.StreamInfoItem;
import static org.hamcrest.CoreMatchers.*;
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.ServiceList.SoundCloud;
import static org.schabi.newpipe.extractor.services.DefaultTests.*;
@ -24,7 +24,7 @@ public class SoundcloudPlaylistExtractorTest {
public static class LuvTape implements BasePlaylistExtractorTest {
private static SoundcloudPlaylistExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (SoundcloudPlaylistExtractor) SoundCloud
@ -91,10 +91,10 @@ public class SoundcloudPlaylistExtractorTest {
}
@Test
public void testUploaderUrl() {
void testUploaderUrl() {
final String uploaderUrl = extractor.getUploaderUrl();
assertIsSecureUrl(uploaderUrl);
assertThat(uploaderUrl, containsString("liluzivert"));
ExtractorAsserts.assertContains("liluzivert", uploaderUrl);
}
@Test
@ -109,10 +109,10 @@ public class SoundcloudPlaylistExtractorTest {
@Test
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 {
assertTrue(extractor.isUploaderVerified());
}
@ -121,7 +121,7 @@ public class SoundcloudPlaylistExtractorTest {
public static class RandomHouseMusic implements BasePlaylistExtractorTest {
private static SoundcloudPlaylistExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (SoundcloudPlaylistExtractor) SoundCloud
@ -188,10 +188,10 @@ public class SoundcloudPlaylistExtractorTest {
}
@Test
public void testUploaderUrl() {
void testUploaderUrl() {
final String uploaderUrl = extractor.getUploaderUrl();
assertIsSecureUrl(uploaderUrl);
assertThat(uploaderUrl, containsString("micky96"));
ExtractorAsserts.assertContains("micky96", uploaderUrl);
}
@Test
@ -206,10 +206,10 @@ public class SoundcloudPlaylistExtractorTest {
@Test
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 {
assertFalse(extractor.isUploaderVerified());
}
@ -218,7 +218,7 @@ public class SoundcloudPlaylistExtractorTest {
public static class EDMxxx implements BasePlaylistExtractorTest {
private static SoundcloudPlaylistExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (SoundcloudPlaylistExtractor) SoundCloud
@ -231,7 +231,7 @@ public class SoundcloudPlaylistExtractorTest {
//////////////////////////////////////////////////////////////////////////*/
@Test
public void testGetPageInNewExtractor() throws Exception {
void testGetPageInNewExtractor() throws Exception {
PlaylistExtractor newExtractor = SoundCloud.getPlaylistExtractor(extractor.getUrl());
defaultTestGetPageInNewExtractor(extractor, newExtractor);
}
@ -300,10 +300,10 @@ public class SoundcloudPlaylistExtractorTest {
}
@Test
public void testUploaderUrl() {
void testUploaderUrl() {
final String uploaderUrl = extractor.getUploaderUrl();
assertIsSecureUrl(uploaderUrl);
assertTrue(uploaderUrl, uploaderUrl.contains("user350509423"));
ExtractorAsserts.assertContains("user350509423", uploaderUrl);
}
@Test
@ -318,10 +318,10 @@ public class SoundcloudPlaylistExtractorTest {
@Test
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 {
assertFalse(extractor.isUploaderVerified());
}
@ -330,7 +330,7 @@ public class SoundcloudPlaylistExtractorTest {
public static class SmallPlaylist implements BasePlaylistExtractorTest {
private static SoundcloudPlaylistExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
extractor = (SoundcloudPlaylistExtractor) SoundCloud
@ -377,7 +377,7 @@ public class SoundcloudPlaylistExtractorTest {
}
@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 {
try {
defaultTestMoreItems(extractor);
@ -404,10 +404,10 @@ public class SoundcloudPlaylistExtractorTest {
}
@Test
public void testUploaderUrl() {
void testUploaderUrl() {
final String uploaderUrl = extractor.getUploaderUrl();
assertIsSecureUrl(uploaderUrl);
assertThat(uploaderUrl, containsString("breezy-123"));
ExtractorAsserts.assertContains("breezy-123", uploaderUrl);
}
@Test
@ -425,7 +425,7 @@ public class SoundcloudPlaylistExtractorTest {
assertEquals(2, extractor.getStreamCount());
}
@Override
@Test
public void testUploaderVerified() throws Exception {
assertFalse(extractor.isUploaderVerified());
}

View File

@ -1,9 +1,10 @@
package org.schabi.newpipe.extractor.services.soundcloud;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.ExtractorAsserts;
import org.schabi.newpipe.extractor.MediaFormat;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService;
@ -20,9 +21,7 @@ import java.util.List;
import javax.annotation.Nullable;
import static junit.framework.TestCase.assertEquals;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
public class SoundcloudStreamExtractorTest {
@ -35,7 +34,7 @@ public class SoundcloudStreamExtractorTest {
private static final String URL = UPLOADER + "/" + ID + "#t=" + TIMESTAMP;
private static StreamExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
extractor = SoundCloud.getStreamExtractor(URL);
@ -76,7 +75,7 @@ public class SoundcloudStreamExtractorTest {
@Test
@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 {
super.testRelatedItems();
}
@ -89,7 +88,7 @@ public class SoundcloudStreamExtractorTest {
private static final String URL = UPLOADER + "/" + ID + "#t=" + TIMESTAMP;
private static StreamExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
extractor = SoundCloud.getStreamExtractor(URL);
@ -102,7 +101,7 @@ public class SoundcloudStreamExtractorTest {
@Override
@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/pull/601")
public void testRelatedItems() throws Exception {
@ -146,7 +145,7 @@ public class SoundcloudStreamExtractorTest {
private static final String URL = UPLOADER + "/" + ID + "#t=" + TIMESTAMP;
private static StreamExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
extractor = SoundCloud.getStreamExtractor(URL);
@ -192,12 +191,12 @@ public class SoundcloudStreamExtractorTest {
final String mediaUrl = audioStream.getUrl();
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
assertThat(mediaUrl, containsString("-hls-opus-media.sndcdn.com"));
assertThat(mediaUrl, containsString(".64.opus"));
ExtractorAsserts.assertContains("-hls-opus-media.sndcdn.com", mediaUrl);
ExtractorAsserts.assertContains(".64.opus", mediaUrl);
}
if (audioStream.getFormat() == MediaFormat.MP3) {
// 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;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
@ -11,7 +10,7 @@ import org.schabi.newpipe.extractor.services.soundcloud.linkHandler.SoundcloudSt
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
/**
* Test for {@link SoundcloudStreamLinkHandlerFactory}
@ -19,15 +18,15 @@ import static org.junit.Assert.*;
public class SoundcloudStreamLinkHandlerFactoryTest {
private static SoundcloudStreamLinkHandlerFactory linkHandler;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
linkHandler = SoundcloudStreamLinkHandlerFactory.getInstance();
NewPipe.init(DownloaderTestImpl.getInstance());
}
@Test(expected = IllegalArgumentException.class)
public void getIdWithNullAsUrl() throws ParsingException {
linkHandler.fromUrl(null).getId();
@Test
public void getIdWithNullAsUrl() {
assertThrows(IllegalArgumentException.class, () -> linkHandler.fromUrl(null));
}
@Test

View File

@ -1,7 +1,9 @@
package org.schabi.newpipe.extractor.services.soundcloud;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
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.extractor.NewPipe;
import org.schabi.newpipe.extractor.ServiceList;
@ -15,7 +17,7 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
/**
* Test for {@link SoundcloudSubscriptionExtractor}
@ -24,54 +26,49 @@ public class SoundcloudSubscriptionExtractorTest {
private static SoundcloudSubscriptionExtractor subscriptionExtractor;
private static LinkHandlerFactory urlHandler;
@BeforeClass
@BeforeAll
public static void setupClass() {
NewPipe.init(DownloaderTestImpl.getInstance());
subscriptionExtractor = new SoundcloudSubscriptionExtractor(ServiceList.SoundCloud);
urlHandler = ServiceList.SoundCloud.getChannelLHFactory();
}
@Test
public void testFromChannelUrl() throws Exception {
testList(subscriptionExtractor.fromChannelUrl("https://soundcloud.com/monstercat"));
testList(subscriptionExtractor.fromChannelUrl("http://soundcloud.com/monstercat"));
testList(subscriptionExtractor.fromChannelUrl("soundcloud.com/monstercat"));
testList(subscriptionExtractor.fromChannelUrl("monstercat"));
//Empty followings user
testList(subscriptionExtractor.fromChannelUrl("some-random-user-184047028"));
}
@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) {
@ParameterizedTest
@ValueSource(strings = {
"https://soundcloud.com/monstercat",
"http://soundcloud.com/monstercat",
"soundcloud.com/monstercat",
"monstercat",
// Empty followings user
"some-random-user-184047028"
})
void testFromChannelUrl(final String channelUrl) throws Exception {
for (SubscriptionItem item : subscriptionExtractor.fromChannelUrl(channelUrl)) {
assertNotNull(item.getName());
assertNotNull(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;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
@ -9,7 +9,7 @@ import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;
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;
/**
@ -18,7 +18,7 @@ import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
public class SoundcloudSuggestionExtractorTest {
private static SuggestionExtractor suggestionExtractor;
@BeforeClass
@BeforeAll
public static void setUp() {
NewPipe.init(DownloaderTestImpl.getInstance());
suggestionExtractor = SoundCloud.getSuggestionExtractor();

View File

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

View File

@ -1,19 +1,18 @@
package org.schabi.newpipe.extractor.services.soundcloud.search;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
import 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.services.soundcloud.linkHandler.SoundcloudSearchQueryHandlerFactory.*;
public class SoundcloudSearchQHTest {
@BeforeClass
@BeforeAll
public static void setUpClass() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
}

View File

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

View File

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

View File

@ -1,6 +1,6 @@
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.extractor.ListExtractor;
import org.schabi.newpipe.extractor.NewPipe;
@ -16,7 +16,7 @@ import java.util.List;
import java.util.Map;
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.services.DefaultTests.defaultTestRelatedItems;

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.youtube;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderFactory;
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
import org.schabi.newpipe.extractor.NewPipe;
@ -19,10 +19,10 @@ import java.util.List;
import java.util.Locale;
import java.util.Random;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
public class YoutubeCommentsExtractorTest {
@ -36,7 +36,7 @@ public class YoutubeCommentsExtractorTest {
private static final String commentContent = "Category: Education";
private static YoutubeCommentsExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey();
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 static YoutubeCommentsExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey();
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 static YoutubeCommentsExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -199,7 +199,7 @@ public class YoutubeCommentsExtractorTest {
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 static YoutubeCommentsExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -238,7 +238,7 @@ public class YoutubeCommentsExtractorTest {
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 static YoutubeCommentsExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -268,9 +268,9 @@ public class YoutubeCommentsExtractorTest {
CommentsInfoItem pinnedComment = comments.getItems().get(0);
assertTrue("First comment isn't pinned", pinnedComment.isPinned());
assertTrue("The first pinned comment has no likes", pinnedComment.getLikeCount() > 0);
assertTrue("The first pinned comment has no vote count", !Utils.isBlank(pinnedComment.getTextualLikeCount()));
assertTrue(pinnedComment.isPinned(), "First comment isn't pinned");
assertTrue(pinnedComment.getLikeCount() > 0, "The first pinned comment has no likes");
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 static YoutubeCommentsExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -302,8 +302,8 @@ public class YoutubeCommentsExtractorTest {
CommentsInfoItem pinnedComment = comments.getItems().get(0);
assertTrue("First comment isn't pinned", pinnedComment.isPinned());
assertTrue("The first pinned comment has no vote count", !Utils.isBlank(pinnedComment.getTextualLikeCount()));
assertTrue(pinnedComment.isPinned(), "First comment isn't pinned");
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 static YoutubeCommentsExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -329,11 +329,12 @@ public class YoutubeCommentsExtractorTest {
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());
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;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeCommentsLinkHandlerFactory;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class YoutubeCommentsLinkHandlerFactoryTest {
private static YoutubeCommentsLinkHandlerFactory linkHandler;
@BeforeClass
@BeforeAll
public static void setUp() {
NewPipe.init(DownloaderTestImpl.getInstance());
linkHandler = YoutubeCommentsLinkHandlerFactory.getInstance();
}
@Test(expected = IllegalArgumentException.class)
public void getIdWithNullAsUrl() throws ParsingException {
linkHandler.fromId(null);
@Test
public void getIdWithNullAsUrl() {
assertThrows(IllegalArgumentException.class, () -> linkHandler.fromId(null));
}
@Test

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.youtube;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderFactory;
import org.schabi.newpipe.extractor.NewPipe;
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.util.Random;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
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.services.DefaultTests.assertNoMoreItems;
import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems;
@ -25,7 +26,7 @@ public class YoutubeFeedExtractorTest {
public static class Kurzgesagt implements BaseListExtractorTest {
private static YoutubeFeedExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -46,8 +47,7 @@ public class YoutubeFeedExtractorTest {
@Test
public void testName() {
String name = extractor.getName();
assertTrue(name, name.startsWith("Kurzgesagt"));
assertTrue(extractor.getName().startsWith("Kurzgesagt"));
}
@Test
@ -82,16 +82,16 @@ public class YoutubeFeedExtractorTest {
public static class NotAvailable {
@BeforeClass
@BeforeAll
public static void setUp() throws IOException {
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "notAvailable/"));
}
@Test(expected = ContentNotAvailableException.class)
public void AccountTerminatedFetch() throws Exception {
@Test
void AccountTerminatedFetch() throws Exception {
YoutubeFeedExtractor extractor = (YoutubeFeedExtractor) YouTube
.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;
import org.junit.Before;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.ExtractorAsserts;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import java.io.IOException;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
public class YoutubeJavaScriptExtractorTest {
@Before
@BeforeEach
public void setup() throws IOException {
NewPipe.init(DownloaderTestImpl.getInstance());
}
@Test
public void testExtractJavaScriptUrlIframe() throws ParsingException {
assertThat(YoutubeJavaScriptExtractor.extractJavaScriptUrl(), endsWith("base.js"));
assertTrue(YoutubeJavaScriptExtractor.extractJavaScriptUrl().endsWith("base.js"));
}
@Test
public void testExtractJavaScriptUrlEmbed() throws ParsingException {
assertThat(YoutubeJavaScriptExtractor.extractJavaScriptUrl("d4IGg5dqeO8"), endsWith("base.js"));
assertTrue(YoutubeJavaScriptExtractor.extractJavaScriptUrl("d4IGg5dqeO8").endsWith("base.js"));
}
@Test
@ -48,9 +48,8 @@ public class YoutubeJavaScriptExtractorTest {
}
private void assertPlayerJsCode(final String playerJsCode) {
assertThat(playerJsCode, allOf(
containsString(" Copyright The Closure Library Authors.\n"
+ " SPDX-License-Identifier: Apache-2.0"),
containsString("var _yt_player")));
ExtractorAsserts.assertContains(" Copyright The Closure Library Authors.\n"
+ " SPDX-License-Identifier: Apache-2.0", playerJsCode);
ExtractorAsserts.assertContains("var _yt_player", playerJsCode);
}
}

View File

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

View File

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

View File

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

View File

@ -1,12 +1,14 @@
package org.schabi.newpipe.extractor.services.youtube;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderFactory;
import org.schabi.newpipe.extractor.ExtractorAsserts;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.NewPipe;
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.playlist.PlaylistExtractor;
import org.schabi.newpipe.extractor.services.BasePlaylistExtractorTest;
@ -16,9 +18,10 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import java.io.IOException;
import java.util.Random;
import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertEquals;
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.ServiceList.YouTube;
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/";
public static class NotAvailable {
@BeforeClass
@BeforeAll
public static void setUp() throws IOException {
YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1));
NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "notAvailable"));
}
@Test(expected = ContentNotAvailableException.class)
public void nonExistentFetch() throws Exception {
@Test
void nonExistentFetch() throws Exception {
final PlaylistExtractor extractor =
YouTube.getPlaylistExtractor("https://www.youtube.com/playlist?list=PL11111111111111111111111111111111");
extractor.fetchPage();
assertThrows(ContentNotAvailableException.class, extractor::fetchPage);
}
@Test(expected = ContentNotAvailableException.class)
public void invalidId() throws Exception {
@Test
void invalidId() throws Exception {
final PlaylistExtractor extractor =
YouTube.getPlaylistExtractor("https://www.youtube.com/playlist?list=INVALID_ID");
extractor.fetchPage();
assertThrows(ContentNotAvailableException.class, extractor::fetchPage);
}
}
public static class TimelessPopHits implements BasePlaylistExtractorTest {
private static YoutubePlaylistExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -81,8 +84,7 @@ public class YoutubePlaylistExtractorTest {
@Test
public void testName() throws Exception {
String name = extractor.getName();
assertTrue(name, name.startsWith("Pop Music Playlist"));
assertTrue(extractor.getName().startsWith("Pop Music Playlist"));
}
@Test
@ -122,15 +124,15 @@ public class YoutubePlaylistExtractorTest {
public void testThumbnailUrl() throws Exception {
final String thumbnailUrl = extractor.getThumbnailUrl();
assertIsSecureUrl(thumbnailUrl);
assertTrue(thumbnailUrl, thumbnailUrl.contains("yt"));
ExtractorAsserts.assertContains("yt", thumbnailUrl);
}
@Ignore
@Disabled
@Test
public void testBannerUrl() {
final String bannerUrl = extractor.getBannerUrl();
assertIsSecureUrl(bannerUrl);
assertTrue(bannerUrl, bannerUrl.contains("yt"));
ExtractorAsserts.assertContains("yt", bannerUrl);
}
@Test
@ -141,18 +143,18 @@ public class YoutubePlaylistExtractorTest {
@Test
public void testUploaderName() throws Exception {
final String uploaderName = extractor.getUploaderName();
assertTrue(uploaderName, uploaderName.contains("Just Hits"));
ExtractorAsserts.assertContains("Just Hits", uploaderName);
}
@Test
public void testUploaderAvatarUrl() throws Exception {
final String uploaderAvatarUrl = extractor.getUploaderAvatarUrl();
assertTrue(uploaderAvatarUrl, uploaderAvatarUrl.contains("yt"));
ExtractorAsserts.assertContains("yt", uploaderAvatarUrl);
}
@Test
public void testStreamCount() throws Exception {
assertTrue("Error in the streams count", extractor.getStreamCount() > 100);
ExtractorAsserts.assertGreater(100, extractor.getStreamCount());
}
@Override
@ -164,7 +166,7 @@ public class YoutubePlaylistExtractorTest {
public static class HugePlaylist implements BasePlaylistExtractorTest {
private static YoutubePlaylistExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -242,15 +244,15 @@ public class YoutubePlaylistExtractorTest {
public void testThumbnailUrl() throws Exception {
final String thumbnailUrl = extractor.getThumbnailUrl();
assertIsSecureUrl(thumbnailUrl);
assertTrue(thumbnailUrl, thumbnailUrl.contains("yt"));
ExtractorAsserts.assertContains("yt", thumbnailUrl);
}
@Ignore
@Disabled
@Test
public void testBannerUrl() {
final String bannerUrl = extractor.getBannerUrl();
assertIsSecureUrl(bannerUrl);
assertTrue(bannerUrl, bannerUrl.contains("yt"));
ExtractorAsserts.assertContains("yt", bannerUrl);
}
@Test
@ -266,12 +268,12 @@ public class YoutubePlaylistExtractorTest {
@Test
public void testUploaderAvatarUrl() throws Exception {
final String uploaderAvatarUrl = extractor.getUploaderAvatarUrl();
assertTrue(uploaderAvatarUrl, uploaderAvatarUrl.contains("yt"));
ExtractorAsserts.assertContains("yt", uploaderAvatarUrl);
}
@Test
public void testStreamCount() throws Exception {
assertTrue("Error in the streams count", extractor.getStreamCount() > 100);
ExtractorAsserts.assertGreater(100, extractor.getStreamCount());
}
@Override
@ -283,7 +285,7 @@ public class YoutubePlaylistExtractorTest {
public static class LearningPlaylist implements BasePlaylistExtractorTest {
private static YoutubePlaylistExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -304,8 +306,7 @@ public class YoutubePlaylistExtractorTest {
@Test
public void testName() throws Exception {
String name = extractor.getName();
assertTrue(name, name.startsWith("Anatomy & Physiology"));
assertTrue(extractor.getName().startsWith("Anatomy & Physiology"));
}
@Test
@ -332,7 +333,7 @@ public class YoutubePlaylistExtractorTest {
defaultTestRelatedItems(extractor);
}
@Ignore
@Disabled
@Test
public void testMoreRelatedItems() throws Exception {
defaultTestMoreItems(extractor);
@ -346,15 +347,15 @@ public class YoutubePlaylistExtractorTest {
public void testThumbnailUrl() throws Exception {
final String thumbnailUrl = extractor.getThumbnailUrl();
assertIsSecureUrl(thumbnailUrl);
assertTrue(thumbnailUrl, thumbnailUrl.contains("yt"));
ExtractorAsserts.assertContains("yt", thumbnailUrl);
}
@Ignore
@Disabled
@Test
public void testBannerUrl() {
final String bannerUrl = extractor.getBannerUrl();
assertIsSecureUrl(bannerUrl);
assertTrue(bannerUrl, bannerUrl.contains("yt"));
ExtractorAsserts.assertContains("yt", bannerUrl);
}
@Test
@ -365,18 +366,18 @@ public class YoutubePlaylistExtractorTest {
@Test
public void testUploaderName() throws Exception {
final String uploaderName = extractor.getUploaderName();
assertTrue(uploaderName, uploaderName.contains("CrashCourse"));
ExtractorAsserts.assertContains("CrashCourse", uploaderName);
}
@Test
public void testUploaderAvatarUrl() throws Exception {
final String uploaderAvatarUrl = extractor.getUploaderAvatarUrl();
assertTrue(uploaderAvatarUrl, uploaderAvatarUrl.contains("yt"));
ExtractorAsserts.assertContains("yt", uploaderAvatarUrl);
}
@Test
public void testStreamCount() throws Exception {
assertTrue("Error in the streams count", extractor.getStreamCount() > 40);
ExtractorAsserts.assertGreater(40, extractor.getStreamCount());
}
@Override
@ -387,7 +388,7 @@ public class YoutubePlaylistExtractorTest {
public static class ContinuationsTests {
@BeforeClass
@BeforeAll
public static void setUp() throws IOException {
YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1));
@ -413,7 +414,7 @@ public class YoutubePlaylistExtractorTest {
final ListExtractor.InfoItemsPage<StreamInfoItem> page = defaultTestMoreItems(
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;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubePlaylistLinkHandlerFactory;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
/**
* Test for {@link YoutubePlaylistLinkHandlerFactory}
@ -15,15 +15,15 @@ import static org.junit.Assert.*;
public class YoutubePlaylistLinkHandlerFactoryTest {
private static YoutubePlaylistLinkHandlerFactory linkHandler;
@BeforeClass
@BeforeAll
public static void setUp() {
NewPipe.init(DownloaderTestImpl.getInstance());
linkHandler = YoutubePlaylistLinkHandlerFactory.getInstance();
}
@Test(expected = IllegalArgumentException.class)
public void getIdWithNullAsUrl() throws ParsingException {
linkHandler.fromId(null);
@Test
public void getIdWithNullAsUrl() {
assertThrows(IllegalArgumentException.class, () -> linkHandler.fromId(null));
}
@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/>.
*/
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.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.YoutubePlaylistExtractor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
/**
@ -42,7 +42,7 @@ public class YoutubeServiceTest {
static StreamingService service;
static KioskList kioskList;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
NewPipe.init(DownloaderTestImpl.getInstance());
service = YouTube;
@ -50,25 +50,25 @@ public class YoutubeServiceTest {
}
@Test
public void testGetKioskAvailableKiosks() throws Exception {
assertFalse("No kiosk got returned", kioskList.getAvailableKiosks().isEmpty());
void testGetKioskAvailableKiosks() {
assertFalse(kioskList.getAvailableKiosks().isEmpty(), "No kiosk got returned");
}
@Test
public void testGetDefaultKiosk() throws Exception {
void testGetDefaultKiosk() throws Exception {
assertEquals(kioskList.getDefaultKioskExtractor(null).getId(), "Trending");
}
@Test
public void getPlayListExtractorIsNormalPlaylist() throws Exception {
void getPlayListExtractorIsNormalPlaylist() throws Exception {
final PlaylistExtractor extractor = service.getPlaylistExtractor(
"https://www.youtube.com/watch?v=JhqtYOnNrTs&list=PL-EkZZikQIQVqk9rBWzEo5b-2GeozElS");
assertTrue(extractor instanceof YoutubePlaylistExtractor);
}
@Test
public void getPlaylistExtractorIsMix() throws Exception {
void getPlaylistExtractorIsMix() throws Exception {
final String videoId = "_AzeUSL9lZc";
PlaylistExtractor extractor = YouTube.getPlaylistExtractor(
"https://www.youtube.com/watch?v=" + videoId + "&list=RD" + videoId);

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.youtube;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.FoundAdException;
@ -11,7 +11,7 @@ import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeStreamLi
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
/**
* 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 YoutubeStreamLinkHandlerFactory linkHandler;
@BeforeClass
@BeforeAll
public static void setUp() {
linkHandler = YoutubeStreamLinkHandlerFactory.getInstance();
NewPipe.init(DownloaderTestImpl.getInstance());
}
@Test(expected = IllegalArgumentException.class)
public void getIdWithNullAsUrl() throws ParsingException {
linkHandler.fromId(null);
@Test
public void getIdWithNullAsUrl() {
assertThrows(IllegalArgumentException.class, () -> linkHandler.fromId(null));
}
@Test(expected = FoundAdException.class)
@Test
public void getIdForAd() throws ParsingException {
linkHandler.fromUrl(AD_URL).getId();
assertThrows(FoundAdException.class, () -> linkHandler.fromUrl(AD_URL));
}
@Test

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.youtube;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.ServiceList;
@ -16,7 +16,7 @@ import java.io.FileInputStream;
import java.util.Arrays;
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.extractor.utils.Utils.UTF_8;
@ -29,7 +29,7 @@ public class YoutubeSubscriptionExtractorTest {
private static YoutubeSubscriptionExtractor subscriptionExtractor;
private static LinkHandlerFactory urlHandler;
@BeforeClass
@BeforeAll
public static void setupClass() {
//Doesn't make network requests
NewPipe.init(DownloaderTestImpl.getInstance());
@ -107,7 +107,7 @@ public class YoutubeSubscriptionExtractorTest {
if (!correctType) {
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/>.
*/
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderFactory;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
@ -31,7 +31,7 @@ import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;
import java.io.IOException;
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;
/**
@ -43,7 +43,7 @@ public class YoutubeSuggestionExtractorTest {
private static SuggestionExtractor suggestionExtractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1));

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.youtube;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mozilla.javascript.EvaluatorException;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
@ -9,14 +9,13 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
import java.io.IOException;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.fail;
public class YoutubeThrottlingDecrypterTest {
@Before
@BeforeEach
public void setup() throws IOException {
NewPipe.init(DownloaderTestImpl.getInstance());
}
@ -49,9 +48,9 @@ public class YoutubeThrottlingDecrypterTest {
@Test
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==";
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/>.
*/
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderFactory;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService;
@ -30,8 +30,8 @@ import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
import java.util.Random;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
/**
@ -43,7 +43,7 @@ public class YoutubeTrendingKioskInfoTest {
static KioskInfo kioskInfo;
@BeforeClass
@BeforeAll
public static void setUp()
throws Exception {
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/>.
*/
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeTrendingLinkHandlerFactory;
import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
/**
@ -39,7 +39,7 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube;
public class YoutubeTrendingLinkHandlerFactoryTest {
private static LinkHandlerFactory LinkHandlerFactory;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
LinkHandlerFactory = YouTube.getKioskList().getListLinkHandlerFactoryByType("Trending");
NewPipe.init(DownloaderTestImpl.getInstance());

View File

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

View File

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

View File

@ -1,9 +1,9 @@
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 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.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory.CHANNELS;
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;
import org.junit.BeforeClass;
import org.junit.jupiter.api.BeforeAll;
import org.schabi.newpipe.downloader.DownloaderFactory;
import org.schabi.newpipe.extractor.NewPipe;
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.StreamType;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
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 StreamExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1));

View File

@ -1,6 +1,6 @@
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.extractor.NewPipe;
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 StreamExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1));

View File

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

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.extractor.services.youtube.stream;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderFactory;
import org.schabi.newpipe.extractor.NewPipe;
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 StreamExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey();
YoutubeParsingHelper.setNumberGenerator(new Random(1));

View File

@ -1,6 +1,6 @@
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.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService;
@ -25,7 +25,7 @@ public class YoutubeStreamExtractorUnlistedTest extends DefaultStreamExtractorTe
static final String URL = YoutubeStreamExtractorDefaultTest.BASE_URL + ID;
private static StreamExtractor extractor;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
YoutubeParsingHelper.resetClientVersionAndKey();
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.JsonParser;
import com.grack.nanojson.JsonParserException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import java.util.List;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class JsonUtilsTest {

View File

@ -1,9 +1,9 @@
package org.schabi.newpipe.extractor.utils;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
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;
public class StringUtilsTest {
@ -48,7 +48,7 @@ public class StringUtilsTest {
assertEquals(expected, substring);
}
@Ignore("Functionality currently not needed")
@Disabled("Functionality currently not needed")
@Test
public void lessClosing__success() {
String expected = "{{{}}}";

View File

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

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