< prev index next >

test/javax/xml/jaxp/unittest/validation/tck/Bug6974551Test.java

Print this page




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package validation.tck;
  25 
  26 import java.io.IOException;
  27 
  28 import javax.xml.XMLConstants;
  29 import javax.xml.parsers.SAXParser;
  30 import javax.xml.parsers.SAXParserFactory;
  31 import javax.xml.transform.stream.StreamSource;
  32 import javax.xml.validation.Schema;
  33 import javax.xml.validation.SchemaFactory;
  34 import javax.xml.validation.Validator;
  35 
  36 import org.testng.Assert;

  37 import org.testng.annotations.Test;
  38 import org.xml.sax.SAXException;
  39 import org.xml.sax.SAXParseException;
  40 import org.xml.sax.helpers.DefaultHandler;
  41 
  42 /*
  43  * @bug 6974551
  44  * @summary Test Validation for SAXParser can expose whitespace facet for xs:anySimpleType.
  45  */

  46 public class Bug6974551Test {
  47     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
  48     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
  49 
  50     static String _xml = Bug6974551Test.class.getResource("Bug6974551.xml").getPath();
  51     static String _xsd = Bug6974551Test.class.getResource("Bug6974551.xsd").getPath();
  52 
  53     @Test
  54     public void testSAX() {
  55         try {
  56             Schema schema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(new StreamSource(_xsd));
  57             SAXParserFactory spf = SAXParserFactory.newInstance();
  58             spf.setNamespaceAware(true);
  59             spf.setValidating(true);
  60             spf.setSchema(schema);
  61             SAXParser parser = spf.newSAXParser();
  62             MyErrorHandler errorHandler = new MyErrorHandler();
  63             parser.parse(_xml, errorHandler);
  64             if (!errorHandler.errorOccured) {
  65                 Assert.fail("should report error");




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package validation.tck;
  25 
  26 import java.io.IOException;
  27 
  28 import javax.xml.XMLConstants;
  29 import javax.xml.parsers.SAXParser;
  30 import javax.xml.parsers.SAXParserFactory;
  31 import javax.xml.transform.stream.StreamSource;
  32 import javax.xml.validation.Schema;
  33 import javax.xml.validation.SchemaFactory;
  34 import javax.xml.validation.Validator;
  35 
  36 import org.testng.Assert;
  37 import org.testng.annotations.Listeners;
  38 import org.testng.annotations.Test;
  39 import org.xml.sax.SAXException;
  40 import org.xml.sax.SAXParseException;
  41 import org.xml.sax.helpers.DefaultHandler;
  42 
  43 /*
  44  * @bug 6974551
  45  * @summary Test Validation for SAXParser can expose whitespace facet for xs:anySimpleType.
  46  */
  47 @Listeners({jaxp.library.FilePolicy.class})
  48 public class Bug6974551Test {
  49     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
  50     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
  51 
  52     static String _xml = Bug6974551Test.class.getResource("Bug6974551.xml").getPath();
  53     static String _xsd = Bug6974551Test.class.getResource("Bug6974551.xsd").getPath();
  54 
  55     @Test
  56     public void testSAX() {
  57         try {
  58             Schema schema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(new StreamSource(_xsd));
  59             SAXParserFactory spf = SAXParserFactory.newInstance();
  60             spf.setNamespaceAware(true);
  61             spf.setValidating(true);
  62             spf.setSchema(schema);
  63             SAXParser parser = spf.newSAXParser();
  64             MyErrorHandler errorHandler = new MyErrorHandler();
  65             parser.parse(_xml, errorHandler);
  66             if (!errorHandler.errorOccured) {
  67                 Assert.fail("should report error");


< prev index next >