-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added junit test refs Edirom/MEIGarage#13
- Loading branch information
1 parent
1a04e96
commit 2956c0c
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<validation-result xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://meigarage.edirom.de/ege-webservice/schemas/validation-result.xsd"> | ||
<status>ERROR</status> | ||
<messages> | ||
<message><![CDATA[Error in line (44), column (18) : element "funding" not allowed anywhere; expected the element end-tag or element "arranger", "author", "biblScope", "composer", "contents", "contributor", "editor", "funder", "identifier", "librettist", "lyricist", "respStmt", "seriesStmt", "sponsor" or "title"]]></message> | ||
<message><![CDATA[Error in line (50), column (35) : element "funding" not allowed anywhere; expected the element end-tag or element "arranger", "author", "biblScope", "composer", "contents", "contributor", "editor", "funder", "identifier", "librettist", "lyricist", "respStmt", "seriesStmt", "sponsor" or "title"]]></message> | ||
<message><![CDATA[Error in line (275), column (46) : element "layer" not allowed here; expected the element end-tag or element "add", "anchoredText", "annot", "app", "cb", "choice", "colLayout", "corr", "curve", "damage", "del", "div", "ending", "gap", "handShift", "line", "measure", "orig", "pb", "reg", "relation", "relationList", "restore", "sb", "scoreDef", "section", "sic", "staff", "staffDef", "subst", "supplied" or "unclear"]]></message> | ||
<message><![CDATA[Error in line (276), column (28) : element "staff" not allowed here; expected the element end-tag or element "accid", "add", "anchoredText", "annot", "app", "artic", "bTrem", "barLine", "beam", "beatRpt", "cb", "choice", "chord", "clef", "clefGrp", "colLayout", "corr", "curve", "custos", "damage", "del", "dot", "fTrem", "gap", "graceGrp", "halfmRpt", "handShift", "keySig", "ligature", "line", "mRest", "mRpt", "mRpt2", "mSpace", "mensur", "meterSig", "meterSigGrp", "midi", "multiRest", "multiRpt", "neume", "note", "orig", "pad", "pb", "proport", "reg", "rest", "restore", "sb", "sic", "space", "subst", "supplied", "syllable", "tuplet" or "unclear"]]></message> | ||
<message><![CDATA[Error in line (292), column (56) : element "dir" not allowed here; expected the element end-tag or element "accid", "add", "anchoredText", "annot", "app", "artic", "bTrem", "barLine", "beam", "beatRpt", "cb", "choice", "chord", "clef", "clefGrp", "colLayout", "corr", "curve", "custos", "damage", "del", "dot", "fTrem", "gap", "graceGrp", "halfmRpt", "handShift", "keySig", "ligature", "line", "mRest", "mRpt", "mRpt2", "mSpace", "mensur", "meterSig", "meterSigGrp", "midi", "multiRest", "multiRpt", "neume", "note", "orig", "pad", "pb", "proport", "reg", "rest", "restore", "sb", "sic", "space", "subst", "supplied", "syllable", "tuplet" or "unclear"]]></message> | ||
<message><![CDATA[Error in line (293), column (57) : element "dir" not allowed here; expected the element end-tag or element "accid", "add", "anchoredText", "annot", "app", "artic", "bTrem", "barLine", "beam", "beatRpt", "cb", "choice", "chord", "clef", "clefGrp", "colLayout", "corr", "curve", "custos", "damage", "del", "dot", "fTrem", "gap", "graceGrp", "halfmRpt", "handShift", "keySig", "ligature", "line", "mRest", "mRpt", "mRpt2", "mSpace", "mensur", "meterSig", "meterSigGrp", "midi", "multiRest", "multiRpt", "neume", "note", "orig", "pad", "pb", "proport", "reg", "rest", "restore", "sb", "sic", "space", "subst", "supplied", "syllable", "tuplet" or "unclear"]]></message> | ||
<message><![CDATA[Error in line (294), column (55) : element "dir" not allowed here; expected the element end-tag or element "accid", "add", "anchoredText", "annot", "app", "artic", "bTrem", "barLine", "beam", "beatRpt", "cb", "choice", "chord", "clef", "clefGrp", "colLayout", "corr", "curve", "custos", "damage", "del", "dot", "fTrem", "gap", "graceGrp", "halfmRpt", "handShift", "keySig", "ligature", "line", "mRest", "mRpt", "mRpt2", "mSpace", "mensur", "meterSig", "meterSigGrp", "midi", "multiRest", "multiRpt", "neume", "note", "orig", "pad", "pb", "proport", "reg", "rest", "restore", "sb", "sic", "space", "subst", "supplied", "syllable", "tuplet" or "unclear"]]></message> | ||
</messages> | ||
</validation-result> |
69 changes: 69 additions & 0 deletions
69
src/test/java/de/edirom/meigarage/mei/MEIValidatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package de.edirom.meigarage.mei; | ||
|
||
import de.edirom.meigarage.MEIValidator; | ||
import pl.psnc.dl.ege.configuration.EGEConfigurationManager; | ||
import pl.psnc.dl.ege.exception.ConverterException; | ||
import pl.psnc.dl.ege.exception.EGEException; | ||
import pl.psnc.dl.ege.types.ConversionActionArguments; | ||
import pl.psnc.dl.ege.types.DataType; | ||
import pl.psnc.dl.ege.types.ValidationResult; | ||
import pl.psnc.dl.ege.utils.IOResolver; | ||
|
||
import java.io.*; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class MEIValidatorTest { | ||
private MEIValidator validator; | ||
|
||
@org.junit.Before | ||
public void setUp() throws Exception { | ||
validator = new MEIValidator(); | ||
} | ||
|
||
@org.junit.After | ||
public void tearDown() throws Exception { | ||
validator = null; | ||
} | ||
|
||
@org.junit.Test | ||
public void validate() throws IOException, EGEException { | ||
InputStream is = new FileInputStream("src/test/resources/test-input.mei"); | ||
//OutputStream os = new FileOutputStream("src/test/resources/test-output.ly.zip"); | ||
DataType inputType = new DataType("mei401","text/xml"); | ||
//DataType outputType = new DataType("lilypond","text/x-lilypond"); | ||
//System.out.println("##################" + new String(Files.readAllBytes(Paths.get("src/test/resources/test-input.mei.zip"))) + is.toString()); | ||
String tempDir = "src/test/temp"; | ||
ValidationResult result = validator.validate(is, inputType); | ||
PrintWriter out = new PrintWriter(tempDir + File.separator + "test-output.xml"); | ||
String baseprefix = "https://meigarage.edirom.de/ege-webservice/"; | ||
out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); | ||
out.println("<validation-result xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"" + baseprefix | ||
+ "schemas/validation-result.xsd\">"); | ||
out.println("<status>" + result.getStatus() | ||
+ "</status>"); | ||
out.println("<messages>"); | ||
for (String msg : result.getMessages()) { | ||
out.println("<message><![CDATA[" + msg + "]]></message>"); | ||
} | ||
out.println("</messages>"); | ||
out.println("</validation-result>"); | ||
out.close(); | ||
assertNotNull(new File("src/test/temp/test-output.xml")); | ||
//System.out.println(new String(Files. readAllBytes(Paths.get("src/test/resources/test-output.txt/result.txt")), "UTF-8")); | ||
assertNotEquals("", new String(Files.readAllBytes(Paths.get("src/test/temp/test-output.xml")), "UTF-8")); | ||
assertEquals("The files differ!", | ||
new String(Files.readAllBytes(Paths.get("src/test/temp/test-output.xml"))).replaceAll("uri=\"[\\s\\S]*?\"|[\\s]*",""), | ||
new String(Files.readAllBytes(Paths.get("src/test/expected-output.xml"))).replaceAll("uri=\"[\\s\\S]*?\"|[\\s]*","")); | ||
|
||
is.close(); | ||
} | ||
|
||
@org.junit.Test | ||
public void getSupportedValidationTypes() { | ||
assertNotNull(validator.getSupportedValidationTypes()); | ||
System.out.println(validator.getSupportedValidationTypes()); | ||
} | ||
} |