< prev index next >

test/javax/xml/jaxp/unittest/common/Bug6941169Test.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  */


  27 import java.io.StringWriter;
  28 import java.security.AllPermission;
  29 import java.security.Permission;
  30 import java.security.Permissions;
  31 
  32 import javax.xml.XMLConstants;
  33 import javax.xml.parsers.DocumentBuilder;
  34 import javax.xml.parsers.DocumentBuilderFactory;
  35 import javax.xml.transform.Transformer;
  36 import javax.xml.transform.TransformerFactory;
  37 import javax.xml.transform.dom.DOMSource;
  38 import javax.xml.transform.sax.SAXSource;
  39 import javax.xml.transform.stream.StreamResult;
  40 import javax.xml.transform.stream.StreamSource;
  41 import javax.xml.validation.Schema;
  42 import javax.xml.validation.SchemaFactory;
  43 import javax.xml.validation.Validator;
  44 import javax.xml.xpath.XPath;
  45 import javax.xml.xpath.XPathFactory;
  46 


  47 import org.testng.Assert;

  48 import org.testng.annotations.Test;
  49 import org.w3c.dom.Document;
  50 import org.xml.sax.InputSource;
  51 
  52 /*
  53  * @bug 6941169
  54  * @summary Test use-service-mechanism feature.
  55  */

  56 public class Bug6941169Test {
  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     private static final String DOM_FACTORY_ID = "javax.xml.parsers.DocumentBuilderFactory";
  61     private static final String SAX_FACTORY_ID = "javax.xml.parsers.SAXParserFactory";
  62 
  63     // impl specific feature
  64     final String ORACLE_FEATURE_SERVICE_MECHANISM = "http://www.oracle.com/feature/use-service-mechanism";
  65 
  66     static String _xml = Bug6941169Test.class.getResource("Bug6941169.xml").getPath();
  67     static String _xsd = Bug6941169Test.class.getResource("Bug6941169.xsd").getPath();
  68 
  69     @Test
  70     public void testValidation_SAX_withoutServiceMech() {
  71         System.out.println("Validation using SAX Source;  Service mechnism is turned off;  SAX Impl should be the default:");
  72         InputSource is = new InputSource(Bug6941169Test.class.getResourceAsStream("Bug6941169.xml"));
  73         SAXSource ss = new SAXSource(is);
  74         System.setProperty(SAX_FACTORY_ID, "MySAXFactoryImpl");
  75         long start = System.currentTimeMillis();


   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  */


  27 import java.io.StringWriter;
  28 import java.security.AllPermission;
  29 import java.security.Permission;
  30 import java.security.Permissions;
  31 
  32 import javax.xml.XMLConstants;
  33 import javax.xml.parsers.DocumentBuilder;
  34 import javax.xml.parsers.DocumentBuilderFactory;
  35 import javax.xml.transform.Transformer;
  36 import javax.xml.transform.TransformerFactory;
  37 import javax.xml.transform.dom.DOMSource;
  38 import javax.xml.transform.sax.SAXSource;
  39 import javax.xml.transform.stream.StreamResult;
  40 import javax.xml.transform.stream.StreamSource;
  41 import javax.xml.validation.Schema;
  42 import javax.xml.validation.SchemaFactory;
  43 import javax.xml.validation.Validator;
  44 import javax.xml.xpath.XPath;
  45 import javax.xml.xpath.XPathFactory;
  46 
  47 import jaxp.library.JAXPTestUtilities;
  48 
  49 import org.testng.Assert;
  50 import org.testng.annotations.Listeners;
  51 import org.testng.annotations.Test;
  52 import org.w3c.dom.Document;
  53 import org.xml.sax.InputSource;
  54 
  55 /*
  56  * @bug 6941169
  57  * @summary Test use-service-mechanism feature.
  58  */
  59 @Listeners({jaxp.library.FilePolicy.class})
  60 public class Bug6941169Test {
  61     static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
  62     static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
  63 
  64     private static final String DOM_FACTORY_ID = "javax.xml.parsers.DocumentBuilderFactory";
  65     private static final String SAX_FACTORY_ID = "javax.xml.parsers.SAXParserFactory";
  66 
  67     // impl specific feature
  68     final String ORACLE_FEATURE_SERVICE_MECHANISM = "http://www.oracle.com/feature/use-service-mechanism";
  69 
  70     static String _xml = Bug6941169Test.class.getResource("Bug6941169.xml").getPath();
  71     static String _xsd = Bug6941169Test.class.getResource("Bug6941169.xsd").getPath();
  72 
  73     @Test
  74     public void testValidation_SAX_withoutServiceMech() {
  75         System.out.println("Validation using SAX Source;  Service mechnism is turned off;  SAX Impl should be the default:");
  76         InputSource is = new InputSource(Bug6941169Test.class.getResourceAsStream("Bug6941169.xml"));
  77         SAXSource ss = new SAXSource(is);
  78         System.setProperty(SAX_FACTORY_ID, "MySAXFactoryImpl");
  79         long start = System.currentTimeMillis();


< prev index next >