Skip to content

Commit

Permalink
add file compare to unit test refs Edirom/MEIGarage#13
Browse files Browse the repository at this point in the history
  • Loading branch information
anneferger committed Apr 10, 2024
1 parent c26e453 commit bf852f5
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
!test-input.*.zip
!required.sh
!meico.jar
!expected-output.mpm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class ConverterConfiguration {
CONVERSIONS.add(getConversionActionArgument(Conversion.MEI30TOMPM));
CONVERSIONS.add(getConversionActionArgument(Conversion.MEI30TOMIDI));
CONVERSIONS.add(getConversionActionArgument(Conversion.MIDIMEICOTOMP3));
CONVERSIONS.add(getConversionActionArgument(Conversion.MEI40TOMP3));
}

private static ConversionActionArguments getConversionActionArgument(Conversion format) {
Expand Down
11 changes: 10 additions & 1 deletion src/test/java/de/edirom/meigarage/meico/MeicoConverterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,23 @@ public void convert() throws IOException, ConverterException {
InputStream is = new FileInputStream("src/test/resources/test-input.mei.zip");
OutputStream os = new FileOutputStream("src/test/resources/test-output.mpm.zip");
DataType inputType = new DataType("mei40", "text/xml");
//DataType inputType = new DataType("midi", "audio/x-midi");
DataType outputType = new DataType("mpm", "text/xml");
//DataType outputType = new DataType("mp3", "audio/mp3");
ConversionActionArguments conversionActionArguments = new ConversionActionArguments(inputType, outputType, null);
String tempDir = "src/test/temp";
converter.convert(is, os, conversionActionArguments, tempDir);
//assertNotNull(new File("src/test/resources/test-output.mp3.zip"));
assertNotNull(new File("src/test/resources/test-output.mpm.zip"));
InputStream isout = new FileInputStream("src/test/resources/test-output.mpm.zip");
EGEConfigurationManager.getInstance().getStandardIOResolver().decompressStream(isout, new File("src/test/resources/test-output.mpm"));
assertNotEquals("", new String(Files.readAllBytes(Paths.get("src/test/resources/test-output.mpm/test2-input.mpm")), "UTF-8"));
//assertNotEquals("", new String(Files.readAllBytes(Paths.get("src/test/resources/test-output.mpm/test2-input.mpm")), "UTF-8"));
//assertArrayEquals("Binary files differ",
// Files.readAllBytes(Paths.get("src/test/resources/expected-output.mp3")),
// Files.readAllBytes(Paths.get("src/test/resources/test-output.mp3/test2-input_MEI export performance.mp3")));
assertEquals("The files differ!",
new String(Files.readAllBytes(Paths.get("src/test/resources/test-output.mpm/test2-input.mpm"))).replaceAll("uri=\"[\\s\\S]*?\"",""),
new String(Files.readAllBytes(Paths.get("src/test/resources/expected-output.mpm"))).replaceAll("uri=\"[\\s\\S]*?\"",""));
is.close();
os.close();
isout.close();
Expand Down
26 changes: 26 additions & 0 deletions src/test/resources/expected-output.mpm
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<mpm xmlns="http://www.cemfi.de/mpm/ns/1.0">
<metadata>
<author>meico</author>
<comment>This MPM has been generated from 'test2-input.mei' using the meico MEI converter.</comment>
<relatedResources>
<resource uri="/media/data/Arbeit_NFDI4Culture/OxGarages/meico-converter/src/test/temp/88a67b4f-833c-45ca-b993-eb6d922b8475/test2-input.mei" type="mei"/>
<resource uri="/media/data/Arbeit_NFDI4Culture/OxGarages/meico-converter/src/test/temp/88a67b4f-833c-45ca-b993-eb6d922b8475/test2-input.msm" type="msm"/>
</relatedResources>
</metadata>
<performance name="MEI export performance" pulsesPerQuarter="720">
<global>
<header/>
<dated/>
</global>
<part name="" number="1" midi.channel="0" midi.port="0">
<header/>
<dated>
<tempoMap>
<style date="0.0" name.ref="MEI export"/>
<tempo date="0.0" bpm="92" beatLength="0.125"/>
</tempoMap>
</dated>
</part>
</performance>
</mpm>

0 comments on commit bf852f5

Please sign in to comment.