implementation group: "org.jetbrains.kotlinx", name: "kotlinx-html-jvm", version: "0.11.0"
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
- testImplementation group: "junit", name: "junit", version: "4.13.2"
+ testImplementation(platform("org.junit:junit-bom:5.11.3"))
+ testImplementation group: "org.junit.jupiter", name: "junit-jupiter-engine"
testImplementation group: "org.hamcrest", name: "hamcrest", version: "2.2"
testImplementation group: "org.mockito", name: "mockito-core", version: "5.11.0"
testImplementation group: "com.spotify", name: "hamcrest-jackson", version: "1.3.2"
}
tasks.named('test') {
+ useJUnitPlatform()
jvmArgs += "--add-opens=java.base/java.lang=ALL-UNNAMED"
jvmArgs += "--add-opens=java.base/java.util=ALL-UNNAMED"
}
package net.pterodactylus.rhynodge;
+import org.junit.jupiter.api.Test;
+
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.is;
import static org.mockito.Mockito.mock;
-import org.junit.Test;
-
/**
* Unit test for {@link Reaction}.
*
import net.pterodactylus.rhynodge.output.DefaultOutput;
import net.pterodactylus.rhynodge.output.Output;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit test for {@link EmailAction}.
import net.pterodactylus.rhynodge.states.FailedState;
import net.pterodactylus.rhynodge.states.TorrentState;
import net.pterodactylus.rhynodge.states.TorrentState.TorrentFile;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit test for {@link BlacklistFilter}.
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.Collections;
import java.util.List;
import com.google.common.base.Optional;
import org.jsoup.nodes.Document;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit test for {@link ComicSiteFilter}.
*/
public class ComicSiteFilterTest {
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void comicSiteFilterRequiresHtmlState() {
State state = new FailedState();
ComicSiteFilter comicSiteFilter = new TestComicSiteFilter(null, null, null);
- comicSiteFilter.filter(state);
+ assertThrows(IllegalArgumentException.class, () -> comicSiteFilter.filter(state));
}
@Test
assertThat(comic.strips(), contains(new Strip("http://foo/url1.gif", "Comment 1"), new Strip("http://foo/url2.gif", "Comment 2"), new Strip("http://foo/url3.gif", "")));
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void illegalUrlThrowsException() {
State state = new HtmlState("http://foo/^", null);
ComicSiteFilter comicSiteFilter = new TestComicSiteFilter("Title", asList("url1.gif"), Collections.<String>emptyList());
- comicSiteFilter.filter(state);
+ assertThrows(IllegalStateException.class, () -> comicSiteFilter.filter(state));
}
private static class TestComicSiteFilter extends ComicSiteFilter {
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import net.pterodactylus.rhynodge.State;
import net.pterodactylus.rhynodge.states.EpisodeState;
import net.pterodactylus.rhynodge.states.HtmlState;
import net.pterodactylus.rhynodge.states.TorrentState;
import net.pterodactylus.rhynodge.states.TorrentState.TorrentFile;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit test for {@link EpisodeFilter}.
assertThat(newState.success(), is(false));
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void episodeFilterRequiresATorrentState() {
State state = new HtmlState("http://foo/", null);
- episodeFilter.filter(state);
+ assertThrows(IllegalStateException.class, () -> episodeFilter.filter(state));
}
@Test
import com.spotify.hamcrest.jackson.JsonMatchers.jsonObject
import com.spotify.hamcrest.jackson.JsonMatchers.jsonText
import net.pterodactylus.rhynodge.Filter
-import net.pterodactylus.rhynodge.states.AbstractState
import net.pterodactylus.rhynodge.states.FailedState
import net.pterodactylus.rhynodge.states.HttpState
import net.pterodactylus.rhynodge.states.JsonState
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.contains
import org.hamcrest.Matchers.instanceOf
-import org.junit.Assert
-import org.junit.Assert.assertThrows
-import org.junit.Test
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.assertThrows
class JsonFilterTest {
@Test
fun `json filter throws exception if given state is not an http state`() {
- assertThrows(IllegalArgumentException::class.java) { filter.filter(StringState("foo")) }
+ assertThrows<IllegalArgumentException> { filter.filter(StringState("foo")) }
}
@Test
import com.google.common.base.Optional;
import org.jsoup.nodes.Document;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit test for {@link AbstruseGooseComicFilter}.
import net.pterodactylus.rhynodge.states.HtmlState;
import org.jsoup.nodes.Document;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit test for {@link CyanideAndHappinessComicFilter}.
import net.pterodactylus.rhynodge.states.HtmlState;
import org.jsoup.nodes.Document;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit test for {@link GirlGeniusComicFilterTest}.
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeDiagnosingMatcher;
import org.jsoup.nodes.Document;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit test for {@link ScandinaviaAndTheWorldComicFilterTest}.
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit test for {@link KickAssTorrentsFilter}.
import org.hamcrest.Matchers;
import org.jsoup.nodes.Document;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit test for {@link PirateBayFilter}.
import org.hamcrest.Matchers;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
import org.hamcrest.Matchers;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit test for {@link TorrentzEuFilter}.
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.io.Files;
import org.hamcrest.Matchers;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import static com.google.common.base.Charsets.UTF_8;
-import static com.google.common.base.Objects.equal;
import static org.apache.log4j.Level.OFF;
import static org.apache.log4j.Logger.getLogger;
import static org.hamcrest.MatcherAssert.assertThat;
*/
public class StateManagerTest {
- @Rule
- public TemporaryFolder tempFolder = new TemporaryFolder();
- private final File statePath;
- private final StateManager stateManager;
+ @TempDir private File tempFolder;
+ private StateManager stateManager;
- @BeforeClass
+ @BeforeAll
public static void deactivateLogging() {
getLogger(StateManager.class).setLevel(OFF);
}
- public StateManagerTest() throws IOException {
- tempFolder.create();
- statePath = tempFolder.newFolder();
- stateManager = new StateManager(StateDirectory.of(statePath.getPath()));
+ @BeforeEach
+ public void createStateManager() {
+ stateManager = new StateManager(StateDirectory.of(tempFolder.getPath()));
}
@Test
- public void successStateCanBeRestored() {
+ public void successStateCanBeRestored(@TempDir File tempDir) throws IOException {
TestState testState = new TestState();
stateManager.saveState("test", testState);
Optional<State> restoredState = stateManager.loadLastState("test");
@Test
public void invalidJsonFileCanNotBeLoaded() throws IOException {
- Files.write("not json", new File(statePath, "test.last.json"), UTF_8);
+ Files.write("not json", new File(tempFolder, "test.last.json"), UTF_8);
Optional<State> restoredState = stateManager.loadLastState("test");
assertThat(restoredState.isPresent(), is(false));
}
@Test
public void jsonWithInvalidFieldsCanNotBeLoaded() throws IOException {
- Files.write("{\"not\":\"json\"}", new File(statePath, "test.last.json"), UTF_8);
+ Files.write("{\"not\":\"json\"}", new File(tempFolder, "test.last.json"), UTF_8);
Optional<State> restoredState = stateManager.loadLastState("test");
assertThat(restoredState.isPresent(), is(false));
}
public void unmappableStateCanBeSavedButNotLoaded() throws IOException {
InvalidState invalidState = new InvalidState();
stateManager.saveState("test", invalidState);
- assertThat(new File(statePath, "test.last.json").exists(), is(false));
+ assertThat(new File(tempFolder, "test.last.json").exists(), is(false));
}
public static class TestState extends AbstractState {
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
/**
* Unit test for {@link Parser}.
*
MatcherAssert.assertThat(finalTestOptions.getOptionOne(), Matchers.is("test"));
}
- @Test(expected = RequiredOptionIsMissing.class)
+ @Test
public void parserThrowsIfRequiredOptionIsMissing() {
Mockito.when(environment.getValue("foo")).thenReturn(Optional.empty());
- RequiredTestOptions requiredTestOptions = parser.parseEnvironment(RequiredTestOptions::new);
- requiredTestOptions.getOptionOne();
+ assertThrows(RequiredOptionIsMissing.class, () -> parser.parseEnvironment(RequiredTestOptions::new));
}
@Test
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit test for {@link SystemEnvironment}.
import com.google.inject.Injector;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit test for {@link ObjectBinding}.
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.equalTo
import org.hamcrest.TypeSafeDiagnosingMatcher
-import org.junit.Test
+import org.junit.jupiter.api.Test
import java.util.Optional
import java.util.Optional.empty
import java.util.Optional.of
import net.pterodactylus.rhynodge.states.FailedState
import net.pterodactylus.rhynodge.states.TorrentState
import net.pterodactylus.rhynodge.states.TorrentState.TorrentFile
-import org.hamcrest.MatcherAssert
import org.hamcrest.MatcherAssert.assertThat
-import org.hamcrest.Matchers
+import org.hamcrest.Matchers.containsInAnyOrder
import org.hamcrest.Matchers.equalTo
-import org.junit.Test
+import org.junit.jupiter.api.Test
/**
* Unit test for [SizeBlacklistFilter].
matchingTorrentFile1,
matchingTorrentFile2
))) as TorrentState
- assertThat(filteredState.torrentFiles(), Matchers.containsInAnyOrder(
+ assertThat(filteredState.torrentFiles(), containsInAnyOrder(
notMatchingTorrentFile1,
notMatchingTorrentFile2
))
import net.pterodactylus.rhynodge.states.HtmlState
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.contains
-import org.junit.Test
+import org.junit.jupiter.api.Test
/**
* Unit test for [BusinessCatComicFilter].
import org.hamcrest.Matchers.empty
import org.hamcrest.Matchers.equalTo
import org.jsoup.nodes.Document
-import org.junit.Test
+import org.junit.jupiter.api.Test
/**
* Unit test for [ChiefOBrienAtWorkComicFilter].
import net.pterodactylus.rhynodge.states.HtmlState
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.equalTo
-import org.junit.Test
+import org.junit.jupiter.api.Test
abstract class ComicSiteFilterTest {
import net.pterodactylus.rhynodge.states.HtmlState
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.contains
-import org.junit.Test
+import org.junit.jupiter.api.Test
/**
* Unit test for [CtrlAltDelComicFilter].
import net.pterodactylus.rhynodge.states.HtmlState
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.contains
-import org.junit.Test
+import org.junit.jupiter.api.Test
class DrugsAndWiresComicFilterTest {
import net.pterodactylus.rhynodge.states.ComicState.Strip
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.contains
-import org.junit.Test
+import org.junit.jupiter.api.Test
/**
* Unit test for [HeldentageFilter].
import net.pterodactylus.rhynodge.states.HtmlState
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.contains
-import org.junit.Test
+import org.junit.jupiter.api.Test
/**
* Unit test for [LeastICouldDoComicFilterTest].
import net.pterodactylus.rhynodge.states.HtmlState
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.contains
-import org.junit.Test
+import org.junit.jupiter.api.Test
class PoorlyDrawnLinesComicFilterTest {
import net.pterodactylus.rhynodge.states.HtmlState
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.contains
-import org.junit.Test
+import org.junit.jupiter.api.Test
class QuestionableContentFilterTest {
import net.pterodactylus.rhynodge.states.HtmlState
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.*
-import org.junit.Test
+import org.junit.jupiter.api.Test
/**
* Unit test for [SaturdayMorningBreakfastCerealComicFilter].
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.contains
import org.hamcrest.Matchers.instanceOf
-import org.junit.Test
+import org.junit.jupiter.api.Test
/**
* Unit test for [SinfestComicFilter].
import net.pterodactylus.rhynodge.states.HtmlState
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.contains
-import org.junit.Test
+import org.junit.jupiter.api.Test
class SoggyCardboardComicFilterTest {
package net.pterodactylus.rhynodge.filters.comics
-import net.pterodactylus.rhynodge.filters.ResourceLoader.*
-import net.pterodactylus.rhynodge.states.*
-import net.pterodactylus.rhynodge.states.ComicState.*
-import org.hamcrest.MatcherAssert.*
-import org.hamcrest.Matchers.*
-import org.junit.*
+import net.pterodactylus.rhynodge.filters.ResourceLoader.loadDocument
+import net.pterodactylus.rhynodge.states.ComicState
+import net.pterodactylus.rhynodge.states.ComicState.Comic
+import net.pterodactylus.rhynodge.states.ComicState.Strip
+import net.pterodactylus.rhynodge.states.HtmlState
+import org.hamcrest.MatcherAssert.assertThat
+import org.hamcrest.Matchers.contains
+import org.junit.jupiter.api.Test
class TheMonsterUnderTheBedFilterTest {
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.contains
import org.hamcrest.Matchers.instanceOf
-import org.junit.Assert.assertThrows
-import org.junit.Test
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.assertThrows
import java.time.Instant.parse
class EpicGamesFilterTest {
@Test
fun `filter throws exception when given html state`() {
- assertThrows(IllegalArgumentException::class.java) { filter.filter(HttpState("", 200, "", byteArrayOf())) }
+ assertThrows<IllegalArgumentException> { filter.filter(HttpState("", 200, "", byteArrayOf())) }
}
@Test
import org.hamcrest.Matchers.empty
import org.hamcrest.Matchers.equalTo
import org.hamcrest.Matchers.instanceOf
-import org.junit.Assert.assertThrows
-import org.junit.Test
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.assertThrows
import java.time.Instant
class EpicGamesMergerTest {
@Test
fun `merger throws exception if previous state is not a free games state`() {
- assertThrows(IllegalArgumentException::class.java) { merger.mergeStates(TestState(), emptyState) }
+ assertThrows<IllegalArgumentException> { merger.mergeStates(TestState(), emptyState) }
}
@Test
fun `merger throws exception if current state is not a free games state`() {
- assertThrows(IllegalArgumentException::class.java) { merger.mergeStates(emptyState, TestState()) }
+ assertThrows<IllegalArgumentException> { merger.mergeStates(emptyState, TestState()) }
}
@Test
import org.hamcrest.Matchers.contains
import org.hamcrest.Matchers.equalTo
import org.jsoup.Jsoup
-import org.junit.Test
+import org.junit.jupiter.api.Test
import java.time.Instant
import java.time.ZoneOffset
import org.hamcrest.Matchers.hasItems
import org.hamcrest.TypeSafeDiagnosingMatcher
import org.jsoup.Jsoup
-import org.junit.Test
+import org.junit.jupiter.api.Test
import java.time.LocalDateTime
/**
import org.jsoup.Jsoup
import org.jsoup.nodes.Element
import org.jsoup.nodes.TextNode
-import org.junit.Test
+import org.junit.jupiter.api.Test
import java.time.LocalDateTime
class MovieStateTest {
import org.hamcrest.Matchers.containsInAnyOrder
import org.hamcrest.Matchers.empty
import org.hamcrest.Matchers.equalTo
-import org.junit.Assert.assertThrows
-import org.junit.Test
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.assertThrows
import java.time.LocalDateTime
class SavoyMergerTest {
@Test
fun `merger throws exception if first state is not a movie state`() {
- assertThrows(IllegalArgumentException::class.java) { merger.mergeStates(TestState(), MovieState(emptySet())) }
+ assertThrows<IllegalArgumentException> { merger.mergeStates(TestState(), MovieState(emptySet())) }
}
@Test
fun `merger throws exception if second state is not a movie state`() {
- assertThrows(IllegalArgumentException::class.java) { merger.mergeStates(MovieState(emptySet()), TestState()) }
+ assertThrows<IllegalArgumentException> { merger.mergeStates(MovieState(emptySet()), TestState()) }
}
@Test
import net.pterodactylus.rhynodge.states.ComicState.Comic
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.contains
-import org.junit.Test
+import org.junit.jupiter.api.Test
class ComicMergerTest {
import net.pterodactylus.rhynodge.states.StateManagerTest.TestState
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.equalTo
-import org.junit.Test
+import org.junit.jupiter.api.Test
class LastStateMergerTest {
import net.pterodactylus.rhynodge.State
import net.pterodactylus.rhynodge.states.AbstractState
import net.pterodactylus.rhynodge.states.FailedState
-import net.pterodactylus.rhynodge.states.StateManagerTest
import net.pterodactylus.rhynodge.states.StateManagerTest.TestState
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.`is`
import org.hamcrest.Matchers.sameInstance
-import org.junit.Rule
-import org.junit.Test
-import org.junit.rules.ExpectedException
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.assertThrows
import org.mockito.Mockito.`when`
import org.mockito.Mockito.mock
import org.mockito.Mockito.never
*/
class FallbackQueryTest {
- @JvmField @Rule val expectedException = ExpectedException.none()!!
-
private val firstQuery = mock(Query::class.java)
private val secondQuery = mock(Query::class.java)
private val thirdQuery = mock(Query::class.java)
@Test
fun `fallback query can not be created without queries`() {
- expectedException.expect(IllegalArgumentException::class.java)
- FallbackQuery()
+ assertThrows<IllegalArgumentException> { FallbackQuery() }
}
}
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.equalTo
-import org.junit.Test
+import org.junit.jupiter.api.Test
import java.time.Clock
import java.time.Instant.now
import java.time.ZoneOffset.UTC
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.spotify.hamcrest.jackson.JsonMatchers.jsonObject
import org.hamcrest.MatcherAssert.assertThat
-import org.junit.Test
+import org.junit.jupiter.api.Test
import java.io.StringWriter
class JsonStateTest {
import org.hamcrest.MatcherAssert
import org.hamcrest.Matchers
-import org.junit.Test
+import org.junit.jupiter.api.Test
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicReference