1 package com.freemindcafe.xml.xsd.sample3;
4 import java.io.InputStream;
5 import java.io.StringWriter;
6 import java.util.ArrayList;
8 import junit.framework.Assert;
19 public void read_xml_and_validate_against_the_schema_fails()
throws Exception{
20 InputStream stream = this.getClass().getResourceAsStream(
"/com/freemindcafe/xml/xsd/sample3/po1.xml");
22 XmlOptions options =
new XmlOptions();
23 ArrayList<Object> validationErrors=
new ArrayList<Object>();
24 options.setErrorListener(validationErrors);
25 if (!document.validate(options)) {
26 StringWriter sW=
new StringWriter();
27 for (Object o : validationErrors) {
30 System.out.println(sW.toString());
32 Assert.assertFalse(document.validate());
37 public void read_xml_and_validate_against_the_schema_succeeds()
throws Exception{
38 InputStream stream = this.getClass().getResourceAsStream(
"/com/freemindcafe/xml/xsd/sample3/po2.xml");
40 XmlOptions options =
new XmlOptions();
41 ArrayList<Object> validationErrors=
new ArrayList<Object>();
42 options.setErrorListener(validationErrors);
43 if (!document.validate(options)) {
44 StringWriter sW=
new StringWriter();
45 for (Object o : validationErrors) {
48 System.out.println(sW.toString());
50 Assert.assertTrue(document.validate());