Skip to content

Commit

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

[Kitodo-XmlSchemaConverter] Replace Junit 4 with Junit5 and fix test dependency
  • Loading branch information
solth authored May 23, 2024
2 parents f86190d + 804d858 commit aa0fc91
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
8 changes: 6 additions & 2 deletions Kitodo-XML-SchemaConverter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,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>net.sf.saxon</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
package org.kitodo.xmlschemaconverter;

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 java.io.ByteArrayInputStream;
import java.io.File;
Expand All @@ -32,8 +35,7 @@

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.kitodo.api.schemaconverter.DataRecord;
import org.kitodo.api.schemaconverter.FileFormat;
import org.kitodo.api.schemaconverter.MetadataFormat;
Expand Down Expand Up @@ -66,11 +68,10 @@ public void shouldConvertModsToInternalFormat() throws IOException, ParserConfig
internalFormatRecord = converter.convert(testRecord, MetadataFormat.KITODO, FileFormat.XML, xsltFiles);
}

Assert.assertNotNull("Conversion result is empty!", internalFormatRecord);
Assert.assertEquals("Conversion result has wrong MetadataFormat!",
MetadataFormat.KITODO, internalFormatRecord.getMetadataFormat());
Assert.assertEquals("Conversion result has wrong FileFormat!", FileFormat.XML, internalFormatRecord.getFileFormat());
Assert.assertThat("Wrong class of original data object!", internalFormatRecord.getOriginalData(), instanceOf(String.class));
assertNotNull(internalFormatRecord, "Conversion result is empty!");
assertEquals(MetadataFormat.KITODO, internalFormatRecord.getMetadataFormat(), "Conversion result has wrong MetadataFormat!");
assertEquals(FileFormat.XML, internalFormatRecord.getFileFormat(), "Conversion result has wrong FileFormat!");
assertThat("Wrong class of original data object!", internalFormatRecord.getOriginalData(), instanceOf(String.class));
Document resultDocument = parseInputStreamToDocument((String) internalFormatRecord.getOriginalData());
NodeList metadataNodes = resultDocument.getElementsByTagName("kitodo:metadata");

Expand All @@ -95,9 +96,9 @@ public void shouldConvertModsToInternalFormat() throws IOException, ParserConfig
}
}

Assert.assertEquals("Title after conversion is wrong!", "Test-Title", title);
Assert.assertEquals("Catalog ID after conversion is wrong!", "67890", catalogId);
Assert.assertEquals("PublicationYear after conversion is wrong!", "1999", year);
assertEquals("Test-Title", title, "Title after conversion is wrong!");
assertEquals("67890", catalogId, "Catalog ID after conversion is wrong!");
assertEquals("1999", year, "PublicationYear after conversion is wrong!");
}

@Test
Expand All @@ -115,11 +116,10 @@ public void shouldConvertMarcToInternalFormat() throws IOException, ParserConfig
internalFormatRecord = converter.convert(testRecord, MetadataFormat.KITODO, FileFormat.XML, xsltFiles);
}

Assert.assertNotNull("Conversion result is empty!", internalFormatRecord);
Assert.assertEquals("Conversion result has wrong MetadataFormat!",
MetadataFormat.KITODO, internalFormatRecord.getMetadataFormat());
Assert.assertEquals("Conversion result has wrong FileFormat!", FileFormat.XML, internalFormatRecord.getFileFormat());
Assert.assertThat("Wrong class of original data object!", internalFormatRecord.getOriginalData(), instanceOf(String.class));
assertNotNull(internalFormatRecord, "Conversion result is empty!");
assertEquals(MetadataFormat.KITODO, internalFormatRecord.getMetadataFormat(), "Conversion result has wrong MetadataFormat!");
assertEquals(FileFormat.XML, internalFormatRecord.getFileFormat(), "Conversion result has wrong FileFormat!");
assertThat("Wrong class of original data object!", internalFormatRecord.getOriginalData(), instanceOf(String.class));
Document resultDocument = parseInputStreamToDocument((String) internalFormatRecord.getOriginalData());
NodeList metadataNodes = resultDocument.getElementsByTagName("kitodo:metadata");

Expand Down Expand Up @@ -148,10 +148,10 @@ public void shouldConvertMarcToInternalFormat() throws IOException, ParserConfig
}
}

Assert.assertEquals("Title after conversion is wrong!", "Test-Title", title);
Assert.assertEquals("Catalog ID after conversion is wrong!", "67890", catalogId);
Assert.assertEquals("PlaceOfPublication after conversion is wrong!", "Test-Place", place);
Assert.assertEquals("shelfmarksource after conversion is wrong!", "Test-Shelflocator", shelfmarksource);
assertEquals("Test-Title", title, "Title after conversion is wrong!");
assertEquals("67890", catalogId, "Catalog ID after conversion is wrong!");
assertEquals("Test-Place", place, "PlaceOfPublication after conversion is wrong!");
assertEquals("Test-Shelflocator", shelfmarksource, "shelfmarksource after conversion is wrong!");
}

private Document parseInputStreamToDocument(String inputString) throws ParserConfigurationException,
Expand Down

0 comments on commit aa0fc91

Please sign in to comment.