< prev index next >

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

Print this page




  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.File;
  27 import java.io.IOException;
  28 
  29 import javax.xml.XMLConstants;
  30 import javax.xml.parsers.ParserConfigurationException;
  31 import javax.xml.parsers.SAXParser;
  32 import javax.xml.parsers.SAXParserFactory;
  33 import javax.xml.transform.stream.StreamSource;
  34 import javax.xml.validation.Schema;
  35 import javax.xml.validation.SchemaFactory;
  36 import javax.xml.validation.Validator;
  37 
  38 import org.testng.Assert;

  39 import org.testng.annotations.Test;
  40 import org.xml.sax.ErrorHandler;
  41 import org.xml.sax.SAXException;
  42 import org.xml.sax.SAXNotRecognizedException;
  43 import org.xml.sax.SAXNotSupportedException;
  44 import org.xml.sax.SAXParseException;
  45 import org.xml.sax.helpers.DefaultHandler;
  46 
  47 /*
  48  * @bug 6963468
  49  * @summary Test Validation allows element a is a union type and element b specifies a as its substitution group and b type is or is derived from one of the member types of the union.
  50  */

  51 public class Bug6963468Test {
  52     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
  53     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
  54 
  55     @Test
  56     public void test() {
  57         try {
  58             SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
  59             schemaFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
  60 
  61             Schema schema = schemaFactory.newSchema(new StreamSource(Bug6963468Test.class.getResourceAsStream("Bug6963468.xsd")));
  62 
  63             Validator validator = schema.newValidator();
  64             validator.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
  65             validator.setErrorHandler(new ErrorHandler() {
  66                 public void error(SAXParseException exception) throws SAXException {
  67                     exception.printStackTrace();
  68                 }
  69 
  70                 public void fatalError(SAXParseException exception) throws SAXException {




  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.File;
  27 import java.io.IOException;
  28 
  29 import javax.xml.XMLConstants;
  30 import javax.xml.parsers.ParserConfigurationException;
  31 import javax.xml.parsers.SAXParser;
  32 import javax.xml.parsers.SAXParserFactory;
  33 import javax.xml.transform.stream.StreamSource;
  34 import javax.xml.validation.Schema;
  35 import javax.xml.validation.SchemaFactory;
  36 import javax.xml.validation.Validator;
  37 
  38 import org.testng.Assert;
  39 import org.testng.annotations.Listeners;
  40 import org.testng.annotations.Test;
  41 import org.xml.sax.ErrorHandler;
  42 import org.xml.sax.SAXException;
  43 import org.xml.sax.SAXNotRecognizedException;
  44 import org.xml.sax.SAXNotSupportedException;
  45 import org.xml.sax.SAXParseException;
  46 import org.xml.sax.helpers.DefaultHandler;
  47 
  48 /*
  49  * @bug 6963468
  50  * @summary Test Validation allows element a is a union type and element b specifies a as its substitution group and b type is or is derived from one of the member types of the union.
  51  */
  52 @Listeners({jaxp.library.FilePolicy.class})
  53 public class Bug6963468Test {
  54     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
  55     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
  56 
  57     @Test
  58     public void test() {
  59         try {
  60             SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
  61             schemaFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
  62 
  63             Schema schema = schemaFactory.newSchema(new StreamSource(Bug6963468Test.class.getResourceAsStream("Bug6963468.xsd")));
  64 
  65             Validator validator = schema.newValidator();
  66             validator.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
  67             validator.setErrorHandler(new ErrorHandler() {
  68                 public void error(SAXParseException exception) throws SAXException {
  69                     exception.printStackTrace();
  70                 }
  71 
  72                 public void fatalError(SAXParseException exception) throws SAXException {


< prev index next >