Skip to content

Commit

Permalink
Merge pull request kitodo#6077 from slub/replace_junit4_with_junit5_k…
Browse files Browse the repository at this point in the history
…itodo-queryurlimport

[Kitodo-QueryUrlImport] Replace Junit 4 with Junit5 and fix test dependency
  • Loading branch information
solth authored May 23, 2024
2 parents 839d01d + 1c8a0a2 commit f86190d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
8 changes: 6 additions & 2 deletions Kitodo-Query-URL-Import/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@
<artifactId>jdom2</artifactId>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
</dependency>
<dependency>
<groupId>com.xebialabs.restito</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import static com.xebialabs.restito.semantics.Condition.get;
import static com.xebialabs.restito.semantics.Condition.parameter;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import com.xebialabs.restito.server.StubServer;

Expand All @@ -34,10 +37,9 @@
import javax.xml.parsers.ParserConfigurationException;

import org.apache.commons.io.IOUtils;
import org.junit.AfterClass;
import org.junit.Assert;
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.Test;
import org.kitodo.api.externaldatamanagement.DataImport;
import org.kitodo.api.externaldatamanagement.SearchInterfaceType;
import org.kitodo.api.schemaconverter.DataRecord;
Expand All @@ -61,7 +63,7 @@ public class QueryURLImportTest {
private static final int PORT = 8888;
private static final String SRU = "SRU";

@BeforeClass
@BeforeAll
public static void setup() throws IOException {
server = new StubServer(PORT).run();
try (InputStream inputStream = Files.newInputStream(Paths.get(TEST_FILE_PATH))) {
Expand All @@ -75,16 +77,13 @@ public void shouldGetFullRecordById() throws IOException, SAXException, ParserCo
NoRecordFoundException {
QueryURLImport queryURLImport = new QueryURLImport();
DataRecord importRecord = queryURLImport.getFullRecordById(dataImport, RECORD_ID);
Assert.assertNotNull(importRecord);
Assert.assertThat("Original data of data record has wrong class!",
importRecord.getOriginalData(), instanceOf(String.class));
assertNotNull(importRecord);
assertThat("Original data of data record has wrong class!", importRecord.getOriginalData(), instanceOf(String.class));
Document xmlDocument = parseInputStreamToDocument((String) importRecord.getOriginalData());
NodeList recordIdentifierNodeList = xmlDocument.getElementsByTagName(RECORD_IDENTIFIER);
Assert.assertEquals("Wrong number of record identifiers found!", 1,
recordIdentifierNodeList.getLength());
assertEquals(1, recordIdentifierNodeList.getLength(), "Wrong number of record identifiers found!");
Element recordIdentifierElement = (Element) recordIdentifierNodeList.item(0);
Assert.assertEquals("Wrong record identifier found!", RECORD_IDENTIFIER_VALUE,
recordIdentifierElement.getTextContent());
assertEquals(RECORD_IDENTIFIER_VALUE, recordIdentifierElement.getTextContent(), "Wrong record identifier found!");
}

private static void setupServer(String serverResponse) {
Expand Down Expand Up @@ -127,7 +126,7 @@ private static DataImport createNewDataImport() {
return dataImport;
}

@AfterClass
@AfterAll
public static void shutdown() {
server.stop();
}
Expand Down

0 comments on commit f86190d

Please sign in to comment.