OpenJDK / jdk / jdk
changeset 26335:67078b90e47b
8037819: Xerces Update: jaxp/validation/XMLSchemaFactory
Reviewed-by: lancea
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/BaseTest.java Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,338 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.File; +import java.net.URL; + +import javax.xml.XMLConstants; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.dom.DOMResult; +import javax.xml.transform.dom.DOMSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.Validator; + + +import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl; +import com.sun.org.apache.xerces.internal.impl.Constants; +import com.sun.org.apache.xerces.internal.impl.xs.SchemaGrammar; +import com.sun.org.apache.xerces.internal.xs.ElementPSVI; +import com.sun.org.apache.xerces.internal.xs.ItemPSVI; +import com.sun.org.apache.xerces.internal.xs.XSElementDeclaration; +import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; +import javax.xml.transform.stream.StreamSource; +import org.w3c.dom.Document; +import org.w3c.dom.Node; + +public abstract class BaseTest { + protected final static String ROOT_TYPE = Constants.XERCES_PROPERTY_PREFIX + + Constants.ROOT_TYPE_DEFINITION_PROPERTY; + + protected final static String IGNORE_XSI_TYPE = Constants.XERCES_FEATURE_PREFIX + + Constants.IGNORE_XSI_TYPE_FEATURE; + + protected final static String ID_IDREF_CHECKING = Constants.XERCES_FEATURE_PREFIX + + Constants.ID_IDREF_CHECKING_FEATURE; + + protected final static String IDC_CHECKING = Constants.XERCES_FEATURE_PREFIX + + Constants.IDC_CHECKING_FEATURE; + + protected final static String UNPARSED_ENTITY_CHECKING = Constants.XERCES_FEATURE_PREFIX + + Constants.UNPARSED_ENTITY_CHECKING_FEATURE; + + protected final static String USE_GRAMMAR_POOL_ONLY = Constants.XERCES_FEATURE_PREFIX + + Constants.USE_GRAMMAR_POOL_ONLY_FEATURE; + + protected final static String DYNAMIC_VALIDATION = Constants.XERCES_FEATURE_PREFIX + + Constants.DYNAMIC_VALIDATION_FEATURE; + + protected final static String DOCUMENT_CLASS_NAME = Constants.XERCES_PROPERTY_PREFIX + + Constants.DOCUMENT_CLASS_NAME_PROPERTY; + + protected Schema schema; + protected Validator fValidator; + + protected SpecialCaseErrorHandler fErrorHandler; + + DocumentBuilder builder; + protected Document fDocument; + + protected ElementPSVI fRootNode; + + protected URL fDocumentURL; + protected String documentPath; + protected String fDocumentId; + + static String errMessage; + + int passed = 0, failed = 0; + + public static boolean isWindows = false; + static { + if (System.getProperty("os.name").indexOf("Windows")>-1) { + isWindows = true; + } + }; + public static final String USER_DIR = System.getProperty("user.dir", "."); + public static final String BASE_DIR = System.getProperty("test.src", USER_DIR) + .replaceAll("\\" + System.getProperty("file.separator"), "/"); + + protected abstract String getSchemaFile(); + + protected abstract String getXMLDocument(); + + public BaseTest(String name) { + fErrorHandler = new SpecialCaseErrorHandler(getRelevantErrorIDs()); + } + + protected void setUp() throws Exception { + + DocumentBuilderFactory docFactory = DocumentBuilderFactory + .newInstance(); + docFactory.setAttribute(DOCUMENT_CLASS_NAME, + "com.sun.org.apache.xerces.internal.dom.PSVIDocumentImpl"); + docFactory.setNamespaceAware(true); + builder = docFactory.newDocumentBuilder(); + + documentPath = BASE_DIR + "/" + getXMLDocument(); +System.out.println("documentPath:"+documentPath); + if (isWindows) { + fDocumentId = "file:/" + documentPath; + } else { + fDocumentId = "file:" + documentPath; + } + //fDocumentURL = ClassLoader.getSystemResource(documentPath); + //fDocumentURL = getClass().getResource(documentPath); +System.out.println("fDocumentId:"+fDocumentId); +//System.out.println("fDocumentURL.toExternalForm:"+fDocumentURL.toExternalForm()); +/** + if (fDocumentURL == null) { + throw new FileNotFoundException("Couldn't find xml file for test: " + documentPath); + } + fDocument = builder.parse(fDocumentURL.toExternalForm()); + fRootNode = (ElementPSVI) fDocument.getDocumentElement(); + */ + SchemaFactory sf = SchemaFactory + .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + sf.setFeature(USE_GRAMMAR_POOL_ONLY, getUseGrammarPoolOnly()); + String schemaPath = BASE_DIR + "/" + getSchemaFile(); + /** + URL schemaURL = ClassLoader.getSystemResource(schemaPath); + if (schemaURL == null) { + throw new FileNotFoundException("Couldn't find schema file for test: " + schemaPath); + } + */ + schema = sf.newSchema(new StreamSource(new File(schemaPath))); + } + + protected void tearDown() throws Exception { + fValidator = null; + fDocument = null; + fRootNode = null; + fErrorHandler.reset(); + System.out.println("\nNumber of tests passed: " + passed); + System.out.println("Number of tests failed: " + failed + "\n"); + + if (errMessage != null) { + throw new RuntimeException(errMessage); + } + } + + protected void validateDocument() throws Exception { + Source source = new DOMSource(fDocument); + source.setSystemId(fDocumentId); + Result result = new DOMResult(fDocument); + fValidator.validate(source, result); + } + + protected void validateFragment() throws Exception { + Source source = new DOMSource((Node) fRootNode); + source.setSystemId(fDocumentId); + Result result = new DOMResult((Node) fRootNode); + fValidator.validate(source, result); + } + + protected void reset() throws Exception { + try { +System.out.println("new File(documentPath)" + new File(documentPath)); + + fDocument = builder.parse(new File(documentPath)); + fRootNode = (ElementPSVI) fDocument.getDocumentElement(); +System.out.println("fDocument" + fDocument); +System.out.println("fRootNode" + fRootNode); + fValidator = schema.newValidator(); + fErrorHandler.reset(); + fValidator.setErrorHandler(fErrorHandler); + fValidator.setFeature(DYNAMIC_VALIDATION, false); + } catch (Exception e) { + e.printStackTrace(); + } + } + + protected PSVIElementNSImpl getChild(int n) { + int numFound = 0; + Node child = ((Node) fRootNode).getFirstChild(); + while (child != null) { + if (child.getNodeType() == Node.ELEMENT_NODE) { + numFound++; + if (numFound == n) { + return (PSVIElementNSImpl) child; + } + } + child = child.getNextSibling(); + } + return null; + } + + protected String[] getRelevantErrorIDs() { + return new String[] {}; + } + + protected boolean getUseGrammarPoolOnly() { + return false; + } + + // specialized asserts + + protected void assertValidity(short expectedValidity, short actualValidity) { + String expectedString = expectedValidity == ItemPSVI.VALIDITY_VALID ? "valid" + : (expectedValidity == ItemPSVI.VALIDITY_INVALID ? "invalid" + : "notKnown"); + String actualString = actualValidity == ItemPSVI.VALIDITY_VALID ? "valid" + : (actualValidity == ItemPSVI.VALIDITY_INVALID ? "invalid" + : "notKnown"); + String message = "{validity} was <" + actualString + + "> but it should have been <" + expectedString + ">"; + assertEquals(message, expectedValidity, actualValidity); + } + + protected void assertValidationAttempted(short expectedAttempted, + short actualAttempted) { + String expectedString = expectedAttempted == ItemPSVI.VALIDATION_FULL ? "full" + : (expectedAttempted == ItemPSVI.VALIDATION_PARTIAL ? "partial" + : "none"); + String actualString = actualAttempted == ItemPSVI.VALIDATION_FULL ? "full" + : (actualAttempted == ItemPSVI.VALIDATION_PARTIAL ? "partial" + : "none"); + String message = "{validity} was <" + actualString + + "> but it should have been <" + expectedString + ">"; + assertEquals(message, expectedAttempted, actualAttempted); + } + + protected void assertElementName(String expectedName, String actualName) { + assertEquals("Local name of element declaration is wrong.", + expectedName, actualName); + } + + protected void assertElementNull(XSElementDeclaration elem) { + assertNull("Element declaration should be null.", elem); + } + + protected void assertElementNamespace(String expectedName, String actualName) { + assertEquals("Namespace of element declaration is wrong.", + expectedName, actualName); + } + + protected void assertElementNamespaceNull(String actualName) { + assertNull("Local name of element declaration should be null.", + actualName); + } + + protected void assertTypeName(String expectedName, String actualName) { + assertEquals("Local name of type definition is wrong.", expectedName, + actualName); + } + + protected void assertTypeNull(XSTypeDefinition type) { + assertNull("Type definition should be null.", type); + } + + protected void assertTypeNamespace(String expectedName, String actualName) { + assertEquals("Namespace of type definition is wrong.", expectedName, + actualName); + } + + protected void assertTypeNamespaceNull(String actualName) { + assertNull("Namespace of type definition should be null.", actualName); + } + + protected void assertError(String error) { + assertTrue("Error <" + error + "> should have occured, but did not.", + fErrorHandler.specialCaseFound(error)); + } + + protected void assertNoError(String error) { + assertFalse("Error <" + error + + "> should not have occured (but it did)", fErrorHandler + .specialCaseFound(error)); + } + + protected void assertAnyType(XSTypeDefinition type) { + assertEquals("Type is supposed to be anyType", SchemaGrammar.fAnyType, + type); + } + + void assertEquals(String msg, Object expected, Object actual) { + if (!expected.equals(actual)) { + fail(msg + " Expected: " + expected + " Actual: " + actual); + } else { + success(null); + } + } + void assertNull(String msg, Object value) { + if (value != null) { + fail(msg); + } else { + success(null); + } + } + void assertTrue(String msg, boolean value) { + if (!value) { + fail(msg); + } else { + success(null); + } + } + void assertFalse(String msg, boolean value) { + if (value) { + fail(msg); + } else { + success(null); + } + } + void fail(String errMsg) { + if (errMessage == null) { + errMessage = errMsg; + } else { + errMessage = errMessage + "\n" + errMsg; + } + failed++; + } + + void success(String msg) { + passed++; + System.out.println(msg); + if (msg != null) { + if (msg.length() != 0) { + System.out.println(msg); + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/BasicTest.java Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl; +import com.sun.org.apache.xerces.internal.xs.ItemPSVI; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class BasicTest extends BaseTest { + + protected String getXMLDocument() { + return "base.xml"; + } + + protected String getSchemaFile() { + return "base.xsd"; + } + + public BasicTest(String name) { + super(name); + } + + @BeforeClass + protected void setUp() throws Exception { + super.setUp(); + } + + @AfterClass + protected void tearDown() throws Exception { + super.tearDown(); + } + + @Test + public void testSimpleValidation() { + try { + reset(); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + doValidityAsserts(); + } + + @Test + public void testSimpleValidationWithTrivialXSIType() { + try { + reset(); + ((PSVIElementNSImpl) fRootNode).setAttributeNS( + "http://www.w3.org/2001/XMLSchema-instance", "type", "X"); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + doValidityAsserts(); + } + + private void doValidityAsserts() { + assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementName("A", fRootNode.getElementDeclaration().getName()); + assertElementNamespaceNull(fRootNode.getElementDeclaration() + .getNamespace()); + assertTypeName("X", fRootNode.getTypeDefinition().getName()); + assertTypeNamespaceNull(fRootNode.getTypeDefinition().getNamespace()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/FixedAttrTest.java Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl; +import com.sun.org.apache.xerces.internal.xs.ItemPSVI; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * The purpose of this test is to execute all of the isComparable calls in + * XMLSchemaValidator. There are two calls in processElementContent and two + * calls in processOneAttribute. + * + * @author peterjm + */ +public class FixedAttrTest extends BaseTest { + + protected String getXMLDocument() { + return "fixedAttr.xml"; + } + + protected String getSchemaFile() { + return "base.xsd"; + } + + public FixedAttrTest(String name) { + super(name); + } + + @BeforeClass + protected void setUp() throws Exception { + super.setUp(); + } + + @AfterClass + protected void tearDown() throws Exception { + super.tearDown(); + } + + @Test + public void testDefault() { + try { + reset(); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementName("A", fRootNode.getElementDeclaration().getName()); + + PSVIElementNSImpl child = super.getChild(1); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("B", child.getElementDeclaration().getName()); + + child = super.getChild(2); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("D", child.getElementDeclaration().getName()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/IdIdrefCheckingTest.java Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,160 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl; +import com.sun.org.apache.xerces.internal.xs.ItemPSVI; +import org.xml.sax.SAXException; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +// duplicate IDs +// reference to non-existent ID + +public class IdIdrefCheckingTest extends BaseTest { + public static final String DUPLICATE_ID = "cvc-id.2"; + + public static final String NO_ID_BINDING = "cvc-id.1"; + + protected String getXMLDocument() { + return "idIdref.xml"; + } + + protected String getSchemaFile() { + return "base.xsd"; + } + + protected String[] getRelevantErrorIDs() { + return new String[] { DUPLICATE_ID, NO_ID_BINDING }; + } + + public IdIdrefCheckingTest(String name) { + super(name); + } + + @BeforeClass + protected void setUp() throws Exception { + super.setUp(); + } + + @AfterClass + protected void tearDown() throws Exception { + super.tearDown(); + } + + @Test + public void testDefault() { + try { + reset(); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkDefault(); + } + + @Test + public void testSetFalse() { + try { + reset(); + fValidator.setFeature(ID_IDREF_CHECKING, false); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkValidResult(); + } + + @Test + public void testSetTrue() { + try { + reset(); + fValidator.setFeature(ID_IDREF_CHECKING, true); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkDefault(); + } + + private void checkDefault() { + assertError(DUPLICATE_ID); + assertError(NO_ID_BINDING); + + assertValidity(ItemPSVI.VALIDITY_INVALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementName("A", fRootNode.getElementDeclaration().getName()); + assertTypeName("X", fRootNode.getTypeDefinition().getName()); + + PSVIElementNSImpl child = super.getChild(1); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("A", child.getElementDeclaration().getName()); + assertTypeName("idType", child.getTypeDefinition().getName()); + + child = super.getChild(2); + assertValidity(ItemPSVI.VALIDITY_INVALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("A", child.getElementDeclaration().getName()); + assertTypeName("idType", child.getTypeDefinition().getName()); + + child = super.getChild(3); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("A", child.getElementDeclaration().getName()); + assertTypeName("idrefType", child.getTypeDefinition().getName()); + } + + private void checkValidResult() { + assertNoError(DUPLICATE_ID); + assertNoError(NO_ID_BINDING); + + assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementName("A", fRootNode.getElementDeclaration().getName()); + assertTypeName("X", fRootNode.getTypeDefinition().getName()); + + PSVIElementNSImpl child = super.getChild(1); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("A", child.getElementDeclaration().getName()); + assertTypeName("idType", child.getTypeDefinition().getName()); + + child = super.getChild(2); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("A", child.getElementDeclaration().getName()); + assertTypeName("idType", child.getTypeDefinition().getName()); + + child = super.getChild(3); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("A", child.getElementDeclaration().getName()); + assertTypeName("idrefType", child.getTypeDefinition().getName()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/IdentityConstraintCheckingTest.java Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,186 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl; +import com.sun.org.apache.xerces.internal.xs.ItemPSVI; +import org.xml.sax.SAXException; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class IdentityConstraintCheckingTest extends BaseTest { + // These values are unstable, since they're not actually error keys, but + // simply + // the first part of the error message. + public static final String DUPLICATE_UNIQUE = "cvc-identity-constraint.4.1"; + + public static final String DUPLICATE_KEY = "cvc-identity-constraint.4.2.2"; + + public static final String INVALID_KEYREF = "cvc-identity-constraint.4.3"; + + protected String getXMLDocument() { + return "idc.xml"; + } + + protected String getSchemaFile() { + return "idc.xsd"; + } + + protected String[] getRelevantErrorIDs() { + return new String[] { DUPLICATE_UNIQUE, DUPLICATE_KEY, INVALID_KEYREF }; + } + + public IdentityConstraintCheckingTest(String name) { + super(name); + } + + @BeforeClass + protected void setUp() throws Exception { + super.setUp(); + } + + @AfterClass + protected void tearDown() throws Exception { + super.tearDown(); + } + + @Test + public void testDefault() { + try { + reset(); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkDefault(); + } + + @Test + public void testSetFalse() { + try { + reset(); + fValidator.setFeature(IDC_CHECKING, false); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkValidResult(); + } + + @Test + public void testSetTrue() { + try { + reset(); + fValidator.setFeature(IDC_CHECKING, true); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkDefault(); + } + + private void checkDefault() { + assertError(DUPLICATE_UNIQUE); + assertError(DUPLICATE_KEY); + assertError(INVALID_KEYREF); + + assertValidity(ItemPSVI.VALIDITY_INVALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementName("itemList", fRootNode.getElementDeclaration() + .getName()); + assertTypeName("itemListType", fRootNode.getTypeDefinition().getName()); + + // this one is valid because it's the first one to define the unique + // value + PSVIElementNSImpl child = super.getChild(1); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("item", child.getElementDeclaration().getName()); + assertTypeName("itemType", child.getTypeDefinition().getName()); + + // invalid because it repeats the unique value + child = super.getChild(2); + assertValidity(ItemPSVI.VALIDITY_INVALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("item", child.getElementDeclaration().getName()); + assertTypeName("itemType", child.getTypeDefinition().getName()); + + // invalid because it repeats the key + child = super.getChild(3); + assertValidity(ItemPSVI.VALIDITY_INVALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("item", child.getElementDeclaration().getName()); + assertTypeName("itemType", child.getTypeDefinition().getName()); + + // valid because key references aren't figured out until the validation + // root + child = super.getChild(4); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("itemRef", child.getElementDeclaration().getName()); + assertTypeName("string", child.getTypeDefinition().getName()); + } + + private void checkValidResult() { + assertNoError(DUPLICATE_UNIQUE); + assertNoError(DUPLICATE_KEY); + assertNoError(INVALID_KEYREF); + + assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementName("itemList", fRootNode.getElementDeclaration() + .getName()); + assertTypeName("itemListType", fRootNode.getTypeDefinition().getName()); + + PSVIElementNSImpl child = super.getChild(1); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("item", child.getElementDeclaration().getName()); + assertTypeName("itemType", child.getTypeDefinition().getName()); + + child = super.getChild(2); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("item", child.getElementDeclaration().getName()); + assertTypeName("itemType", child.getTypeDefinition().getName()); + + child = super.getChild(3); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("item", child.getElementDeclaration().getName()); + assertTypeName("itemType", child.getTypeDefinition().getName()); + + child = super.getChild(4); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("itemRef", child.getElementDeclaration().getName()); + assertTypeName("string", child.getTypeDefinition().getName()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/IgnoreXSITypeTest_A_A.java Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,151 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl; +import com.sun.org.apache.xerces.internal.xs.ItemPSVI; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class IgnoreXSITypeTest_A_A extends BaseTest { + + protected String getXMLDocument() { + return "xsitype_A_A.xml"; + } + + protected String getSchemaFile() { + return "base.xsd"; + } + + public IgnoreXSITypeTest_A_A(String name) { + super(name); + } + + @BeforeClass + protected void setUp() throws Exception { + super.setUp(); + } + + @AfterClass + protected void tearDown() throws Exception { + super.tearDown(); + } + + @Test + public void testDefaultDocument() { + try { + reset(); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + // default value of the feature is false + checkFalseResult(); + } + + @Test + public void testDefaultFragment() { + try { + reset(); + validateFragment(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + // default value of the feature is false + checkFalseResult(); + } + + @Test + public void testSetFalseDocument() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, false); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkFalseResult(); + } + + @Test + public void testSetFalseFragment() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, false); + validateFragment(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkFalseResult(); + } + + @Test + public void testSetTrueDocument() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, true); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkTrueResult(); + } + + @Test + public void testSetTrueFragment() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, true); + validateFragment(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkTrueResult(); + } + + private void checkTrueResult() { + checkResult(); + } + + private void checkFalseResult() { + checkResult(); + } + + private void checkResult() { + assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementName("A", fRootNode.getElementDeclaration().getName()); + assertTypeName("Y", fRootNode.getTypeDefinition().getName()); + assertTypeNamespaceNull(fRootNode.getTypeDefinition().getNamespace()); + + PSVIElementNSImpl child = super.getChild(1); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("A", child.getElementDeclaration().getName()); + assertTypeName("Y", child.getTypeDefinition().getName()); + assertTypeNamespaceNull(child.getTypeDefinition().getNamespace()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/IgnoreXSITypeTest_A_C.java Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,151 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl; +import com.sun.org.apache.xerces.internal.xs.ItemPSVI; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class IgnoreXSITypeTest_A_C extends BaseTest { + + protected String getXMLDocument() { + return "xsitype_A_C.xml"; + } + + protected String getSchemaFile() { + return "base.xsd"; + } + + public IgnoreXSITypeTest_A_C(String name) { + super(name); + } + + + @BeforeClass + protected void setUp() throws Exception { + super.setUp(); + } + + @AfterClass + protected void tearDown() throws Exception { + super.tearDown(); + } + + @Test + public void testDefaultDocument() { + try { + reset(); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + // default value of the feature is false + checkFalseResult(); + } + + @Test + public void testDefaultFragment() { + try { + reset(); + validateFragment(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + // default value of the feature is false + checkFalseResult(); + } + + @Test + public void testSetFalseDocument() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, false); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkFalseResult(); + } + + @Test + public void testSetFalseFragment() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, false); + validateFragment(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkFalseResult(); + } + + @Test + public void testSetTrueDocument() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, true); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkTrueResult(); + } + + @Test + public void testSetTrueFragment() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, true); + validateFragment(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkTrueResult(); + } + + private void checkTrueResult() { + checkResult(); + } + + private void checkFalseResult() { + checkResult(); + } + + private void checkResult() { + assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementName("A", fRootNode.getElementDeclaration().getName()); + assertTypeName("Y", fRootNode.getTypeDefinition().getName()); + assertTypeNamespaceNull(fRootNode.getTypeDefinition().getNamespace()); + + PSVIElementNSImpl child = super.getChild(1); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementNull(child.getElementDeclaration()); + assertTypeName("Y", child.getTypeDefinition().getName()); + assertTypeNamespaceNull(child.getTypeDefinition().getNamespace()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/IgnoreXSITypeTest_C_A.java Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,157 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl; +import com.sun.org.apache.xerces.internal.xs.ItemPSVI; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class IgnoreXSITypeTest_C_A extends BaseTest { + + protected String getXMLDocument() { + return "xsitype_C_A.xml"; + } + + protected String getSchemaFile() { + return "base.xsd"; + } + + public IgnoreXSITypeTest_C_A(String name) { + super(name); + } + + + @BeforeClass + protected void setUp() throws Exception { + super.setUp(); + } + + @AfterClass + protected void tearDown() throws Exception { + super.tearDown(); + } + + @Test + public void testDefaultDocument() { + try { + reset(); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + // default value of the feature is false + checkFalseResult(); + } + + @Test + public void testDefaultFragment() { + try { + reset(); + validateFragment(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + // default value of the feature is false + checkFalseResult(); + } + + @Test + public void testSetFalseDocument() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, false); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkFalseResult(); + } + + @Test + public void testSetFalseFragment() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, false); + validateFragment(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkFalseResult(); + } + + @Test + public void testSetTrueDocument() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, true); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkTrueResult(); + } + + @Test + public void testSetTrueFragment() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, true); + validateFragment(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkTrueResult(); + } + + private void checkTrueResult() { + assertValidity(ItemPSVI.VALIDITY_NOTKNOWN, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_PARTIAL, fRootNode + .getValidationAttempted()); + assertElementNull(fRootNode.getElementDeclaration()); + assertAnyType(fRootNode.getTypeDefinition()); + + checkChild(); + } + + private void checkFalseResult() { + assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementNull(fRootNode.getElementDeclaration()); + assertTypeName("Y", fRootNode.getTypeDefinition().getName()); + assertTypeNamespaceNull(fRootNode.getTypeDefinition().getNamespace()); + + checkChild(); + } + + private void checkChild() { + PSVIElementNSImpl child = super.getChild(1); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("A", child.getElementDeclaration().getName()); + assertTypeName("Y", child.getTypeDefinition().getName()); + assertTypeNamespaceNull(child.getTypeDefinition().getNamespace()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/IgnoreXSITypeTest_C_AC.java Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,174 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl; +import com.sun.org.apache.xerces.internal.xs.ItemPSVI; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class IgnoreXSITypeTest_C_AC extends BaseTest { + + protected String getXMLDocument() { + return "xsitype_C_AC.xml"; + } + + protected String getSchemaFile() { + return "base.xsd"; + } + + public IgnoreXSITypeTest_C_AC(String name) { + super(name); + } + + + @BeforeClass + protected void setUp() throws Exception { + super.setUp(); + } + + @AfterClass + protected void tearDown() throws Exception { + super.tearDown(); + } + + @Test + public void testDefaultDocument() { + try { + reset(); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + // default value of the feature is false + checkFalseResult(); + } + + @Test + public void testDefaultFragment() { + try { + reset(); + validateFragment(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + // default value of the feature is false + checkFalseResult(); + } + + @Test + public void testSetFalseDocument() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, false); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkFalseResult(); + } + + @Test + public void testSetFalseFragment() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, false); + validateFragment(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkFalseResult(); + } + + @Test + public void testSetTrueDocument() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, true); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkTrueResult(); + } + + @Test + public void testSetTrueFragment() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, true); + validateFragment(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkTrueResult(); + } + + private void checkTrueResult() { + assertValidity(ItemPSVI.VALIDITY_NOTKNOWN, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_PARTIAL, fRootNode + .getValidationAttempted()); + assertElementNull(fRootNode.getElementDeclaration()); + assertAnyType(fRootNode.getTypeDefinition()); + + PSVIElementNSImpl child = super.getChild(1); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("A", child.getElementDeclaration().getName()); + assertTypeName("Y", child.getTypeDefinition().getName()); + assertTypeNamespaceNull(child.getTypeDefinition().getNamespace()); + + child = super.getChild(2); + assertValidity(ItemPSVI.VALIDITY_NOTKNOWN, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_NONE, child + .getValidationAttempted()); + assertElementNull(child.getElementDeclaration()); + assertAnyType(child.getTypeDefinition()); + } + + private void checkFalseResult() { + assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementNull(fRootNode.getElementDeclaration()); + assertTypeName("Y", fRootNode.getTypeDefinition().getName()); + assertTypeNamespaceNull(fRootNode.getTypeDefinition().getNamespace()); + + PSVIElementNSImpl child = super.getChild(1); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("A", child.getElementDeclaration().getName()); + assertTypeName("Y", child.getTypeDefinition().getName()); + assertTypeNamespaceNull(child.getTypeDefinition().getNamespace()); + + child = super.getChild(2); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementNull(child.getElementDeclaration()); + assertTypeName("Y", child.getTypeDefinition().getName()); + assertTypeNamespaceNull(child.getTypeDefinition().getNamespace()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/IgnoreXSITypeTest_C_C.java Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,158 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl; +import com.sun.org.apache.xerces.internal.xs.ItemPSVI; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class IgnoreXSITypeTest_C_C extends BaseTest { + + protected String getXMLDocument() { + return "xsitype_C_C.xml"; + } + + protected String getSchemaFile() { + return "base.xsd"; + } + + public IgnoreXSITypeTest_C_C(String name) { + super(name); + } + + + @BeforeClass + protected void setUp() throws Exception { + super.setUp(); + } + + @AfterClass + protected void tearDown() throws Exception { + super.tearDown(); + } + + @Test + public void testDefaultDocument() { + try { + reset(); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + // default value of the feature is false + checkFalseResult(); + } + + @Test + public void testDefaultFragment() { + try { + reset(); + validateFragment(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + // default value of the feature is false + checkFalseResult(); + } + + @Test + public void testSetFalseDocument() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, false); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkFalseResult(); + } + + @Test + public void testSetFalseFragment() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, false); + validateFragment(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkFalseResult(); + } + + @Test + public void testSetTrueDocument() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, true); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkTrueResult(); + } + + @Test + public void testSetTrueFragment() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, true); + validateFragment(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkTrueResult(); + } + + private void checkTrueResult() { + assertValidity(ItemPSVI.VALIDITY_NOTKNOWN, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_NONE, fRootNode + .getValidationAttempted()); + assertElementNull(fRootNode.getElementDeclaration()); + assertAnyType(fRootNode.getTypeDefinition()); + + PSVIElementNSImpl child = super.getChild(1); + assertValidity(ItemPSVI.VALIDITY_NOTKNOWN, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_NONE, child + .getValidationAttempted()); + assertElementNull(child.getElementDeclaration()); + assertAnyType(child.getTypeDefinition()); + } + + private void checkFalseResult() { + assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementNull(fRootNode.getElementDeclaration()); + assertTypeName("Y", fRootNode.getTypeDefinition().getName()); + assertTypeNamespaceNull(fRootNode.getTypeDefinition().getNamespace()); + + PSVIElementNSImpl child = super.getChild(1); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementNull(child.getElementDeclaration()); + assertTypeName("Y", child.getTypeDefinition().getName()); + assertTypeNamespaceNull(child.getTypeDefinition().getNamespace()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/IgnoreXSITypeTest_C_CA.java Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,173 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl; +import com.sun.org.apache.xerces.internal.xs.ItemPSVI; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class IgnoreXSITypeTest_C_CA extends BaseTest { + + protected String getXMLDocument() { + return "xsitype_C_CA.xml"; + } + + protected String getSchemaFile() { + return "base.xsd"; + } + + public IgnoreXSITypeTest_C_CA(String name) { + super(name); + } + + @BeforeClass + protected void setUp() throws Exception { + super.setUp(); + } + + @AfterClass + protected void tearDown() throws Exception { + super.tearDown(); + } + + @Test + public void testDefaultDocument() { + try { + reset(); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + // default value of the feature is false + checkFalseResult(); + } + + @Test + public void testDefaultFragment() { + try { + reset(); + validateFragment(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + // default value of the feature is false + checkFalseResult(); + } + + @Test + public void testSetFalseDocument() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, false); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkFalseResult(); + } + + @Test + public void testSetFalseFragment() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, false); + validateFragment(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkFalseResult(); + } + + @Test + public void testSetTrueDocument() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, true); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkTrueResult(); + } + + @Test + public void testSetTrueFragment() { + try { + reset(); + fValidator.setFeature(IGNORE_XSI_TYPE, true); + validateFragment(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkTrueResult(); + } + + private void checkTrueResult() { + assertValidity(ItemPSVI.VALIDITY_NOTKNOWN, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_PARTIAL, fRootNode + .getValidationAttempted()); + assertElementNull(fRootNode.getElementDeclaration()); + assertAnyType(fRootNode.getTypeDefinition()); + + PSVIElementNSImpl child = super.getChild(1); + assertValidity(ItemPSVI.VALIDITY_NOTKNOWN, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_NONE, child + .getValidationAttempted()); + assertElementNull(child.getElementDeclaration()); + assertAnyType(child.getTypeDefinition()); + + child = super.getChild(2); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("A", child.getElementDeclaration().getName()); + assertTypeName("Y", child.getTypeDefinition().getName()); + assertTypeNamespaceNull(child.getTypeDefinition().getNamespace()); + } + + private void checkFalseResult() { + assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementNull(fRootNode.getElementDeclaration()); + assertTypeName("Y", fRootNode.getTypeDefinition().getName()); + assertTypeNamespaceNull(fRootNode.getTypeDefinition().getNamespace()); + + PSVIElementNSImpl child = super.getChild(1); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementNull(child.getElementDeclaration()); + assertTypeName("Y", child.getTypeDefinition().getName()); + assertTypeNamespaceNull(child.getTypeDefinition().getNamespace()); + + child = super.getChild(2); + assertValidity(ItemPSVI.VALIDITY_VALID, child.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, child + .getValidationAttempted()); + assertElementName("A", child.getElementDeclaration().getName()); + assertTypeName("Y", child.getTypeDefinition().getName()); + assertTypeNamespaceNull(child.getTypeDefinition().getNamespace()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/RootTypeDefinitionTest.java Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,235 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import javax.xml.namespace.QName; +import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl; +import com.sun.org.apache.xerces.internal.impl.xs.SchemaSymbols; +import com.sun.org.apache.xerces.internal.xs.ItemPSVI; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class RootTypeDefinitionTest extends BaseTest { + private QName unknownType; + + private QName typeX; + + private QName typeY; + + private QName typeZ; + + private QName typeOtherNamespace; + + private final static String UNKNOWN_TYPE_ERROR = "cvc-type.1"; + + private final static String INVALID_DERIVATION_ERROR = "cvc-elt.4.3"; + + protected String getXMLDocument() { + return "base.xml"; + } + + protected String getSchemaFile() { + return "base.xsd"; + } + + protected String[] getRelevantErrorIDs() { + return new String[] { UNKNOWN_TYPE_ERROR, INVALID_DERIVATION_ERROR }; + } + + public RootTypeDefinitionTest(String name) { + super(name); + unknownType = new QName("W"); + typeX = new QName("X"); + typeY = new QName("Y"); + typeZ = new QName("Z"); + typeOtherNamespace = new QName("xslt.unittests", "W", "unit"); + } + + + @BeforeClass + protected void setUp() throws Exception { + super.setUp(); + } + + @AfterClass + protected void tearDown() throws Exception { + super.tearDown(); + } + + @Test + public void testDefault() { + try { + reset(); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkDefault(); + } + + @Test + public void testSettingNull() { + try { + reset(); + fValidator.setProperty(ROOT_TYPE, null); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkDefault(); + } + + @Test + public void testSettingToUnknownType() { + try { + reset(); + fValidator.setProperty(ROOT_TYPE, unknownType); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + assertError(UNKNOWN_TYPE_ERROR); + checkDefault(); + } + + @Test + public void testSettingToEqualType() { + try { + reset(); + fValidator.setProperty(ROOT_TYPE, typeX); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementNull(fRootNode.getElementDeclaration()); + assertTypeName("X", fRootNode.getTypeDefinition().getName()); + } + + @Test + public void testSettingToDerivedType() { + try { + reset(); + // this is required to make it a valid type Y node + ((PSVIElementNSImpl) fRootNode).setAttributeNS(null, "attr", "typeY"); + fValidator.setProperty(ROOT_TYPE, typeY); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementNull(fRootNode.getElementDeclaration()); + assertTypeName("Y", fRootNode.getTypeDefinition().getName()); + } + + @Test + public void testSettingToNonDerivedType() { + try { + reset(); + fValidator.setProperty(ROOT_TYPE, typeZ); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementNull(fRootNode.getElementDeclaration()); + assertTypeName("Z", fRootNode.getTypeDefinition().getName()); + } + + @Test + public void testSettingToOtherSchemaType() { + try { + reset(); + ((PSVIElementNSImpl) fRootNode).setAttributeNS(SchemaSymbols.URI_XSI, + SchemaSymbols.XSI_SCHEMALOCATION, + "xslt.unittests otherNamespace.xsd"); + fValidator.setProperty(ROOT_TYPE, typeOtherNamespace); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementNull(fRootNode.getElementDeclaration()); + assertTypeName("W", fRootNode.getTypeDefinition().getName()); + assertTypeNamespace("xslt.unittests", fRootNode.getTypeDefinition() + .getNamespace()); + } + + @Test + public void testSettingTypeAndXSIType() { + try { + reset(); + // this is required to make it a valid type Y node + ((PSVIElementNSImpl) fRootNode).setAttributeNS(null, "attr", "typeY"); + ((PSVIElementNSImpl) fRootNode).setAttributeNS(SchemaSymbols.URI_XSI, + SchemaSymbols.XSI_TYPE, "Y"); + fValidator.setProperty(ROOT_TYPE, typeX); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementNull(fRootNode.getElementDeclaration()); + assertTypeName("Y", fRootNode.getTypeDefinition().getName()); + } + + @Test + public void testSettingTypeAndInvalidXSIType() { + try { + reset(); + ((PSVIElementNSImpl) fRootNode).setAttributeNS(SchemaSymbols.URI_XSI, + SchemaSymbols.XSI_TYPE, "Z"); + fValidator.setProperty(ROOT_TYPE, typeX); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + assertError(INVALID_DERIVATION_ERROR); + assertValidity(ItemPSVI.VALIDITY_INVALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementNull(fRootNode.getElementDeclaration()); + assertTypeName("Z", fRootNode.getTypeDefinition().getName()); + } + + private void checkDefault() { + assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementName("A", fRootNode.getElementDeclaration().getName()); + assertTypeName("X", fRootNode.getTypeDefinition().getName()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/SpecialCaseErrorHandler.java Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.util.HashMap; + +import org.xml.sax.ErrorHandler; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; + +public class SpecialCaseErrorHandler implements ErrorHandler { + public static final boolean DEBUG = false; + + private HashMap<String, Boolean> errors; + + public SpecialCaseErrorHandler(String[] specialCases) { + errors = new HashMap<>(); + for (int i = 0; i < specialCases.length; ++i) { + errors.put(specialCases[i], Boolean.FALSE); + } + } + + public void reset() { + errors.keySet().stream().forEach((error) -> { + errors.put(error, Boolean.FALSE); + }); + } + + @Override + public void warning(SAXParseException arg0) throws SAXException { + if (DEBUG) { + System.err.println(arg0.getMessage()); + } + } + + @Override + public void error(SAXParseException arg0) throws SAXException { + if (DEBUG) { + System.err.println(arg0.getMessage()); + } + errors.keySet().stream().filter((error) -> (arg0.getMessage().startsWith(error))).forEach((error) -> { + errors.put(error, Boolean.TRUE); + }); + } + + public void fatalError(SAXParseException arg0) throws SAXException { + throw arg0; + } + + public boolean specialCaseFound(String key) { + return ((Boolean) errors.get(key)).booleanValue(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/TEST.properties Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,3 @@ +# This file identifies root(s) of the test-ng hierarchy. + +TestNG.dirs = .
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/UnparsedEntityCheckingTest.java Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,152 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.sun.org.apache.xerces.internal.dom.PSVIElementNSImpl; +import com.sun.org.apache.xerces.internal.xs.ItemPSVI; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class UnparsedEntityCheckingTest extends BaseTest { + public static final String UNDECLARED_ENTITY = "UndeclaredEntity"; + + protected String getXMLDocument() { + return "unparsedEntity.xml"; + } + + protected String getSchemaFile() { + return "base.xsd"; + } + + protected String[] getRelevantErrorIDs() { + return new String[] { UNDECLARED_ENTITY }; + } + + public UnparsedEntityCheckingTest(String name) { + super(name); + } + + @BeforeClass + protected void setUp() throws Exception { + super.setUp(); + } + + @AfterClass + protected void tearDown() throws Exception { + super.tearDown(); + } + + @Test + public void testDefaultValid() { + try { + reset(); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkDefault(); + } + + @Test + public void testSetFalseValid() { + try { + reset(); + fValidator.setFeature(UNPARSED_ENTITY_CHECKING, false); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkDefault(); + } + + @Test + public void testSetTrueValid() { + try { + reset(); + fValidator.setFeature(UNPARSED_ENTITY_CHECKING, true); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkDefault(); + } + + @Test + public void testDefaultInvalid() { + try { + reset(); + ((PSVIElementNSImpl) fRootNode).setAttributeNS(null, + "unparsedEntityAttr", "invalid"); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkInvalid(); + } + + @Test + public void testSetFalseInvalid() { + try { + reset(); + ((PSVIElementNSImpl) fRootNode).setAttributeNS(null, + "unparsedEntityAttr", "invalid"); + fValidator.setFeature(UNPARSED_ENTITY_CHECKING, false); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkDefault(); + } + + @Test + public void testSetTrueInvalid() { + try { + reset(); + ((PSVIElementNSImpl) fRootNode).setAttributeNS(null, + "unparsedEntityAttr", "invalid"); + fValidator.setFeature(UNPARSED_ENTITY_CHECKING, true); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + checkInvalid(); + } + + private void checkDefault() { + assertNoError(UNDECLARED_ENTITY); + assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementName("A", fRootNode.getElementDeclaration().getName()); + assertTypeName("X", fRootNode.getTypeDefinition().getName()); + } + + private void checkInvalid() { + assertError(UNDECLARED_ENTITY); + assertValidity(ItemPSVI.VALIDITY_INVALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementName("A", fRootNode.getElementDeclaration().getName()); + assertTypeName("X", fRootNode.getTypeDefinition().getName()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/UseGrammarPoolOnlyTest_False.java Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.sun.org.apache.xerces.internal.xs.ItemPSVI; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class UseGrammarPoolOnlyTest_False extends BaseTest { + private final static String UNKNOWN_TYPE_ERROR = "cvc-type.1"; + + private final static String INVALID_DERIVATION_ERROR = "cvc-elt.4.3"; + + protected String getXMLDocument() { + return "otherNamespace.xml"; + } + + protected String getSchemaFile() { + return "base.xsd"; + } + + protected String[] getRelevantErrorIDs() { + return new String[] { UNKNOWN_TYPE_ERROR, INVALID_DERIVATION_ERROR }; + } + + protected boolean getUseGrammarPoolOnly() { + return false; + } + + public UseGrammarPoolOnlyTest_False(String name) { + super(name); + } + + @BeforeClass + protected void setUp() throws Exception { + super.setUp(); + } + + @AfterClass + protected void tearDown() throws Exception { + super.tearDown(); + } + + /** + * The purpose of this test is to check if setting the USE_GRAMMAR_POOL_ONLY + * feature to true causes external schemas to not be read. This + * functionality already existed prior to adding the XSLT 2.0 validation + * features; however, because the class that controlled it changed, this + * test simply ensures that the existing functionality did not disappear. + * -PM + */ + @Test + public void testUsingOnlyGrammarPool() { + try { + reset(); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + assertValidity(ItemPSVI.VALIDITY_VALID, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_FULL, fRootNode + .getValidationAttempted()); + assertElementName("A", fRootNode.getElementDeclaration().getName()); + assertElementNamespace("xslt.unittests", fRootNode + .getElementDeclaration().getNamespace()); + assertTypeName("W", fRootNode.getTypeDefinition().getName()); + assertTypeNamespace("xslt.unittests", fRootNode.getTypeDefinition() + .getNamespace()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/UseGrammarPoolOnlyTest_True.java Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.sun.org.apache.xerces.internal.xs.ItemPSVI; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class UseGrammarPoolOnlyTest_True extends BaseTest { + + protected String getXMLDocument() { + return "otherNamespace.xml"; + } + + protected String getSchemaFile() { + return "base.xsd"; + } + + protected boolean getUseGrammarPoolOnly() { + return true; + } + + public UseGrammarPoolOnlyTest_True(String name) { + super(name); + } + + @BeforeClass + protected void setUp() throws Exception { + super.setUp(); + } + + @AfterClass + protected void tearDown() throws Exception { + super.tearDown(); + } + + /** + * The purpose of this test is to check if setting the USE_GRAMMAR_POOL_ONLY + * feature to true causes external schemas to not be read. This + * functionality already existed prior to adding the XSLT 2.0 validation + * features; however, because the class that controlled it changed, this + * test simply ensures that the existing functionality did not disappear. + * -PM + */ + @Test + public void testUsingOnlyGrammarPool() { + try { + reset(); + validateDocument(); + } catch (Exception e) { + fail("Validation failed: " + e.getMessage()); + } + + assertValidity(ItemPSVI.VALIDITY_NOTKNOWN, fRootNode.getValidity()); + assertValidationAttempted(ItemPSVI.VALIDATION_NONE, fRootNode + .getValidationAttempted()); + assertElementNull(fRootNode.getElementDeclaration()); + assertAnyType(fRootNode.getTypeDefinition()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/base.xml Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,3 @@ +<?xml version="1.0"?> +<A attr="typeX"> +</A>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/base.xsd Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,74 @@ +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <xsd:element name="A" type="X"/> + + <!-- The purpose of this element is: + a) To have a fixed attribute use + b) To have an attribute with a fixed attribute declaration + c) To have a complex type with simple content and a fixed value + d) To have an element declaration with a fixed value + --> + <xsd:element name="B" fixed="howdy"> + <xsd:complexType> + <xsd:simpleContent> + <xsd:extension base="xsd:string"> + <xsd:attribute ref="fixedAttr" use="required" fixed="hello"/> + </xsd:extension> + </xsd:simpleContent> + </xsd:complexType> + </xsd:element> + + <xsd:element name="D" type="xsd:string" fixed="hey"/> + + <xsd:attribute name="attr" type="xsd:string"/> + + <xsd:attribute name="unparsedEntityAttr" type="xsd:ENTITIES"/> + + <xsd:attribute name="fixedAttr" type="xsd:string" fixed="hello"/> + + <xsd:complexType name="X"> + <xsd:sequence> + <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + <xsd:attribute ref="attr"/> + <xsd:attribute ref="unparsedEntityAttr"/> + </xsd:complexType> + + <xsd:complexType name="Y"> + <xsd:complexContent> + <xsd:restriction base="X"> + <xsd:sequence> + <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + <xsd:attribute ref="attr" fixed="typeY"/> + <xsd:attribute ref="unparsedEntityAttr" use="prohibited"/> + </xsd:restriction> + </xsd:complexContent> + </xsd:complexType> + + <!-- Z is the same as X, but is not derived from X. --> + <xsd:complexType name="Z"> + <xsd:sequence> + <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + <xsd:attribute ref="attr"/> + <xsd:attribute ref="unparsedEntityAttr"/> + </xsd:complexType> + + <xsd:complexType name="idType"> + <xsd:complexContent> + <xsd:extension base="X"> + <xsd:attribute name="idAttr" type="xsd:ID"/> + </xsd:extension> + </xsd:complexContent> + </xsd:complexType> + + <xsd:complexType name="idrefType"> + <xsd:complexContent> + <xsd:extension base="X"> + <xsd:attribute name="idrefAttr" type="xsd:IDREF"/> + </xsd:extension> + </xsd:complexContent> + </xsd:complexType> + +</xsd:schema>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/fixedAttr.xml Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,5 @@ +<?xml version="1.0"?> +<A> + <B fixedAttr="hello">howdy</B> + <D>hey</D> +</A>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/idIdref.xml Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<A xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <A xsi:type="idType" idAttr="ONE"/> + <A xsi:type="idType" idAttr="ONE"/> + <A xsi:type="idrefType" idrefAttr="TWO"/> +</A>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/idc.xml Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<itemList> + <item uniqueAttr="ONE">1</item> + <item uniqueAttr="ONE">2</item> + <item uniqueAttr="TWO">2</item> + <itemRef>3</itemRef> +</itemList>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/idc.xsd Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,41 @@ +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <xsd:element name="itemList" type="itemListType"> + <xsd:unique name="itemAttr"> + <xsd:selector xpath="item"/> + <xsd:field xpath="@uniqueAttr"/> + </xsd:unique> + + <xsd:key name="itemValueKey"> + <xsd:selector xpath="item"/> + <xsd:field xpath="."/> + </xsd:key> + + <xsd:keyref name="itemKeyRef" refer="itemValueKey"> + <xsd:selector xpath="itemRef"/> + <xsd:field xpath="."/> + </xsd:keyref> + </xsd:element> + + <xsd:element name="item" type="itemType"/> + + <xsd:attribute name="uniqueAttr" type="xsd:string"/> + + <xsd:attribute name="unparsedEntityAttr" type="xsd:ENTITIES"/> + + <xsd:complexType name="itemListType"> + <xsd:sequence> + <xsd:element ref="item" maxOccurs="unbounded"/> + <xsd:element name="itemRef" type="xsd:string" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="itemType"> + <xsd:simpleContent> + <xsd:extension base="xsd:string"> + <xsd:attribute ref="uniqueAttr" use="required"/> + </xsd:extension> + </xsd:simpleContent> + </xsd:complexType> + +</xsd:schema>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/otherNamespace.xml Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<unit:A xmlns:unit="xslt.unittests" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="xslt.unittests otherNamespace.xsd" + attr="typeX"> +</unit:A>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/otherNamespace.xsd Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,18 @@ +<xsd:schema + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:unit="xslt.unittests" + targetNamespace="xslt.unittests"> + + <xsd:import schemaLocation="base.xsd"/> + + <xsd:element name="A" type="unit:W"/> + + <xsd:complexType name="W"> + <xsd:sequence> + <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + <xsd:attribute ref="attr"/> + <xsd:attribute ref="unparsedEntityAttr"/> + </xsd:complexType> + +</xsd:schema>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/unparsedEntity.dtd Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,3 @@ +<!NOTATION myNotation SYSTEM "somethingElse" > +<!ENTITY myUnparsedEntity SYSTEM "something" NDATA myNotation > +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/unparsedEntity.xml Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<!DOCTYPE personnel SYSTEM "unparsedEntity.dtd"> +<A attr="blah" unparsedEntityAttr="myUnparsedEntity"> +</A>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/xsitype_A_A.xml Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<A attr="typeY" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:type="Y"> + <A attr="typeY" xsi:type="Y"/> +</A>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/xsitype_A_C.xml Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<A attr="typeY" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:type="Y"> + <C attr="typeY" xsi:type="Y"/> +</A>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/xsitype_C_A.xml Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<C attr="typeY" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:type="Y"> + <A attr="typeY" xsi:type="Y"/> +</C>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/xsitype_C_AC.xml Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<C attr="typeY" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:type="Y"> + <A attr="typeY" xsi:type="Y"/> + <C attr="typeY" xsi:type="Y"/> +</C>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/xsitype_C_C.xml Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<C attr="typeY" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:type="Y"> + <C attr="typeY" xsi:type="Y"/> +</C>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/testng/validation/8037819/xsitype_C_CA.xml Fri Aug 29 11:59:34 2014 -0700 @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<C attr="typeY" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:type="Y"> + <C attr="typeY" xsi:type="Y"/> + <A attr="typeY" xsi:type="Y"/> +</C>