Browse Source

Updated to JUnit 5

pull/768/head
litetex 7 months ago
parent
commit
a2cbdf0991
  1. 2
      build.gradle
  2. 7
      extractor/build.gradle
  3. 25
      extractor/src/test/java/org/schabi/newpipe/MockOnly.java
  4. 51
      extractor/src/test/java/org/schabi/newpipe/MockOnlyRule.java
  5. 29
      extractor/src/test/java/org/schabi/newpipe/extractor/ExtractorAsserts.java
  6. 10
      extractor/src/test/java/org/schabi/newpipe/extractor/NewPipeTest.java
  7. 10
      extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultExtractorTest.java
  8. 2
      extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultListExtractorTest.java
  9. 6
      extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultSearchExtractorTest.java
  10. 36
      extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultStreamExtractorTest.java
  11. 31
      extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultTests.java
  12. 12
      extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelExtractorTest.java
  13. 20
      extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelLinkHandlerFactoryTest.java
  14. 12
      extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampCommentsExtractorTest.java
  15. 9
      extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampCommentsLinkHandlerFactoryTest.java
  16. 12
      extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampFeaturedExtractorTest.java
  17. 8
      extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampFeaturedLinkHandlerFactoryTest.java
  18. 19
      extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistExtractorTest.java
  19. 10
      extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistLinkHandlerFactoryTest.java
  20. 10
      extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampRadioExtractorTest.java
  21. 18
      extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampRadioStreamExtractorTest.java
  22. 12
      extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampSearchExtractorTest.java
  23. 8
      extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampSearchQueryHandlerFactoryTest.java
  24. 10
      extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampStreamExtractorTest.java
  25. 8
      extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampStreamLinkHandlerFactoryTest.java
  26. 8
      extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampSuggestionExtractorTest.java
  27. 12
      extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCConferenceExtractorTest.java
  28. 8
      extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCConferenceLinkHandlerFactoryTest.java
  29. 12
      extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCConferenceListExtractorTest.java
  30. 6
      extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCLiveStreamListExtractorTest.java
  31. 8
      extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCOggTest.java
  32. 10
      extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCRecentListExtractorTest.java
  33. 19
      extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCStreamExtractorTest.java
  34. 8
      extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCStreamLinkHandlerFactoryTest.java
  35. 8
      extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/search/MediaCCCSearchExtractorTest.java
  36. 15
      extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeAccountExtractorTest.java
  37. 14
      extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeChannelExtractorTest.java
  38. 10
      extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeChannelLinkHandlerFactoryTest.java
  39. 14
      extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeCommentsExtractorTest.java
  40. 10
      extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeCommentsLinkHandlerFactoryTest.java
  41. 12
      extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubePlaylistExtractorTest.java
  42. 10
      extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubePlaylistLinkHandlerFactoryTest.java
  43. 18
      extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeStreamExtractorTest.java
  44. 8
      extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeStreamLinkHandlerFactoryTest.java
  45. 8
      extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeTrendingExtractorTest.java
  46. 10
      extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeTrendingLinkHandlerFactoryTest.java
  47. 12
      extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/search/PeertubeSearchExtractorTest.java
  48. 8
      extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/search/PeertubeSearchQHTest.java
  49. 14
      extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java
  50. 10
      extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractorTest.java
  51. 12
      extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsLinkHandlerFactoryTest.java
  52. 33
      extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelperTest.java
  53. 37
      extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractorTest.java
  54. 27
      extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorTest.java
  55. 15
      extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamLinkHandlerFactoryTest.java
  56. 10
      extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSubscriptionExtractorTest.java
  57. 8
      extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSuggestionExtractorTest.java
  58. 19
      extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/search/SoundcloudSearchExtractorTest.java
  59. 9
      extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/search/SoundcloudSearchQHTest.java
  60. 169
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java
  61. 12
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelLinkHandlerFactoryTest.java
  62. 4
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelLocalizationTest.java
  63. 45
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java
  64. 19
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsLinkHandlerFactoryTest.java
  65. 22
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeFeedExtractorTest.java
  66. 23
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeJavaScriptExtractorTest.java
  67. 8
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeKioskExtractorTest.java
  68. 78
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeMixPlaylistExtractorTest.java
  69. 18
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelperTest.java
  70. 81
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java
  71. 14
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistLinkHandlerFactoryTest.java
  72. 22
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeServiceTest.java
  73. 18
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamLinkHandlerFactoryTest.java
  74. 10
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSubscriptionExtractorTest.java
  75. 8
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSuggestionExtractorTest.java
  76. 17
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeThrottlingDecrypterTest.java
  77. 10
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingKioskInfoTest.java
  78. 12
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingLinkHandlerFactoryTest.java
  79. 20
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeMusicSearchExtractorTest.java
  80. 34
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorTest.java
  81. 4
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchQHTest.java
  82. 5
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorAgeRestrictedTest.java
  83. 4
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorControversialTest.java
  84. 71
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorDefaultTest.java
  85. 6
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorLivestreamTest.java
  86. 4
      extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorUnlistedTest.java
  87. 4
      extractor/src/test/java/org/schabi/newpipe/extractor/utils/JsonUtilsTest.java
  88. 8
      extractor/src/test/java/org/schabi/newpipe/extractor/utils/StringUtilsTest.java
  89. 4
      extractor/src/test/java/org/schabi/newpipe/extractor/utils/UtilsTest.java
  90. 2
      timeago-parser/build.gradle

2
build.gradle

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

7
extractor/build.gradle

@ -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'
}

25
extractor/src/test/java/org/schabi/newpipe/MockOnly.java

@ -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();
}

51
extractor/src/test/java/org/schabi/newpipe/MockOnlyRule.java

@ -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();
}
};
}
}

29
extractor/src/test/java/org/schabi/newpipe/extractor/ExtractorAsserts.java

@ -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,12 @@ 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);
assertTrue(actual >= expected, actual + " is not at least " + expected);
}
// this assumes that sorting a and b in-place is not an issue, so it's only intended for tests
@ -85,4 +83,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 +"'");
}
}

10
extractor/src/test/java/org/schabi/newpipe/extractor/NewPipeTest.java

@ -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);
}
}

10
extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultExtractorTest.java

@ -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);
}
}

2
extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultListExtractorTest.java

@ -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;

6
extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultSearchExtractorTest.java

@ -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;

36
extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultStreamExtractorTest.java

@ -1,6 +1,8 @@
package org.schabi.newpipe.extractor.services;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
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,13 +25,11 @@ 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.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.assertAtLeast;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEqualsOrderIndependent;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
@ -149,13 +149,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());
}
}
@ -265,8 +265,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 +287,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 +309,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 +333,7 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
assertTrue(dashMpdUrl.isEmpty());
} else {
assertIsSecureUrl(dashMpdUrl);
assertThat(extractor().getDashMpdUrl(), containsString(expectedDashMpdUrlContains()));
ExtractorAsserts.assertContains(expectedDashMpdUrlContains(), extractor().getDashMpdUrl());
}
}

31
extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultTests.java

@ -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());

12
extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelExtractorTest.java

@ -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

20
extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampChannelLinkHandlerFactoryTest.java

@ -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"));
}
}

12
extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampCommentsExtractorTest.java

@ -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");

9
extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampCommentsLinkHandlerFactoryTest.java

@ -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());

12
extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampFeaturedExtractorTest.java

@ -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

8
extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampFeaturedLinkHandlerFactoryTest.java

@ -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();
}

19
extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistExtractorTest.java

@ -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");

10
extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampPlaylistLinkHandlerFactoryTest.java

@ -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());

10
extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampRadioExtractorTest.java

@ -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

18
extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampRadioStreamExtractorTest.java

@ -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; }

12
extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampSearchExtractorTest.java

@ -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);

8
extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampSearchQueryHandlerFactoryTest.java

@ -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());

10
extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampStreamExtractorTest.java

@ -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());

8
extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampStreamLinkHandlerFactoryTest.java

@ -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());

8
extractor/src/test/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampSuggestionExtractorTest.java

@ -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();

12
extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCConferenceExtractorTest.java

@ -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");

8
extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCConferenceLinkHandlerFactoryTest.java

@ -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());

12
extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCConferenceListExtractorTest.java

@ -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;
@ -10,7 +10,7 @@ import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCConfer
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.MediaCCC;
@ -21,7 +21,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);
@ -30,8 +30,8 @@ public class MediaCCCConferenceListExtractorTest {
@Test
public void getConferencesListTest() throws Exception {
assertTrue("returned list was to small",
extractor.getInitialPage().getItems().size() >= 174);
assertTrue(extractor.getInitialPage().getItems().size() >= 174,
"returned list was to small");
}
@Test

6
extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCLiveStreamListExtractorTest.java

@ -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);

8
extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCOggTest.java

@ -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());

10
extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCRecentListExtractorTest.java

@ -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);

19
extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCStreamExtractorTest.java

@ -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());
}

8
extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCStreamLinkHandlerFactoryTest.java

@ -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());

8
extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/search/MediaCCCSearchExtractorTest.java

@ -1,6 +1,6 @@
package org.schabi.newpipe.extractor.services.media_ccc.search;