Skip to content

Commit

Permalink
Add test for the Vocabulary attributes in the XSD.
Browse files Browse the repository at this point in the history
Add test for @ValueConceptLink allowed or not.
  • Loading branch information
menzowindhouwer committed Jun 16, 2017
1 parent cff5260 commit 28fae96
Show file tree
Hide file tree
Showing 4 changed files with 7,782 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/test/java/eu/clarin/cmd/toolkit/TestCMDToolkit.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ protected Document transform(XsltTransformer trans,Source src) throws Exception
protected boolean xPathCompiler(Document doc, String xpath, String profileId) throws Exception {
XPathCompiler xpc = SaxonUtils.getProcessor().newXPathCompiler();

xpc.declareNamespace("xs","http://www.w3.org/2001/XMLSchema");
xpc.declareNamespace("cmd","http://www.clarin.eu/cmd/1");
if(profileId != null) xpc.declareNamespace("cmdp", "http://www.clarin.eu/cmd/1/profiles/" + profileId);

Expand Down Expand Up @@ -628,4 +629,36 @@ public void testEmpty() throws Exception {

System.out.println("* END : CMD Empty tests");
}

@Test
public void testCLAVAS() throws Exception {
System.out.println("* BEGIN: CMD CLAVAS tests");

String profile = "/toolkit/CLAVAS/profiles/TestCLAVAS.xml";
String valid_record = "/toolkit/CLAVAS/records/valid.xml";
String invalid_record = "/toolkit/CLAVAS/records/invalid.xml";

// the profile should be a valid CMDI 1.2 profile
assertTrue(validateCMDSpec(profile, new javax.xml.transform.stream.StreamSource(new java.io.File(TestCMDToolkit.class.getResource(profile).toURI()))));

Document profileSchema = transformCMDSpecInXSD(profile + " (valid CLAVAS)", new javax.xml.transform.stream.StreamSource(new java.io.File(TestCMDToolkit.class.getResource(profile).toURI())));
SchemAnon profileAnon = new SchemAnon(new DOMSource(profileSchema));

// validate the 1.2 record for allowed @cmd:ValueConceptLink attributes
boolean validRecordTest = validateCMDRecord(profile + " (valid CLAVAS)", profileAnon, valid_record, new javax.xml.transform.stream.StreamSource(new java.io.File(TestCMDToolkit.class.getResource(valid_record).toURI())));

// validate the 1.2 record for allowed @cmd:ValueConceptLink attributes
boolean invalidRecordTest = validateCMDRecord(profile + " (invalid CLAVAS)", profileAnon, invalid_record, new javax.xml.transform.stream.StreamSource(new java.io.File(TestCMDToolkit.class.getResource(invalid_record).toURI())));

// assertions
assertTrue(validRecordTest);
assertFalse(invalidRecordTest);
assertTrue(xpath(profileSchema,"//xs:element[@name='iso-639-3-code']/@cmd:Vocabulary"));
assertTrue(xpath(profileSchema,"//xs:element[@name='iso-639-3-code']/@cmd:ValueProperty"));
assertTrue(xpath(profileSchema,"//xs:element[@name='name']/@cmd:Vocabulary"));
assertTrue(xpath(profileSchema,"//xs:element[@name='name']/@cmd:ValueProperty"));
assertTrue(xpath(profileSchema,"//xs:element[@name='name']/@cmd:ValueLanguage"));

System.out.println("* END : CMD CLAVAS tests");
}
}
Loading

0 comments on commit 28fae96

Please sign in to comment.