01: package org.geotools.xml;
02:
03: import java.util.List;
04:
05: import org.geotools.ml.MLConfiguration;
06: import org.geotools.ml.Mail;
07: import org.geotools.ml.bindings.MLSchemaLocationResolver;
08:
09: import junit.framework.TestCase;
10:
11: public class ParserTest extends TestCase {
12:
13: public void testParse() throws Exception {
14:
15: Parser parser = new Parser(new MLConfiguration());
16: List mails = (List) parser.parse(MLSchemaLocationResolver.class
17: .getResourceAsStream("mails.xml"));
18:
19: assertEquals(2, mails.size());
20:
21: Mail mail = (Mail) mails.get(0);
22: assertEquals(0, mail.getId().intValue());
23:
24: mail = (Mail) mails.get(1);
25: assertEquals(1, mail.getId().intValue());
26: }
27:
28: public void testParseValid() throws Exception {
29: Parser parser = new Parser(new MLConfiguration());
30: parser.setValidating(true);
31: parser.parse(MLSchemaLocationResolver.class
32: .getResourceAsStream("mails.xml"));
33:
34: assertEquals(0, parser.getValidationErrors().size());
35: }
36:
37: public void testParseInValid() throws Exception {
38: Parser parser = new Parser(new MLConfiguration());
39: parser.setValidating(true);
40: parser.parse(MLSchemaLocationResolver.class
41: .getResourceAsStream("mails-invalid.xml"));
42:
43: assertFalse(0 == parser.getValidationErrors().size());
44: }
45: }
|