< prev index next >

test/javax/xml/jaxp/unittest/validation/Bug6467424Test.java

Print this page


   1 /*
   2  * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  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  */


  26 import java.io.File;
  27 import java.io.IOException;
  28 import java.io.StringWriter;
  29 
  30 import javax.xml.XMLConstants;
  31 import javax.xml.parsers.DocumentBuilder;
  32 import javax.xml.parsers.DocumentBuilderFactory;
  33 import javax.xml.parsers.ParserConfigurationException;
  34 import javax.xml.transform.Transformer;
  35 import javax.xml.transform.TransformerConfigurationException;
  36 import javax.xml.transform.TransformerException;
  37 import javax.xml.transform.TransformerFactory;
  38 import javax.xml.transform.dom.DOMResult;
  39 import javax.xml.transform.dom.DOMSource;
  40 import javax.xml.transform.stream.StreamResult;
  41 import javax.xml.validation.Schema;
  42 import javax.xml.validation.SchemaFactory;
  43 import javax.xml.validation.Validator;
  44 
  45 import org.testng.Assert;

  46 import org.testng.annotations.Test;
  47 import org.w3c.dom.Document;
  48 import org.xml.sax.SAXException;
  49 
  50 /*
  51  * @bug 6467424
  52  * @summary Test Validator augments the default delement value if feature element-default is on.
  53  */

  54 public class Bug6467424Test {
  55     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
  56     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
  57 
  58     @Test
  59     public void test() {
  60         // System.setSecurityManager(new SecurityManager());
  61         try {
  62             SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
  63             File schemaLocation = new File(getClass().getResource("Bug6467424.xsd").getFile());
  64             Schema schema = factory.newSchema(schemaLocation);
  65             Validator validator = schema.newValidator();
  66 
  67             DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
  68             domFactory.setNamespaceAware(true); // never forget this
  69             DocumentBuilder builder = domFactory.newDocumentBuilder();
  70             Document doc = builder.parse(new File(getClass().getResource("Bug6467424.xml").getFile()));
  71 
  72             DOMSource source = new DOMSource(doc);
  73             DOMResult result = new DOMResult();


   1 /*
   2  * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  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  */


  26 import java.io.File;
  27 import java.io.IOException;
  28 import java.io.StringWriter;
  29 
  30 import javax.xml.XMLConstants;
  31 import javax.xml.parsers.DocumentBuilder;
  32 import javax.xml.parsers.DocumentBuilderFactory;
  33 import javax.xml.parsers.ParserConfigurationException;
  34 import javax.xml.transform.Transformer;
  35 import javax.xml.transform.TransformerConfigurationException;
  36 import javax.xml.transform.TransformerException;
  37 import javax.xml.transform.TransformerFactory;
  38 import javax.xml.transform.dom.DOMResult;
  39 import javax.xml.transform.dom.DOMSource;
  40 import javax.xml.transform.stream.StreamResult;
  41 import javax.xml.validation.Schema;
  42 import javax.xml.validation.SchemaFactory;
  43 import javax.xml.validation.Validator;
  44 
  45 import org.testng.Assert;
  46 import org.testng.annotations.Listeners;
  47 import org.testng.annotations.Test;
  48 import org.w3c.dom.Document;
  49 import org.xml.sax.SAXException;
  50 
  51 /*
  52  * @bug 6467424
  53  * @summary Test Validator augments the default delement value if feature element-default is on.
  54  */
  55 @Listeners({jaxp.library.FilePolicy.class})
  56 public class Bug6467424Test {
  57     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
  58     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
  59 
  60     @Test
  61     public void test() {
  62         // System.setSecurityManager(new SecurityManager());
  63         try {
  64             SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
  65             File schemaLocation = new File(getClass().getResource("Bug6467424.xsd").getFile());
  66             Schema schema = factory.newSchema(schemaLocation);
  67             Validator validator = schema.newValidator();
  68 
  69             DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
  70             domFactory.setNamespaceAware(true); // never forget this
  71             DocumentBuilder builder = domFactory.newDocumentBuilder();
  72             Document doc = builder.parse(new File(getClass().getResource("Bug6467424.xml").getFile()));
  73 
  74             DOMSource source = new DOMSource(doc);
  75             DOMResult result = new DOMResult();


< prev index next >