Skip to content
Closed

junit5 #1152

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ dependencies {
implementation 'com.jidesoft:jide-oss:3.6.18'
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation 'com.fasterxml.jackson.core:jackson-core:2.15.0'


testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:4.11.0'
testImplementation 'com.squareup.okhttp3:mockwebserver:4.10.0'
testImplementation "org.hamcrest:hamcrest-all:1.3"
testImplementation "org.hamcrest:hamcrest-junit:2.0.0.0"
testImplementation 'org.assertj:assertj-core:3.23.1'

testImplementation "org.hamcrest:hamcrest:2.2"
testImplementation "org.junit.jupiter:junit-jupiter:5.14.4"
testImplementation "org.junit.platform:junit-platform-launcher:1.14.4"
}


Expand Down Expand Up @@ -97,6 +96,7 @@ configurations {
}

test {
useJUnitPlatform()
}

task developTest(type: Test) {
Expand Down Expand Up @@ -132,6 +132,7 @@ task performanceTest(type: Test) {

tasks.withType(Test) {
reports.html.destination = file("${reporting.baseDir}/${name}")
useJUnitPlatform()
}

ext {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package de.mediathekview.mlib.daten;

import de.mediathekview.mlib.Const;
import de.mediathekview.mlib.daten.DatenFilm;
import de.mediathekview.mlib.daten.ListeFilme;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class ListeFilmeTest {

Expand Down
19 changes: 9 additions & 10 deletions src/test/developTest/java/mServer/crawler/AddToFilmlistTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import static jakarta.ws.rs.core.HttpHeaders.CONTENT_LENGTH;
import static jakarta.ws.rs.core.HttpHeaders.CONTENT_TYPE;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;

import de.mediathekview.mlib.Const;
import de.mediathekview.mlib.daten.DatenFilm;
Expand All @@ -16,11 +16,10 @@
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import org.assertj.core.api.Assertions;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

//FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class AddToFilmlistTest {
Expand All @@ -46,7 +45,7 @@ public class AddToFilmlistTest {
private ListeFilme list;
private ListeFilme listToAdd;

@BeforeClass
@BeforeAll
public static void setUpClass() throws IOException {
mockServer = new MockWebServer();
Dispatcher dispatcher = new Dispatcher() {
Expand Down Expand Up @@ -102,12 +101,12 @@ public MockResponse dispatch(RecordedRequest request) throws InterruptedExceptio
baseUrl = mockServer.url("").toString();
}

@AfterClass
@AfterAll
public static void teardownClass() throws IOException {
mockServer.shutdown();
mockServer.close();
}

@Before
@BeforeEach
public void setUp() {
MserverDaten.system[MserverKonstanten.SYSTEM_BANNEDFILMLIST_NR] = "file:dist/bannedFilmList.txt";
listToAdd = new ListeFilme();
Expand Down
3 changes: 2 additions & 1 deletion src/test/developTest/java/mServer/test/JsonFileReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
import java.io.IOException;

import static org.junit.jupiter.api.Assertions.fail;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import static org.junit.Assert.fail;

/**
* Reads a json file
Expand Down
3 changes: 2 additions & 1 deletion src/test/developTest/java/mServer/test/TestFileReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import static org.junit.Assert.fail;

import static org.junit.jupiter.api.Assertions.fail;

public class TestFileReader {
private TestFileReader() {}
Expand Down
11 changes: 6 additions & 5 deletions src/test/developTest/java/mServer/tool/HashFileWriterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
import java.time.OffsetDateTime;

import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;

public class HashFileWriterTest {
private static final String FILE_NAME_FILMLISTE_HASH = "filmliste.id";
Expand All @@ -21,12 +22,12 @@ public class HashFileWriterTest {
public void testWriteHash() throws IOException {
String id = OffsetDateTime.now().toInstant().toString();
new HashFileWriter(basePath.toString()).writeHash(id);
Assert.assertThat("Das schreiben der Test Filmlisten ID hat nicht geklappt.",
assertThat("Das schreiben der Test Filmlisten ID hat nicht geklappt.",
Files.readAllLines(basePath.resolve(FILE_NAME_FILMLISTE_HASH), StandardCharsets.UTF_8).get(0),
Matchers.equalTo(id));
}

@After
@AfterEach
public void deleteIfExist() throws IOException {
Path filmlistIdPath = basePath.resolve(FILE_NAME_FILMLISTE_HASH);
if (Files.exists(filmlistIdPath)) {
Expand Down
28 changes: 14 additions & 14 deletions src/test/developTest/java/mServer/tool/M3U8UtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import java.util.Map;

import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Test;

import org.junit.jupiter.api.Test;
import mServer.crawler.sender.base.Qualities;

import static org.hamcrest.MatcherAssert.assertThat;

/**
* A test class for the util class {@link M3U8Utils}.
*/
Expand All @@ -33,9 +33,9 @@ public class M3U8UtilsTest
public void testGatherUrlsFromWDRM3U8_MoreThenThree_Positiv()
{
Map<Qualities, String> qualitiesAndUrls = M3U8Utils.gatherUrlsFromWdrM3U8(TEST_URL_POSITIV_MORE_THEN_THREE_ELEMENTS);
Assert.assertThat(qualitiesAndUrls.get(Qualities.SMALL), CoreMatchers.is(AWAITED_URL_SMALL));
Assert.assertThat(qualitiesAndUrls.get(Qualities.NORMAL), CoreMatchers.is(AWAITED_URL_NORMAL));
Assert.assertThat(qualitiesAndUrls.get(Qualities.HD), CoreMatchers.is(AWAITED_URL_HD));
assertThat(qualitiesAndUrls.get(Qualities.SMALL), CoreMatchers.is(AWAITED_URL_SMALL));
assertThat(qualitiesAndUrls.get(Qualities.NORMAL), CoreMatchers.is(AWAITED_URL_NORMAL));
assertThat(qualitiesAndUrls.get(Qualities.HD), CoreMatchers.is(AWAITED_URL_HD));
}

/**
Expand All @@ -45,9 +45,9 @@ public void testGatherUrlsFromWDRM3U8_MoreThenThree_Positiv()
public void testGatherUrlsFromWDRM3U8_ExactThree_Positiv()
{
Map<Qualities, String> qualitiesAndUrls = M3U8Utils.gatherUrlsFromWdrM3U8(TEST_URL_POSITIV_THREE_ELEMENTS);
Assert.assertThat(qualitiesAndUrls.get(Qualities.SMALL), CoreMatchers.is(AWAITED_URL_SMALL));
Assert.assertThat(qualitiesAndUrls.get(Qualities.NORMAL), CoreMatchers.is(AWAITED_URL_NORMAL));
Assert.assertThat(qualitiesAndUrls.get(Qualities.HD), CoreMatchers.is(AWAITED_URL_HD));
assertThat(qualitiesAndUrls.get(Qualities.SMALL), CoreMatchers.is(AWAITED_URL_SMALL));
assertThat(qualitiesAndUrls.get(Qualities.NORMAL), CoreMatchers.is(AWAITED_URL_NORMAL));
assertThat(qualitiesAndUrls.get(Qualities.HD), CoreMatchers.is(AWAITED_URL_HD));
}

/**
Expand All @@ -57,8 +57,8 @@ public void testGatherUrlsFromWDRM3U8_ExactThree_Positiv()
public void testGatherUrlsFromWDRM3U8_ExactTwo_Positiv()
{
Map<Qualities, String> qualitiesAndUrls = M3U8Utils.gatherUrlsFromWdrM3U8(TEST_URL_POSITIV_TWO_ELEMENTS);
Assert.assertThat(qualitiesAndUrls.get(Qualities.SMALL), CoreMatchers.is(AWAITED_URL_SMALL));
Assert.assertThat(qualitiesAndUrls.get(Qualities.NORMAL), CoreMatchers.is(AWAITED_URL_NORMAL));
assertThat(qualitiesAndUrls.get(Qualities.SMALL), CoreMatchers.is(AWAITED_URL_SMALL));
assertThat(qualitiesAndUrls.get(Qualities.NORMAL), CoreMatchers.is(AWAITED_URL_NORMAL));
}

/**
Expand All @@ -68,7 +68,7 @@ public void testGatherUrlsFromWDRM3U8_ExactTwo_Positiv()
public void testGatherUrlsFromWDRM3U8_ExactOne_Positiv()
{
Map<Qualities, String> qualitiesAndUrls = M3U8Utils.gatherUrlsFromWdrM3U8(TEST_URL_POSITIV_ONE_ELEMENT);
Assert.assertThat(qualitiesAndUrls.get(Qualities.SMALL), CoreMatchers.is(AWAITED_URL_SMALL));
assertThat(qualitiesAndUrls.get(Qualities.SMALL), CoreMatchers.is(AWAITED_URL_SMALL));
}

/**
Expand All @@ -78,7 +78,7 @@ public void testGatherUrlsFromWDRM3U8_ExactOne_Positiv()
public void testGatherUrlsFromWDRM3U8_NoneElement_Negativ()
{
Map<Qualities, String> qualitiesAndUrls = M3U8Utils.gatherUrlsFromWdrM3U8(TEST_URL_NEGATIV_NONE_ELEMENT);
Assert.assertThat(qualitiesAndUrls.isEmpty(), CoreMatchers.is(true));
assertThat(qualitiesAndUrls.isEmpty(), CoreMatchers.is(true));
}

/**
Expand All @@ -88,6 +88,6 @@ public void testGatherUrlsFromWDRM3U8_NoneElement_Negativ()
public void testGatherUrlsFromWDRM3U8_WrongUrl_Negativ()
{
Map<Qualities, String> qualitiesAndUrls = M3U8Utils.gatherUrlsFromWdrM3U8(TEST_URL_NEGATIV_WRONG_URL);
Assert.assertThat(qualitiesAndUrls.isEmpty(), CoreMatchers.is(true));
assertThat(qualitiesAndUrls.isEmpty(), CoreMatchers.is(true));
}
}
10 changes: 5 additions & 5 deletions src/test/performanceTest/java/PerformanceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import etm.core.monitor.EtmMonitor;
import etm.core.renderer.SimpleTextRenderer;
import mServer.Main;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.net.URISyntaxException;
import java.nio.file.Path;
Expand All @@ -20,7 +20,7 @@ public class PerformanceTest
private EtmMonitor performanceMonitor;
private Path testConfigPath;

@Before
@BeforeEach
public void setUp() throws URISyntaxException
{
BasicEtmConfigurator.configure();
Expand All @@ -30,7 +30,7 @@ public void setUp() throws URISyntaxException
testConfigPath = Paths.get(getClass().getResource(TEST_REOSURCES_FOLDERPATH).toURI());
}

@After
@AfterEach
public void tearDown()
{
performanceMonitor.stop();
Expand Down
Loading