Path: blob/master/test/jdk/javax/xml/jaxp/validation/8049514/FeaturePropagationTest.java
41154 views
/*1* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/222324/**25* @test26* @bug 804951427* @summary verifies that feature set on the factory is propagated properly28* to the validator29* @run main/othervm FeaturePropagationTest30*/313233import java.io.ByteArrayInputStream;34import java.io.InputStreamReader;35import javax.xml.XMLConstants;36import javax.xml.transform.stream.StreamSource;37import javax.xml.validation.*;3839/**40* JDK-804951441*42* FEATURE_SECURE_PROCESSING can not be turned off on a validator through43* SchemaFactory44*/45public class FeaturePropagationTest {4647static String xsd = "<?xml version='1.0'?>\n" + "<schema xmlns='http://www.w3.org/2001/XMLSchema'\n"48+ " xmlns:test='jaxp13_test'\n"49+ " targetNamespace='jaxp13_test'\n"50+ " elementFormDefault='qualified'>\n"51+ " <element name='test' type='string'/>\n"52+ "</schema>\n";5354public static void main(String[] args) throws Exception {55InputStreamReader reader = new InputStreamReader(new ByteArrayInputStream(xsd.getBytes()));56StreamSource xsdSource = new StreamSource(reader);5758SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");59schemaFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false);60Schema schema = null;61schema = schemaFactory.newSchema(xsdSource);6263Validator validator = schema.newValidator();6465if (validator.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING)) {66throw new RuntimeException("Feature set on the factory is not inherited!");67}6869}70}717273