< prev index next >

test/javax/xml/jaxp/unittest/validation/CR6740048.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  */
  23 
  24 package validation;
  25 
  26 import java.io.IOException;
  27 import java.io.InputStream;
  28 
  29 import javax.xml.parsers.DocumentBuilder;
  30 import javax.xml.parsers.DocumentBuilderFactory;
  31 import javax.xml.parsers.ParserConfigurationException;
  32 

  33 import org.testng.annotations.Test;
  34 import org.testng.Assert;
  35 import org.w3c.dom.Document;
  36 import org.xml.sax.ErrorHandler;
  37 import org.xml.sax.SAXException;
  38 import org.xml.sax.SAXParseException;
  39 
  40 /*
  41  * @bug 6740048
  42  * @summary Test DocumentBuilder can be reused when the DocumentBuilderFactory sets schema.
  43  */

  44 public class CR6740048 {
  45     private static final String TAG_INFO = "containerInfo";
  46     private static final String SCHEMA_LANGUAGE_URL = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
  47     private static final String SCHEMA_SOURCE_URL = "http://java.sun.com/xml/jaxp/properties/schemaSource";
  48     private static final String XML_SCHEMA_URL = "http://www.w3.org/2001/XMLSchema";
  49 
  50     @Test
  51     public final void testReusingDocumentBuilder() {
  52 
  53         try {
  54             //ClassLoader loader = CR6740048.class.getClassLoader();
  55 
  56             // Object xsd = loader.getResourceAsStream("CR6740048.xsd");
  57             InputStream xsd = this.getClass().getResourceAsStream("CR6740048.xsd");
  58             // create document builder
  59             DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
  60             docBuilderFactory.setNamespaceAware(true);
  61 
  62             if (xsd != null) {
  63                 docBuilderFactory.setValidating(true);


   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  */
  23 
  24 package validation;
  25 
  26 import java.io.IOException;
  27 import java.io.InputStream;
  28 
  29 import javax.xml.parsers.DocumentBuilder;
  30 import javax.xml.parsers.DocumentBuilderFactory;
  31 import javax.xml.parsers.ParserConfigurationException;
  32 
  33 import org.testng.annotations.Listeners;
  34 import org.testng.annotations.Test;
  35 import org.testng.Assert;
  36 import org.w3c.dom.Document;
  37 import org.xml.sax.ErrorHandler;
  38 import org.xml.sax.SAXException;
  39 import org.xml.sax.SAXParseException;
  40 
  41 /*
  42  * @bug 6740048
  43  * @summary Test DocumentBuilder can be reused when the DocumentBuilderFactory sets schema.
  44  */
  45 @Listeners({jaxp.library.FilePolicy.class})
  46 public class CR6740048 {
  47     private static final String TAG_INFO = "containerInfo";
  48     private static final String SCHEMA_LANGUAGE_URL = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
  49     private static final String SCHEMA_SOURCE_URL = "http://java.sun.com/xml/jaxp/properties/schemaSource";
  50     private static final String XML_SCHEMA_URL = "http://www.w3.org/2001/XMLSchema";
  51 
  52     @Test
  53     public final void testReusingDocumentBuilder() {
  54 
  55         try {
  56             //ClassLoader loader = CR6740048.class.getClassLoader();
  57 
  58             // Object xsd = loader.getResourceAsStream("CR6740048.xsd");
  59             InputStream xsd = this.getClass().getResourceAsStream("CR6740048.xsd");
  60             // create document builder
  61             DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
  62             docBuilderFactory.setNamespaceAware(true);
  63 
  64             if (xsd != null) {
  65                 docBuilderFactory.setValidating(true);


< prev index next >