OpenJDK / portola / portola
changeset 27830:85b0d46b0104
8043084: XML JAXP unittest co-location
Reviewed-by: joehw, dfuchs
Contributed-by: frank.yuan@oracle.com
line wrap: on
line diff
--- a/jaxp/test/TEST.ROOT Wed Jul 05 20:07:55 2017 +0200 +++ b/jaxp/test/TEST.ROOT Tue Nov 18 12:01:27 2014 -0800 @@ -1,3 +1,6 @@ # This file identifies the root of the test-suite hierarchy. # It also contains test-suite configuration information. +# Tests that must run in othervm mode +othervm.dirs=javax/xml/jaxp/unittest +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/TEST.properties Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,3 @@ +# jaxp test uses TestNG +TestNG.dirs = unittest +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/common/Bug6350682.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.common; + +import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.TransformerFactoryConfigurationError; + +import org.testng.Assert; +import org.testng.annotations.Test; + +/* + * @bug 6350682 + * @summary Test SAXParserFactory and TransformerFactory can newInstance when setContextClassLoader(null). + */ +public class Bug6350682 { + + @Test + public void testSAXParserFactory() { + try { + Thread.currentThread().setContextClassLoader(null); + if (Bug6350682.class.getClassLoader() == null) + System.out.println("this class loader is NULL"); + else + System.out.println("this class loader is NOT NULL"); + SAXParserFactory factory = SAXParserFactory.newInstance(); + Assert.assertTrue(factory != null, "Failed to get an instance of a SAXParserFactory"); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail("Exception occured: " + e.getMessage()); + } + } + + @Test + public void testTransformerFactory() { + try { + Thread.currentThread().setContextClassLoader(null); + TransformerFactory factory = TransformerFactory.newInstance(); + Assert.assertTrue(factory != null, "Failed to get an instance of a TransformerFactory"); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail("Exception occured: " + e.getMessage()); + } catch (TransformerFactoryConfigurationError error) { + error.printStackTrace(); + Assert.fail(error.toString()); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/common/Bug6723276Test.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.common; + +import org.testng.annotations.Test; +import org.testng.Assert; +import java.net.URL; +import java.net.URLClassLoader; + +import javax.xml.parsers.SAXParserFactory; + +/* + * @bug 6723276 + * @summary Test JAXP class can be loaded by bootstrap classloader. + */ +public class Bug6723276Test { + + @Test + public void test1() { + try { + SAXParserFactory.newInstance(); + } catch (Exception e) { + if (e.getMessage().indexOf("org.apache.xerces.jaxp.SAXParserFactoryImpl not found") > 0) { + Assert.fail(e.getMessage()); + } + } + } + + @Test + public void test2() { + try { + System.out.println(Thread.currentThread().getContextClassLoader()); + System.out.println(ClassLoader.getSystemClassLoader().getParent()); + Thread.currentThread().setContextClassLoader(new URLClassLoader(new URL[0], ClassLoader.getSystemClassLoader().getParent())); + SAXParserFactory.newInstance(); + } catch (Exception e) { + if (e.getMessage().indexOf("org.apache.xerces.jaxp.SAXParserFactoryImpl not found") > 0) { + Assert.fail(e.getMessage()); + } + } + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/common/Bug6941169.xml Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,10 @@ +<?xml version="1.0"?> +<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Bug6941169.xsd"> + <fooTest> + test + + + + information + </fooTest> +</root>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/common/Bug6941169.xsd Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,11 @@ +<?xml version="1.0"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <xs:element name="root"> + <xs:complexType> + <xs:sequence> + <xs:element name="fooTest" type="xs:anySimpleType" fixed="test information"/> + </xs:sequence> + </xs:complexType> + </xs:element> +</xs:schema> +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/common/Bug6941169Test.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,501 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.common; + +import java.io.InputStream; +import java.io.StringWriter; +import java.security.AllPermission; +import java.security.Permission; +import java.security.Permissions; + +import javax.xml.XMLConstants; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.sax.SAXSource; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.Validator; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathFactory; + +import org.testng.Assert; +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; + +/* + * @bug 6941169 + * @summary Test use-service-mechanism feature. + */ +public class Bug6941169Test { + static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; + static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource"; + + private static final String DOM_FACTORY_ID = "javax.xml.parsers.DocumentBuilderFactory"; + private static final String SAX_FACTORY_ID = "javax.xml.parsers.SAXParserFactory"; + + // impl specific feature + final String ORACLE_FEATURE_SERVICE_MECHANISM = "http://www.oracle.com/feature/use-service-mechanism"; + + static String _xml = Bug6941169Test.class.getResource("Bug6941169.xml").getPath(); + static String _xsd = Bug6941169Test.class.getResource("Bug6941169.xsd").getPath(); + + @Test + public void testValidation_SAX_withoutServiceMech() { + System.out.println("Validation using SAX Source; Service mechnism is turned off; SAX Impl should be the default:"); + InputSource is = new InputSource(Bug6941169Test.class.getResourceAsStream("Bug6941169.xml")); + SAXSource ss = new SAXSource(is); + System.setProperty(SAX_FACTORY_ID, "MySAXFactoryImpl"); + long start = System.currentTimeMillis(); + try { + SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + factory.setFeature(ORACLE_FEATURE_SERVICE_MECHANISM, false); + Schema schema = factory.newSchema(new StreamSource(_xsd)); + Validator validator = schema.newValidator(); + validator.validate(ss, null); + } catch (Exception e) { + // e.printStackTrace(); + String error = e.getMessage(); + if (error.indexOf("javax.xml.parsers.FactoryConfigurationError: Provider MySAXFactoryImpl not found") > 0) { + Assert.fail(e.getMessage()); + } else { + System.out.println("Default impl is used"); + } + + // System.out.println(e.getMessage()); + + } + long end = System.currentTimeMillis(); + double elapsedTime = ((end - start)); + System.out.println("Time elapsed: " + elapsedTime); + System.clearProperty(SAX_FACTORY_ID); + } + + @Test + public void testValidation_SAX_withServiceMech() { + System.out.println("Validation using SAX Source. Using service mechnism (by default) to find SAX Impl:"); + InputSource is = new InputSource(Bug6941169Test.class.getResourceAsStream("Bug6941169.xml")); + SAXSource ss = new SAXSource(is); + System.setProperty(SAX_FACTORY_ID, "MySAXFactoryImpl"); + long start = System.currentTimeMillis(); + try { + SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + Schema schema = factory.newSchema(new StreamSource(_xsd)); + Validator validator = schema.newValidator(); + validator.validate(ss, null); + Assert.fail("User impl MySAXFactoryImpl should be used."); + } catch (Exception e) { + String error = e.getMessage(); + if (error.indexOf("javax.xml.parsers.FactoryConfigurationError: Provider MySAXFactoryImpl not found") > 0) { + // expected + } + // System.out.println(e.getMessage()); + + } + long end = System.currentTimeMillis(); + double elapsedTime = ((end - start)); + System.out.println("Time elapsed: " + elapsedTime); + System.clearProperty(SAX_FACTORY_ID); + } + + @Test + public void testValidation_SAX_withSM() { + System.out.println("Validation using SAX Source with security manager:"); + InputSource is = new InputSource(Bug6941169Test.class.getResourceAsStream("Bug6941169.xml")); + SAXSource ss = new SAXSource(is); + System.setProperty(SAX_FACTORY_ID, "MySAXFactoryImpl"); + Permissions granted = new java.security.Permissions(); + granted.add(new AllPermission()); + System.setSecurityManager(new MySM(granted)); + + long start = System.currentTimeMillis(); + try { + SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + factory.setFeature(ORACLE_FEATURE_SERVICE_MECHANISM, false); + Schema schema = factory.newSchema(new StreamSource(_xsd)); + Validator validator = schema.newValidator(); + validator.validate(ss, null); + } catch (Exception e) { + String error = e.getMessage(); + if (error.indexOf("javax.xml.parsers.FactoryConfigurationError: Provider MySAXFactoryImpl not found") > 0) { + Assert.fail(e.getMessage()); + } else { + System.out.println("Default impl is used"); + } + + // System.out.println(e.getMessage()); + + } finally { + System.clearProperty(SAX_FACTORY_ID); + System.setSecurityManager(null); + } + long end = System.currentTimeMillis(); + double elapsedTime = ((end - start)); + System.out.println("Time elapsed: " + elapsedTime); + System.setSecurityManager(null); + + } + + @Test + public void testTransform_DOM_withoutServiceMech() { + System.out.println("Transform using DOM Source; Service mechnism is turned off; Default DOM Impl should be the default:"); + DOMSource domSource = new DOMSource(); + domSource.setSystemId(_xml); + + // DOMSource domSource = new + // DOMSource(getDocument(Bug6941169Test.class.getResourceAsStream("Bug6941169.xml"))); + System.setProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl"); + long start = System.currentTimeMillis(); + try { + TransformerFactory factory = TransformerFactory.newInstance(); + factory.setFeature(ORACLE_FEATURE_SERVICE_MECHANISM, false); + + Transformer t = factory.newTransformer(); + + StringWriter result = new StringWriter(); + StreamResult streamResult = new StreamResult(result); + t.transform(domSource, streamResult); + System.out.println("Writing to " + result.toString()); + + } catch (Exception e) { + // e.printStackTrace(); + String error = e.getMessage(); + if (error.indexOf("Provider MyDOMFactoryImpl not found") > 0) { + Assert.fail(e.getMessage()); + } else { + System.out.println("Default impl is used"); + } + + // System.out.println(e.getMessage()); + + } catch (Error e) { + // e.printStackTrace(); + String error = e.getMessage(); + if (error.indexOf("Provider MyDOMFactoryImpl not found") > 0) { + Assert.fail(e.getMessage()); + } else { + System.out.println("Default impl is used"); + } + + // System.out.println(e.getMessage()); + + } + + long end = System.currentTimeMillis(); + double elapsedTime = ((end - start)); + System.out.println("Time elapsed: " + elapsedTime); + System.clearProperty(DOM_FACTORY_ID); + } + + /** this is by default */ + @Test + public void testTransform_DOM_withServiceMech() { + System.out.println("Transform using DOM Source; By default, the factory uses services mechanism to look up impl:"); + DOMSource domSource = new DOMSource(); + domSource.setSystemId(_xml); + + // DOMSource domSource = new + // DOMSource(getDocument(Bug6941169Test.class.getResourceAsStream("Bug6941169.xml"))); + System.setProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl"); + long start = System.currentTimeMillis(); + try { + TransformerFactory factory = TransformerFactory.newInstance(); + Transformer t = factory.newTransformer(); + + StringWriter result = new StringWriter(); + StreamResult streamResult = new StreamResult(result); + t.transform(domSource, streamResult); + System.out.println("Writing to " + result.toString()); + + Assert.fail("User impl MyDOMFactoryImpl should be used."); + + } catch (Exception e) { + String error = e.getMessage(); + if (error.indexOf("Provider MyDOMFactoryImpl not found") > 0) { + // expected + } + System.out.println(error); + + } catch (Error e) { + String error = e.getMessage(); + if (error.indexOf("Provider MyDOMFactoryImpl not found") > 0) { + // expected + } + System.out.println(error); + + } + + long end = System.currentTimeMillis(); + double elapsedTime = ((end - start)); + System.out.println("Time elapsed: " + elapsedTime); + System.clearProperty(DOM_FACTORY_ID); + } + + @Test + public void testTransform_DOM_withSM() { + System.out.println("Transform using DOM Source; Security Manager is set:"); + DOMSource domSource = new DOMSource(); + domSource.setSystemId(_xml); + + // DOMSource domSource = new + // DOMSource(getDocument(Bug6941169Test.class.getResourceAsStream("Bug6941169.xml"))); + Permissions granted = new java.security.Permissions(); + granted.add(new AllPermission()); + System.setSecurityManager(new MySM(granted)); + System.setProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl"); + long start = System.currentTimeMillis(); + try { + TransformerFactory factory = TransformerFactory.newInstance("com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl", + TransformerFactory.class.getClassLoader()); + Transformer t = factory.newTransformer(); + + StringWriter result = new StringWriter(); + StreamResult streamResult = new StreamResult(result); + t.transform(domSource, streamResult); + System.out.println("Writing to " + result.toString()); + + } catch (Exception e) { + String error = e.getMessage(); + if (error.indexOf("Provider MyDOMFactoryImpl not found") > 0) { + Assert.fail(e.getMessage()); + } else { + System.out.println("Default impl is used"); + } + + // System.out.println(e.getMessage()); + + } catch (Error e) { + String error = e.getMessage(); + if (error.indexOf("Provider MyDOMFactoryImpl not found") > 0) { + Assert.fail(e.getMessage()); + } else { + System.out.println("Default impl is used"); + } + + // System.out.println(e.getMessage()); + + } finally { + System.clearProperty(DOM_FACTORY_ID); + System.setSecurityManager(null); + } + long end = System.currentTimeMillis(); + double elapsedTime = ((end - start)); + System.out.println("Time elapsed: " + elapsedTime); + System.clearProperty(DOM_FACTORY_ID); + } + + @Test + public void testXPath_DOM_withoutServiceMech() { + final String XPATH_EXPRESSION = "/fooTest"; + System.out.println("Evaluate DOM Source; Service mechnism is turned off; Default DOM Impl should be used:"); + Document doc = getDocument(Bug6941169Test.class.getResourceAsStream("Bug6941169.xml")); + System.setProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl"); + long start = System.currentTimeMillis(); + try { + XPathFactory xPathFactory = XPathFactory.newInstance(); + xPathFactory.setFeature(ORACLE_FEATURE_SERVICE_MECHANISM, false); + + XPath xPath = xPathFactory.newXPath(); + + String xPathResult = xPath.evaluate(XPATH_EXPRESSION, doc); + + } catch (Exception e) { + // e.printStackTrace(); + String error = e.getMessage(); + if (error.indexOf("MyDOMFactoryImpl not found") > 0) { + Assert.fail(e.getMessage()); + } else { + System.out.println("Default impl is used"); + } + + // System.out.println(e.getMessage()); + + } catch (Error e) { + // e.printStackTrace(); + String error = e.getMessage(); + if (error.indexOf("MyDOMFactoryImpl not found") > 0) { + Assert.fail(e.getMessage()); + } else { + System.out.println("Default impl is used"); + } + + // System.out.println(e.getMessage()); + + } + + long end = System.currentTimeMillis(); + double elapsedTime = ((end - start)); + System.out.println("Time elapsed: " + elapsedTime); + System.clearProperty(DOM_FACTORY_ID); + } + + @Test + public void testXPath_DOM_withServiceMech() { + final String XPATH_EXPRESSION = "/fooTest"; + System.out.println("Evaluate DOM Source; Service mechnism is on by default; It would try to use MyDOMFactoryImpl:"); + InputStream input = getClass().getResourceAsStream("Bug6941169.xml"); + InputSource source = new InputSource(input); + System.setProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl"); + long start = System.currentTimeMillis(); + try { + XPathFactory xPathFactory = XPathFactory.newInstance(); + + XPath xPath = xPathFactory.newXPath(); + + String xPathResult = xPath.evaluate(XPATH_EXPRESSION, source); + Assert.fail("User impl MyDOMFactoryImpl should be used."); + + } catch (Exception e) { + // e.printStackTrace(); + String error = e.getMessage(); + if (error.indexOf("MyDOMFactoryImpl not found") > 0) { + System.out.println("Tried to locate MyDOMFactoryImpl"); + } else { + Assert.fail(e.getMessage()); + + } + + // System.out.println(e.getMessage()); + + } catch (Error e) { + // e.printStackTrace(); + String error = e.getMessage(); + if (error.indexOf("MyDOMFactoryImpl not found") > 0) { + System.out.println("Tried to locate MyDOMFactoryImpl"); + } else { + Assert.fail(e.getMessage()); + + } + + // System.out.println(e.getMessage()); + + } + + long end = System.currentTimeMillis(); + double elapsedTime = ((end - start)); + System.out.println("Time elapsed: " + elapsedTime); + System.clearProperty(DOM_FACTORY_ID); + } + + @Test + public void testXPath_DOM_withSM() { + final String XPATH_EXPRESSION = "/fooTest"; + System.out.println("Evaluate DOM Source; Security Manager is set:"); + Permissions granted = new java.security.Permissions(); + granted.add(new AllPermission()); + System.setSecurityManager(new MySM(granted)); + InputStream input = getClass().getResourceAsStream("Bug6941169.xml"); + InputSource source = new InputSource(input); + System.setProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl"); + long start = System.currentTimeMillis(); + try { + XPathFactory xPathFactory = XPathFactory.newInstance("http://java.sun.com/jaxp/xpath/dom", + "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl", null); + + XPath xPath = xPathFactory.newXPath(); + + String xPathResult = xPath.evaluate(XPATH_EXPRESSION, source); + System.out.println("Use default impl"); + } catch (Exception e) { + // e.printStackTrace(); + String error = e.getMessage(); + if (error.indexOf("MyDOMFactoryImpl not found") > 0) { + Assert.fail(e.getMessage()); + } else { + System.out.println("Default impl should be used"); + } + + // System.out.println(e.getMessage()); + + } catch (Error e) { + // e.printStackTrace(); + String error = e.getMessage(); + if (error.indexOf("MyDOMFactoryImpl not found") > 0) { + Assert.fail(e.getMessage()); + } else { + System.out.println("Default impl should be used"); + } + + // System.out.println(e.getMessage()); + + } finally { + System.clearProperty(DOM_FACTORY_ID); + System.setSecurityManager(null); + } + long end = System.currentTimeMillis(); + double elapsedTime = ((end - start)); + System.out.println("Time elapsed: " + elapsedTime); + System.clearProperty(DOM_FACTORY_ID); + } + + @Test + public void testSM() { + SecurityManager sm = System.getSecurityManager(); + if (System.getSecurityManager() != null) { + System.out.println("Security manager not cleared: " + sm.toString()); + } else { + System.out.println("Security manager cleared: "); + } + } + + private static Document getDocument(InputStream in) { + + Document document = null; + + try { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); + DocumentBuilder db = dbf.newDocumentBuilder(); + document = db.parse(in); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(e.toString()); + } + + return document; + } + + class MySM extends SecurityManager { + Permissions granted; + + public MySM(Permissions perms) { + granted = perms; + } + + @Override + public void checkPermission(Permission perm) { + if (granted.implies(perm)) { + return; + } + super.checkPermission(perm); + } + + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/common/Bug6979306Test.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.common; + +import org.testng.annotations.Test; + +import com.sun.org.apache.xalan.internal.xslt.EnvironmentCheck; + +/* + * @bug 6979306 + * @summary Test JAXP component version. + */ +public class Bug6979306Test { + + @Test + public void test() { + String[] input = {}; + EnvironmentCheck.main(input); + com.sun.org.apache.xerces.internal.impl.Version.main(input); + com.sun.org.apache.xalan.internal.Version._main(input); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/common/Bug7143711Test.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.common; + +import java.security.AllPermission; +import java.security.Permission; +import java.security.Permissions; + +import javax.xml.XMLConstants; +import javax.xml.transform.TransformerFactory; +import javax.xml.validation.SchemaFactory; +import javax.xml.xpath.XPathFactory; + +import org.testng.Assert; +import org.testng.annotations.Test; + +/* + * @bug 7143711 + * @summary Test set use-service-mechanism shall not override what's set by the constructor in secure mode. + */ +public class Bug7143711Test { + static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; + static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource"; + + private static final String DOM_FACTORY_ID = "javax.xml.parsers.DocumentBuilderFactory"; + private static final String SAX_FACTORY_ID = "javax.xml.parsers.SAXParserFactory"; + + // impl specific feature + final String ORACLE_FEATURE_SERVICE_MECHANISM = "http://www.oracle.com/feature/use-service-mechanism"; + + @Test + public void testValidation_SAX_withSM() { + System.out.println("Validation using SAX Source with security manager:"); + System.setProperty(SAX_FACTORY_ID, "MySAXFactoryImpl"); + Permissions granted = new java.security.Permissions(); + granted.add(new AllPermission()); + System.setSecurityManager(new MySM(granted)); + + try { + SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + // should not allow + factory.setFeature(ORACLE_FEATURE_SERVICE_MECHANISM, true); + if ((boolean) factory.getFeature(ORACLE_FEATURE_SERVICE_MECHANISM)) { + Assert.fail("should not override in secure mode"); + } + } catch (Exception e) { + Assert.fail(e.getMessage()); + + } finally { + System.clearProperty(SAX_FACTORY_ID); + System.setSecurityManager(null); + } + + System.setSecurityManager(null); + + } + + @Test + public void testTransform_DOM_withSM() { + System.out.println("Transform using DOM Source; Security Manager is set:"); + + Permissions granted = new java.security.Permissions(); + granted.add(new AllPermission()); + System.setSecurityManager(new MySM(granted)); + System.setProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl"); + + try { + TransformerFactory factory = TransformerFactory.newInstance("com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl", + TransformerFactory.class.getClassLoader()); + factory.setFeature(ORACLE_FEATURE_SERVICE_MECHANISM, true); + if (((com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl) factory).useServicesMechnism()) { + Assert.fail("should not override in secure mode"); + } + + } catch (Exception e) { + Assert.fail(e.getMessage()); + } finally { + System.clearProperty(DOM_FACTORY_ID); + System.setSecurityManager(null); + } + + System.clearProperty(DOM_FACTORY_ID); + } + + @Test + public void testXPath_DOM_withSM() { + System.out.println("Evaluate DOM Source; Security Manager is set:"); + Permissions granted = new java.security.Permissions(); + granted.add(new AllPermission()); + System.setSecurityManager(new MySM(granted)); + System.setProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl"); + + try { + XPathFactory xPathFactory = XPathFactory.newInstance("http://java.sun.com/jaxp/xpath/dom", + "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl", null); + xPathFactory.setFeature(ORACLE_FEATURE_SERVICE_MECHANISM, true); + if ((boolean) xPathFactory.getFeature(ORACLE_FEATURE_SERVICE_MECHANISM)) { + Assert.fail("should not override in secure mode"); + } + + } catch (Exception e) { + Assert.fail(e.getMessage()); + } finally { + System.clearProperty(DOM_FACTORY_ID); + System.setSecurityManager(null); + } + + System.clearProperty(DOM_FACTORY_ID); + } + + @Test + public void testSM() { + SecurityManager sm = System.getSecurityManager(); + if (System.getSecurityManager() != null) { + System.out.println("Security manager not cleared: " + sm.toString()); + } else { + System.out.println("Security manager cleared: "); + } + } + + class MySM extends SecurityManager { + Permissions granted; + + public MySM(Permissions perms) { + granted = perms; + } + + @Override + public void checkPermission(Permission perm) { + if (granted.implies(perm)) { + return; + } + super.checkPermission(perm); + } + + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/datatype/Bug6320118.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.datatype; + +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.XMLGregorianCalendar; + +import org.testng.Assert; +import org.testng.annotations.Test; + +/* + * @bug 6320118 + * @summary Test xml datatype XMLGregorianCalendar. + */ +public class Bug6320118 { + + DatatypeFactory df; + + @Test + public void test1() { + try { + df = DatatypeFactory.newInstance(); + } catch (DatatypeConfigurationException e) { + Assert.fail(e.getMessage()); + } + + try { + XMLGregorianCalendar calendar = df.newXMLGregorianCalendar(1970, 1, 1, 24, 0, 0, 0, 0); + } catch (IllegalArgumentException e) { + Assert.fail(e.getMessage()); + } + } + + @Test + public void test2() { + try { + df = DatatypeFactory.newInstance(); + } catch (DatatypeConfigurationException e) { + Assert.fail(e.getMessage()); + } + + try { + XMLGregorianCalendar calendar = df.newXMLGregorianCalendarTime(24, 0, 0, 0); + } catch (IllegalArgumentException e) { + Assert.fail(e.getMessage()); + } + } + + @Test + public void test3() { + try { + df = DatatypeFactory.newInstance(); + } catch (DatatypeConfigurationException e) { + Assert.fail(e.getMessage()); + } + try { + XMLGregorianCalendar calendar = df.newXMLGregorianCalendar(); + // Must fail as other params are not 0 but undefined + calendar.setHour(24); + Assert.fail("test3() - Expected IllegalArgumentException not thrown"); + } catch (IllegalArgumentException e) { + // falls through + } + } + + @Test + public void test4() { + try { + df = DatatypeFactory.newInstance(); + } catch (DatatypeConfigurationException e) { + Assert.fail(e.getMessage()); + } + + try { + XMLGregorianCalendar calendar = df.newXMLGregorianCalendar(); + calendar.setTime(24, 0, 0, 0); + } catch (IllegalArgumentException e) { + Assert.fail(e.getMessage()); + } + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/datatype/Bug6937951Test.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.datatype; + +import org.testng.Assert; +import org.testng.annotations.Test; + +/* + * @bug 6937951 + * @summary Test midnight is same as the start of the next day in XMLGregorianCalendar. + */ +public class Bug6937951Test { + + @Test + public void test() throws DatatypeConfigurationException { + DatatypeFactory dtf = DatatypeFactory.newInstance(); + XMLGregorianCalendar c1 = dtf.newXMLGregorianCalendar("1999-12-31T24:00:00"); + XMLGregorianCalendar c2 = dtf.newXMLGregorianCalendar("2000-01-01T00:00:00"); + System.out.println("c1: " + c1.getYear() + "-" + c1.getMonth() + "-" + c1.getDay() + "T" + c1.getHour()); + System.out.println(c1.equals(c2) ? "pass" : "fail"); // fails + if (!c1.equals(c2)) + Assert.fail("hour 24 needs to be treated as equal to hour 0 of the next day"); + if (c1.getYear() != 2000 && c1.getHour() != 0) + Assert.fail("hour 24 needs to be treated as equal to hour 0 of the next day"); + + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/datatype/Bug6937964Test.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,262 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.datatype; + +import java.math.BigDecimal; +import java.math.BigInteger; + +import javax.xml.namespace.QName; + +import org.testng.Assert; +import org.testng.annotations.Test; + +/* + * @bug 6937964 + * @summary Test Duration is normalized. + */ +public class Bug6937964Test { + /** + * Print debugging to System.err. + */ + private static final boolean DEBUG = false; + /** + * Constant to indicate expected lexical test failure. + */ + private static final String TEST_VALUE_FAIL = "*FAIL*"; + + private static final String FIELD_UNDEFINED = "FIELD_UNDEFINED"; + static final DatatypeConstants.Field[] fields = { DatatypeConstants.YEARS, DatatypeConstants.MONTHS, DatatypeConstants.DAYS, DatatypeConstants.HOURS, + DatatypeConstants.MINUTES, DatatypeConstants.SECONDS }; + + @Test + public void test() throws DatatypeConfigurationException { + DatatypeFactory dtf = DatatypeFactory.newInstance(); + Duration d = dtf.newDurationYearMonth("P20Y15M"); + int years = d.getYears(); + System.out.println(d.getYears() == 21 ? "pass" : "fail"); + } + + @Test + public void testNewDurationYearMonthLexicalRepresentation() throws DatatypeConfigurationException { + DatatypeFactory dtf = DatatypeFactory.newInstance(); + Duration d = dtf.newDurationYearMonth("P20Y15M"); + int years = d.getYears(); + Assert.assertTrue(years == 21, "Return value should be normalized"); + } + + @Test + public void testNewDurationYearMonthMilliseconds() throws DatatypeConfigurationException { + DatatypeFactory dtf = DatatypeFactory.newInstance(); + Duration d = dtf.newDurationYearMonth(671976000000L); + int years = d.getYears(); + System.out.println("Years: " + years); + Assert.assertTrue(years == 21, "Return value should be normalized"); + } + + @Test + public void testNewDurationYearMonthBigInteger() throws DatatypeConfigurationException { + DatatypeFactory dtf = DatatypeFactory.newInstance(); + BigInteger year = new BigInteger("20"); + BigInteger mon = new BigInteger("15"); + Duration d = dtf.newDurationYearMonth(true, year, mon); + int years = d.getYears(); + Assert.assertTrue(years == 21, "Return value should be normalized"); + } + + @Test + public void testNewDurationYearMonthInt() throws DatatypeConfigurationException { + DatatypeFactory dtf = DatatypeFactory.newInstance(); + Duration d = dtf.newDurationYearMonth(true, 20, 15); + int years = d.getYears(); + Assert.assertTrue(years == 21, "Return value should be normalized"); + } + + @Test + public void testNewDurationDayTimeLexicalRepresentation() throws DatatypeConfigurationException { + DatatypeFactory dtf = DatatypeFactory.newInstance(); + Duration d = dtf.newDurationDayTime("P1DT23H59M65S"); + int days = d.getDays(); + Assert.assertTrue(days == 2, "Return value should be normalized"); + } + + @Test + public void testNewDurationDayTimeMilliseconds() throws DatatypeConfigurationException { + DatatypeFactory dtf = DatatypeFactory.newInstance(); + Duration d = dtf.newDurationDayTime(172805000L); + int days = d.getDays(); + Assert.assertTrue(days == 2, "Return value should be normalized"); + } + + @Test + public void testNewDurationDayTimeBigInteger() throws DatatypeConfigurationException { + DatatypeFactory dtf = DatatypeFactory.newInstance(); + BigInteger day = new BigInteger("1"); + BigInteger hour = new BigInteger("23"); + BigInteger min = new BigInteger("59"); + BigInteger sec = new BigInteger("65"); + Duration d = dtf.newDurationDayTime(true, day, hour, min, sec); + int days = d.getDays(); + System.out.println("Days: " + days); + Assert.assertTrue(days == 2, "Return value should be normalized"); + } + + @Test + public void testNewDurationDayTimeInt() throws DatatypeConfigurationException { + DatatypeFactory dtf = DatatypeFactory.newInstance(); + Duration d = dtf.newDurationDayTime(true, 1, 23, 59, 65); + int days = d.getDays(); + System.out.println("Days: " + days); + Assert.assertTrue(days == 2, "Return value should be normalized"); + } + + @Test + public final void testNewDurationYearMonthLexicalRepresentation1() { + + /** + * Lexical test values to test. + */ + final String[] TEST_VALUES_LEXICAL = { "P13M", "P1Y1M", "-P13M", "-P1Y1M", "P1Y", "P1Y", "-P1Y", "-P1Y", "P1Y25M", "P3Y1M", "-P1Y25M", "-P3Y1M" }; + + DatatypeFactory datatypeFactory = null; + try { + datatypeFactory = DatatypeFactory.newInstance(); + } catch (DatatypeConfigurationException datatypeConfigurationException) { + Assert.fail(datatypeConfigurationException.toString()); + } + + if (DEBUG) { + System.err.println("DatatypeFactory created: " + datatypeFactory.toString()); + } + + // test each value + for (int onTestValue = 0; onTestValue < TEST_VALUES_LEXICAL.length; onTestValue = onTestValue + 2) { + + if (DEBUG) { + System.err.println("testing value: \"" + TEST_VALUES_LEXICAL[onTestValue] + "\", expecting: \"" + TEST_VALUES_LEXICAL[onTestValue + 1] + "\""); + } + + try { + Duration duration = datatypeFactory.newDurationYearMonth(TEST_VALUES_LEXICAL[onTestValue]); + + if (DEBUG) { + System.err.println("Duration created: \"" + duration.toString() + "\""); + } + + // was this expected to fail? + if (TEST_VALUES_LEXICAL[onTestValue + 1].equals(TEST_VALUE_FAIL)) { + Assert.fail("the value \"" + TEST_VALUES_LEXICAL[onTestValue] + "\" is invalid yet it created the Duration \"" + duration.toString() + "\""); + } + + // right XMLSchemaType? + // TODO: enable test, it should pass, it fails with Exception(s) + // for now due to a bug + try { + QName xmlSchemaType = duration.getXMLSchemaType(); + if (!xmlSchemaType.equals(DatatypeConstants.DURATION_YEARMONTH)) { + Assert.fail("Duration created with XMLSchemaType of\"" + xmlSchemaType + "\" was expected to be \"" + + DatatypeConstants.DURATION_YEARMONTH + "\" and has the value \"" + duration.toString() + "\""); + } + } catch (IllegalStateException illegalStateException) { + // TODO; this test really should pass + System.err.println("Please fix this bug that is being ignored, for now: " + illegalStateException.getMessage()); + } + + // does it have the right value? + if (!TEST_VALUES_LEXICAL[onTestValue + 1].equals(duration.toString())) { + Assert.fail("Duration created with \"" + TEST_VALUES_LEXICAL[onTestValue] + "\" was expected to be \"" + + TEST_VALUES_LEXICAL[onTestValue + 1] + "\" and has the value \"" + duration.toString() + "\""); + } + + // Duration created with correct value + } catch (Exception exception) { + + if (DEBUG) { + System.err.println("Exception in creating duration: \"" + exception.toString() + "\""); + } + + // was this expected to succed? + if (!TEST_VALUES_LEXICAL[onTestValue + 1].equals(TEST_VALUE_FAIL)) { + Assert.fail("the value \"" + TEST_VALUES_LEXICAL[onTestValue] + "\" is valid yet it failed with \"" + exception.toString() + "\""); + } + // expected failure + } + } + } + + /** + * TCK test failure + */ + @Test + public void testNewDurationDayTime005() { + BigInteger one = new BigInteger("1"); + BigInteger zero = new BigInteger("0"); + BigDecimal bdZero = new BigDecimal("0"); + BigDecimal bdOne = new BigDecimal("1"); + + Object[][] values = { + // lex, isPositive, years, month, days, hours, minutes, seconds + { "P1D", Boolean.TRUE, null, null, one, zero, zero, bdZero }, { "PT1H", Boolean.TRUE, null, null, zero, one, zero, bdZero }, + { "PT1M", Boolean.TRUE, null, null, zero, zero, one, bdZero }, { "PT1.1S", Boolean.TRUE, null, null, zero, zero, zero, bdOne }, + { "-PT1H1.1S", Boolean.FALSE, null, null, zero, one, zero, bdOne }, }; + + StringBuffer result = new StringBuffer(); + DatatypeFactory df = null; + + try { + df = DatatypeFactory.newInstance(); + } catch (DatatypeConfigurationException e) { + Assert.fail(e.toString()); + } + + for (int valueIndex = 0; valueIndex < values.length; ++valueIndex) { + Duration duration = null; + try { + duration = df.newDurationDayTime(values[valueIndex][1].equals(Boolean.TRUE), ((BigInteger) values[valueIndex][4]).intValue(), + ((BigInteger) values[valueIndex][5]).intValue(), ((BigInteger) values[valueIndex][6]).intValue(), + ((BigDecimal) values[valueIndex][7]).intValue()); + } catch (IllegalArgumentException e) { + result.append("; unexpected " + e + " trying to create duration \'" + values[valueIndex][0] + "\'"); + } + if (duration != null) { + if ((duration.getSign() == 1) != values[valueIndex][1].equals(Boolean.TRUE)) { + result.append("; " + values[valueIndex][0] + ": wrong sign " + duration.getSign() + ", expected " + values[valueIndex][1]); + } + for (int i = 0; i < fields.length; ++i) { + Number value = duration.getField(fields[i]); + if ((value != null && values[valueIndex][2 + i] == null) || (value == null && values[valueIndex][2 + i] != null) + || (value != null && !value.equals(values[valueIndex][2 + i]))) { + result.append("; " + values[valueIndex][0] + ": wrong value of the field " + fields[i] + ": \'" + value + "\'" + ", expected \'" + + values[valueIndex][2 + i] + "\'"); + } + } + } + } + + if (result.length() > 0) { + Assert.fail(result.substring(2)); + } + System.out.println("OK"); + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/datatype/Bug7042647Test.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.datatype; + +import java.util.Calendar; +import java.util.GregorianCalendar; + +import org.testng.Assert; +import org.testng.annotations.Test; + +/* + * @bug 7042647 + * @summary Test getFirstDayOfWeek is correct after converting XMLGregorianCalendar to a GregorianCalendar. + */ +public class Bug7042647Test { + + @Test + public void test() throws DatatypeConfigurationException { + XMLGregorianCalendar xmlCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(1970, 1, 1, 0, 0, 0, 0, 0); + GregorianCalendar calendar = xmlCalendar.toGregorianCalendar(); + int firstDayOfWeek = calendar.getFirstDayOfWeek(); + Calendar defaultCalendar = Calendar.getInstance(); + int defaultFirstDayOfWeek = defaultCalendar.getFirstDayOfWeek(); + if (firstDayOfWeek != defaultFirstDayOfWeek) { + Assert.fail("Failed firstDayOfWeek=" + firstDayOfWeek + " != defaultFirstDayOfWeek=" + defaultFirstDayOfWeek); + } else { + System.out.println("Success firstDayOfWeek=" + firstDayOfWeek + " == defaultFirstDayOfWeek=" + defaultFirstDayOfWeek); + } + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/datatype/DatatypeFactoryTest.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,631 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.datatype; + +import java.math.BigDecimal; +import java.math.BigInteger; + +import javax.xml.namespace.QName; + +import org.testng.Assert; +import org.testng.annotations.Test; + +/* + * @summary Test DatatypeFactory. + */ +public class DatatypeFactoryTest { + + private static final boolean DEBUG = false; + + private static final String TEST_VALUE_FAIL = "*FAIL*"; + + private static final String FIELD_UNDEFINED = "FIELD_UNDEFINED"; + + static int parseInt(String value) { + return FIELD_UNDEFINED.equals(value) ? DatatypeConstants.FIELD_UNDEFINED : Integer.parseInt(value); + } + + static BigDecimal parseBigDecimal(String value) { + return FIELD_UNDEFINED.equals(value) ? null : new BigDecimal(value); + } + + static BigInteger parseBigInteger(String value) { + return FIELD_UNDEFINED.equals(value) ? null : new BigInteger(value); + } + + @Test + public final void testNewDurationMilliseconds() { + + /* + * to generate millisecond values + * final TimeZone GMT = TimeZone.getTimeZone("GMT"); GregorianCalendar + * gregorianCalendar = new GregorianCalendar(GMT); + * gregorianCalendar.setTimeInMillis(0); + * gregorianCalendar.add(Calendar.HOUR_OF_DAY, 1); + * gregorianCalendar.add(Calendar.MINUTE, 1); + * System.err.println("1 hour, 1 minute = " + + * gregorianCalendar.getTimeInMillis() + " milliseconds"); + */ + + /** + * Millisecond test values to test. + */ + final long[] TEST_VALUES_MILLISECONDS = { 0L, // 0 + 1L, // 1 millisecond + -1L, 1000L, // 1 second + -1000L, 1001L, // 1 second, 1 millisecond + -1001L, 60000L, // 1 minute + -60000L, 61000L, // 1 minute, 1 second + -61000L, 3600000L, // 1 hour + -3600000L, 3660000L, // 1 hour, 1 minute + -3660000L, 86400000L, // 1 day + -86400000L, 90000000L, // 1 day, 1 hour + -90000000L, 2678400000L, // 1 month + -2678400000L, 2764800000L, // 1 month, 1 day + -2764800000L, 31536000000L, // 1 year + -31536000000L, 34214400000L, // 1 year, 1 month + -34214400000L }; + + /** + * Millisecond test value results of test. + */ + final String[] TEST_VALUES_MILLISECONDS_RESULTS = { "P0Y0M0DT0H0M0.000S", // 0 + "P0Y0M0DT0H0M0.001S", // 1 millisecond + "-P0Y0M0DT0H0M0.001S", "P0Y0M0DT0H0M1.000S", // 1 second + "-P0Y0M0DT0H0M1.000S", "P0Y0M0DT0H0M1.001S", // 1 second, 1 + // millisecond + "-P0Y0M0DT0H0M1.001S", "P0Y0M0DT0H1M0.000S", // 1 minute + "-P0Y0M0DT0H1M0.000S", "P0Y0M0DT0H1M1.000S", // 1 minute, 1 + // second + "-P0Y0M0DT0H1M1.000S", "P0Y0M0DT1H0M0.000S", // 1 hour + "-P0Y0M0DT1H0M0.000S", "P0Y0M0DT1H1M0.000S", // 1 hour, 1 minute + "-P0Y0M0DT1H1M0.000S", "P0Y0M1DT0H0M0.000S", // 1 day + "-P0Y0M1DT0H0M0.000S", "P0Y0M1DT1H0M0.000S", // 1 day, 1 hour + "-P0Y0M1DT1H0M0.000S", "P0Y1M0DT0H0M0.000S", // 1 month + "-P0Y1M0DT0H0M0.000S", "P0Y1M1DT0H0M0.000S", // 1 month, 1 day + "-P0Y1M1DT0H0M0.000S", "P1Y0M0DT0H0M0.000S", // 1 year + "-P1Y0M0DT0H0M0.000S", "P1Y1M0DT0H0M0.000S", // 1 year, 1 month + "-P1Y1M0DT0H0M0.000S" }; + + DatatypeFactory datatypeFactory = null; + try { + datatypeFactory = DatatypeFactory.newInstance(); + } catch (DatatypeConfigurationException datatypeConfigurationException) { + Assert.fail(datatypeConfigurationException.toString()); + } + + if (DEBUG) { + System.err.println("DatatypeFactory created: " + datatypeFactory.toString()); + } + + // test each value + for (int onTestValue = 0; onTestValue < TEST_VALUES_MILLISECONDS.length; onTestValue++) { + + if (DEBUG) { + System.err.println("testing value: \"" + TEST_VALUES_MILLISECONDS[onTestValue] + "\", expecting: \"" + + TEST_VALUES_MILLISECONDS_RESULTS[onTestValue] + "\""); + } + + try { + Duration duration = datatypeFactory.newDuration(TEST_VALUES_MILLISECONDS[onTestValue]); + + if (DEBUG) { + System.err.println("Duration created: \"" + duration.toString() + "\""); + } + + // was this expected to fail? + if (TEST_VALUES_MILLISECONDS_RESULTS[onTestValue].equals(TEST_VALUE_FAIL)) { + Assert.fail("the value \"" + TEST_VALUES_MILLISECONDS[onTestValue] + "\" is invalid yet it created the Duration \"" + duration.toString() + + "\""); + } + + // right XMLSchemaType? + QName xmlSchemaType = duration.getXMLSchemaType(); + if (!xmlSchemaType.equals(DatatypeConstants.DURATION)) { + Assert.fail("Duration created with XMLSchemaType of\"" + xmlSchemaType + "\" was expected to be \"" + DatatypeConstants.DURATION + + "\" and has the value \"" + duration.toString() + "\""); + } + + // does it have the right value? + if (!TEST_VALUES_MILLISECONDS_RESULTS[onTestValue].equals(duration.toString())) { + Assert.fail("Duration created with \"" + TEST_VALUES_MILLISECONDS[onTestValue] + "\" was expected to be \"" + + TEST_VALUES_MILLISECONDS_RESULTS[onTestValue] + "\" and has the value \"" + duration.toString() + "\""); + } + + // Duration created with correct value + } catch (Exception exception) { + + if (DEBUG) { + System.err.println("Exception in creating duration: \"" + exception.toString() + "\""); + } + + // was this expected to succed? + if (!TEST_VALUES_MILLISECONDS_RESULTS[onTestValue].equals(TEST_VALUE_FAIL)) { + Assert.fail("the value \"" + TEST_VALUES_MILLISECONDS[onTestValue] + "\" is valid yet it failed with \"" + exception.toString() + "\""); + } + // expected failure + } + } + } + + /** + * Test {@link DatatypeFactory.newDurationYearMonth(String + * lexicalRepresentation)}. + */ + @Test + public final void testNewDurationYearMonthLexicalRepresentation() { + + /** + * Lexical test values to test. + */ + final String[] TEST_VALUES_LEXICAL = { null, TEST_VALUE_FAIL, "", TEST_VALUE_FAIL, "-", TEST_VALUE_FAIL, "P", TEST_VALUE_FAIL, "-P", TEST_VALUE_FAIL, + "P1D", TEST_VALUE_FAIL, "P1Y1M1D", TEST_VALUE_FAIL, "P1M", "P1M", "-P1M", "-P1M", "P1Y", "P1Y", "-P1Y", "-P1Y", "P1Y1M", "P1Y1M", "-P1Y1M", + "-P1Y1M" }; + + DatatypeFactory datatypeFactory = null; + try { + datatypeFactory = DatatypeFactory.newInstance(); + } catch (DatatypeConfigurationException datatypeConfigurationException) { + Assert.fail(datatypeConfigurationException.toString()); + } + + if (DEBUG) { + System.err.println("DatatypeFactory created: " + datatypeFactory.toString()); + } + + // test each value + for (int onTestValue = 0; onTestValue < TEST_VALUES_LEXICAL.length; onTestValue = onTestValue + 2) { + + if (DEBUG) { + System.err.println("testing value: \"" + TEST_VALUES_LEXICAL[onTestValue] + "\", expecting: \"" + TEST_VALUES_LEXICAL[onTestValue + 1] + "\""); + } + + try { + Duration duration = datatypeFactory.newDurationYearMonth(TEST_VALUES_LEXICAL[onTestValue]); + + if (DEBUG) { + System.err.println("Duration created: \"" + duration.toString() + "\""); + } + + // was this expected to fail? + if (TEST_VALUES_LEXICAL[onTestValue + 1].equals(TEST_VALUE_FAIL)) { + Assert.fail("the value \"" + TEST_VALUES_LEXICAL[onTestValue] + "\" is invalid yet it created the Duration \"" + duration.toString() + "\""); + } + + // right XMLSchemaType? + // TODO: enable test, it should pass, it fails with Exception(s) + // for now due to a bug + try { + QName xmlSchemaType = duration.getXMLSchemaType(); + if (!xmlSchemaType.equals(DatatypeConstants.DURATION_YEARMONTH)) { + Assert.fail("Duration created with XMLSchemaType of\"" + xmlSchemaType + "\" was expected to be \"" + + DatatypeConstants.DURATION_YEARMONTH + "\" and has the value \"" + duration.toString() + "\""); + } + } catch (IllegalStateException illegalStateException) { + // TODO; this test really should pass + System.err.println("Please fix this bug that is being ignored, for now: " + illegalStateException.getMessage()); + } + + // does it have the right value? + if (!TEST_VALUES_LEXICAL[onTestValue + 1].equals(duration.toString())) { + Assert.fail("Duration created with \"" + TEST_VALUES_LEXICAL[onTestValue] + "\" was expected to be \"" + + TEST_VALUES_LEXICAL[onTestValue + 1] + "\" and has the value \"" + duration.toString() + "\""); + } + + // Duration created with correct value + } catch (Exception exception) { + + if (DEBUG) { + System.err.println("Exception in creating duration: \"" + exception.toString() + "\""); + } + + // was this expected to succed? + if (!TEST_VALUES_LEXICAL[onTestValue + 1].equals(TEST_VALUE_FAIL)) { + Assert.fail("the value \"" + TEST_VALUES_LEXICAL[onTestValue] + "\" is valid yet it failed with \"" + exception.toString() + "\""); + } + // expected failure + } + } + } + + /** + * Test {@link DatatypeFactory.newDurationYearMonth(long milliseconds)}. + * + */ + @Test + public final void testNewDurationYearMonthMilliseconds() { + + /** + * Millisecond test values to test. + */ + final long[] TEST_VALUES_MILLISECONDS = { 0L, 1L, -1L, 2678400000L, // 31 + // days, + // e.g. + // 1 + // month + -2678400000L, 5270400000L, // 61 days, e.g. 2 months + -5270400000L, 31622400000L, // 366 days, e.g. 1 year + -31622400000L, 34300800000L, // 397 days, e.g. 1 year, 1 month + -34300800000L }; + + /** + * Millisecond test value results of test. + */ + final String[] TEST_VALUES_MILLISECONDS_RESULTS = { "P0Y0M", "P0Y0M", "P0Y0M", "P0Y1M", "-P0Y1M", "P0Y2M", "-P0Y2M", "P1Y0M", "-P1Y0M", "P1Y1M", + "-P1Y1M" }; + + DatatypeFactory datatypeFactory = null; + try { + datatypeFactory = DatatypeFactory.newInstance(); + } catch (DatatypeConfigurationException datatypeConfigurationException) { + Assert.fail(datatypeConfigurationException.toString()); + } + + if (DEBUG) { + System.err.println("DatatypeFactory created: " + datatypeFactory.toString()); + } + + // test each value + for (int onTestValue = 0; onTestValue < TEST_VALUES_MILLISECONDS.length; onTestValue++) { + + if (DEBUG) { + System.err.println("testing value: \"" + TEST_VALUES_MILLISECONDS[onTestValue] + "\", expecting: \"" + + TEST_VALUES_MILLISECONDS_RESULTS[onTestValue] + "\""); + } + + try { + Duration duration = datatypeFactory.newDurationYearMonth(TEST_VALUES_MILLISECONDS[onTestValue]); + + if (DEBUG) { + System.err.println("Duration created: \"" + duration.toString() + "\""); + } + + // was this expected to fail? + if (TEST_VALUES_MILLISECONDS_RESULTS[onTestValue].equals(TEST_VALUE_FAIL)) { + Assert.fail("the value \"" + TEST_VALUES_MILLISECONDS[onTestValue] + "\" is invalid yet it created the Duration \"" + duration.toString() + + "\""); + } + + // right XMLSchemaType? + QName xmlSchemaType = duration.getXMLSchemaType(); + if (!xmlSchemaType.equals(DatatypeConstants.DURATION_YEARMONTH)) { + Assert.fail("Duration created with XMLSchemaType of\"" + xmlSchemaType + "\" was expected to be \"" + DatatypeConstants.DURATION_YEARMONTH + + "\" and has the value \"" + duration.toString() + "\""); + } + + // does it have the right value? + if (!TEST_VALUES_MILLISECONDS_RESULTS[onTestValue].equals(duration.toString())) { + Assert.fail("Duration created with \"" + TEST_VALUES_MILLISECONDS[onTestValue] + "\" was expected to be \"" + + TEST_VALUES_MILLISECONDS_RESULTS[onTestValue] + "\" and has the value \"" + duration.toString() + "\""); + } + + // only YEAR & MONTH should have values + int days = duration.getDays(); + int hours = duration.getHours(); + int minutes = duration.getMinutes(); + if (days != 0 || hours != 0 || minutes != 0) { + Assert.fail("xdt:yearMonthDuration created without discarding remaining milliseconds: " + " days = " + days + ", hours = " + hours + + ", minutess = " + minutes); + } + + // Duration created with correct values + } catch (Exception exception) { + + if (DEBUG) { + System.err.println("Exception in creating duration: \"" + exception.toString() + "\""); + } + + // was this expected to succed? + if (!TEST_VALUES_MILLISECONDS_RESULTS[onTestValue].equals(TEST_VALUE_FAIL)) { + Assert.fail("the value \"" + TEST_VALUES_MILLISECONDS[onTestValue] + "\" is valid yet it failed with \"" + exception.toString() + "\""); + } + // expected failure + } + } + } + + /** + * Test {@link DatatypeFactory.newDurationDayTime(long milliseconds)}. + */ + @Test + public final void testNewDurationDayTime() { + + /** + * Millisecond test values to test. + */ + final long[] TEST_VALUES_MILLISECONDS = { 0L, 1L, -1L, 2678400000L, // 31 + // days, + // e.g. + // 1 + // month + -2678400000L, 5270400000L, // 61 days, e.g. 2 months + -5270400000L, 31622400000L, // 366 days, e.g. 1 year + -31622400000L, 34300800000L, // 397 days, e.g. 1 year, 1 month + -34300800000L }; + + /** + * Millisecond test value results of test. + */ + final String[] TEST_VALUES_MILLISECONDS_RESULTS = { "P0Y0M0DT0H0M0.000S", "P0Y0M0DT0H0M0.001S", "-P0Y0M0DT0H0M0.001S", "P0Y1M", "-P0Y1M", "P0Y2M", + "-P0Y2M", "P1Y0M", "-P1Y0M", "P1Y1M", "-P1Y1M" }; + + DatatypeFactory datatypeFactory = null; + try { + datatypeFactory = DatatypeFactory.newInstance(); + } catch (DatatypeConfigurationException datatypeConfigurationException) { + Assert.fail(datatypeConfigurationException.toString()); + } + + if (DEBUG) { + System.err.println("DatatypeFactory created: " + datatypeFactory.toString()); + } + + // test each value + for (int onTestValue = 0; onTestValue < TEST_VALUES_MILLISECONDS.length; onTestValue++) { + + if (DEBUG) { + System.err.println("testing value: \"" + TEST_VALUES_MILLISECONDS[onTestValue] + "\", expecting: \"" + + TEST_VALUES_MILLISECONDS_RESULTS[onTestValue] + "\""); + } + + try { + Duration duration = datatypeFactory.newDurationDayTime(TEST_VALUES_MILLISECONDS[onTestValue]); + + if (DEBUG) { + System.err.println("Duration created: \"" + duration.toString() + "\""); + } + + // was this expected to fail? + if (TEST_VALUES_MILLISECONDS_RESULTS[onTestValue].equals(TEST_VALUE_FAIL)) { + Assert.fail("the value \"" + TEST_VALUES_MILLISECONDS[onTestValue] + "\" is invalid yet it created the Duration \"" + duration.toString() + + "\""); + } + + // does it have the right value? + if (!TEST_VALUES_MILLISECONDS_RESULTS[onTestValue].equals(duration.toString())) { + // TODO: this is bug that should be fixed + if (false) { + Assert.fail("Duration created with \"" + TEST_VALUES_MILLISECONDS[onTestValue] + "\" was expected to be \"" + + TEST_VALUES_MILLISECONDS_RESULTS[onTestValue] + "\" and has the value \"" + duration.toString() + "\""); + } else { + System.err.println("Please fix this bug: " + "Duration created with \"" + TEST_VALUES_MILLISECONDS[onTestValue] + + "\" was expected to be \"" + TEST_VALUES_MILLISECONDS_RESULTS[onTestValue] + "\" and has the value \"" + duration.toString() + + "\""); + } + } + + // only day, hour, minute, and second should have values + QName xmlSchemaType = duration.getXMLSchemaType(); + int years = duration.getYears(); + int months = duration.getMonths(); + + if (!xmlSchemaType.equals(DatatypeConstants.DURATION_DAYTIME) || years != 0 || months != 0) { + // TODO: this is bug that should be fixed + if (false) { + Assert.fail("xdt:dayTimeDuration created without discarding remaining milliseconds: " + " XMLSchemaType = " + xmlSchemaType + + ", years = " + years + ", months = " + months); + } else { + System.err.println("Please fix this bug: " + "xdt:dayTimeDuration created without discarding remaining milliseconds: " + + " XMLSchemaType = " + xmlSchemaType + ", years = " + years + ", months = " + months); + } + } + + // Duration created with correct values + } catch (Exception exception) { + + if (DEBUG) { + System.err.println("Exception in creating duration: \"" + exception.toString() + "\""); + } + + // was this expected to succed? + if (!TEST_VALUES_MILLISECONDS_RESULTS[onTestValue].equals(TEST_VALUE_FAIL)) { + Assert.fail("the value \"" + TEST_VALUES_MILLISECONDS[onTestValue] + "\" is valid yet it failed with \"" + exception.toString() + "\""); + } + // expected failure + } + } + } + + /** + * Test {@link DatatypeFactory.newXMLGregorianCalendar(String + * lexicalRepresentation)}. + */ + @Test + public final void testNewXMLGregorianCalendarLexicalRepresentation() { + + /** + * Lexical test values to test. + */ + final String[] TEST_VALUES_LEXICAL = { null, TEST_VALUE_FAIL, "", TEST_VALUE_FAIL, "---01", "---01", // gDay + "---01Z", "---01Z", // gDay, UTC + "---01-08:00", "---01-08:00", // gDay, PDT + "--01--", TEST_VALUE_FAIL, // gMonth pre errata, --MM--(z?) + "--01", "--01", // gMonth + "--01Z", "--01Z", // gMonth, UTC + "--01-08:00", "--01-08:00", // gMonth, PDT + "--01-01", "--01-01", // gMonthDay + "--01-01Z", "--01-01Z", // gMonthDay, UTC + "--01-01-08:00", "--01-01-08:00" // gMonthDay, PDT + }; + + // get a DatatypeFactory + DatatypeFactory datatypeFactory = null; + try { + datatypeFactory = DatatypeFactory.newInstance(); + } catch (DatatypeConfigurationException datatypeConfigurationException) { + Assert.fail(datatypeConfigurationException.toString()); + } + + if (DEBUG) { + System.err.println("DatatypeFactory created: " + datatypeFactory.toString()); + } + + // test each value + for (int onTestValue = 0; onTestValue < TEST_VALUES_LEXICAL.length; onTestValue = onTestValue + 2) { + + if (DEBUG) { + System.err.println("testing value: \"" + TEST_VALUES_LEXICAL[onTestValue] + "\", expecting: \"" + TEST_VALUES_LEXICAL[onTestValue + 1] + "\""); + } + + try { + XMLGregorianCalendar xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar(TEST_VALUES_LEXICAL[onTestValue]); + + if (DEBUG) { + System.err.println("XMLGregorianCalendar created: \"" + xmlGregorianCalendar.toString() + "\""); + } + + // was this expected to fail? + if (TEST_VALUES_LEXICAL[onTestValue + 1].equals(TEST_VALUE_FAIL)) { + Assert.fail("the value \"" + TEST_VALUES_LEXICAL[onTestValue] + "\" is invalid yet it created the XMLGregorianCalendar \"" + + xmlGregorianCalendar.toString() + "\""); + } + + // does it have the right value? + if (!TEST_VALUES_LEXICAL[onTestValue + 1].equals(xmlGregorianCalendar.toString())) { + Assert.fail("XMLGregorianCalendar created with \"" + TEST_VALUES_LEXICAL[onTestValue] + "\" was expected to be \"" + + TEST_VALUES_LEXICAL[onTestValue + 1] + "\" and has the value \"" + xmlGregorianCalendar.toString() + "\""); + } + + // XMLGregorianCalendar created with correct value + } catch (Exception exception) { + + if (DEBUG) { + System.err.println("Exception in creating XMLGregorianCalendar: \"" + exception.toString() + "\""); + } + + // was this expected to succed? + if (!TEST_VALUES_LEXICAL[onTestValue + 1].equals(TEST_VALUE_FAIL)) { + Assert.fail("the value \"" + TEST_VALUES_LEXICAL[onTestValue] + "\" is valid yet it failed with \"" + exception.toString() + "\""); + } + // expected failure + } + } + } + + /** + * Test {@link DatatypeFactory.newXMLGregorianCalendar( BigInteger year, int + * month, int day, int hour, int minute, int second, BigDecimal + * fractionalSecond, int timezone)} and + * DatatypeFactory.newXMLGregorianCalendar( int year, int month, int day, + * int hour, int minute, int second, int fractionalSecond, int timezone)} . + */ + @Test + public final void testNewXMLGregorianCalendarYearMonthDayHourMinuteSecondFractionalSecondTimezone() { + + final String[][] invalidDates = { + { "1970", "-1", "1", "0", "0", "0", "0", "0" }, + { "1970", "0", "1", "0", "0", "0", "0", "0" }, + { "1970", "13", "1", "0", "0", "0", "0", "0" }, + { "1970", "1", "-1", "0", "0", "0", "0", "0" }, + { "1970", "1", "0", "0", "0", "0", "0", "0" }, + { "1970", "1", "32", "0", "0", "0", "0", "0" }, + { "1970", "1", "1", "-1", "0", "0", "0", "0" }, + // valid per Schema Errata: + // http://www.w3.org/2001/05/xmlschema-errata#e2-45 + // {"1970", "1", "1", "24", "0", "0", "0", "0" } + // put in a repeat value to preserve offsets & TCK tests + { "1970", "1", "1", "0", "-1", "0", "0", "0" }, { "1970", "1", "1", "0", "-1", "0", "0", "0" }, { "1970", "1", "1", "0", "60", "0", "0", "0" }, + { "1970", "1", "1", "0", "0", "-1", "0", "0" }, { "1970", "1", "1", "0", "0", "61", "0", "0" }, + { "1970", "1", "1", "0", "0", "0", "-0.000001", "0" }, { "1970", "1", "1", "0", "0", "0", "1.0001", "0" }, + { "1970", "1", "1", "0", "0", "0", "0", "841" }, { "1970", "1", "1", "0", "0", "0", "0", "-841" }, }; + + // get a DatatypeFactory + DatatypeFactory datatypeFactory = null; + try { + datatypeFactory = DatatypeFactory.newInstance(); + } catch (DatatypeConfigurationException datatypeConfigurationException) { + Assert.fail(datatypeConfigurationException.toString()); + } + + if (DEBUG) { + System.err.println("DatatypeFactory created: " + datatypeFactory.toString()); + } + + // test values, expect failure + for (int valueIndex = 0; valueIndex < invalidDates.length; ++valueIndex) { + + try { + + if (DEBUG) { + System.err.println("testing DatatypeFactory.newXMLGregorianCalendar(" + invalidDates[valueIndex][0] + ", " + invalidDates[valueIndex][1] + + ", " + invalidDates[valueIndex][2] + ", " + invalidDates[valueIndex][3] + ", " + invalidDates[valueIndex][4] + ", " + + invalidDates[valueIndex][5] + ", " + invalidDates[valueIndex][6] + ", " + invalidDates[valueIndex][7] + ")"); + } + + XMLGregorianCalendar xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar(parseBigInteger(invalidDates[valueIndex][0]), + parseInt(invalidDates[valueIndex][1]), parseInt(invalidDates[valueIndex][2]), parseInt(invalidDates[valueIndex][3]), + parseInt(invalidDates[valueIndex][4]), parseInt(invalidDates[valueIndex][5]), parseBigDecimal(invalidDates[valueIndex][6]), + parseInt(invalidDates[valueIndex][7])); + + if (DEBUG) { + System.err.println("created XMLGregorianCalendar: " + xmlGregorianCalendar.toString()); + } + + // unexpected success, should have failed + Assert.fail("expected IllegalArgumentException " + "for DatatypeFactory.newXMLGregorianCalendar(" + invalidDates[valueIndex][0] + ", " + + invalidDates[valueIndex][1] + ", " + invalidDates[valueIndex][2] + ", " + invalidDates[valueIndex][3] + ", " + + invalidDates[valueIndex][4] + ", " + invalidDates[valueIndex][5] + ", " + invalidDates[valueIndex][6] + ", " + + invalidDates[valueIndex][7] + "). " + "Instead, XMLGregorianCalendar: \"" + xmlGregorianCalendar.toString() + "\" was created."); + } catch (IllegalArgumentException illegalArgumentException) { + // expected failure + if (DEBUG) { + System.err.println("Exception creating XMLGregorianCalendar: " + illegalArgumentException.toString()); + } + } + } + + // test with all ints + int[] testIndex = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14, 15, }; + for (int i = 0; i < testIndex.length; ++i) { + int valueIndex = testIndex[i]; + try { + if (DEBUG) { + System.err.println("testing DatatypeFactory.newXMLGregorianCalendar(" + invalidDates[valueIndex][0] + ", " + invalidDates[valueIndex][1] + + ", " + invalidDates[valueIndex][2] + ", " + invalidDates[valueIndex][3] + ", " + invalidDates[valueIndex][4] + ", " + + invalidDates[valueIndex][5] + ", " + invalidDates[valueIndex][6] + ", " + invalidDates[valueIndex][7] + ")"); + } + + XMLGregorianCalendar xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar(parseInt(invalidDates[valueIndex][0]), + parseInt(invalidDates[valueIndex][1]), parseInt(invalidDates[valueIndex][2]), parseInt(invalidDates[valueIndex][3]), + parseInt(invalidDates[valueIndex][4]), parseInt(invalidDates[valueIndex][5]), parseInt(invalidDates[valueIndex][6]), + parseInt(invalidDates[valueIndex][7])); + + if (DEBUG) { + System.err.println("created XMLGregorianCalendar: " + xmlGregorianCalendar.toString()); + } + + // unexpected success, should have failed + Assert.fail("expected IllegalArgumentException " + "for DatatypeFactory.newXMLGregorianCalendar(" + invalidDates[valueIndex][0] + ", " + + invalidDates[valueIndex][1] + ", " + invalidDates[valueIndex][2] + ", " + invalidDates[valueIndex][3] + ", " + + invalidDates[valueIndex][4] + ", " + invalidDates[valueIndex][5] + ", " + invalidDates[valueIndex][6] + ", " + + invalidDates[valueIndex][7] + "). " + "Instead, XMLGregorianCalendar: \"" + xmlGregorianCalendar.toString() + "\" was created."); + } catch (IllegalArgumentException illegalArgumentException) { + // expected failure + if (DEBUG) { + System.err.println("Exception creating XMLGregorianCalendar: " + illegalArgumentException.toString()); + } + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/datatype/DurationTest.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,476 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.datatype; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.TimeZone; + +import javax.xml.namespace.QName; + +import org.testng.Assert; +import org.testng.AssertJUnit; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/* + * @summary Test Duration. + */ +public class DurationTest { + + private final static boolean DEBUG = true; + + protected Duration duration = null; + + @BeforeMethod + protected void setUp() { + try { + duration = DatatypeFactory.newInstance().newDuration(100); + } catch (DatatypeConfigurationException dce) { + dce.printStackTrace(); + Assert.fail("Failed to create instance of DatatypeFactory " + dce.getMessage()); + } + } + + @Test + public void testDurationSubtract() { + try { + Duration bigDur = DatatypeFactory.newInstance().newDuration(20000); + Duration smallDur = DatatypeFactory.newInstance().newDuration(10000); + if (smallDur.subtract(bigDur).getSign() != -1) { + Assert.fail("smallDur.subtract(bigDur).getSign() is not -1"); + } + if (bigDur.subtract(smallDur).getSign() != 1) { + Assert.fail("bigDur.subtract(smallDur).getSign() is not 1"); + } + if (smallDur.subtract(smallDur).getSign() != 0) { + Assert.fail("smallDur.subtract(smallDur).getSign() is not 0"); + } + } catch (DatatypeConfigurationException e) { + e.printStackTrace(); + } + } + + @Test + public void testDurationMultiply() { + int num = 5000; // millisends. 5 seconds + int factor = 2; + try { + Duration dur = DatatypeFactory.newInstance().newDuration(num); + if (dur.multiply(factor).getSeconds() != 10) { + Assert.fail("duration.multiply() return wrong value"); + } + // factor is 2*10^(-1) + if (dur.multiply(new BigDecimal(new BigInteger("2"), 1)).getSeconds() != 1) { + Assert.fail("duration.multiply() return wrong value"); + } + if (dur.subtract(DatatypeFactory.newInstance().newDuration(1000)).multiply(new BigDecimal(new BigInteger("2"), 1)).getSeconds() != 0) { + Assert.fail("duration.multiply() return wrong value"); + } + } catch (DatatypeConfigurationException e) { + e.printStackTrace(); + } + } + + @Test + public void testDurationAndCalendar1() { + int year = 1; + int month = 2; + int day = 3; + int hour = 4; + int min = 5; + int sec = 6; + String lexicalRepresentation = "P" + year + "Y" + month + "M" + day + "DT" + hour + "H" + min + "M" + sec + "S"; + try { + Duration dur = DatatypeFactory.newInstance().newDuration(lexicalRepresentation); + System.out.println(dur.toString()); + AssertJUnit.assertTrue("year should be 1", dur.getYears() == year); + AssertJUnit.assertTrue("month should be 2", dur.getMonths() == month); + AssertJUnit.assertTrue("day should be 3", dur.getDays() == day); + AssertJUnit.assertTrue("hour should be 4", dur.getHours() == hour); + AssertJUnit.assertTrue("minute should be 5", dur.getMinutes() == min); + AssertJUnit.assertTrue("second should be 6", dur.getSeconds() == sec); + } catch (DatatypeConfigurationException e) { + e.printStackTrace(); + } + } + + @Test + public void testDurationAndCalendar2() { + try { + AssertJUnit.assertTrue("10.00099S means 10 sec since it will be rounded to zero", DatatypeFactory.newInstance().newDuration("PT10.00099S") + .getTimeInMillis(new Date()) == 10000); + AssertJUnit.assertTrue("10.00099S means 10 sec since it will be rounded to zero", DatatypeFactory.newInstance().newDuration("-PT10.00099S") + .getTimeInMillis(new Date()) == -10000); + AssertJUnit.assertTrue("10.00099S means 10 sec since it will be rounded to zero", DatatypeFactory.newInstance().newDuration("PT10.00099S") + .getTimeInMillis(new GregorianCalendar()) == 10000); + AssertJUnit.assertTrue("10.00099S means 10 sec since it will be rounded to zero", DatatypeFactory.newInstance().newDuration("-PT10.00099S") + .getTimeInMillis(new GregorianCalendar()) == -10000); + } catch (DatatypeConfigurationException e) { + e.printStackTrace(); + } + } + + @Test + public void testDurationAndCalendar3() { + try { + Calendar cal = new GregorianCalendar(); + cal.set(Calendar.SECOND, 59); + DatatypeFactory.newInstance().newDuration(10000).addTo(cal); + AssertJUnit.assertTrue("sec will be 9", cal.get(Calendar.SECOND) == 9); + + Date date = new Date(); + date.setSeconds(59); + DatatypeFactory.newInstance().newDuration(10000).addTo(date); + AssertJUnit.assertTrue("sec will be 9", date.getSeconds() == 9); + } catch (DatatypeConfigurationException e) { + e.printStackTrace(); + } + } + + @Test + public void testEqualsWithDifferentObjectParam() { + + AssertJUnit.assertFalse("equals method should return false for any object other than Duration", duration.equals(new Integer(0))); + } + + @Test + public void testEqualsWithNullObjectParam() { + + AssertJUnit.assertFalse("equals method should return false for null parameter", duration.equals(null)); + } + + @Test + public void testEqualsWithEqualObjectParam() { + try { + AssertJUnit.assertTrue("equals method is expected to return true", duration.equals(DatatypeFactory.newInstance().newDuration(100))); + } catch (DatatypeConfigurationException dce) { + dce.printStackTrace(); + Assert.fail("Failed to create instance of DatatypeFactory " + dce.getMessage()); + } + } + + /** + * Inspired by CR 5077522 Duration.compare makes mistakes for some values. + */ + @Test + public void testCompareWithInderterminateRelation() { + + final String[][] partialOrder = { // partialOrder + { "P1Y", "<>", "P365D" }, { "P1Y", "<>", "P366D" }, { "P1M", "<>", "P28D" }, { "P1M", "<>", "P29D" }, { "P1M", "<>", "P30D" }, { "P1M", "<>", "P31D" }, + { "P5M", "<>", "P150D" }, { "P5M", "<>", "P151D" }, { "P5M", "<>", "P152D" }, { "P5M", "<>", "P153D" }, { "PT2419200S", "<>", "P1M" }, + { "PT2678400S", "<>", "P1M" }, { "PT31536000S", "<>", "P1Y" }, { "PT31622400S", "<>", "P1Y" }, { "PT525600M", "<>", "P1Y" }, + { "PT527040M", "<>", "P1Y" }, { "PT8760H", "<>", "P1Y" }, { "PT8784H", "<>", "P1Y" }, { "P365D", "<>", "P1Y" }, }; + + DatatypeFactory df = null; + try { + df = DatatypeFactory.newInstance(); + } catch (DatatypeConfigurationException ex) { + ex.printStackTrace(); + Assert.fail(ex.toString()); + } + + boolean compareErrors = false; + + for (int valueIndex = 0; valueIndex < partialOrder.length; ++valueIndex) { + Duration duration1 = df.newDuration(partialOrder[valueIndex][0]); + Duration duration2 = df.newDuration(partialOrder[valueIndex][2]); + int cmp = duration1.compare(duration2); + int expected = ">".equals(partialOrder[valueIndex][1]) ? DatatypeConstants.GREATER + : "<".equals(partialOrder[valueIndex][1]) ? DatatypeConstants.LESSER : "==".equals(partialOrder[valueIndex][1]) ? DatatypeConstants.EQUAL + : DatatypeConstants.INDETERMINATE; + + // just note any errors, do not fail until all cases have been + // tested + if (expected != cmp) { + compareErrors = true; + System.err.println("returned " + cmp2str(cmp) + " for durations \'" + duration1 + "\' and " + duration2 + "\', but expected " + + cmp2str(expected)); + } + } + + if (compareErrors) { + // TODO; fix bug, these tests should pass + if (false) { + Assert.fail("Errors in comparing indeterminate relations, see Stderr"); + } else { + System.err.println("Please fix this bug: " + "Errors in comparing indeterminate relations, see Stderr"); + } + } + } + + public static String cmp2str(int cmp) { + return cmp == DatatypeConstants.LESSER ? "LESSER" : cmp == DatatypeConstants.GREATER ? "GREATER" : cmp == DatatypeConstants.EQUAL ? "EQUAL" + : cmp == DatatypeConstants.INDETERMINATE ? "INDETERMINATE" : "UNDEFINED"; + } + + /** + * Inspired by CR 6238220 javax.xml.datatype.Duration has no clear + * description concerning return values range. + */ + @Test + public void testNormalizedReturnValues() throws Exception { + + final Object[] TEST_VALUES = { + // test 61 seconds -> 1 minute, 1 second + true, // isPositive, + BigInteger.ZERO, // years, + BigInteger.ZERO, // months + BigInteger.ZERO, // days + BigInteger.ZERO, // hours + BigInteger.ZERO, // minutes + new BigDecimal(61), // seconds + 61000L, // durationInMilliSeconds, + "P0Y0M0DT0H0M61S", // lexicalRepresentation + + // test - 61 seconds -> - 1 minute, 1 second + false, // isPositive, + BigInteger.ZERO, // years, + BigInteger.ZERO, // months + BigInteger.ZERO, // days + BigInteger.ZERO, // hours + BigInteger.ZERO, // minutes + new BigDecimal(61), // seconds + 61000L, // durationInMilliSeconds, + "-P0Y0M0DT0H0M61S", // lexicalRepresentation + }; + + final Object[] NORM_VALUES = { + // test 61 seconds -> 1 minute, 1 second + true, // normalized isPositive, + BigInteger.ZERO, // normalized years, + BigInteger.ZERO, // normalized months + BigInteger.ZERO, // normalized days + BigInteger.ZERO, // normalized hours + BigInteger.ONE, // normalized minutes + BigDecimal.ONE, // normalized seconds + 61000L, // normalized durationInMilliSeconds, + "P0Y0M0DT0H1M1.000S", // normalized lexicalRepresentation + + // test - 61 seconds -> - 1 minute, 1 second + false, // normalized isPositive, + BigInteger.ZERO, // normalized years, + BigInteger.ZERO, // normalized months + BigInteger.ZERO, // normalized days + BigInteger.ZERO, // normalized hours + BigInteger.ONE, // normalized minutes + BigDecimal.ONE, // normalized seconds + 61000L, // normalized durationInMilliSeconds, + "-P0Y0M0DT0H1M1.000S" // normalized lexicalRepresentation + }; + + for (int onValue = 0; onValue < TEST_VALUES.length; onValue += 9) { + newDurationTester(((Boolean) TEST_VALUES[onValue]).booleanValue(), // isPositive, + ((Boolean) NORM_VALUES[onValue]).booleanValue(), // normalized + // isPositive, + (BigInteger) TEST_VALUES[onValue + 1], // years, + (BigInteger) NORM_VALUES[onValue + 1], // normalized years, + (BigInteger) TEST_VALUES[onValue + 2], // months + (BigInteger) NORM_VALUES[onValue + 2], // normalized months + (BigInteger) TEST_VALUES[onValue + 3], // days + (BigInteger) NORM_VALUES[onValue + 3], // normalized days + (BigInteger) TEST_VALUES[onValue + 4], // hours + (BigInteger) NORM_VALUES[onValue + 4], // normalized hours + (BigInteger) TEST_VALUES[onValue + 5], // minutes + (BigInteger) NORM_VALUES[onValue + 5], // normalized minutes + (BigDecimal) TEST_VALUES[onValue + 6], // seconds + (BigDecimal) NORM_VALUES[onValue + 6], // normalized seconds + ((Long) TEST_VALUES[onValue + 7]).longValue(), // durationInMilliSeconds, + ((Long) NORM_VALUES[onValue + 7]).longValue(), // normalized + // durationInMilliSeconds, + (String) TEST_VALUES[onValue + 8], // lexicalRepresentation + (String) NORM_VALUES[onValue + 8]); // normalized + // lexicalRepresentation + + newDurationDayTimeTester(((Boolean) TEST_VALUES[onValue]).booleanValue(), // isPositive, + ((Boolean) NORM_VALUES[onValue]).booleanValue(), // normalized + // isPositive, + BigInteger.ZERO, // years, + BigInteger.ZERO, // normalized years, + BigInteger.ZERO, // months + BigInteger.ZERO, // normalized months + (BigInteger) TEST_VALUES[onValue + 3], // days + (BigInteger) NORM_VALUES[onValue + 3], // normalized days + (BigInteger) TEST_VALUES[onValue + 4], // hours + (BigInteger) NORM_VALUES[onValue + 4], // normalized hours + (BigInteger) TEST_VALUES[onValue + 5], // minutes + (BigInteger) NORM_VALUES[onValue + 5], // normalized minutes + (BigDecimal) TEST_VALUES[onValue + 6], // seconds + (BigDecimal) NORM_VALUES[onValue + 6], // normalized seconds + ((Long) TEST_VALUES[onValue + 7]).longValue(), // durationInMilliSeconds, + ((Long) NORM_VALUES[onValue + 7]).longValue(), // normalized + // durationInMilliSeconds, + (String) TEST_VALUES[onValue + 8], // lexicalRepresentation + (String) NORM_VALUES[onValue + 8]); // normalized + // lexicalRepresentation + } + } + + private void newDurationTester(boolean isPositive, boolean normalizedIsPositive, BigInteger years, BigInteger normalizedYears, BigInteger months, + BigInteger normalizedMonths, BigInteger days, BigInteger normalizedDays, BigInteger hours, BigInteger normalizedHours, BigInteger minutes, + BigInteger normalizedMinutes, BigDecimal seconds, BigDecimal normalizedSeconds, long durationInMilliSeconds, long normalizedDurationInMilliSeconds, + String lexicalRepresentation, String normalizedLexicalRepresentation) { + + DatatypeFactory datatypeFactory = null; + try { + datatypeFactory = DatatypeFactory.newInstance(); + } catch (DatatypeConfigurationException ex) { + ex.printStackTrace(); + Assert.fail(ex.toString()); + } + + // create 4 Durations using the 4 different constructors + + Duration durationBigInteger = datatypeFactory.newDuration(isPositive, years, months, days, hours, minutes, seconds); + durationAssertEquals(durationBigInteger, DatatypeConstants.DURATION, normalizedIsPositive, normalizedYears.intValue(), normalizedMonths.intValue(), + normalizedDays.intValue(), normalizedHours.intValue(), normalizedMinutes.intValue(), normalizedSeconds.intValue(), + normalizedDurationInMilliSeconds, normalizedLexicalRepresentation); + + Duration durationInt = datatypeFactory.newDuration(isPositive, years.intValue(), months.intValue(), days.intValue(), hours.intValue(), + minutes.intValue(), seconds.intValue()); + durationAssertEquals(durationInt, DatatypeConstants.DURATION, normalizedIsPositive, normalizedYears.intValue(), normalizedMonths.intValue(), + normalizedDays.intValue(), normalizedHours.intValue(), normalizedMinutes.intValue(), normalizedSeconds.intValue(), + normalizedDurationInMilliSeconds, normalizedLexicalRepresentation); + + Duration durationMilliseconds = datatypeFactory.newDuration(durationInMilliSeconds); + durationAssertEquals(durationMilliseconds, DatatypeConstants.DURATION, normalizedIsPositive, normalizedYears.intValue(), normalizedMonths.intValue(), + normalizedDays.intValue(), normalizedHours.intValue(), normalizedMinutes.intValue(), normalizedSeconds.intValue(), + normalizedDurationInMilliSeconds, normalizedLexicalRepresentation); + + Duration durationLexical = datatypeFactory.newDuration(lexicalRepresentation); + durationAssertEquals(durationLexical, DatatypeConstants.DURATION, normalizedIsPositive, normalizedYears.intValue(), normalizedMonths.intValue(), + normalizedDays.intValue(), normalizedHours.intValue(), normalizedMinutes.intValue(), normalizedSeconds.intValue(), + normalizedDurationInMilliSeconds, normalizedLexicalRepresentation); + } + + private void newDurationDayTimeTester(boolean isPositive, boolean normalizedIsPositive, BigInteger years, BigInteger normalizedYears, BigInteger months, + BigInteger normalizedMonths, BigInteger days, BigInteger normalizedDays, BigInteger hours, BigInteger normalizedHours, BigInteger minutes, + BigInteger normalizedMinutes, BigDecimal seconds, BigDecimal normalizedSeconds, long durationInMilliSeconds, long normalizedDurationInMilliSeconds, + String lexicalRepresentation, String normalizedLexicalRepresentation) { + + DatatypeFactory datatypeFactory = null; + try { + datatypeFactory = DatatypeFactory.newInstance(); + } catch (DatatypeConfigurationException ex) { + ex.printStackTrace(); + Assert.fail(ex.toString()); + } + + // create 4 dayTime Durations using the 4 different constructors + + Duration durationDayTimeBigInteger = datatypeFactory.newDurationDayTime(isPositive, days, hours, minutes, seconds.toBigInteger()); + durationAssertEquals(durationDayTimeBigInteger, DatatypeConstants.DURATION_DAYTIME, normalizedIsPositive, normalizedYears.intValue(), + normalizedMonths.intValue(), normalizedDays.intValue(), normalizedHours.intValue(), normalizedMinutes.intValue(), normalizedSeconds.intValue(), + normalizedDurationInMilliSeconds, normalizedLexicalRepresentation); + + /* + * Duration durationDayTimeInt = datatypeFactory.newDurationDayTime( + * isPositive, days.intValue(), hours.intValue(), minutes.intValue(), + * seconds.intValue()); Duration durationDayTimeMilliseconds = + * datatypeFactory.newDurationDayTime( durationInMilliSeconds); Duration + * durationDayTimeLexical = datatypeFactory.newDurationDayTime( + * lexicalRepresentation); + * Duration durationYearMonthBigInteger = + * datatypeFactory.newDurationYearMonth( isPositive, years, months); + * Duration durationYearMonthInt = datatypeFactory.newDurationYearMonth( + * isPositive, years.intValue(), months.intValue()); Duration + * durationYearMonthMilliseconds = datatypeFactory.newDurationYearMonth( + * durationInMilliSeconds); Duration durationYearMonthLexical = + * datatypeFactory.newDurationYearMonth( lexicalRepresentation) ; + */ + + } + + private void durationAssertEquals(Duration duration, QName xmlSchemaType, boolean isPositive, int years, int months, int days, int hours, int minutes, + int seconds, long milliseconds, String lexical) { + + final TimeZone GMT = TimeZone.getTimeZone("GMT"); + final GregorianCalendar EPOCH = new GregorianCalendar(GMT); + EPOCH.clear(); + + if (DEBUG) { + System.out.println("Testing Duration: " + duration.toString()); + } + + // sign + if (DEBUG) { + boolean actual = (duration.getSign() == 1) ? true : false; + System.out.println("sign:"); + System.out.println(" expected: \"" + isPositive + "\""); + System.out.println(" actual: \"" + actual + "\""); + } + + if (DEBUG) { + System.out.println("years:"); + System.out.println(" expected: \"" + years + "\""); + System.out.println(" actual: \"" + duration.getYears() + "\""); + } + + if (DEBUG) { + System.out.println("months:"); + System.out.println(" expected: \"" + months + "\""); + System.out.println(" actual: \"" + duration.getMonths() + "\""); + } + + if (DEBUG) { + System.out.println("days:"); + System.out.println(" expected: \"" + days + "\""); + System.out.println(" actual: \"" + duration.getDays() + "\""); + } + + if (DEBUG) { + System.out.println("hours:"); + System.out.println(" expected: \"" + hours + "\""); + System.out.println(" actual: \"" + duration.getHours() + "\""); + } + + if (DEBUG) { + System.out.println("minutes:"); + System.out.println(" expected: \"" + minutes + "\""); + System.out.println(" actual: \"" + duration.getMinutes() + "\""); + } + + if (DEBUG) { + System.out.println("seconds:"); + System.out.println(" expected: \"" + seconds + "\""); + System.out.println(" actual: \"" + duration.getSeconds() + "\""); + } + + if (DEBUG) { + System.out.println("milliseconds:"); + System.out.println(" expected: \"" + milliseconds + "\""); + System.out.println(" actual: \"" + duration.getTimeInMillis(EPOCH) + "\""); + } + + if (DEBUG) { + System.out.println("lexical:"); + System.out.println(" expected: \"" + lexical + "\""); + System.out.println(" actual: \"" + duration.toString() + "\""); + } + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/datatype/FactoryFindTest.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.datatype; + +import java.net.URL; +import java.net.URLClassLoader; + +import org.testng.Assert; +import org.testng.annotations.Test; + +/* + * @summary Test Classloader for DatatypeFactory. + */ +public class FactoryFindTest { + + boolean myClassLoaderUsed = false; + + public FactoryFindTest(String name) { + } + + @Test + public void testFactoryFind() { + try { + // System.setProperty("jaxp.debug", "true"); + + DatatypeFactory factory = DatatypeFactory.newInstance(); + Assert.assertTrue(factory.getClass().getClassLoader() == null); + + Thread.currentThread().setContextClassLoader(null); + factory = DatatypeFactory.newInstance(); + Assert.assertTrue(factory.getClass().getClassLoader() == null); + + Thread.currentThread().setContextClassLoader(new MyClassLoader()); + factory = DatatypeFactory.newInstance(); + if (System.getSecurityManager() == null) + Assert.assertTrue(myClassLoaderUsed); + else + Assert.assertFalse(myClassLoaderUsed); + } catch (Exception ex) { + } + + } + + class MyClassLoader extends URLClassLoader { + + public MyClassLoader() { + super(new URL[0]); + } + + public Class loadClass(String name) throws ClassNotFoundException { + myClassLoaderUsed = true; + return super.loadClass(name); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/datatype/XMLGregorianCalendarTest.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,219 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.datatype; + +import org.testng.Assert; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/* + * @summary Test XMLGregorianCalendar. + */ +public class XMLGregorianCalendarTest { + + private static final boolean DEBUG = false; + + private static final int TEST_VALUE_FAIL = 0; + + private static final int TEST_VALUE_PASS = 1; + + private XMLGregorianCalendar calendar; + + @BeforeMethod + protected void setUp() { + try { + calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(); + } catch (DatatypeConfigurationException dce) { + dce.printStackTrace(); + Assert.fail("Failed to create instance of DatatypeFactory " + dce.getMessage()); + } + } + + @Test + public final void testSetTime() { + + /** + * Hour, minute, second values to test and expected result. + */ + final int[] TEST_VALUES = { 24, 0, 0, TEST_VALUE_PASS, 24, 1, 0, TEST_VALUE_FAIL, 24, 0, 1, TEST_VALUE_FAIL, 24, DatatypeConstants.FIELD_UNDEFINED, 0, + TEST_VALUE_FAIL, 24, 0, DatatypeConstants.FIELD_UNDEFINED, TEST_VALUE_FAIL }; + + // create DatatypeFactory + DatatypeFactory datatypeFactory = null; + try { + datatypeFactory = DatatypeFactory.newInstance(); + } catch (DatatypeConfigurationException datatypeConfigurationException) { + Assert.fail(datatypeConfigurationException.toString()); + } + + if (DEBUG) { + System.err.println("DatatypeFactory created: " + datatypeFactory.toString()); + } + + // create XMLGregorianCalendar + XMLGregorianCalendar xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar(); + + // test each value + for (int onTestValue = 0; onTestValue < TEST_VALUES.length; onTestValue = onTestValue + 4) { + + if (DEBUG) { + System.err.println("testing values: (" + TEST_VALUES[onTestValue] + ", " + TEST_VALUES[onTestValue + 1] + ", " + TEST_VALUES[onTestValue + 2] + + ") expected (0=fail, 1=pass): " + TEST_VALUES[onTestValue + 3]); + } + + try { + // set time + xmlGregorianCalendar.setTime(TEST_VALUES[onTestValue], TEST_VALUES[onTestValue + 1], TEST_VALUES[onTestValue + 2]); + + if (DEBUG) { + System.err.println("XMLGregorianCalendar created: \"" + xmlGregorianCalendar.toString() + "\""); + } + + // was this expected to fail? + if (TEST_VALUES[onTestValue + 3] == TEST_VALUE_FAIL) { + Assert.fail("the values: (" + TEST_VALUES[onTestValue] + ", " + TEST_VALUES[onTestValue + 1] + ", " + TEST_VALUES[onTestValue + 2] + + ") are invalid, " + "yet it created the XMLGregorianCalendar \"" + xmlGregorianCalendar.toString() + "\""); + } + } catch (Exception exception) { + + if (DEBUG) { + System.err.println("Exception in creating XMLGregorianCalendar: \"" + exception.toString() + "\""); + } + + // was this expected to succed? + if (TEST_VALUES[onTestValue + 3] == TEST_VALUE_PASS) { + Assert.fail("the values: (" + TEST_VALUES[onTestValue] + ", " + TEST_VALUES[onTestValue + 1] + ", " + TEST_VALUES[onTestValue + 2] + + ") are valid yet it failed with \"" + exception.toString() + "\""); + } + // expected failure + } + } + } + + @Test + public final void testSetHour() { + + /** + * Hour values to test and expected result. + */ + final int[] TEST_VALUES = { + // setTime(H, M, S), hour override, expected result + 0, 0, 0, 0, TEST_VALUE_PASS, 0, 0, 0, 23, TEST_VALUE_PASS, 0, 0, 0, 24, TEST_VALUE_PASS, + // creates invalid state + 0, 0, 0, DatatypeConstants.FIELD_UNDEFINED, TEST_VALUE_FAIL, + // violates Schema Errata + 0, 0, 1, 24, TEST_VALUE_FAIL }; + + // create DatatypeFactory + DatatypeFactory datatypeFactory = null; + try { + datatypeFactory = DatatypeFactory.newInstance(); + } catch (DatatypeConfigurationException datatypeConfigurationException) { + Assert.fail(datatypeConfigurationException.toString()); + } + + if (DEBUG) { + System.err.println("DatatypeFactory created: " + datatypeFactory.toString()); + } + + // create XMLGregorianCalendar + XMLGregorianCalendar xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar(); + + // test each value + for (int onTestValue = 0; onTestValue < TEST_VALUES.length; onTestValue = onTestValue + 5) { + + if (DEBUG) { + System.err.println("testing values: (" + TEST_VALUES[onTestValue] + ", " + TEST_VALUES[onTestValue + 1] + ", " + TEST_VALUES[onTestValue + 2] + + ", " + TEST_VALUES[onTestValue + 3] + ") expected (0=fail, 1=pass): " + TEST_VALUES[onTestValue + 4]); + } + + try { + // set time to known valid value + xmlGregorianCalendar.setTime(TEST_VALUES[onTestValue], TEST_VALUES[onTestValue + 1], TEST_VALUES[onTestValue + 2]); + // now explicitly set hour + xmlGregorianCalendar.setHour(TEST_VALUES[onTestValue + 3]); + + if (DEBUG) { + System.err.println("XMLGregorianCalendar created: \"" + xmlGregorianCalendar.toString() + "\""); + } + + // was this expected to fail? + if (TEST_VALUES[onTestValue + 4] == TEST_VALUE_FAIL) { + Assert.fail("the values: (" + TEST_VALUES[onTestValue] + ", " + TEST_VALUES[onTestValue + 1] + ", " + TEST_VALUES[onTestValue + 2] + ", " + + TEST_VALUES[onTestValue + 3] + ") are invalid, " + "yet it created the XMLGregorianCalendar \"" + xmlGregorianCalendar.toString() + + "\""); + } + } catch (Exception exception) { + + if (DEBUG) { + System.err.println("Exception in creating XMLGregorianCalendar: \"" + exception.toString() + "\""); + } + + // was this expected to succed? + if (TEST_VALUES[onTestValue + 4] == TEST_VALUE_PASS) { + Assert.fail("the values: (" + TEST_VALUES[onTestValue] + ", " + TEST_VALUES[onTestValue + 1] + ", " + TEST_VALUES[onTestValue + 2] + ", " + + TEST_VALUES[onTestValue + 3] + ") are valid yet it failed with \"" + exception.toString() + "\""); + } + // expected failure + } + } + } + + @Test + public void testEqualsWithDifferentObjectParam() { + + Assert.assertFalse(calendar.equals(new Integer(0)), "equals method should return false for any object other" + " than XMLGregorianCalendar"); + } + + @Test + public void testEqualsWithNullObjectParam() { + + Assert.assertFalse(calendar.equals(null), "equals method should return false for null parameter"); + } + + @Test + public void testEqualsWithEqualObjectParam() { + + try { + Assert.assertTrue(calendar.equals(DatatypeFactory.newInstance().newXMLGregorianCalendar()), "equals method is expected to return true"); + } catch (DatatypeConfigurationException dce) { + dce.printStackTrace(); + Assert.fail("Failed to create instance of DatatypeFactory " + dce.getMessage()); + } + } + + @Test + public void testToString() { + try { + String inputDateTime = "2006-10-23T22:15:01.000000135+08:00"; + DatatypeFactory factory = DatatypeFactory.newInstance(); + XMLGregorianCalendar calendar = factory.newXMLGregorianCalendar(inputDateTime); + String toStr = calendar.toString(); + Assert.assertTrue(toStr.indexOf("E") == -1, "String value cannot contain exponent"); + } catch (DatatypeConfigurationException dce) { + dce.printStackTrace(); + Assert.fail("Failed to create instance of DatatypeFactory " + dce.getMessage()); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug4674384_MAX_OCCURS_Test.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import java.io.File; + +import org.testng.Assert; +import org.testng.annotations.Test; +import org.xml.sax.helpers.DefaultHandler; + +/* + * @bug 4674384 + * @summary Test large maxOccurs. + */ +public class Bug4674384_MAX_OCCURS_Test { + + @Test + public final void testLargeMaxOccurs() { + + String XML_FILE_NAME = "Bug4674384_MAX_OCCURS_Test.xml"; + + try { + // create and initialize the parser + SAXParserFactory spf = SAXParserFactory.newInstance(); + spf.setNamespaceAware(true); + spf.setValidating(true); + + SAXParser parser = spf.newSAXParser(); + parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema"); + + File xmlFile = new File(getClass().getResource(XML_FILE_NAME).getPath()); + + parser.parse(xmlFile, new DefaultHandler()); + } catch (Exception e) { + System.err.println("Failure: File " + XML_FILE_NAME + " was parsed with a large value of maxOccurs."); + e.printStackTrace(); + Assert.fail("Failure: File " + XML_FILE_NAME + " was parsed with a large value of maxOccurs. " + e.getMessage()); + } + + System.out.println("Success: File " + XML_FILE_NAME + " was parsed with a large value of maxOccurs."); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug4674384_MAX_OCCURS_Test.xml Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<test:a + xmlns:test="test" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="test Bug4674384_MAX_OCCURS_Test.xsd"> +<b>1</b> +<b>2</b> +</test:a>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug4674384_MAX_OCCURS_Test.xsd Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,15 @@ +<?xml version="1.0"?> + +<xsd:schema + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns="test" + targetNamespace="test"> + + <xsd:element name="a" type="A"/> + <xsd:complexType name="A"> + <xsd:sequence> + <xsd:element name="b" type="xsd:string" maxOccurs="3000"/> + </xsd:sequence> + </xsd:complexType> + +</xsd:schema>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug4934208.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +import org.testng.Assert; +import org.testng.annotations.Test; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; + +import util.DraconianErrorHandler; + +/* + * @bug 4934208 + * @summary Test SAXParser can parse keyref constraint with a selector that is a union xpath expression selecting a node and its child. + */ +public class Bug4934208 { + @Test + public void test1() throws Exception { + parse(new InputSource(Bug4934208.class.getResourceAsStream("test1.xml"))); + } + + @Test + public void test2() throws Exception { + try { + parse(new InputSource(Bug4934208.class.getResourceAsStream("test2.xml"))); + } catch (SAXException e) { + Assert.assertTrue(e.getMessage().startsWith("cvc-complex-type.2.4.a")); + } + } + + private void parse(InputSource is) throws Exception { + SAXParserFactory spf = SAXParserFactory.newInstance(); + spf.setNamespaceAware(true); + spf.setValidating(true); + SAXParser parser = spf.newSAXParser(); + + parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema"); + parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", Bug4934208.class.getResourceAsStream("test.xsd")); + + XMLReader r = parser.getXMLReader(); + + r.setErrorHandler(new DraconianErrorHandler()); + r.parse(is); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug4967002.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import java.io.StringReader; + +import javax.xml.XMLConstants; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.stream.StreamSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; + +import org.testng.Assert; +import org.testng.annotations.Test; +import org.xml.sax.InputSource; + +/* + * @bug 4967002 + * @summary Test DocumentBuilderFactory.newDocumentBuilder() throws ParserConfigurationException + * when it uses the "http://java.sun.com/xml/jaxp/properties/schemaSource" property + * and/or the "http://java.sun.com/xml/jaxp/properties/schemaLanguage" property + * in conjunction with setting a Schema object. + */ +public class Bug4967002 { + String schemaSource = "<?xml version='1.0'?>\n" + "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>\n" + " <xsd:element name='test101'>\n" + + " <xsd:complexType>\n" + " <xsd:attribute name='attr'/>\n" + " <xsd:attribute name='attr2' default='DEF'/>\n" + + " </xsd:complexType>\n" + " </xsd:element>\n" + "</xsd:schema>\n"; + + Schema createSchema() { + SchemaFactory schFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + try { + Schema sch = schFactory.newSchema(new StreamSource(new StringReader(schemaSource))); + return sch; + } catch (Exception se) { + throw new IllegalStateException("No Schema : " + se); + } + } + + @Test + public void test1() { + setAttr(true); + } + + @Test + public void test2() { + setAttr(false); + } + + void setAttr(boolean setSrc) { + DocumentBuilderFactory docBFactory = DocumentBuilderFactory.newInstance(); + Schema sch = createSchema(); + docBFactory.setSchema(sch); + docBFactory.setNamespaceAware(true); + docBFactory.setValidating(true); + + final String aSchemaLanguage = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; + final String aSchemaSource = "http://java.sun.com/xml/jaxp/properties/schemaSource"; + + docBFactory.setAttribute(aSchemaLanguage, "http://www.w3.org/2001/XMLSchema"); + // System.out.println("---- Set schemaLanguage: " + + // docBFactory.getAttribute(aSchemaLanguage)); + if (setSrc) { + docBFactory.setAttribute(aSchemaSource, new InputSource(new StringReader(schemaSource))); + // System.out.println("---- Set schemaSource: " + + // docBFactory.getAttribute(aSchemaSource)); + } + + try { + docBFactory.newDocumentBuilder(); + Assert.fail("ParserConfigurationException expected"); + } catch (ParserConfigurationException pce) { + return; // success + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug4985486.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import javax.xml.parsers.SAXParserFactory; + +import org.testng.Assert; +import org.testng.annotations.Test; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +/* + * @bug 4985486 + * @summary Test SAXParser can parse large characters(more than 10000). + */ +public class Bug4985486 { + + @Test + public void test1() throws Exception { + SAXParserFactory spf = SAXParserFactory.newInstance(); + System.out.println(spf.getClass().getName()); + spf.setNamespaceAware(true); + spf.newSAXParser().parse(Bug4985486.class.getResourceAsStream("Bug4985486.xml"), new Handler()); + } + + private class Handler extends DefaultHandler { + StringBuffer buf = new StringBuffer(); + + public void characters(char[] ch, int start, int length) throws SAXException { + buf.append(ch, start, length); + } + + public void endDocument() throws SAXException { + String contents = buf.toString(); + Assert.assertTrue(contents.endsWith("[END]")); + while (contents.length() >= 10) { + Assert.assertTrue(contents.startsWith("0123456789")); + contents = contents.substring(10); + } + } + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug4985486.xml Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,2 @@ +<?xml version="1.0"?> +<root>0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789[END]</root>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug4991020.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +import org.testng.annotations.Test; + +/* + * @bug 4991020 + * @summary Test XPath like "node_name/." can be parsed. + */ +public class Bug4991020 { + + protected static SAXParser createParser() throws Exception { + SAXParserFactory spf = SAXParserFactory.newInstance(); + spf.setNamespaceAware(true); + spf.setValidating(true); + SAXParser parser = spf.newSAXParser(); + parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema"); + + return parser; + } + + @Test + public void test1() throws Exception { + SAXParser parser = createParser(); + parser.parse(Bug4991020.class.getResource("Bug4991020.xml").toExternalForm(), new util.DraconianErrorHandler()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug4991020.xml Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,5 @@ +<?xml version="1.0"?> +<test:root xmlns:test="test" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="test Bug4991020.xsd" +><child>123</child></test:root>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug4991020.xsd Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="test"> + <xsd:element name="root"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="child" type="xsd:string"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:key name="key1"> + <xsd:selector xpath="."/> + <xsd:field xpath="child/."/> + </xsd:key> + </xsd:element> +</xsd:schema>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug4991946.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +import org.testng.annotations.Test; + +/* + * @bug 4991946 + * @summary Can parse the element type is anyType in the schema and is substituted by the simple type via the 'xsi:type' attribute in xml document. + */ +public class Bug4991946 { + + protected static SAXParser createParser() throws Exception { + SAXParserFactory spf = SAXParserFactory.newInstance(); + spf.setNamespaceAware(true); + spf.setValidating(true); + SAXParser parser = spf.newSAXParser(); + parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema"); + + return parser; + } + + @Test + public void test1() throws Exception { + SAXParser parser = createParser(); + parser.parse(Bug4991946.class.getResource("Bug4991946.xml").toExternalForm(), new util.DraconianErrorHandler()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug4991946.xml Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<test:root xmlns:test="test" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="test Bug4991946.xsd" + xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <child xsi:type="xsd:string">123</child> +</test:root>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug4991946.xsd Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="test"> + <xsd:element name="root"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="child" type="xsd:anyType"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:key name="key1"> + <xsd:selector xpath="."/> + <xsd:field xpath="child"/> + </xsd:key> + </xsd:element> +</xsd:schema>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug5010072.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import javax.xml.validation.SchemaFactory; + +import org.testng.Assert; +import org.testng.annotations.Test; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; +import org.xml.sax.helpers.DefaultHandler; + +/* + * @bug 5010072 + * @summary Test SchemaFactory throws SAXException if xpath is "@". + */ +public class Bug5010072 { + + protected static class ErrorHandler extends DefaultHandler { + public int errorCounter = 0; + + public void error(SAXParseException e) throws SAXException { + + System.err.println("Error: " + "[[" + e.getPublicId() + "][" + e.getSystemId() + "]]" + "[[" + e.getLineNumber() + "][" + e.getColumnNumber() + + "]]" + e); + + errorCounter++; + + throw e; + } + + public void fatalError(SAXParseException e) throws SAXException { + System.err.println("Fatal Error: " + e); + errorCounter++; + } + } + + @Test + public void test1() throws Exception { + SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); + + ErrorHandler errorHandler = new ErrorHandler(); + schemaFactory.setErrorHandler(errorHandler); + + try { + schemaFactory.newSchema(Bug5010072.class.getResource("Bug5010072.xsd")); + Assert.fail("should fail to compile"); + } catch (SAXException e) { + ; // as expected + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug5010072.xsd Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,14 @@ +<?xml version="1.0"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <xsd:element name="root"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="tid" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:complexType> + <xsd:unique id="foo123" name="uid"> + <xsd:selector xpath=".//tid"/> + <xsd:field xpath="@"/> + </xsd:unique> + </xsd:element> +</xsd:schema>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug5025825.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import java.io.StringReader; + +import javax.xml.XMLConstants; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.stream.StreamSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; + +import org.testng.Assert; +import org.testng.annotations.Test; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +/* + * @bug 5025825 + * @summary Test if SAXParserFactory set a Schema object, when SAXParser sets "http://java.sun.com/xml/jaxp/properties/schemaSource" property + * and/or "http://java.sun.com/xml/jaxp/properties/schemaLanguage" property, it shall throw SAXException. + */ +public class Bug5025825 { + + String schemaSource = "<?xml version='1.0'?>\n" + "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>\n" + " <xsd:element name='test101'>\n" + + " <xsd:complexType>\n" + " <xsd:attribute name='attr'/>\n" + " <xsd:attribute name='attr2' default='DEF'/>\n" + + " </xsd:complexType>\n" + " </xsd:element>\n" + "</xsd:schema>\n"; + + private Schema createSchema() throws SAXException { + SchemaFactory schFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + return schFactory.newSchema(new StreamSource(new StringReader(schemaSource))); + } + + @Test + public void test1() throws Exception { + Schema sch = createSchema(); + Assert.assertNotNull(sch); + + SAXParserFactory spFactory = SAXParserFactory.newInstance(); + spFactory.setNamespaceAware(true); + spFactory.setValidating(true); + spFactory.setSchema(sch); + + SAXParser sParser = spFactory.newSAXParser(); + + final String aSchemaLanguage = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; + final String aSchemaSource = "http://java.sun.com/xml/jaxp/properties/schemaSource"; + + try { + sParser.setProperty(aSchemaLanguage, "http://www.w3.org/2001/XMLSchema"); + Assert.fail("---- Set schemaLanguage: " + sParser.getProperty(aSchemaLanguage)); + } catch (SAXException e) { + ; // as expected + } + + try { + sParser.setProperty(aSchemaSource, new InputSource(new StringReader(schemaSource))); + Assert.fail("---- Set schemaSource: " + sParser.getProperty(aSchemaSource)); + } catch (SAXException e) { + ; // as expected + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug6309988.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,380 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import java.io.File; +import java.io.InputStream; + +import javax.xml.XMLConstants; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +import org.testng.Assert; +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.xml.sax.SAXParseException; + +/* + * @bug 6309988 + * @summary Test elementAttributeLimit, maxOccurLimit, entityExpansionLimit. + */ +public class Bug6309988 { + + DocumentBuilderFactory dbf = null; + static boolean _isSecureMode = false; + static { + if (System.getSecurityManager() != null) { + _isSecureMode = true; + System.out.println("Security Manager is present"); + } else { + System.out.println("Security Manager is NOT present"); + } + } + + /* + * Given XML document has more than 10000 attributes. Exception is expected + */ + @Test + public void testDOMParserElementAttributeLimit() { + try { + dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder parser = dbf.newDocumentBuilder(); + Document doc = parser.parse(this.getClass().getResourceAsStream("DosTest.xml")); + Assert.fail("SAXParserException is expected, as given XML document contains more than 10000 attributes"); + } catch (SAXParseException e) { + System.out.println(e.getMessage()); + } catch (Exception e) { + Assert.fail("Exception " + e.getMessage()); + } + } + + /* + * Given XML document has more than 10000 attributes. It should report an + * error. + */ + @Test + public void testDOMNSParserElementAttributeLimit() { + try { + dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); + DocumentBuilder parser = dbf.newDocumentBuilder(); + Document doc = parser.parse(this.getClass().getResourceAsStream("DosTest.xml")); + Assert.fail("SAXParserException is expected, as given XML document contains more than 10000 attributes"); + } catch (SAXParseException e) { + System.out.println(e.getMessage()); + } catch (Exception e) { + Assert.fail("Exception " + e.getMessage()); + } + } + + /* + * Given XML document has more than 10000 attributes. Parsing this XML + * document in non-secure mode, should not report any error. + */ + @Test + public void testDOMNSParserElementAttributeLimitWithoutSecureProcessing() { + if (_isSecureMode) + return; // jaxp secure feature can not be turned off when security + // manager is present + try { + dbf = DocumentBuilderFactory.newInstance(); + dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false); + dbf.setNamespaceAware(true); + DocumentBuilder parser = dbf.newDocumentBuilder(); + Document doc = parser.parse(this.getClass().getResourceAsStream("DosTest.xml")); + + } catch (SAXParseException e) { + Assert.fail(e.getMessage()); + } catch (Exception e) { + Assert.fail("Exception " + e.getMessage()); + } + } + + /* + * Before 8014530: Given XML document has 3 attributes and System property + * is set to 2. Parsing this XML document in non-secure mode, should not + * report an error. + * After 8014530: System properties will override FSP, the result of this + * test should be the same as + * testSystemElementAttributeLimitWithSecureProcessing + */ + @Test + public void testSystemElementAttributeLimitWithoutSecureProcessing() { + if (_isSecureMode) + return; // jaxp secure feature can not be turned off when security + // manager is present + try { + dbf = DocumentBuilderFactory.newInstance(); + dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false); + dbf.setNamespaceAware(true); + System.setProperty("elementAttributeLimit", "2"); + DocumentBuilder parser = dbf.newDocumentBuilder(); + Document doc = parser.parse(this.getClass().getResourceAsStream("DosTest3.xml")); + + Assert.fail("SAXParserException is expected, as given XML document contains more than 2 attributes"); + } catch (Exception e) { + String errMsg = e.getMessage(); + Throwable cause = e.getCause(); + if (cause != null) { + errMsg += cause.getMessage(); + } + if (errMsg.contains("JAXP0001")) { + // expected + } else { + Assert.fail("Unexpected error: " + e.getMessage()); + } + } finally { + System.clearProperty("elementAttributeLimit"); + } + } + + /* + * Given XML document has 3 attributes and System property is set to 2. + * Parsing this XML document in secure mode, should report an error. + */ + @Test + public void testSystemElementAttributeLimitWithSecureProcessing() { + try { + dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); + System.setProperty("elementAttributeLimit", "2"); + DocumentBuilder parser = dbf.newDocumentBuilder(); + Document doc = parser.parse(this.getClass().getResourceAsStream("DosTest3.xml")); + Assert.fail("SAXParserException is expected, as given XML document contains more than 2 attributes"); + } catch (SAXParseException e) { + System.out.println(e.getMessage()); + } catch (Exception e) { + Assert.fail("Exception " + e.getMessage()); + } finally { + System.setProperty("elementAttributeLimit", ""); + } + } + + /* + * Default value for secure processing feature should be true. + */ + @Test + public void testDOMSecureProcessingDefaultValue() { + try { + dbf = DocumentBuilderFactory.newInstance(); + Assert.assertTrue(dbf.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING), "Default value for secureProcessing feature should be true"); + + } catch (Exception e) { + Assert.fail("Exception " + e.getMessage()); + } + } + + /* + * Default value for secure processing feature should be true. + */ + @Test + public void testSAXSecureProcessingDefaultValue() { + try { + SAXParserFactory spf = SAXParserFactory.newInstance(); + Assert.assertTrue(spf.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING), "Default value for secureProcessing feature should be true"); + + } catch (Exception e) { + Assert.fail("Exception " + e.getMessage()); + } + } + + /* + * This method sets system property for maxOccurLimit=2 and secure process + * feature is off. Given doument contains more than 2 elements and hence an + * error should be reported. + */ + @Test + public void testSystemMaxOccurLimitWithoutSecureProcessing() { + if (_isSecureMode) + return; // jaxp secure feature can not be turned off when security + // manager is present + try { + SAXParserFactory spf = SAXParserFactory.newInstance(); + spf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false); + spf.setValidating(true); + System.setProperty("maxOccurLimit", "2"); + // Set the properties for Schema Validation + String SCHEMA_LANG = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; + String SCHEMA_TYPE = "http://www.w3.org/2001/XMLSchema"; + // Get the Schema location as a File object + File schemaFile = new File(this.getClass().getResource("toys.xsd").toURI()); + // Get the parser + SAXParser parser = spf.newSAXParser(); + parser.setProperty(SCHEMA_LANG, SCHEMA_TYPE); + parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", schemaFile); + + InputStream is = this.getClass().getResourceAsStream("toys.xml"); + MyErrorHandler eh = new MyErrorHandler(); + parser.parse(is, eh); + Assert.assertFalse(eh.errorOccured, "Not Expected Error"); + System.setProperty("maxOccurLimit", ""); + } catch (Exception e) { + Assert.fail("Exception occured: " + e.getMessage()); + } + } + + /* + * This test will take longer time to execute( abt 120sec). This method + * tries to validate a document. This document contains an element whose + * maxOccur is '3002'. Since secure processing feature is off, document + * should be parsed without any errors. + */ + @Test + public void testValidMaxOccurLimitWithOutSecureProcessing() { + if (_isSecureMode) + return; // jaxp secure feature can not be turned off when security + // manager is present + try { + SAXParserFactory spf = SAXParserFactory.newInstance(); + spf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false); + spf.setValidating(true); + // Set the properties for Schema Validation + String SCHEMA_LANG = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; + String SCHEMA_TYPE = "http://www.w3.org/2001/XMLSchema"; + // Get the Schema location as a File object + File schemaFile = new File(this.getClass().getResource("toys3002.xsd").toURI()); + // Get the parser + SAXParser parser = spf.newSAXParser(); + parser.setProperty(SCHEMA_LANG, SCHEMA_TYPE); + parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", schemaFile); + + InputStream is = this.getClass().getResourceAsStream("toys.xml"); + MyErrorHandler eh = new MyErrorHandler(); + parser.parse(is, eh); + Assert.assertFalse(eh.errorOccured, "Expected Error as maxOccurLimit is exceeded"); + + } catch (Exception e) { + Assert.fail("Exception occured: " + e.getMessage()); + } + } + + /* + * Before 8014530: System property is set to 2. Given XML document has more + * than 2 entity references. Parsing this document in non-secure mode, + * should *not* report an error. + * After 8014530: System properties will override FSP, the result of this + * test should be the same as + * testSystemElementAttributeLimitWithSecureProcessing + */ + @Test + public void testSystemEntityExpansionLimitWithOutSecureProcessing() { + if (_isSecureMode) + return; // jaxp secure feature can not be turned off when security + // manager is present + try { + System.setProperty("entityExpansionLimit", "2"); + dbf = DocumentBuilderFactory.newInstance(); + dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false); + dbf.setValidating(true); + DocumentBuilder parser = dbf.newDocumentBuilder(); + Document doc = parser.parse(this.getClass().getResourceAsStream("entity.xml")); + Assert.fail("SAXParserException is expected, as given XML document contains more 2 entity references"); + } catch (Exception e) { + String errMsg = e.getMessage(); + Throwable cause = e.getCause(); + if (cause != null) { + errMsg += cause.getMessage(); + } + if (errMsg.contains("JAXP0001")) { + // expected + } else { + Assert.fail("Unexpected error: " + e.getMessage()); + } + } finally { + System.clearProperty("entityExpansionLimit"); + } + } + + /* + * System property is set to 2. Given XML document has more than 2 entity + * references. Parsing this document in secure mode, should report an error. + */ + @Test + public void testSystemEntityExpansionLimitWithSecureProcessing() { + try { + dbf = DocumentBuilderFactory.newInstance(); + dbf.setValidating(true); + System.setProperty("entityExpansionLimit", "2"); + DocumentBuilder parser = dbf.newDocumentBuilder(); + Document doc = parser.parse(this.getClass().getResourceAsStream("entity.xml")); + Assert.fail("SAXParserException is expected, as given XML document contains more 2 entity references"); + + } catch (SAXParseException e) { + System.out.println(e.getMessage()); + } catch (Exception e) { + Assert.fail("Exception " + e.getMessage()); + } finally { + System.setProperty("entityExpansionLimit", ""); + } + } + + /* + * Given XML document has more than 64000 entity references. Parsing this + * document in secure mode, should report an error. + */ + @Test + public void testEntityExpansionLimitWithSecureProcessing() { + try { + dbf = DocumentBuilderFactory.newInstance(); + dbf.setValidating(true); + DocumentBuilder parser = dbf.newDocumentBuilder(); + Document doc = parser.parse(this.getClass().getResourceAsStream("entity64K.xml")); + Assert.fail("SAXParserException is expected, as given XML document contains more 2 entity references"); + + } catch (SAXParseException e) { + System.out.println(e.getMessage()); + } catch (Exception e) { + Assert.fail("Exception " + e.getMessage()); + } finally { + System.setProperty("entityExpansionLimit", ""); + } + } + + /* + * Given XML document has more than 64000 entity references. Parsing this + * document in non-secure mode, should not report any error. + */ + @Test + public void testEntityExpansionLimitWithOutSecureProcessing() { + if (_isSecureMode) + return; // jaxp secure feature can not be turned off when security + // manager is present + try { + dbf = DocumentBuilderFactory.newInstance(); + dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false); + dbf.setValidating(true); + DocumentBuilder parser = dbf.newDocumentBuilder(); + Document doc = parser.parse(this.getClass().getResourceAsStream("entity64K.xml")); + + } catch (SAXParseException e) { + Assert.fail("Exception " + e.getMessage()); + } catch (Exception e) { + Assert.fail("Exception " + e.getMessage()); + } finally { + System.setProperty("entityExpansionLimit", ""); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug6341770.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import java.io.File; +import java.io.FileWriter; +import java.io.PrintWriter; + +import javax.xml.parsers.SAXParserFactory; + +import org.testng.Assert; +import org.testng.annotations.Test; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +/* + * @bug 6341770 + * @summary Test external entity linked to non-ASCII base URL. + */ +public class Bug6341770 { + + // naming a file "aux" would fail on windows. + @Test + public void testNonAsciiURI() { + try { + File dir = File.createTempFile("sko\u0159ice", null); + dir.delete(); + dir.mkdir(); + File main = new File(dir, "main.xml"); + PrintWriter w = new PrintWriter(new FileWriter(main)); + w.println("<!DOCTYPE r [<!ENTITY aux SYSTEM \"aux1.xml\">]>"); + w.println("<r>&aux;</r>"); + w.flush(); + w.close(); + File aux = new File(dir, "aux1.xml"); + w = new PrintWriter(new FileWriter(aux)); + w.println("<x/>"); + w.flush(); + w.close(); + System.out.println("Parsing: " + main); + SAXParserFactory.newInstance().newSAXParser().parse(main, new DefaultHandler() { + public void startElement(String uri, String localname, String qname, Attributes attr) throws SAXException { + System.out.println("encountered <" + qname + ">"); + } + }); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail("Exception: " + e.getMessage()); + } + System.out.println("OK."); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug6361283.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +import org.testng.Assert; +import org.testng.annotations.Test; + +/* + * @bug 6361283 + * @summary Test SAXParser returns version as 1.1 for XML 1.1 document. + */ +public class Bug6361283 { + + @Test + public void testXMLVersion() { + try { + SAXParserFactory factory = SAXParserFactory.newInstance(); + SAXParser parser = factory.newSAXParser(); + Assert.assertTrue(factory.getFeature("http://xml.org/sax/features/use-locator2"), "use-locator2 should have value as true"); + MyDefaultHandler dh = new MyDefaultHandler(); + parser.parse(this.getClass().getResourceAsStream("catalog.xml"), dh); + Assert.assertTrue(dh.xmlVersion.equals("1.1"), "XML Document version should be 1.1"); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail("Exception occured: " + e.getMessage()); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug6506304Test.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import org.testng.Assert; +import org.testng.annotations.Test; +import org.xml.sax.XMLReader; + +/* + * @bug 6506304 + * @summary Test MalformedURLException: unknown protocol won't be thrown when there is a space within the full path file name. + */ +public class Bug6506304Test { + public static boolean isWindows = false; + static { + if (System.getProperty("os.name").indexOf("Windows") > -1) { + isWindows = true; + } + }; + + @Test + public void testPath() throws Exception { + if (isWindows) { + try { + SAXParserFactory factory = SAXParserFactory.newInstance(); + factory.setNamespaceAware(true); + SAXParser jaxpParser = factory.newSAXParser(); + XMLReader reader = jaxpParser.getXMLReader(); + reader.parse("C:/space error/x.xml"); + System.exit(0); + } catch (Exception e) { + System.out.println(e.getMessage()); + if (e.getMessage().equalsIgnoreCase("unknown protocol: c")) { + Assert.fail("jdk5 allowed the above form"); + } else if (e.getMessage().indexOf("(The system cannot find the path specified)") > 0) { + // expected + } + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug6518733.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import java.io.FileReader; + +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +import org.testng.Assert; +import org.testng.annotations.Test; +import org.xml.sax.Attributes; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +/* + * @bug 6518733 + * @summary Test SAX parser handles several attributes that each contain a newline within the attribute value. + */ +public class Bug6518733 { + + @Test + public void test() { + SAXParserFactory factory = SAXParserFactory.newInstance(); + try { + SAXParser saxParser = factory.newSAXParser(); + saxParser.parse(new InputSource(new FileReader(getClass().getResource("Bug6518733.xml").getFile())), new Handler()); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + static class Handler extends org.xml.sax.helpers.DefaultHandler { + public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { + // Make sure that the value of attribute q7 is "7 G" + if (qName.equals("obj")) { + Assert.assertTrue(attrs.getValue("", "q7").equals("7 G")); + } + } + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug6518733.xml Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,32 @@ +<?xml version="1.0"?> + +<obj + +q1="1 +A" + +q2="2 +B" + +q3="3 +C" + +q4="4 +D" + +q5="5 +E" + +q6="6 +F" + +q7="7 +G" + +q8="8 +H" + +q9="9 +I" + +/>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug6564400.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; + +import javax.xml.XMLConstants; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.stream.StreamSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; + +import org.testng.Assert; +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.Text; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +/* + * @bug 6564400 + * @summary Test ignorable whitespace handling with schema validation. + */ +public class Bug6564400 { + private boolean sawIgnorable = false; + Schema schema = null; + + public Bug6564400(String name) { + String xsdFile = "Bug6564400.xsd"; + File schemaFile = new File(xsdFile); + + // Now attempt to load up the schema + try { + SchemaFactory schFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + schema = schFactory.newSchema(new StreamSource(getClass().getResourceAsStream(xsdFile))); + } catch (Exception e) { + // Nevermind, bad things will happen later + } + } + + @Test + public void testDOM() throws ParserConfigurationException, SAXException, IOException { + InputStream xmlFile = getClass().getResourceAsStream("Bug6564400.xml"); + + // Set the options on the DocumentFactory to remove comments, remove + // whitespace + // and validate against the schema. + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + docFactory.setIgnoringComments(true); + docFactory.setIgnoringElementContentWhitespace(true); + docFactory.setSchema(schema); + + DocumentBuilder parser = docFactory.newDocumentBuilder(); + Document xmlDoc = parser.parse(xmlFile); + + boolean ok = dump(xmlDoc, true); + Assert.assertEquals(true, ok); + } + + @Test + public void testSAX() throws ParserConfigurationException, SAXException, IOException { + InputStream xmlFile = getClass().getResourceAsStream("Bug6564400.xml"); + + // Parse with SAX + SAXParserFactory saxFactory = SAXParserFactory.newInstance(); + saxFactory.setSchema(schema); + + SAXParser saxparser = saxFactory.newSAXParser(); + + sawIgnorable = false; + saxparser.parse(xmlFile, new MyHandler()); + Assert.assertEquals(true, sawIgnorable); + } + + @Test + public void testConformantDOM() throws ParserConfigurationException, SAXException, IOException { + InputStream xmlFile = getClass().getResourceAsStream("Bug6564400.xml"); + + // Set the options on the DocumentFactory to remove comments, remove + // whitespace + // and validate against the schema. + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + docFactory.setIgnoringComments(true); + docFactory.setIgnoringElementContentWhitespace(true); + docFactory.setSchema(schema); + docFactory.setFeature("http://java.sun.com/xml/schema/features/report-ignored-element-content-whitespace", true); + + DocumentBuilder parser = docFactory.newDocumentBuilder(); + Document xmlDoc = parser.parse(xmlFile); + + boolean ok = dump(xmlDoc, true); + Assert.assertEquals(false, ok); + } + + @Test + public void testConformantSAX() throws ParserConfigurationException, SAXException, IOException { + InputStream xmlFile = getClass().getResourceAsStream("Bug6564400.xml"); + + // Parse with SAX + SAXParserFactory saxFactory = SAXParserFactory.newInstance(); + saxFactory.setSchema(schema); + saxFactory.setFeature("http://java.sun.com/xml/schema/features/report-ignored-element-content-whitespace", true); + + SAXParser saxparser = saxFactory.newSAXParser(); + + sawIgnorable = false; + saxparser.parse(xmlFile, new MyHandler()); + Assert.assertEquals(false, sawIgnorable); + } + + private boolean dump(Node node) { + return dump(node, false); + } + + private boolean dump(Node node, boolean silent) { + return dump(node, silent, 0); + } + + private boolean dump(Node node, boolean silent, int depth) { + boolean ok = true; + if (!silent) { + for (int i = 0; i < depth; i++) { + System.out.print(" "); + } + System.out.println(node); + } + + if (node.getNodeType() == Node.TEXT_NODE) { + String text = ((Text) node).getData(); + ok = ok && text.trim().length() > 0; + } + + if (node.getNodeType() == Node.ELEMENT_NODE || node.getNodeType() == Node.DOCUMENT_NODE) { + Node child = node.getFirstChild(); + while (child != null) { + ok = ok && dump(child, silent, depth + 1); + child = child.getNextSibling(); + } + } + return ok; + } + + public class MyHandler extends DefaultHandler { + public void ignorableWhitespace(char[] ch, int start, int length) { + sawIgnorable = true; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug6564400.xml Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,4 @@ +<Person> + <FirstName>Doofus</FirstName><!-- MONKEY --> + <LastName>McGee</LastName> +</Person>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug6564400.xsd Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,9 @@ +<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'> + <xsd:element name='Person' type='PersonType'/> + <xsd:complexType name='PersonType'> + <xsd:sequence> + <xsd:element name='FirstName' type='xsd:string'/> + <xsd:element name='LastName' type='xsd:string'/> + </xsd:sequence> + </xsd:complexType> +</xsd:schema>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug6573786.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import java.io.InputStream; +import java.io.StringBufferInputStream; + +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import org.testng.Assert; +import org.testng.annotations.Test; + +/* + * @bug 6573786 + * @summary Test parser error messages are formatted. + */ +public class Bug6573786 { + String _cache = ""; + + @Test + public void test() { + final String XML = "" + "<?xml version='1.0' encoding='UTF-8' standalone='bad_value' ?>" + "<root />"; + + runTest(XML); + + } + + @Test + public void test1() { + final String XML = "" + "<?xml version='1.0' standalone='bad_value' encoding='UTF-8' ?>" + "<root />"; + runTest(XML); + + } + + void runTest(String xmlString) { + Bug6573786ErrorHandler handler = new Bug6573786ErrorHandler(); + try { + InputStream is = new StringBufferInputStream(xmlString); + SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); + parser.parse(is, handler); + } catch (Exception e) { + if (handler.fail) { + Assert.fail("The value of standalone attribute should be merged into the error message."); + } + } + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug6573786ErrorHandler.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; +import org.xml.sax.helpers.DefaultHandler; + +public class Bug6573786ErrorHandler extends DefaultHandler { + public boolean fail = false; + + public void fatalError(SAXParseException e) throws SAXException { + System.out.println(e.getMessage()); + if (e.getMessage().indexOf("bad_value") < 0) { + fail = true; + } + } // fatalError () + + public void error(SAXParseException e) throws SAXException { + System.out.println(e.getMessage()); + } // error () + + public void warning(SAXParseException e) throws SAXException { + System.out.println(e.getMessage()); + } // warning () +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug6594813.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import java.io.StringReader; +import java.io.StringWriter; + +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.sax.SAXSource; +import javax.xml.transform.stream.StreamResult; + +import org.testng.Assert; +import org.testng.annotations.Test; +import org.xml.sax.InputSource; +import org.xml.sax.helpers.DefaultHandler; + +/* + * @bug 6594813 + * @summary Test SAXParser output is wellformed with name space. + */ +public class Bug6594813 { + + public Bug6594813(String name) { + } + + private static final String TESTXML = "<?xml version='1.0' ?>\n" + + "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ns1='http://faulttestservice.org/wsdl'>\n" + + "<soapenv:Body>\n" + "<soapenv:Fault xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>\n" + "<faultcode>\n" + + "soapenv:Server</faultcode>\n" + "<faultstring>\n" + "com.sun.ts.tests.jaxws.sharedwebservices.faultservice.DummyException</faultstring>\n" + + "<detail>\n" + "<ns1:DummyException>\n" + "<dummyField1>\n" + "dummyString1</dummyField1>\n" + "<dummyField2>\n" + "dummyString2</dummyField2>\n" + + "</ns1:DummyException>\n" + "</detail>\n" + "</soapenv:Fault>\n" + "</soapenv:Body>\n" + "</soapenv:Envelope>\n"; + + // simplest XML to re-declare same prefix/namespace mappings + private static final String SIMPLE_TESTXML = "<?xml version='1.0' ?>\n" + "<prefix:ElementName xmlns:prefix='URI'>\n" + + "<prefix:ElementName xmlns:prefix='URI'>\n" + "</prefix:ElementName>\n" + "</prefix:ElementName>\n"; + + private String runTransform(SAXParser sp) throws Exception { + // Run identity transform using SAX parser + SAXSource src = new SAXSource(sp.getXMLReader(), new InputSource(new StringReader(TESTXML))); + Transformer transformer = TransformerFactory.newInstance().newTransformer(); + StringWriter sw = new StringWriter(); + transformer.transform(src, new StreamResult(sw)); + + String result = sw.getBuffer().toString(); + // System.out.println(result); + return result; + } + + private void checkWellFormedness(String xml) throws Exception { + SAXParserFactory spf = SAXParserFactory.newInstance(); + spf.setNamespaceAware(true); // Same as default + spf.setFeature("http://xml.org/sax/features/namespace-prefixes", true); + SAXParser sp = spf.newSAXParser(); + + // Re-parse output to make sure that it is well formed + sp.parse(new InputSource(new StringReader(xml)), new DefaultHandler()); + } + + /** + * Test an identity transform of an XML document with NS decls using a + * non-ns-aware parser. Output result to a StreamSource. Set ns-awareness to + * FALSE and prefixes to FALSE. + */ + @Test + public void testXMLNoNsAwareStreamResult1() { + try { + // Create SAX parser *without* enabling ns + SAXParserFactory spf = SAXParserFactory.newInstance(); + spf.setNamespaceAware(false); // Same as default + spf.setFeature("http://xml.org/sax/features/namespace-prefixes", false); + SAXParser sp = spf.newSAXParser(); + + // Make sure that the output is well formed + String xml = runTransform(sp); + checkWellFormedness(xml); + } catch (Throwable ex) { + Assert.fail(ex.toString()); + } + } + + /** + * Test an identity transform of an XML document with NS decls using a + * non-ns-aware parser. Output result to a StreamSource. Set ns-awareness to + * FALSE and prefixes to TRUE. + */ + @Test + public void testXMLNoNsAwareStreamResult2() { + try { + // Create SAX parser *without* enabling ns + SAXParserFactory spf = SAXParserFactory.newInstance(); + spf.setNamespaceAware(false); // Same as default + spf.setFeature("http://xml.org/sax/features/namespace-prefixes", true); + SAXParser sp = spf.newSAXParser(); + + // Make sure that the output is well formed + String xml = runTransform(sp); + checkWellFormedness(xml); + } catch (Throwable ex) { + Assert.fail(ex.toString()); + } + } + + /** + * Test an identity transform of an XML document with NS decls using a + * non-ns-aware parser. Output result to a StreamSource. Set ns-awareness to + * TRUE and prefixes to FALSE. + */ + @Test + public void testXMLNoNsAwareStreamResult3() { + try { + // Create SAX parser *without* enabling ns + SAXParserFactory spf = SAXParserFactory.newInstance(); + spf.setNamespaceAware(true); // Same as default + spf.setFeature("http://xml.org/sax/features/namespace-prefixes", false); + SAXParser sp = spf.newSAXParser(); + + // Make sure that the output is well formed + String xml = runTransform(sp); + checkWellFormedness(xml); + } catch (Throwable ex) { + Assert.fail(ex.toString()); + } + } + + /** + * Test an identity transform of an XML document with NS decls using a + * non-ns-aware parser. Output result to a StreamSource. Set ns-awareness to + * TRUE and prefixes to TRUE. + */ + @Test + public void testXMLNoNsAwareStreamResult4() { + try { + // Create SAX parser *without* enabling ns + SAXParserFactory spf = SAXParserFactory.newInstance(); + spf.setNamespaceAware(true); // Same as default + spf.setFeature("http://xml.org/sax/features/namespace-prefixes", true); + SAXParser sp = spf.newSAXParser(); + + // Make sure that the output is well formed + String xml = runTransform(sp); + checkWellFormedness(xml); + } catch (Throwable ex) { + Assert.fail(ex.toString()); + } + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug6608841.dtd Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,3 @@ +<!ENTITY % label.qname "IGNORE" > +<!ENTITY % xhtml PUBLIC "-//W3C//DTD XHTML 1.1//EN" "Bug6608841_xhtml11-flat.dtd"> +%xhtml;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug6608841.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import java.io.File; +import java.io.IOException; + +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +import org.testng.annotations.Test; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +/* + * @bug 6608841 + * @summary Test SAX parses external parameter entity. + */ +public class Bug6608841 { + public Bug6608841(String name) { + } + + @Test + public void testParse() throws ParserConfigurationException, SAXException, IOException { + String file = getClass().getResource("Bug6608841.xml").getFile(); + SAXParserFactory spf = SAXParserFactory.newInstance(); + SAXParser parser = spf.newSAXParser(); + parser.parse(new File(file), new MyHandler()); + } + + public class MyHandler extends DefaultHandler { + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug6608841.xml Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,10 @@ +<!DOCTYPE html SYSTEM "Bug6608841.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>Some Title</title> +</head> +<body> +<h1>Some Title</h1> +<p>This is a test. This is only a test.</p> +</body> +</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug6608841_xhtml11-flat.dtd Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,1 @@ +<?doc type="doctype" role="title" { XHTML 1.1 } ?>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug6690015.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import java.io.FileInputStream; + +import javax.xml.parsers.DocumentBuilderFactory; + +import org.testng.Assert; +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; + +/* + * @bug 6518733 + * @summary Test SAX parser handles several attributes with newlines. + */ +public class Bug6690015 { + + public Bug6690015() { + } + + @Test + public void test() { + try { + FileInputStream fis = new FileInputStream(getClass().getResource("bug6690015.xml").getFile()); + + Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(fis)); + Element root = doc.getDocumentElement(); + NodeList textnodes = root.getElementsByTagName("text"); + int len = textnodes.getLength(); + int index = 0; + int attindex = 0; + int attrlen = 0; + NamedNodeMap attrs = null; + + while (index < len) { + Element te = (Element) textnodes.item(index); + attrs = te.getAttributes(); + attrlen = attrs.getLength(); + attindex = 0; + Node node = null; + + while (attindex < attrlen) { + node = attrs.item(attindex); + System.out.println("attr: " + node.getNodeName() + " is shown holding value: " + node.getNodeValue()); + attindex++; + } + index++; + System.out.println("-------------"); + } + fis.close(); + } catch (Exception e) { + Assert.fail("Exception: " + e.getMessage()); + } + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug6760982.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import java.io.File; +import java.io.FileReader; +import java.io.Reader; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.testng.Assert; +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; + +/* + * @bug 6518733 + * @summary Test SAX parser handles several attributes with containing ">". + */ +public class Bug6760982 { + + @Test + public void test() { + try { + Document xmlDoc = _Parse(new File(getClass().getResource("bug6760982.xml").getFile())); + Node node = xmlDoc.getDocumentElement(); + + _ProcessNode(node, 0); + _Flush(); + } catch (Exception e) { + _ErrPrintln("Exception: " + e.toString()); + Assert.fail("Exception: " + e.getMessage()); + } + } + + private static void _Flush() { + System.out.flush(); + System.err.flush(); + } + + private static void _Println(String str, int level) { + for (int i = 0; i < level; i++) + System.out.print(" "); + + System.out.println(str); + System.out.flush(); + } + + private static void _ErrPrintln(String aStr) { + System.out.flush(); + System.err.println(aStr); + System.err.flush(); + } + + private static Document _Parse(File f) throws Exception { + FileReader rd = new FileReader(f); + Document doc = _Parse(rd); + + rd.close(); + + return doc; + } + + private static Document _Parse(Reader src) throws Exception { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + + dbf.setValidating(false); // to improve performance + + DocumentBuilder xmlParser = dbf.newDocumentBuilder(); + InputSource is = new InputSource(src); + + return xmlParser.parse(is); + } + + private static void _PrintAttributes(Node n, int level) { + NamedNodeMap nnmap = n.getAttributes(); + + if (nnmap != null && nnmap.getLength() > 0) { + _Println("<attribs> (" + nnmap.getClass() + "):", level + 1); + + for (int i = 0; i < nnmap.getLength(); i++) { + Node an = nnmap.item(i); + + String nameStr = an.getNodeName(); + String valueStr = an.getNodeValue(); + + if (valueStr != "") + nameStr += " = " + valueStr; + + _Println(nameStr, level + 2); + } + } + } + + private static void _ProcessChildren(Node n, int level) throws Exception { + NodeList nlist = n.getChildNodes(); + + if (nlist != null) + for (int i = 0; i < nlist.getLength(); i++) + _ProcessNode(nlist.item(i), level + 1); + } + + private static void _ProcessNode(Node n, int level) throws Exception { + n.getAttributes(); + n.getChildNodes(); + + // At this point, for JVM 1.6 and Xerces <= 1.3.1, + // Test-XML.xml::mytest:Y's attribute is (already) bad. + + switch (n.getNodeType()) { + + case Node.TEXT_NODE: + String str = n.getNodeValue().trim(); + + /* ...Only print non-empty strings... */ + if (str.length() > 0) { + String valStr = n.getNodeValue(); + + _Println(valStr, level); + } + break; + + case Node.COMMENT_NODE: + break; + + default: { + String nodeNameStr = n.getNodeName(); + + _Println(nodeNameStr + " (" + n.getClass() + "):", level); + + /* ...Print children... */ + _ProcessChildren(n, level); + + /* ...Print optional node attributes... */ + _PrintAttributes(n, level); + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug6849942Test.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import java.io.ByteArrayInputStream; + +import org.testng.Assert; +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.w3c.dom.ProcessingInstruction; +import org.xml.sax.InputSource; + +/* + * @bug 6849942 + * @summary Test parsing an XML that starts with a processing instruction and no prolog. + */ +public class Bug6849942Test { + + @Test + public void test() throws Exception { + try { + ByteArrayInputStream bais = new ByteArrayInputStream("<?xmltarget foo?><test></test>".getBytes()); + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder xmlParser = factory.newDocumentBuilder(); + // DOMParser p = new DOMParser(); + Document document = xmlParser.parse(new InputSource(bais)); + String result = ((ProcessingInstruction) document.getFirstChild()).getData(); + System.out.println(result); + if (!result.equalsIgnoreCase("foo")) { + Assert.fail("missing PI data"); + } + + } catch (Exception e) { + } + } + + @Test + public void testWProlog() throws Exception { + try { + ByteArrayInputStream bais = new ByteArrayInputStream("<?xml version=\"1.1\" encoding=\"UTF-8\"?><?xmltarget foo?><test></test>".getBytes()); + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder xmlParser = factory.newDocumentBuilder(); + // DOMParser p = new DOMParser(); + Document document = xmlParser.parse(new InputSource(bais)); + String result = ((ProcessingInstruction) document.getFirstChild()).getData(); + System.out.println(result); + if (!result.equalsIgnoreCase("foo")) { + Assert.fail("missing PI data"); + } + } catch (Exception e) { + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug7157608.dtd Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,1 @@ +<!ELEMENT arg (#PCDATA)>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug7157608.xml Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + Document : test1.xml + Created on : 2012/04/13, 18:21 + Author : 10385373 + Description: + Purpose of the document follows. +--> + +<root> + +</root>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug7157608Test.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import java.io.File; +import java.io.IOException; + +import org.testng.Assert; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; +import org.xml.sax.helpers.DefaultHandler; + +/* + * @bug 7157608 + * @summary Test feature standard-uri-conformant works. + */ +public class Bug7157608Test { + public static boolean isWindows = false; + static { + if (System.getProperty("os.name").indexOf("Windows") > -1) { + isWindows = true; + } + }; + + String xml1, xml2; + + @BeforeMethod + protected void setUp() throws IOException { + File file1 = new File(getClass().getResource("Bug7157608.xml").getFile()); + xml1 = file1.getPath().replace("\\", "\\\\"); + File file2 = new File(getClass().getResource("Bug7157608_1.xml").getFile()); + xml2 = file2.getPath(); + } + + // case 1 + // standard-uri-confomant is false + // dtd-validation is false + @Test + public void test1() { + if (isWindows) { + try { + ParserSettings ps = new ParserSettings(); + + DocumentBuilder db = getDocumentBuilder(ps); + InputSource is = new InputSource(); + is.setSystemId(xml1); + Document doc = db.parse(is); + System.out.println("test1() :OK"); + } catch (Exception e) { + Assert.fail("test1() :NG"); + + } + } + } + + // case 2 + // standard-uri-confomant is false + // dtd-validation is true + @Test + public void test2() { + if (isWindows) { + try { + ParserSettings ps = new ParserSettings(); + ps.validating = true; + + DocumentBuilder db = getDocumentBuilder(ps); + InputSource is = new InputSource(xml2); + Document doc = db.parse(is); + System.out.println("test2() :OK"); + } catch (Exception e) { + Assert.fail("test2() :NG"); + // logger.info(e.getMessage()); + } + } + } + + // case 3 + // standard-uri-confomant is true + @Test + public void test3() { + if (isWindows) { + try { + ParserSettings ps = new ParserSettings(); + ps.standardUriConformant = true; + + DocumentBuilder db = getDocumentBuilder(ps); + InputSource is = new InputSource(); + is.setSystemId(xml1); + Document doc = db.parse(is); + Assert.fail("test3() :NG"); + } catch (IOException e) { + String returnedErr = e.getMessage(); + String expectedStr = "Opaque part contains invalid character"; + + if (returnedErr.indexOf(expectedStr) >= 0) { + System.out.println("test3() :OK"); + } else { + Assert.fail("test3() :NG"); + } + } catch (Exception e) { + System.out.println("test3() :NG"); + } + } + } + + // case 4 + // standard-uri-confomant is true + // dtd-validation is true + @Test + public void test4() { + if (isWindows) { + try { + ParserSettings ps = new ParserSettings(); + ps.standardUriConformant = true; + ps.validating = true; + + DocumentBuilder db = getDocumentBuilder(ps); + InputSource is = new InputSource(xml2); + Document doc = db.parse(is); + Assert.fail("test4() :NG"); + } catch (IOException e) { + String returnedErr = e.getMessage(); + String expectedStr = "Opaque part contains invalid character"; + + if (returnedErr.indexOf(expectedStr) >= 0) { + System.out.println("test3() :OK"); + } else { + Assert.fail("test3() :NG"); + } + } catch (Exception e) { + Assert.fail("test4() :NG"); + } + } + } + + public DocumentBuilder getDocumentBuilder(ParserSettings ps) { + DocumentBuilder db = null; + try { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + if (ps.standardUriConformant) { + dbf.setFeature("http://apache.org/xml/features/standard-uri-conformant", true); + } + dbf.setValidating(ps.validating); + db = dbf.newDocumentBuilder(); + db.setErrorHandler(new MyHandler()); + } catch (Exception e) { + Assert.fail("standard-uri-conformant not recognized"); + } + return db; + } + + class MyHandler extends DefaultHandler { + @Override + public void warning(SAXParseException e) throws SAXException { + printDetail("**Warning**", e); + } + + @Override + public void error(SAXParseException e) throws SAXException { + printDetail("**Error**", e); + throw new SAXException("Error encountered"); + } + + @Override + public void fatalError(SAXParseException e) throws SAXException { + printDetail("**Fatal Error**", e); + throw new SAXException("Fatal Error encountered"); + } + + public void printDetail(String msg, SAXParseException e) { + System.out.println(msg); + System.out.println(e.getMessage()); + System.out.println(" Line: " + e.getLineNumber()); + System.out.println(" Column: " + e.getColumnNumber()); + System.out.println(" URI: " + e.getSystemId()); + } + + } + + class ParserSettings { + boolean standardUriConformant = false; + boolean validating = false; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug7157608_1.xml Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + Document : test2.xml + Created on : 2012/04/13, 20:08 + Author : 10385373 + Description: + Purpose of the document follows. +--> + +<!DOCTYPE arg PUBLIC '-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN' 'Bug7157608.dtd'> +<arg> +test +</arg>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug7166896Test.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import java.io.IOException; + +import org.testng.Assert; +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + +/* + * @bug 7166896 + * @summary Test DocumentBuilder.parse(String uri) supports IPv6 format. + */ +public class Bug7166896Test { + + @Test + public void test() throws Exception { + final String url = "http://[fe80::la03:73ff:fead:f7b0]/note.xml"; + final DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); + domFactory.setNamespaceAware(true); + DocumentBuilder builder; + Document doc = null; + System.out.println("URL is " + url); + try { + builder = domFactory.newDocumentBuilder(); + // here comes the MalformedURLException. With Java6 / 7 it looks + // like this: + // java.net.MalformedURLException: For input string: + // ":la03:73ff:fead:f7b0%5D" + // which is not fine. + // with xerces 2.11.0 it complains about a non-existing host, which + // is fine + System.out.println("passing URL to DocumentBuilder.parse()"); + doc = builder.parse(url); + + } catch (SAXException e) { + e.printStackTrace(); + } catch (IOException e) { + String em = e.getMessage(); + System.err.println("Error message: " + em); + if (em.contains("For input string: \":la03:73ff:fead:f7b0%5D\"")) { + Assert.fail("failed to accept IPv6 address"); + } + } catch (ParserConfigurationException e) { + e.printStackTrace(); + } + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug8003147Test.java Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.parsers; + +import java.io.FileOutputStream; +import java.util.ArrayList; + +import org.testng.Assert; +import org.testng.annotations.Test; + +import com.sun.org.apache.bcel.internal.classfile.ClassParser; +import com.sun.org.apache.bcel.internal.classfile.ConstantClass; +import com.sun.org.apache.bcel.internal.classfile.ConstantPool; +import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8; +import com.sun.org.apache.bcel.internal.classfile.JavaClass; +import com.sun.org.apache.bcel.internal.classfile.Method; +import com.sun.org.apache.bcel.internal.generic.ClassGen; +import com.sun.org.apache.bcel.internal.generic.MethodGen; + +/* + * @bug 8003147 + * @summary Test port fix for BCEL bug 39695. + */ +public class Bug8003147Test { + + @Test + public void test() throws Exception { + String classfile = getClass().getResource("Bug8003147Test.class").getPath(); + JavaClass jc = new ClassParser(classfile).parse(); + // rename class + ConstantPool cp = jc.getConstantPool(); + int cpIndex = ((ConstantClass) cp.getConstant(jc.getClassNameIndex())).getNameIndex(); + cp.setConstant(cpIndex, new ConstantUtf8("javax/xml/parsers/Bug8003147TestPrime")); + ClassGen gen = new ClassGen(jc); + Method[] methods = jc.getMethods(); + int index; + for (index = 0; index < methods.length; index++) { + if (methods[index].getName().equals("doSomething")) { + break; + } + } + Method m = methods[index]; + MethodGen mg = new MethodGen(m, gen.getClassName(), gen.getConstantPool()); + gen.replaceMethod(m, mg.getMethod()); + String path = classfile.replace("Bug8003147Test", "Bug8003147TestPrime"); + gen.getJavaClass().dump(new FileOutputStream(path)); + + try { + Class.forName("javax.xml.parsers.Bug8003147TestPrime"); + } catch (ClassFormatError cfe) { + cfe.printStackTrace(); + Assert.fail("modified version of class does not pass verification"); + } + } + + public void doSomething(double d, ArrayList<Integer> list) { + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/DosTest.xml Tue Nov 18 12:01:27 2014 -0800 @@ -0,0 +1,2031 @@ +<?xml version="1.0" encoding="UTF-8"?> +<personnel> + +<person id="Big.Boss" A100 = "" +A101 = "" A102 = "" A103 = "" A104 = "" A105 = "" A106 = "" A107 = "" A108 = "" A109 = "" A110 = "" +A111 = "" A112 = "" A113 = "" A114 = "" A115 = "" A116 = "" A117 = "" A118 = "" A119 = "" A120 = "" +A121 = "" A122 = "" A123 = "" A124 = "" A125 = "" A126 = "" A127 = "" A128 = "" A129 = "" A130 = "" +A131 = "" A132 = "" A133 = "" A134 = "" A135 = "" A136 = "" A137 = "" A138 = "" A139 = "" A140 = "" +A141 = "" A142 = "" A143 = "" A144 = "" A145 = "" A146 = "" A147 = "" A148 = "" A149 = "" A150 = "" +A151 = "" A152 = "" A153 = "" A154 = "" A155 = "" A156 = "" A157 = "" A158 = "" A159 = "" A160 = "" +A161 = "" A162 = "" A163 = "" A164 = "" A165 = "" A166 = "" A167 = "" A168 = "" A169 = "" A170 = "" +A171 = "" A172 = "" A173 = "" A174 = "" A175 = "" A176 = "" A177 = "" A178 = "" A179 = "" A180 = "" +A181 = "" A182 = "" A183 = "" A184 = "" A185 = "" A186 = "" A187 = "" A188 = "" A189 = "" A190 = "" +A191 = "" A192 = "" A193 = "" A194 = "" A195 = "" A196 = "" A197 = "" A198 = "" A199 = "" A200 = "" +A201 = "" A202 = "" A203 = "" A204 = "" A205 = "" A206 = "" A207 = "" A208 = "" A209 = "" A210 = "" +A211 = "" A212 = "" A213 = "" A214 = "" A215 = "" A216 = "" A217 = "" A218 = "" A219 = "" A220 = "" +A221 = "" A222 = "" A223 = "" A224 = "" A225 = "" A226 = "" A227 = "" A228 = "" A229 = "" A230 = "" +A231 = "" A232 = "" A233 = "" A234 = "" A235 = "" A236 = "" A237 = "" A238 = "" A239 = "" A240 = "" +A241 = "" A242 = "" A243 = "" A244 = "" A245 = "" A246 = "" A247 = "" A248 = "" A249 = "" A250 = "" +A251 = "" A252 = "" A253 = "" A254 = "" A255 = "" A256 = "" A257 = "" A258 = "" A259 = "" A260 = "" +A261 = "" A262 = "" A263 = "" A264 = "" A265 = "" A266 = "" A267 = "" A268 = "" A269 = "" A270 = "" +A271 = "" A272 = "" A273 = "" A274 = "" A275 = "" A276 = "" A277 = "" A278 = "" A279 = "" A280 = "" +A281 = "" A282 = "" A283 = "" A284 = "" A285 = "" A286 = "" A287 = "" A288 = "" A289 = "" A290 = "" +A291 = "" A292 = "" A293 = "" A294 = "" A295 = "" A296 = "" A297 = "" A298 = "" A299 = "" A300 = "" +A301 = "" A302 = "" A303 = "" A304 = "" A305 = "" A306 = "" A307 = "" A308 = "" A309 = "" A310 = "" +A311 = "" A312 = "" A313 = "" A314 = "" A315 = "" A316 = "" A317 = "" A318 = "" A319 = "" A320 = "" +A321 = "" A322 = "" A323 = "" A324 = "" A325 = "" A326 = "" A327 = "" A328 = "" A329 = "" A330 = "" +A331 = "" A332 = "" A333 = "" A334 = "" A335 = "" A336 = "" A337 = "" A338 = "" A339 = "" A340 = "" +A341 = "" A342 = "" A343 = "" A344 = "" A345 = "" A346 = "" A347 = "" A348 = "" A349 = "" A350 = "" +A351 = "" A352 = "" A353 = "" A354 = "" A355 = "" A356 = "" A357 = "" A358 = "" A359 = "" A360 = "" +A361 = "" A362 = "" A363 = "" A364 = "" A365 = "" A366 = "" A367 = "" A368 = "" A369 = "" A370 = "" +A371 = "" A372 = "" A373 = "" A374 = "" A375 = "" A376 = "" A377 = "" A378 = "" A379 = "" A380 = "" +A381 = "" A382 = "" A383 = "" A384 = "" A385 = "" A386 = "" A387 = "" A388 = "" A389 = "" A390 = "" +A391 = "" A392 = "" A393 = "" A394 = "" A395 = "" A396 = "" A397 = "" A398 = "" A399 = "" A400 = "" +A401 = "" A402 = "" A403 = "" A404 = "" A405 = "" A406 = "" A407 = "" A408 = "" A409 = "" A410 = "" +A411 = "" A412 = "" A413 = "" A414 = "" A415 = "" A416 = "" A417 = "" A418 = "" A419 = "" A420 = "" +A421 = "" A422 = "" A423 = "" A424 = "" A425 = "" A426 = "" A427 = "" A428 = "" A429 = "" A430 = "" +A431 = "" A432 = "" A433 = "" A434 = "" A435 = "" A436 = "" A437 = "" A438 = "" A439 = "" A440 = "" +A441 = "" A442 = "" A443 = "" A444 = "" A445 = "" A446 = "" A447 = "" A448 = "" A449 = "" A450 = "" +A451 = "" A452 = "" A453 = "" A454 = "" A455 = "" A456 = "" A457 = "" A458 = "" A459 = "" A460 = "" +A461 = "" A462 = "" A463 = "" A464 = "" A465 = "" A466 = "" A467 = "" A468 = "" A469 = "" A470 = "" +A471 = "" A472 = "" A473 = "" A474 = "" A475 = "" A476 = "" A477 = "" A478 = "" A479 = "" A480 = "" +A481 = "" A482 = "" A483 = "" A484 = "" A485 = "" A486 = "" A487 = "" A488 = "" A489 = "" A490 = "" +A491 = "" A492 = "" A493 = "" A494 = "" A495 = "" A496 = "" A497 = "" A498 = "" A499 = "" A500 = "" +A501 = "" A502 = "" A503 = "" A504 = "" A505 = "" A506 = "" A507 = "" A508 = "" A509 = "" A510 = "" +A511 = "" A512 = "" A513 = "" A514 = "" A515 = "" A516 = "" A517 = "" A518 = "" A519 = "" A520 = "" +A521 = "" A522 = "" A523 = "" A524 = "" A525 = "" A526 = "" A527 = "" A528 = "" A529 = "" A530 = "" +A531 = "" A532 = "" A533 = "" A534 = "" A535 = "" A536 = "" A537 = "" A538 = "" A539 = "" A540 = "" +A541 = "" A542 = "" A543 = "" A544 = "" A545 = "" A546 = "" A547 = "" A548 = "" A549 = "" A550 = "" +A551 = "" A552 = "" A553 = "" A554 = "" A555 = "" A556 = "" A557 = "" A558 = "" A559 = "" A560 = "" +A561 = "" A562 = "" A563 = "" A564 = "" A565 = "" A566 = "" A567 = "" A568 = "" A569 = "" A570 = "" +A571 = "" A572 = "" A573 = "" A574 = "" A575 = "" A576 = "" A577 = "" A578 = "" A579 = "" A580 = "" +A581 = "" A582 = "" A583 = "" A584 = "" A585 = "" A586 = "" A587 = "" A588 = "" A589 = "" A590 = "" +A591 = "" A592 = "" A593 = "" A594 = "" A595 = "" A596 = "" A597 = "" A598 = "" A599 = "" A600 = "" +A601 = "" A602 = "" A603 = "" A604 = "" A605 = "" A606 = "" A607 = "" A608 = "" A609 = "" A610 = "" +A611 = "" A612 = "" A613 = "" A614 = "" A615 = "" A616 = "" A617 = "" A618 = "" A619 = "" A620 = "" +A621 = "" A622 = "" A623 = "" A624 = "" A625 = "" A626 = "" A627 = "" A628 = "" A629 = "" A630 = "" +A631 = "" A632 = "" A633 = "" A634 = "" A635 = "" A636 = "" A637 = "" A638 = "" A639 = "" A640 = "" +A641 = "" A642 = "" A643 = "" A644 = "" A645 = "" A646 = "" A647 = "" A648 = "" A649 = "" A650 = "" +A651 = "" A652 = "" A653 = "" A654 = "" A655 = "" A656 = "" A657 = "" A658 = "" A659 = "" A660 = "" +A661 = "" A662 = "" A663 = "" A664 = "" A665 = "" A666 = "" A667 = "" A668 = "" A669 = "" A670 = "" +A671 = "" A672 = "" A673 = "" A674 = "" A675 = "" A676 = "" A677 = "" A678 = "" A679 = "" A680 = "" +A681 = "" A682 = "" A683 = "" A684 = "" A685 = "" A686 = "" A687 = "" A688 = "" A689 = "" A690 = "" +A691 = "" A692 = "" A693 = "" A694 = "" A695 = "" A696 = "" A697 = "" A698 = "" A699 = "" A700 = "" +A701 = "" A702 = "" A703 = "" A704 = "" A705 = "" A706 = "" A707 = "" A708 = "" A709 = "" A710 = "" +A711 = "" A712 = "" A713 = "" A714 = "" A715 = "" A716 = "" A717 = "" A718 = "" A719 = "" A720 = "" +A721 = "" A722 = "" A723 = "" A724 = "" A725 = "" A726 = "" A727 = "" A728 = "" A729 = "" A730 = "" +A731 = "" A732 = "" A733 = "" A734 = "" A735 = "" A736 = "" A737 = "" A738 = "" A739 = "" A740 = "" +A741 = "" A742 = "" A743 = "" A744 = "" A745 = "" A746 = "" A747 = "" A748 = "" A749 = "" A750 = "" +A751 = "" A752 = "" A753 = "" A754 = "" A755 = "" A756 = "" A757 = "" A758 = "" A759 = "" A760 = "" +A761 = "" A762 = "" A763 = "" A764 = "" A765 = "" A766 = "" A767 = "" A768 = "" A769 = "" A770 = "" +A771 = "" A772 = "" A773 = "" A774 = "" A775 = "" A776 = "" A777 = "" A778 = "" A779 = "" A780 = "" +A781 = "" A782 = "" A783 = "" A784 = "" A785 = "" A786 = "" A787 = "" A788 = "" A789 = "" A790 = "" +A791 = "" A792 = "" A793 = "" A794 = "" A795 = "" A796 = "" A797 = "" A798 = "" A799 = "" A800 = "" +A801 = "" A802 = "" A803 = "" A804 = "" A805 = "" A806 = "" A807 = "" A808 = "" A809 = "" A810 = "" +A811 = "" A812 = "" A813 = "" A814 = "" A815 = "" A816 = "" A817 = "" A818 = "" A819 = "" A820 = "" +A821 = "" A822 = "" A823 = "" A824 = "" A825 = "" A826 = "" A827 = "" A828 = "" A829 = "" A830 = "" +A831 = "" A832 = "" A833 = "" A834 = "" A835 = "" A836 = "" A837 = "" A838 = "" A839 = "" A840 = "" +A841 = "" A842 = "" A843 = "" A844 = "" A845 = "" A846 = "" A847 = "" A848 = "" A849 = "" A850 = "" +A851 = "" A852 = "" A853 = "" A854 = "" A855 = "" A856 = "" A857 = "" A858 = "" A859 = "" A860 = "" +A861 = "" A862 = "" A863 = "" A864 = "" A865 = "" A866 = "" A867 = "" A868 = "" A869 = "" A870 = "" +A871 = "" A872 = "" A873 = "" A874 = "" A875 = "" A876 = "" A877 = "" A878 = "" A879 = "" A880 = "" +A881 = "" A882 = "" A883 = "" A884 = "" A885 = "" A886 = "" A887 = "" A888 = "" A889 = "" A890 = "" +A891 = "" A892 = "" A893 = "" A894 = "" A895 = "" A896 = "" A897 = "" A898 = "" A899 = "" A900 = "" +A901 = "" A902 = "" A903 = "" A904 = "" A905 = "" A906 = "" A907 = "" A908 = "" A909 = "" A910 = "" +A911 = "" A912 = "" A913 = "" A914 = "" A915 = "" A916 = "" A917 = "" A918 = "" A919 = "" A920 = "" +A921 = "" A922 = "" A923 = "" A924 = "" A925 = "" A926 = "" A927 = "" A928 = "" A929 = "" A930 = "" +A931 = "" A932 = "" A933 = "" A934 = "" A935 = "" A936 = "" A937 = "" A938 = "" A939 = "" A940 = "" +A941 = "" A942 = "" A943 = "" A944 = "" A945 = "" A946 = "" A947 = "" A948 = "" A949 = "" A950 = "" +A951 = "" A952 = "" A953 = "" A954 = "" A955 = "" A956 = "" A957 = "" A958 = "" A959 = "" A960 = "" +A961 = "" A962 = "" A963 = "" A964 = "" A965 = "" A966 = "" A967 = "" A968 = "" A969 = "" A970 = "" +A971 = "" A972 = "" A973 = "" A974 = "" A975 = "" A976 = "" A977 = "" A978 = "" A979 = "" A980 = "" +A981 = "" A982 = "" A983 = "" A984 = "" A985 = "" A986 = "" A987 = "" A988 = "" A989 = "" A990 = "" +A991 = "" A992 = "" A993 = "" A994 = "" A995 = "" A996 = "" A997 = "" A998 = "" A999 = "" A1000 = "" +A1001 = "" A1002 = "" A1003 = "" A1004 = "" A1005 = "" A1006 = "" A1007 = "" A1008 = "" A1009 = "" A1010 = "" +A1011 = "" A1012 = "" A1013 = "" A1014 = "" A1015 = "" A1016 = "" A1017 = "" A1018 = "" A1019 = "" A1020 = "" +A1021 = "" A1022 = "" A1023 = "" A1024 = "" A1025 = "" A1026 = "" A1027 = "" A1028 = "" A1029 = "" A1030 = "" +A1031 = "" A1032 = "" A1033 = "" A1034 = "" A1035 = "" A1036 = "" A1037 = "" A1038 = "" A1039 = "" A1040 = "" +A1041 = "" A1042 = "" A1043 = "" A1044 = "" A1045 = "" A1046 = "" A1047 = "" A1048 = "" A1049 = "" A1050 = "" +A1051 = "" A1052 = "" A1053 = "" A1054 = "" A1055 = "" A1056 = "" A1057 = "" A1058 = "" A1059 = "" A1060 = "" +A1061 = "" A1062 = "" A1063 = "" A1064 = "" A1065 = "" A1066 = "" A1067 = "" A1068 = "" A1069 = "" A1070 = "" +A1071 = "" A1072 = "" A1073 = "" A1074 = "" A1075 = "" A1076 = "" A1077 = "" A1078 = "" A1079 = "" A1080 = "" +A1081 = "" A1082 = "" A1083 = "" A1084 = "" A1085 = "" A1086 = "" A1087 = "" A1088 = "" A1089 = "" A1090 = "" +A1091 = "" A1092 = "" A1093 = "" A1094 = "" A1095 = "" A1096 = "" A1097 = "" A1098 = "" A1099 = "" A1100 = "" +A1101 = "" A1102 = "" A1103 = "" A1104 = "" A1105 = "" A1106 = "" A1107 = "" A1108 = "" A1109 = "" A1110 = "" +A1111 = "" A1112 = "" A1113 = "" A1114 = "" A1115 = "" A1116 = "" A1117 = "" A1118 = "" A1119 = "" A1120 = "" +A1121 = "" A1122 = "" A1123 = "" A1124 = "" A1125 = "" A1126 = "" A1127 = "" A1128 = "" A1129 = "" A1130 = "" +A1131 = "" A1132 = "" A1133 = "" A1134 = "" A1135 = "" A1136 = "" A1137 = "" A1138 = "" A1139 = "" A1140 = "" +A1141 = "" A1142 = "" A1143 = "" A1144 = "" A1145 = "" A1146 = "" A1147 = "" A1148 = "" A1149 = "" A1150 = "" +A1151 = "" A1152 = "" A1153 = "" A1154 = "" A1155 = "" A1156 = "" A1157 = "" A1158 = "" A1159 = "" A1160 = "" +A1161 = "" A1162 = "" A1163 = "" A1164 = "" A1165 = "" A1166 = "" A1167 = "" A1168 = "" A1169 = "" A1170 = "" +A1171 = "" A1172 = "" A1173 = "" A1174 = "" A1175 = "" A1176 = "" A1177 = "" A1178 = "" A1179 = "" A1180 = "" +A1181 = "" A1182 = "" A1183 = "" A1184 = "" A1185 = "" A1186 = "" A1187 = "" A1188 = "" A1189 = "" A1190 = "" +A1191 = "" A1192 = "" A1193 = "" A1194 = "" A1195 = "" A1196 = "" A1197 = "" A1198 = "" A1199 = "" A1200 = "" +A1201 = "" A1202 = "" A1203 = "" A1204 = "" A1205 = "" A1206 = "" A1207 = "" A1208 = "" A1209 = "" A1210 = "" +A1211 = "" A1212 = "" A1213 = "" A1214 = "" A1215 = "" A1216 = "" A1217 = "" A1218 = "" A1219 = "" A1220 = "" +A1221 = "" A1222 = "" A1223 = "" A1224 = "" A1225 = "" A1226 = "" A1227 = "" A1228 = "" A1229 = "" A1230 = "" +A1231 = "" A1232 = "" A1233 = "" A1234 = "" A1235 = "" A1236 = "" A1237 = "" A1238 = "" A1239 = "" A1240 = "" +A1241 = "" A1242 = "" A1243 = "" A1244 = "" A1245 = "" A1246 = "" A1247 = "" A1248 = "" A1249 = "" A1250 = "" +A1251 = "" A1252 = "" A1253 = "" A1254 = "" A1255 = "" A1256 = "" A1257 = "" A1258 = "" A1259 = "" A1260 = "" +A1261 = "" A1262 = "" A1263 = "" A1264 = "" A1265 = "" A1266 = "" A1267 = "" A1268 = "" A1269 = "" A1270 = "" +A1271 = "" A1272 = "" A1273 = "" A1274 = "" A1275 = "" A1276 = "" A1277 = "" A1278 = "" A1279 = "" A1280 = "" +A1281 = "" A1282 = "" A1283 = "" A1284 = "" A1285 = "" A1286 = "" A1287 = "" A1288 = "" A1289 = "" A1290 = "" +A1291 = "" A1292 = "" A1293 = "" A1294 = "" A1295 = "" A1296 = "" A1297 = "" A1298 = "" A1299 = "" A1300 = "" +A1301 = "" A1302 = "" A1303 = "" A1304 = "" A1305 = "" A1306 = "" A1307 = "" A1308 = "" A1309 = "" A1310 = "" +A1311 = "" A1312 = "" A1313 = "" A1314 = "" A1315 = "" A1316 = "" A1317 = "" A1318 = "" A1319 = "" A1320 = "" +A1321 = "" A1322 = "" A1323 = "" A1324 = "" A1325 = "" A1326 = "" A1327 = "" A1328 = "" A1329 = "" A1330 = "" +A1331 = "" A1332 = "" A1333 = "" A1334 = "" A1335 = "" A1336 = "" A1337 = "" A1338 = "" A1339 = "" A1340 = "" +A1341 = "" A1342 = "" A1343 = "" A1344 = "" A1345 = "" A1346 = "" A1347 = "" A1348 = "" A1349 = "" A1350 = "" +A1351 = "" A1352 = "" A1353 = "" A1354 = "" A1355 = "" A1356 = "" A1357 = "" A1358 = "" A1359 = "" A1360 = "" +A1361 = "" A1362 = "" A1363 = "" A1364 = "" A1365 = "" A1366 = "" A1367 = "" A1368 = "" A1369 = "" A1370 = "" +A1371 = "" A1372 = "" A1373 = "" A1374 = "" A1375 = "" A1376 = "" A1377 = "" A1378 = "" A1379 = "" A1380 = "" +A1381 = "" A1382 = "" A1383 = "" A1384 = "" A1385 = "" A1386 = "" A1387 = "" A1388 = "" A1389 = "" A1390 = "" +A1391 = "" A1392 = "" A1393 = "" A1394 = "" A1395 = "" A1396 = "" A1397 = "" A1398 = "" A1399 = "" A1400 = "" +A1401 = "" A1402 = "" A1403 = "" A1404 = "" A1405 = "" A1406 = "" A1407 = "" A1408 = "" A1409 = "" A1410 = "" +A1411 = "" A1412 = "" A1413 = "" A1414 = "" A1415 = "" A1416 = "" A1417 = "" A1418 = "" A1419 = "" A1420 = "" +A1421 = "" A1422 = "" A1423 = "" A1424 = "" A1425 = "" A1426 = "" A1427 = "" A1428 = "" A1429 = "" A1430 = "" +A1431 = "" A1432 = "" A1433 = "" A1434 = "" A1435 = "" A1436 = "" A1437 = "" A1438 = "" A1439 = "" A1440 = "" +A1441 = "" A1442 = "" A1443 = "" A1444 = "" A1445 = "" A1446 = "" A1447 = "" A1448 = "" A1449 = "" A1450 = "" +A1451 = "" A1452 = "" A1453 = "" A1454 = "" A1455 = "" A1456 = "" A1457 = "" A1458 = "" A1459 = "" A1460 = "" +A1461 = "" A1462 = "" A1463 = "" A1464 = "" A1465 = "" A1466 = "" A1467 = "" A1468 = "" A1469 = "" A1470 = "" +A1471 = "" A1472 = "" A1473 = "" A1474 = "" A1475 = "" A1476 = "" A1477 = "" A1478 = "" A1479 = "" A1480 = "" +A1481 = "" A1482 = "" A1483 = "" A1484 = "" A1485 = "" A1486 = "" A1487 = "" A1488 = "" A1489 = "" A1490 = "" +A1491 = "" A1492 = "" A1493 = "" A1494 = "" A1495 = "" A1496 = "" A1497 = "" A1498 = "" A1499 = "" A1500 = "" +A1501 = "" A1502 = "" A1503 = "" A1504 = "" A1505 = "" A1506 = "" A1507 = "" A1508 = "" A1509 = "" A1510 = "" +A1511 = "" A1512 = "" A1513 = "" A1514 = "" A1515 = "" A1516 = "" A1517 = "" A1518 = "" A1519 = "" A1520 = "" +A1521 = "" A1522 = "" A1523 = "" A1524 = "" A1525 = "" A1526 = "" A1527 = "" A1528 = "" A1529 = "" A1530 = "" +A1531 = "" A1532 = "" A1533 = "" A1534 = "" A1535 = "" A1536 = "" A1537 = "" A1538 = "" A1539 = "" A1540 = "" +A1541 = "" A1542 = "" A1543 = "" A1544 = "" A1545 = "" A1546 = "" A1547 = "" A1548 = "" A1549 = "" A1550 = "" +A1551 = "" A1552 = "" A1553 = "" A1554 = "" A1555 = "" A1556 = "" A1557 = "" A1558 = "" A1559 = "" A1560 = "" +A1561 = "" A1562 = "" A1563 = "" A1564 = "" A1565 = "" A1566 = "" A1567 = "" A1568 = "" A1569 = "" A1570 = "" +A1571 = "" A1572 = "" A1573 = "" A1574 = "" A1575 = "" A1576 = "" A1577 = "" A1578 = "" A1579 = "" A1580 = "" +A1581 = "" A1582 = "" A1583 = "" A1584 = "" A1585 = "" A1586 = "" A1587 = "" A1588 = "" A1589 = "" A1590 = "" +A1591 = "" A1592 = "" A1593 = "" A1594 = "" A1595 = "" A1596 = "" A1597 = "" A1598 = "" A1599 = "" A1600 = "" +A1601 = "" A1602 = "" A1603 = "" A1604 = "" A1605 = "" A1606 = "" A1607 = "" A1608 = "" A1609 = "" A1610 = "" +A1611 = "" A1612 = "" A1613 = "" A1614 = "" A1615 = "" A1616 = "" A1617 = "" A1618 = "" A1619 = "" A1620 = "" +A1621 = "" A1622 = "" A1623 = "" A1624 = "" A1625 = "" A1626 = "" A1627 = "" A1628 = "" A1629 = "" A1630 = "" +A1631 = "" A1632 = "" A1633 = "" A1634 = "" A1635 = "" A1636 = "" A1637 = "" A1638 = "" A1639 = "" A1640 = "" +A1641 = "" A1642 = "" A1643 = "" A1644 = "" A1645 = "" A1646 = "" A1647 = "" A1648 = "" A1649 = "" A1650 = "" +A1651 = "" A1652 = "" A1653 = "" A1654 = "" A1655 = "" A1656 = "" A1657 = "" A1658 = "" A1659 = "" A1660 = "" +A1661 = "" A1662 = "" A1663 = "" A1664 = "" A1665 = "" A1666 = "" A1667 = "" A1668 = "" A1669 = "" A1670 = "" +A1671 = "" A1672 = "" A1673 = "" A1674 = "" A1675 = "" A1676 = "" A1677 = "" A1678 = "" A1679 = "" A1680 = "" +A1681 = "" A1682 = "" A1683 = "" A1684 = "" A1685 = "" A1686 = "" A1687 = "" A1688 = "" A1689 = "" A1690 = "" +A1691 = "" A1692 = "" A1693 = "" A1694 = "" A1695 = "" A1696 = "" A1697 = "" A1698 = "" A1699 = "" A1700 = "" +A1701 = "" A1702 = "" A1703 = "" A1704 = "" A1705 = "" A1706 = "" A1707 = "" A1708 = "" A1709 = "" A1710 = "" +A1711 = "" A1712 = "" A1713 = "" A1714 = "" A1715 = "" A1716 = "" A1717 = "" A1718 = "" A1719 = "" A1720 = "" +A1721 = "" A1722 = "" A1723 = "" A1724 = "" A1725 = "" A1726 = "" A1727 = "" A1728 = "" A1729 = "" A1730 = "" +A1731 = "" A1732 = "" A1733 = "" A1734 = "" A1735 = "" A1736 = "" A1737 = "" A1738 = "" A1739 = "" A1740 = "" +A1741 = "" A1742 = "" A1743 = "" A1744 = "" A1745 = "" A1746 = "" A1747 = "" A1748 = "" A1749 = "" A1750 = "" +A1751 = "" A1752 = "" A1753 = "" A1754 = "" A1755 = "" A1756 = "" A1757 = "" A1758 = "" A1759 = "" A1760 = "" +A1761 = "" A1762 = "" A1763 = "" A1764 = "" A1765 = "" A1766 = "" A1767 = "" A1768 = "" A1769 = "" A1770 = "" +A1771 = "" A1772 = "" A1773 = "" A1774 = "" A1775 = "" A1776 = "" A1777 = "" A1778 = "" A1779 = "" A1780 = "" +A1781 = "" A1782 = "" A1783 = "" A1784 = "" A1785 = "" A1786 = "" A1787 = "" A1788 = "" A1789 = "" A1790 = "" +A1791 = "" A1792 = "" A1793 = "" A1794 = "" A1795 = "" A1796 = "" A1797 = "" A1798 = "" A1799 = "" A1800 = "" +A1801 = "" A1802 = "" A1803 = "" A1804 = "" A1805 = "" A1806 = "" A1807 = "" A1808 = "" A1809 = "" A1810 = "" +A1811 = "" A1812 = "" A1813 = "" A1814 = "" A1815 = "" A1816 = "" A1817 = "" A1818 = "" A1819 = "" A1820 = "" +A1821 = "" A1822 = "" A1823 = "" A1824 = "" A1825 = "" A1826 = "" A1827 = "" A1828 = "" A1829 = "" A1830 = "" +A1831 = "" A1832 = "" A1833 = "" A1834 = "" A1835 = "" A1836 = "" A1837 = "" A1838 = "" A1839 = "" A1840 = "" +A1841 = "" A1842 = "" A1843 = "" A1844 = "" A1845 = "" A1846 = "" A1847 = "" A1848 = "" A1849 = "" A1850 = "" +A1851 = "" A1852 = "" A1853 = "" A1854 = "" A1855 = "" A1856 = "" A1857 = "" A1858 = "" A1859 = "" A1860 = "" +A1861 = "" A1862 = "" A1863 = "" A1864 = "" A1865 = "" A1866 = "" A1867 = "" A1868 = "" A1869 = "" A1870 = "" +A1871 = "" A1872 = "" A1873 = "" A1874 = "" A1875 = "" A1876 = "" A1877 = "" A1878 = "" A1879 = "" A1880 = "" +A1881 = "" A1882 = "" A1883 = "" A1884 = "" A1885 = "" A1886 = "" A1887 = "" A1888 = "" A1889 = "" A1890 = "" +A1891 = "" A1892 = "" A1893 = "" A1894 = "" A1895 = "" A1896 = "" A1897 = "" A1898 = "" A1899 = "" A1900 = ""