source: metadata/trunk/toolkit/src/test/java/eu/clarin/cmd/toolkit/TestCMDToolkit.java @ 6929

Last change on this file since 6929 was 6929, checked in by Menzo Windhouwer, 8 years ago

M toolkit/src/test/java/eu/clarin/cmd/toolkit/TestCMDToolkit.java

  • assert if the upgraded record refers to the 1.2/1.1/1.2 schema
File size: 23.7 KB
Line 
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5package eu.clarin.cmd.toolkit;
6
7import java.io.File;
8import java.io.IOException;
9import java.net.URL;
10import java.nio.file.Paths;
11import java.util.HashMap;
12import java.util.List;
13import java.util.Map;
14import javax.xml.XMLConstants;
15import javax.xml.parsers.DocumentBuilder;
16import javax.xml.parsers.DocumentBuilderFactory;
17import javax.xml.transform.Source;
18import javax.xml.transform.dom.DOMSource;
19import javax.xml.transform.stream.StreamSource;
20import javax.xml.validation.Schema;
21import javax.xml.validation.SchemaFactory;
22import javax.xml.validation.Validator;
23import net.sf.saxon.s9api.DOMDestination;
24import net.sf.saxon.s9api.QName;
25import net.sf.saxon.s9api.XPathCompiler;
26import net.sf.saxon.s9api.XPathExecutable;
27import net.sf.saxon.s9api.XPathSelector;
28import net.sf.saxon.s9api.XdmAtomicValue;
29import net.sf.saxon.s9api.XdmDestination;
30import net.sf.saxon.s9api.XdmNode;
31import net.sf.saxon.s9api.XdmValue;
32import net.sf.saxon.s9api.XsltTransformer;
33import nl.mpi.tla.schemanon.Message;
34import nl.mpi.tla.schemanon.SaxonUtils;
35import nl.mpi.tla.schemanon.SchemAnon;
36import org.junit.*;
37
38import static org.junit.Assert.*;
39import org.w3c.dom.Document;
40
41/**
42 *
43 * @author menwin
44 */
45public class TestCMDToolkit {
46
47    XsltTransformer upgradeCMDSpec = null;
48    XsltTransformer downgradeCMDSpec = null;
49    XsltTransformer upgradeCMDRec = null;
50    XsltTransformer transformCMDSpecInXSD = null;
51    XsltTransformer transformCMDoldSpecInXSD = null;
52    SchemAnon validateCMDSpec = null;
53    SchemAnon validateCMDoldSpec = null;
54    SchemAnon validateCMDEnvelop = null;
55
56    @Before
57    public void setUp() {
58        try {
59            upgradeCMDSpec = SaxonUtils.buildTransformer(CMDToolkit.class.getResource("/toolkit/upgrade/cmd-component-1_1-to-1_2.xsl")).load();
60            downgradeCMDSpec = SaxonUtils.buildTransformer(CMDToolkit.class.getResource("/toolkit/downgrade/cmd-component-1_2-to-1_1.xsl")).load();
61            upgradeCMDRec = SaxonUtils.buildTransformer(CMDToolkit.class.getResource("/toolkit/upgrade/cmd-record-1_1-to-1_2.xsl")).load();
62            transformCMDSpecInXSD = SaxonUtils.buildTransformer(CMDToolkit.class.getResource("/toolkit/xslt/comp2schema.xsl")).load();
63            validateCMDSpec = new SchemAnon(CMDToolkit.class.getResource("/toolkit/xsd/cmd-component.xsd").toURI().toURL());
64            validateCMDEnvelop = new SchemAnon(CMDToolkit.class.getResource("/toolkit/xsd/cmd-envelop.xsd").toURI().toURL());
65            //validateCMDoldSpec = new SchemAnon(new URL("http://infra.clarin.eu/cmd/general-component-schema.xsd"));
66            validateCMDoldSpec = new SchemAnon(TestCMDToolkit.class.getResource("/temp/general-component-schema.xsd").toURI().toURL());
67            transformCMDoldSpecInXSD = SaxonUtils.buildTransformer(new URL("http://infra.clarin.eu/cmd/xslt/comp2schema-v2/comp2schema.xsl")).load();
68        } catch(Exception e) {
69            System.err.println("!ERR: couldn't setup the testing environment!");
70            System.err.println(""+e);
71            e.printStackTrace(System.err);
72        }
73    }
74
75    @After
76    public void tearDown() {
77    }
78
79    protected Document transform(XsltTransformer trans,Source src,Map<String,XdmValue> params) throws Exception {
80        try {
81            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
82            DocumentBuilder builder = factory.newDocumentBuilder();
83            Document doc = builder.newDocument();
84            DOMDestination dest = new DOMDestination(doc);
85            trans.setSource(src);
86            trans.setDestination(dest);
87            // always set cmd-toolkit to the current working directory, which is expected to be where pom.xml lives
88            trans.setParameter(new QName("cmd-toolkit"),new XdmAtomicValue(Paths.get("").toAbsolutePath().toString()+"/src/main/resources/toolkit"));
89            if (params!=null)
90                for(String param:params.keySet())
91                    trans.setParameter(new QName(param),params.get(param));
92            trans.transform();
93            return doc;
94        } catch (Exception e) {
95            System.out.println("!ERR: failed transform: "+e);
96            e.printStackTrace(System.out);
97            throw e;
98        }
99    }
100
101    protected Document transform(XsltTransformer trans,Source src) throws Exception {
102        return transform(trans,src,null);
103    }
104
105    protected boolean xpath(Document doc,String xpath) throws Exception {
106        XPathCompiler xpc   = SaxonUtils.getProcessor().newXPathCompiler();
107        xpc.declareNamespace("cmd","http://www.clarin.eu/cmd/1");
108        XPathExecutable xpe = xpc.compile(xpath);
109        XPathSelector xps   = xpe.load();
110        xps.setContextItem(SaxonUtils.getProcessor().newDocumentBuilder().wrap(doc));
111        return xps.effectiveBooleanValue();
112    }
113
114    protected void printMessages(SchemAnon anon) throws Exception {
115        for (Message msg : anon.getMessages()) {
116            System.out.println("" + (msg.isError() ? "ERROR" : "WARNING") + (msg.getLocation() != null ? " at " + msg.getLocation() : ""));
117            System.out.println("  " + msg.getText());
118        }
119    }
120
121    protected int countErrors(SchemAnon anon) throws Exception {
122        int cnt = 0;
123        for (Message msg : anon.getMessages())
124            cnt += (msg.isError()?1:0);
125        return cnt;
126    }
127
128    protected Document upgradeCMDSpec(String spec) throws Exception {
129        System.out.println("Upgrade CMD spec["+spec+"]");
130        return transform(upgradeCMDSpec,new javax.xml.transform.stream.StreamSource(new java.io.File(TestCMDToolkit.class.getResource(spec).toURI())));
131    }
132
133    protected Document upgradeCMDSpec(String spec,Source src) throws Exception {
134        System.out.println("Upgrade CMD spec["+spec+"]");
135        return transform(upgradeCMDSpec,src);
136    }
137
138    protected Document downgradeCMDSpec(String spec) throws Exception {
139        System.out.println("Downgrade CMD spec["+spec+"]");
140        return transform(downgradeCMDSpec,new javax.xml.transform.stream.StreamSource(new java.io.File(TestCMDToolkit.class.getResource(spec).toURI())));
141    }
142
143    protected Document downgradeCMDSpec(String spec,Source src) throws Exception {
144        System.out.println("Downgrade CMD spec["+spec+"]");
145        return transform(downgradeCMDSpec,src);
146    }
147
148    protected Document upgradeCMDRecord(String rec,XdmNode prof) throws Exception {
149        System.out.println("Upgrade CMD spec["+rec+"]");
150        Map<String,XdmValue> params = new HashMap<String,XdmValue>();
151        params.put("cmd-profile", prof);
152        return transform(upgradeCMDRec,new javax.xml.transform.stream.StreamSource(new java.io.File(TestCMDToolkit.class.getResource(rec).toURI())),params);
153    }
154
155    protected Document upgradeCMDRecord(String rec,Document prof) throws Exception {
156        return upgradeCMDRecord(rec,SaxonUtils.getProcessor().newDocumentBuilder().wrap(prof));
157    }
158
159    protected Document transformCMDSpecInXSD(String spec,Source src) throws Exception {
160        System.out.println("Transform CMD spec["+spec+"] into XSD");
161        return transform(transformCMDSpecInXSD,src);
162    }
163
164    protected Document transformCMDSpecInXSD(String spec) throws Exception {
165        return transformCMDSpecInXSD(spec,new javax.xml.transform.stream.StreamSource(new java.io.File(TestCMDToolkit.class.getResource(spec).toURI())));
166    }
167
168    protected boolean validateCMDSpec(String spec,Source src) throws Exception {
169        System.out.println("Validate CMD spec["+spec+"]");
170        boolean res = validateCMDSpec.validate(src);
171        System.out.println("CMD spec["+spec+"]: "+(res?"VALID":"INVALID"));
172        printMessages(validateCMDSpec);
173        return res;
174    }
175
176    protected boolean validateCMDSpec(String spec) throws Exception {
177        return validateCMDSpec(spec,new StreamSource(new java.io.File(TestCMDToolkit.class.getResource(spec).toURI())));
178    }
179
180    protected boolean validateCMDRecord(String spec,SchemAnon anon,String rec,Source src) throws Exception {
181        System.out.println("Validate CMD record["+rec+"] against spec["+spec+"]");
182        boolean res = anon.validate(src);
183        System.out.println("CMD record["+rec+"]: "+(res?"VALID":"INVALID"));
184        printMessages(anon);
185        return res;
186    }
187
188    protected boolean validateCMDEnvelop(String rec,Source src) throws Exception {
189        System.out.println("Validate envelop CMD rec["+rec+"]");
190        boolean res = validateCMDEnvelop.validate(src);
191        System.out.println("CMD rec["+rec+"] evelop: "+(res?"VALID":"INVALID"));
192        printMessages(validateCMDEnvelop);
193        return res;
194    }
195
196    protected boolean validateCMDEnvelop(String rec) throws Exception {
197        return validateCMDEnvelop(rec,new StreamSource(new java.io.File(TestCMDToolkit.class.getResource(rec).toURI())));
198    }
199   
200    protected boolean validateCMDoldSpec(String spec,Source src) throws Exception {
201        System.out.println("Validate CMD 1.1 spec["+spec+"]");
202        boolean res = validateCMDoldSpec.validate(src);
203        System.out.println("CMD old spec["+spec+"]: "+(res?"VALID":"INVALID"));
204        printMessages(validateCMDoldSpec);
205        return res;
206    }
207
208    protected Document transformCMDoldSpecInXSD(String spec,Source src) throws Exception {
209        System.out.println("Transform CMD 1.1 spec["+spec+"] into XSD");
210        return transform(transformCMDoldSpecInXSD,src);
211    }
212
213    protected Document transformCMDoldSpecInXSD(String spec) throws Exception {
214        return transformCMDoldSpecInXSD(spec,new javax.xml.transform.stream.StreamSource(new java.io.File(TestCMDToolkit.class.getResource(spec).toURI())));
215    }
216
217    protected boolean validateOldCMDRecord(String spec,SchemAnon anon,String rec,Source src) throws Exception {
218        System.out.println("Validate CMD 1.1 record["+rec+"] against spec["+spec+"]");
219        boolean res = anon.validate(src);
220        System.out.println("CMD 1.1 record["+rec+"]: "+(res?"VALID":"INVALID"));
221        printMessages(anon);
222        return res;
223    }
224
225    @Test
226    public void testAdelheid() throws Exception {
227        System.out.println("* BEGIN: Adelheid tests (valid)");
228       
229        String profile = "/toolkit/Adelheid/profiles/clarin.eu:cr1:p_1311927752306.xml";
230        String record  = "/toolkit/Adelheid/records/Adelheid.cmdi";
231
232        // upgrade the profile from 1.1 to 1.2
233        System.out.println("- upgrade profile from 1.1 to 1.2");
234        Document upgradedProfile = upgradeCMDSpec(profile);
235
236        // validate the 1.2 profile
237        boolean validProfile = validateCMDSpec(profile+" (upgraded)",new DOMSource(upgradedProfile));
238
239        // assertions
240        // the upgraded profile should be a valid CMDI 1.2 profile
241        assertTrue(validProfile);
242        // so there should be no errors
243        assertEquals(0, countErrors(validateCMDSpec));
244
245        // transform the 1.2 profile into a XSD
246        Document profileSchema = transformCMDSpecInXSD(profile+" (upgraded)",new DOMSource(upgradedProfile));
247        SchemAnon profileAnon = new SchemAnon(new DOMSource(profileSchema));
248
249        // upgrade the record from 1.1 to 1.2
250        System.out.println("- upgrade record from 1.1 to 1.2");
251        Document upgradedRecord = upgradeCMDRecord(record,upgradedProfile);
252
253        // validate the 1.2 record
254        boolean validRecord = validateCMDRecord(profile+" (upgraded)",profileAnon,record+" (upgraded)",new DOMSource(upgradedRecord));
255
256        // assertions
257        // the upgraded record should be a valid CMDI 1.2 record
258        assertTrue(validRecord);
259        // so there should be no errors
260        assertEquals(0, countErrors(profileAnon));
261       
262        // downgrade the 1.2 profile to 1.1
263        System.out.println("- downgrade profile from 1.2 to 1.1");
264        Document oldProfile = downgradeCMDSpec(profile+" (upgraded)",new DOMSource(upgradedProfile));
265       
266        // validate the 1.1 profile
267        boolean validOldProfile = validateCMDoldSpec(profile+" (downgraded)",new DOMSource(oldProfile));
268
269        // assertions
270        // the downgraded profile should be a valid CMDI 1.1 profile
271        assertTrue(validOldProfile);
272        // so there should be no errors
273        assertEquals(0, countErrors(validateCMDoldSpec));       
274
275        System.out.println("*  END : Adelheid tests");
276    }
277
278    @Test
279    public void testAdelheid2() throws Exception {
280        System.out.println("* BEGIN: Adelheid 2 tests (invalid)");
281
282        String profile = "/toolkit/Adelheid/profiles/clarin.eu:cr1:p_1311927752306_1_2.xml";
283        String record  = "/toolkit/Adelheid/records/Adelheid_1_2-invalid.cmdi";
284
285        // validate the 1.2 profile
286        boolean validProfile = validateCMDSpec(profile,new javax.xml.transform.stream.StreamSource(new java.io.File(TestCMDToolkit.class.getResource(profile).toURI())));
287
288        // assertions
289        // the upgraded profile should be a valid CMDI 1.2 profile
290        assertTrue(validProfile);
291        // so there should be no errors
292        assertEquals(0, countErrors(validateCMDSpec));
293
294        Document profileSchema = transformCMDSpecInXSD(profile,new javax.xml.transform.stream.StreamSource(new java.io.File(TestCMDToolkit.class.getResource(profile).toURI())));
295        SchemAnon profileAnon = new SchemAnon(new DOMSource(profileSchema));
296
297        // validate the 1.2 record
298        boolean validRecord = validateCMDRecord(profile,profileAnon,record,new javax.xml.transform.stream.StreamSource(new java.io.File(TestCMDToolkit.class.getResource(record).toURI())));
299
300        // assertions
301        // the record should be a invalid as it misses a the required CoreVersion attribute
302        assertFalse(validRecord);
303
304        // downgrade the 1.2 profile to 1.1
305        Document oldProfile = downgradeCMDSpec(profile);
306       
307        // validate the 1.1 profile
308        boolean validOldProfile = validateCMDoldSpec(profile+" (downgraded)",new DOMSource(oldProfile));
309
310        // assertions
311        // the downgraded profile should be a valid CMDI 1.1 profile
312        assertTrue(validOldProfile);
313        // so there should be no errors
314        assertEquals(0, countErrors(validateCMDoldSpec));   
315       
316        System.out.println("*  END : Adelheid 2 tests");
317    }
318
319    @Test
320    public void testSundhed() throws Exception {
321        System.out.println("* BEGIN: Sundhed tests (valid)");
322       
323        String profile = "/toolkit/TEI/profiles/clarin.eu:cr1:p_1380106710826.xml";
324        String record  = "/toolkit/TEI/records/sundhed_dsn.teiHeader.ref.xml";
325
326        // upgrade the profile from 1.1 to 1.2
327        Document upgradedProfile = upgradeCMDSpec(profile);
328
329        // validate the 1.2 profile
330        boolean validProfile = validateCMDSpec(profile+" (upgraded)",new DOMSource(upgradedProfile));
331
332        // assertions
333        // the upgraded profile should be a valid CMDI 1.2 profile and 'ref' named Attributes should validate
334        assertTrue(validProfile);
335        // so there should be no errors
336        assertEquals(0, countErrors(validateCMDSpec));
337
338        // transform the 1.2 profile into a XSD
339        Document profileSchema = transformCMDSpecInXSD(profile+" (upgraded)",new DOMSource(upgradedProfile));
340        SchemAnon profileAnon = new SchemAnon(new DOMSource(profileSchema));
341
342        // upgrade the record from 1.1 to 1.2
343        Document upgradedRecord = upgradeCMDRecord(record,upgradedProfile);
344
345        // validate the 1.2 record
346        boolean validRecord = validateCMDRecord(profile+" (upgraded)", profileAnon, record+" (upgraded)", new DOMSource(upgradedRecord));
347
348        // assertions
349        // the upgraded record should be a valid CMDI 1.2 record
350        assertTrue(validRecord);
351
352        // so there should be no errors
353        assertEquals(0, countErrors(profileAnon));
354       
355        // downgrade the 1.2 profile to 1.1
356        Document oldProfile = downgradeCMDSpec(profile+" (upgraded)",new DOMSource(upgradedProfile));
357       
358        // validate the 1.1 profile
359        boolean validOldProfile = validateCMDoldSpec(profile+" (downgraded)",new DOMSource(oldProfile));
360
361        // assertions
362        // the downgraded profile should be a valid CMDI 1.1 profile
363        assertTrue(validOldProfile);
364        // so there should be no errors
365        assertEquals(0, countErrors(validateCMDoldSpec));       
366
367        System.out.println("*  END : Sundhed tests");
368    }
369
370    @Test
371    public void testTEI() throws Exception {
372        System.out.println("* BEGIN: TEI tests (valid)");
373
374        String profile = "/toolkit/TEI/profiles/clarin.eu:cr1:p_1380106710826.xml";
375        String record  = "/toolkit/TEI/records/sundhed_dsn.teiHeader.ref.xml";
376
377        // upgrade the profile from 1.1 to 1.2
378        Document upgradedProfile = upgradeCMDSpec(profile);
379
380        // upgrade the record from 1.1 to 1.2
381        Document upgradedRecord = upgradeCMDRecord(record,upgradedProfile);
382
383        // assertions
384        // the @ref attributes on the elements should stay as they are
385        assertTrue(xpath(upgradedRecord,"//*:author/*:name/@ref"));
386
387        System.out.println("*  END : TEI tests");
388    }
389
390    @Test
391    public void testSuccessor() throws Exception {
392        System.out.println("* BEGIN: successor tests (valid+invalid)");
393       
394        String validRecord  = "/toolkit/successor/profiles/successor-valid.xml";
395        String invalidRecord  = "/toolkit/successor/profiles/successor-invalid.xml";
396
397        // assertions
398        assertTrue(validateCMDSpec(validRecord));
399        assertFalse(validateCMDSpec(invalidRecord));
400       
401        System.out.println("*  END : successor tests");
402    }
403
404    @Test
405    public void testOLAC() throws Exception {
406        System.out.println("* BEGIN: OLAC tests (invalid)");
407       
408        String profile = "/toolkit/OLAC/profiles/OLAC-DcmiTerms.xml";
409        String record  = "/toolkit/OLAC/records/org_rosettaproject-record.xml";
410
411        // upgrade the profile from 1.1 to 1.2
412        Document upgradedProfile = upgradeCMDSpec(profile);
413
414        // validate the 1.2 profile
415        boolean validProfile = validateCMDSpec(profile+" (upgraded)",new DOMSource(upgradedProfile));
416
417        // assertions
418        // the upgraded profile should be a valid CMDI 1.2 profile
419        assertTrue(validProfile);
420        // so there should be no errors
421        assertEquals(0, countErrors(validateCMDSpec));
422       
423        // transform the 1.2 profile into a XSD
424        Document profileSchema = transformCMDSpecInXSD(profile+" (upgraded)",new DOMSource(upgradedProfile));
425        SchemAnon profileAnon = new SchemAnon(new DOMSource(profileSchema));
426
427        // upgrade the record from 1.1 to 1.2
428        Document upgradedRecord = upgradeCMDRecord(record,upgradedProfile);
429
430        // validate the 1.2 record
431        boolean validRecord = validateCMDRecord(profile+" (upgraded)",profileAnon,record+" (upgraded)",new DOMSource(upgradedRecord));
432
433        // assertions
434        assertFalse(validRecord);
435
436        // downgrade the 1.2 profile to 1.1
437        Document oldProfile = downgradeCMDSpec(profile+" (upgraded)",new DOMSource(upgradedProfile));
438       
439        // validate the 1.1 profile
440        boolean validOldProfile = validateCMDoldSpec(profile+" (downgraded)",new DOMSource(oldProfile));
441
442        // assertions
443        // the downgraded profile should be a valid CMDI 1.1 profile
444        assertTrue(validOldProfile);
445        // so there should be no errors
446        assertEquals(0, countErrors(validateCMDoldSpec));
447       
448        System.out.println("*  END : OLAC tests");
449    }
450
451    @Test
452    public void testCMD() throws Exception {
453        System.out.println("* BEGIN: CMD tests (invalid)");
454       
455        String profile = "/toolkit/CMD/profiles/components-invalid.xml";
456
457        // validate the 1.2 profile
458        boolean validProfile = validateCMDSpec(profile,new javax.xml.transform.stream.StreamSource(new java.io.File(TestCMDToolkit.class.getResource(profile).toURI())));
459
460        // assertions
461        assertFalse(validProfile);
462
463        System.out.println("*  END : CMD tests");
464    }
465   
466    @Test
467    public void testDownUpgrade() throws Exception {
468        System.out.println("* BEGIN: downgrade/upgrade tests");
469       
470        String profile = "/toolkit/downgrade/profiles/test.xml";
471        String record  = "/toolkit/downgrade/records/test.xml";
472       
473        // validate the 1.2 profile
474        boolean validProfile = validateCMDSpec(profile);
475       
476        // assertions
477        // the profile should be a valid CMDI 1.2 profile
478        assertTrue(validProfile);
479        // so there should be no errors
480        assertEquals(0, countErrors(validateCMDSpec));
481       
482        // downgrade the 1.2 profile to 1.1
483        Document oldProfile = downgradeCMDSpec(profile);
484       
485        // validate the 1.1 profile
486        boolean validOldProfile = validateCMDoldSpec(profile+" (downgraded)",new DOMSource(oldProfile));
487       
488        // assertions
489        // the downgraded profile should be a valid CMDI 1.1 profile
490        assertTrue(validOldProfile);
491        // so there should be no errors
492        assertEquals(0, countErrors(validateCMDoldSpec));
493       
494        // transform the 1.1 profile into a XSD
495        Document profileSchema = transformCMDoldSpecInXSD(profile+" (downgraded)",new DOMSource(oldProfile));
496        SchemAnon profileAnon = new SchemAnon(new DOMSource(profileSchema));
497       
498        // validate the 1.1 record
499        boolean validRecord = validateOldCMDRecord(profile+" (downgraded)",profileAnon,record,new javax.xml.transform.stream.StreamSource(new java.io.File(TestCMDToolkit.class.getResource(record).toURI())));
500
501        // assertions
502        // the record should be valid against the downgraded profile
503        assertTrue(validRecord);
504       
505        // upgrade the 1.1 record to 1.2
506        Document upgradedRecord = upgradeCMDRecord(record,SaxonUtils.buildDocument(new javax.xml.transform.stream.StreamSource(new java.io.File(TestCMDToolkit.class.getResource(profile).toURI()))));
507       
508        // transform the 1.2 profile into a XSD
509        profileSchema = transformCMDSpecInXSD(profile);
510        profileAnon = new SchemAnon(new DOMSource(profileSchema));
511
512        // validate the 1.2 record
513        validRecord = validateCMDRecord(profile,profileAnon,record+" (upgraded)",new DOMSource(upgradedRecord));
514
515        // assertions
516        // the upgraded 1.1 record should be invalid against the original 1.2 profile
517        assertFalse(validRecord);
518         // the upgraded 1.1 record should refer to 1.2/1.1/1.2 profile XSD
519        assertTrue(xpath(upgradedRecord,"ends-with(/*:CMD/@*:schemaLocation,'-1-1-1_2.xsd')"));
520       
521        // upgrade the 1.1 profile to 1.2
522        Document oldNewProfile = upgradeCMDSpec(profile+" (downgraded)",new DOMSource(oldProfile));
523       
524        // validate the 1.2 profile
525        validProfile = validateCMDSpec(profile+" (downgraded/upgraded)",new DOMSource(oldNewProfile));
526
527        // assertions
528        assertTrue(validProfile);
529       
530        // transform the 1.2 profile into a XSD
531        profileSchema = transformCMDSpecInXSD(profile+" (downgraded/upgraded)",new DOMSource(oldNewProfile));
532        profileAnon = new SchemAnon(new DOMSource(profileSchema));
533
534        // validate the 1.2 record
535        validRecord = validateCMDRecord(profile,profileAnon,record+" (upgraded)",new DOMSource(upgradedRecord));
536
537        // assertions
538        // the upgraded 1.1 record should be valid against the downgraded/upgraded 1.2/1.1/1.2 profile
539        assertTrue(validRecord);
540
541        System.out.println("*  END : downgrade/upgrade tests");
542    }
543
544
545}
Note: See TracBrowser for help on using the repository browser.