8047962: XML test colocation: AuctionPortal test
Reviewed-by: joehw
Contributed-by: tristan.yan@oracle.com
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/AuctionController.java Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,386 @@
+/*
+ * 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 test.auctionportal;
+
+import static com.sun.org.apache.xerces.internal.jaxp.JAXPConstants.JAXP_SCHEMA_LANGUAGE;
+import static com.sun.org.apache.xerces.internal.jaxp.JAXPConstants.JAXP_SCHEMA_SOURCE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigInteger;
+import java.nio.file.Paths;
+import java.util.GregorianCalendar;
+import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeConstants;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.Duration;
+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.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+import static jaxp.library.JAXPTestUtilities.bomStream;
+import static jaxp.library.JAXPTestUtilities.failUnexpected;
+import org.testng.annotations.Test;
+import org.w3c.dom.Attr;
+import org.w3c.dom.DOMConfiguration;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.TypeInfo;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSSerializer;
+import org.xml.sax.SAXException;
+import static test.auctionportal.HiBidConstants.PORTAL_ACCOUNT_NS;
+import static test.auctionportal.HiBidConstants.XML_DIR;
+
+/**
+ * This is the user controller class for the Auction portal HiBid.com.
+ */
+public class AuctionController {
+ /**
+ * Check for DOMErrorHandler handling DOMError. Before fix of bug 4890927
+ * DOMConfiguration.setParameter("well-formed",true) throws an exception.
+ */
+ @Test
+ public void testCreateNewItem2Sell() {
+ String xmlFile = XML_DIR + "novelsInvalid.xml";
+
+ try {
+ Document document = DocumentBuilderFactory.newInstance()
+ .newDocumentBuilder().parse(xmlFile);
+
+ document.getDomConfig().setParameter("well-formed", true);
+
+ DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
+ DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
+ MyDOMOutput domOutput = new MyDOMOutput();
+ domOutput.setByteStream(System.out);
+ LSSerializer writer = impl.createLSSerializer();
+ writer.write(document, domOutput);
+ } catch (ParserConfigurationException | SAXException | IOException
+ | ClassNotFoundException | InstantiationException
+ | IllegalAccessException | ClassCastException e) {
+ failUnexpected(e);
+ }
+ }
+
+ /**
+ * Check for DOMErrorHandler handling DOMError. Before fix of bug 4896132
+ * test throws DOM Level 1 node error.
+ */
+ @Test
+ public void testCreateNewItem2SellRetry() {
+ String xmlFile = XML_DIR + "accountInfo.xml";
+
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ Document document = dbf.newDocumentBuilder().parse(xmlFile);
+
+ DOMConfiguration domConfig = document.getDomConfig();
+ MyDOMErrorHandler errHandler = new MyDOMErrorHandler();
+ domConfig.setParameter("error-handler", errHandler);
+
+ DOMImplementationLS impl =
+ (DOMImplementationLS) DOMImplementationRegistry.newInstance()
+ .getDOMImplementation("LS");
+ LSSerializer writer = impl.createLSSerializer();
+ MyDOMOutput domoutput = new MyDOMOutput();
+
+ domoutput.setByteStream(System.out);
+ writer.write(document, domoutput);
+
+ document.normalizeDocument();
+ writer.write(document, domoutput);
+ assertFalse(errHandler.isError());
+ } catch (ParserConfigurationException | SAXException | IOException
+ | ClassNotFoundException | InstantiationException
+ | IllegalAccessException | ClassCastException e) {
+ failUnexpected(e);
+ }
+ }
+
+ /**
+ * Check if setting the attribute to be of type ID works. This will affect
+ * the Attr.isID method according to the spec.
+ */
+ @Test
+ public void testCreateID() {
+ String xmlFile = XML_DIR + "accountInfo.xml";
+
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+
+ Document document = dbf.newDocumentBuilder().parse(xmlFile);
+ Element account = (Element)document
+ .getElementsByTagNameNS(PORTAL_ACCOUNT_NS, "Account").item(0);
+
+ account.setIdAttributeNS(PORTAL_ACCOUNT_NS, "accountID", true);
+ Attr aID = account.getAttributeNodeNS(PORTAL_ACCOUNT_NS, "accountID");
+ assertTrue(aID.isId());
+ } catch (ParserConfigurationException | SAXException | IOException e) {
+ failUnexpected(e);
+ }
+ }
+
+ /**
+ * Check the user data on the node.
+ */
+ @Test
+ public void testCheckingUserData() {
+ String xmlFile = XML_DIR + "accountInfo.xml";
+
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+
+ DocumentBuilder docBuilder = dbf.newDocumentBuilder();
+ Document document = docBuilder.parse(xmlFile);
+
+ Element account = (Element)document.getElementsByTagNameNS(PORTAL_ACCOUNT_NS, "Account").item(0);
+ assertEquals(account.getNodeName(), "acc:Account");
+ Element firstName = (Element) document.getElementsByTagNameNS(PORTAL_ACCOUNT_NS, "FirstName").item(0);
+ assertEquals(firstName.getNodeName(), "FirstName");
+
+ Document doc1 = docBuilder.newDocument();
+ Element someName = doc1.createElement("newelem");
+
+ someName.setUserData("mykey", "dd",
+ (operation, key, data, src, dst) -> {
+ System.err.println("In UserDataHandler" + key);
+ System.out.println("In UserDataHandler");
+ });
+ Element impAccount = (Element)document.importNode(someName, true);
+ assertEquals(impAccount.getNodeName(), "newelem");
+ document.normalizeDocument();
+ String data = (someName.getUserData("mykey")).toString();
+ assertEquals(data, "dd");
+ } catch (ParserConfigurationException | SAXException | IOException e) {
+ failUnexpected(e);
+ }
+ }
+
+
+ /**
+ * Check the UTF-16 XMLEncoding xml file.
+ * @see <a href="content/movies.xml">movies.xml</a>
+ */
+ @Test
+ public void testCheckingEncoding() {
+ // Note since movies.xml is UTF-16 encoding. We're not using stanard XML
+ // file suffix.
+ String xmlFile = XML_DIR + "movies.xml.data";
+
+ //try (FileInputStream is = new FileInputStream(xmlFile)) {
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ InputStream source = bomStream("UTF-16", xmlFile);
+ Document document = dbf.newDocumentBuilder().parse(source);
+ assertEquals(document.getXmlEncoding(), "UTF-16");
+ assertEquals(document.getXmlStandalone(), true);
+ } catch (ParserConfigurationException | SAXException | IOException e) {
+ failUnexpected(e);
+ }
+ }
+
+ /**
+ * Check validation API features. A schema which is including in Bug 4909119
+ * used to be testing for the functionalities.
+ * @see <a href="content/userDetails.xsd">userDetails.xsd</a>
+ */
+ @Test
+ public void testGetOwnerInfo() {
+ String schemaFile = XML_DIR + "userDetails.xsd";
+ String xmlFile = XML_DIR + "userDetails.xml";
+
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ dbf.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA_NS_URI);
+
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI);
+ Schema schema = schemaFactory.newSchema(Paths.get(schemaFile).toFile());
+
+ Validator validator = schema.newValidator();
+ MyErrorHandler eh = new MyErrorHandler();
+ validator.setErrorHandler(eh);
+
+ DocumentBuilder docBuilder = dbf.newDocumentBuilder();
+ docBuilder.setErrorHandler(eh);
+
+ Document document = docBuilder.parse(new FileInputStream(xmlFile));
+ DOMResult dResult = new DOMResult();
+ DOMSource domSource = new DOMSource(document);
+ validator.validate(domSource, dResult);
+ assertFalse(eh.isAnyError());
+ } catch (SAXException | ParserConfigurationException | IOException e) {
+ failUnexpected(e);
+ }
+ }
+
+ /**
+ * Check grammar caching with imported schemas.
+ * @see <a href="content/coins.xsd">coins.xsd</a>
+ * @see <a href="content/coinsImportMe.xsd">coinsImportMe.xsd</a>
+ */
+ @Test
+ public void testGetOwnerItemList() {
+ String xsdFile = XML_DIR + "coins.xsd";
+ String xmlFile = XML_DIR + "coins.xml";
+
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ dbf.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA_NS_URI);
+ dbf.setValidating(false);
+
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI);
+ Schema schema = schemaFactory.newSchema(new File(((xsdFile))));
+
+ MyErrorHandler eh = new MyErrorHandler();
+ Validator validator = schema.newValidator();
+ validator.setErrorHandler(eh);
+
+ DocumentBuilder docBuilder = dbf.newDocumentBuilder();
+ Document document = docBuilder.parse(new FileInputStream(xmlFile));
+ validator.validate(new DOMSource(document), new DOMResult());
+ assertFalse(eh.isAnyError());
+ } catch (SAXException | ParserConfigurationException | IOException e) {
+ failUnexpected(e);
+ }
+ }
+
+
+ /**
+ * Check for the same imported schemas but will use SAXParserFactory and try
+ * parsing using the SAXParser. SCHEMA_SOURCE attribute is using for this
+ * test.
+ * @see <a href="content/coins.xsd">coins.xsd</a>
+ * @see <a href="content/coinsImportMe.xsd">coinsImportMe.xsd</a>
+ */
+
+ @Test
+ public void testGetOwnerItemList1() {
+ String xsdFile = XML_DIR + "coins.xsd";
+ String xmlFile = XML_DIR + "coins.xml";
+
+ try {
+ SAXParserFactory spf = SAXParserFactory.newInstance();
+ spf.setNamespaceAware(true);
+ spf.setValidating(true);
+
+ SAXParser sp = spf.newSAXParser();
+ sp.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA_NS_URI);
+ sp.setProperty(JAXP_SCHEMA_SOURCE, xsdFile);
+
+ MyErrorHandler eh = new MyErrorHandler();
+ sp.parse(new File(xmlFile), eh);
+ assertFalse(eh.isAnyError());
+ } catch (ParserConfigurationException | SAXException | IOException e) {
+ failUnexpected(e);
+ }
+ }
+
+ /**
+ * Check usage of javax.xml.datatype.Duration class.
+ */
+ @Test
+ public void testGetItemDuration() {
+ String xmlFile = XML_DIR + "itemsDuration.xml";
+
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ Document document = dbf.newDocumentBuilder().parse(xmlFile);
+
+ Element durationElement = (Element) document.getElementsByTagName("sellDuration").item(0);
+
+ NodeList childList = durationElement.getChildNodes();
+
+ for (int i = 0; i < childList.getLength(); i++) {
+ System.out.println("child " + i + childList.item(i));
+ }
+
+ Duration duration = DatatypeFactory.newInstance().newDuration("P365D");
+ Duration sellDuration = DatatypeFactory.newInstance().newDuration(childList.item(0).getNodeValue());
+ assertFalse(sellDuration.isShorterThan(duration));
+ assertFalse(sellDuration.isLongerThan(duration));
+ assertEquals(sellDuration.getField(DatatypeConstants.DAYS), BigInteger.valueOf(365));
+ assertEquals(sellDuration.normalizeWith(new GregorianCalendar(1999, 2, 22)), duration);
+
+ Duration myDuration = sellDuration.add(duration);
+ assertEquals(myDuration.normalizeWith(new GregorianCalendar(2003, 2, 22)),
+ DatatypeFactory.newInstance().newDuration("P730D"));
+ } catch (ParserConfigurationException | DatatypeConfigurationException
+ | SAXException | IOException e) {
+ failUnexpected(e);
+ }
+ }
+
+ /**
+ * Check usage of TypeInfo interface introduced in DOM L3.
+ */
+ @Test
+ public void testGetTypeInfo() {
+ String xmlFile = XML_DIR + "accountInfo.xml";
+
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ dbf.setValidating(true);
+ dbf.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA_NS_URI);
+
+ DocumentBuilder docBuilder = dbf.newDocumentBuilder();
+ docBuilder.setErrorHandler(new MyErrorHandler());
+
+ Document document = docBuilder.parse(xmlFile);
+ Element userId = (Element)document.getElementsByTagNameNS(PORTAL_ACCOUNT_NS, "UserID").item(0);
+ TypeInfo typeInfo = userId.getSchemaTypeInfo();
+ assertTrue(typeInfo.getTypeName().equals("nonNegativeInteger"));
+ assertTrue(typeInfo.getTypeNamespace().equals(W3C_XML_SCHEMA_NS_URI));
+
+ Element role = (Element)document.getElementsByTagNameNS(PORTAL_ACCOUNT_NS, "Role").item(0);
+ TypeInfo roletypeInfo = role.getSchemaTypeInfo();
+ assertTrue(roletypeInfo.getTypeName().equals("BuyOrSell"));
+ assertTrue(roletypeInfo.getTypeNamespace().equals(PORTAL_ACCOUNT_NS));
+ } catch (ParserConfigurationException | SAXException | IOException e) {
+ failUnexpected(e);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/AuctionItemRepository.java Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,482 @@
+/*
+ * 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 test.auctionportal;
+
+import static com.sun.org.apache.xerces.internal.impl.Constants.SP_ENTITY_EXPANSION_LIMIT;
+import static com.sun.org.apache.xerces.internal.impl.Constants.SP_MAX_OCCUR_LIMIT;
+import static com.sun.org.apache.xerces.internal.jaxp.JAXPConstants.JAXP_SCHEMA_LANGUAGE;
+import static com.sun.org.apache.xerces.internal.jaxp.JAXPConstants.JAXP_SCHEMA_SOURCE;
+import static org.testng.Assert.assertTrue;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import static javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING;
+import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
+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.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import static jaxp.library.JAXPTestUtilities.compareDocumentWithGold;
+import static jaxp.library.JAXPTestUtilities.failCleanup;
+import static jaxp.library.JAXPTestUtilities.failUnexpected;
+import static org.testng.Assert.assertFalse;
+
+import org.testng.annotations.Test;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import static test.auctionportal.HiBidConstants.CLASS_DIR;
+import static test.auctionportal.HiBidConstants.GOLDEN_DIR;
+import static test.auctionportal.HiBidConstants.XML_DIR;
+
+/**
+ * This is a test class for the Auction portal HiBid.com.
+ */
+public class AuctionItemRepository {
+ /**
+ * XML file for parsing.
+ */
+ private final static String ENTITY_XML = XML_DIR + "entity.xml";
+
+ /**
+ * Feature name.
+ */
+ private final static String FEATURE_NAME = "http://xml.org/sax/features/namespace-prefixes";
+
+ /**
+ * Setting the EntityExpansion Limit to 128000 and checks if the XML
+ * document that has more than two levels of entity expansion is parsed or
+ * not. Previous system property was changed to jdk.xml.entityExpansionLimit
+ * see http://docs.oracle.com/javase/tutorial/jaxp/limits/limits.html.
+ */
+ @Test
+ public void testEntityExpansionSAXPos() {
+ try {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ // Secure processing will limit XML processing to conform to
+ // implementation limits.
+ factory.setFeature(FEATURE_SECURE_PROCESSING, true);
+ // Set entityExpansionLimit as 2 should expect fatalError
+ System.setProperty(SP_ENTITY_EXPANSION_LIMIT, String.valueOf(128000));
+ SAXParser parser = factory.newSAXParser();
+
+ MyErrorHandler fatalHandler = new MyErrorHandler();
+ parser.parse(new File(ENTITY_XML), fatalHandler);
+ assertFalse(fatalHandler.isAnyError());
+ } catch (ParserConfigurationException | SAXException | IOException e) {
+ failUnexpected(e);
+ }
+ }
+ /**
+ * Setting the EntityExpansion Limit to 2 and checks if the XML
+ * document that has more than two levels of entity expansion is parsed or
+ * not. Previous system property was changed to jdk.xml.entityExpansionLimit
+ * see http://docs.oracle.com/javase/tutorial/jaxp/limits/limits.html.
+ */
+ @Test(expectedExceptions = SAXParseException.class)
+ public void testEntityExpansionSAXNeg() throws SAXParseException {
+ //
+ try {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ // Secure processing will limit XML processing to conform to
+ // implementation limits.
+ factory.setFeature(FEATURE_SECURE_PROCESSING, true);
+ // Set entityExpansionLimit as 2 should expect SAXParseException
+ System.setProperty(SP_ENTITY_EXPANSION_LIMIT, String.valueOf(2));
+ SAXParser parser = factory.newSAXParser();
+
+ MyErrorHandler fatalHandler = new MyErrorHandler();
+ parser.parse(new File(ENTITY_XML), fatalHandler);
+ } catch (SAXParseException e) {
+ throw e;
+ } catch (ParserConfigurationException | SAXException | IOException e) {
+ failUnexpected(e);
+ }
+ }
+
+ /**
+ * Testing set MaxOccursLimit to 10000 in the secure processing enabled for
+ * SAXParserFactory.
+ */
+ @Test
+ public void testMaxOccurLimitPos() {
+ String schema_file = XML_DIR + "toys.xsd";
+ String xml_file = XML_DIR + "toys.xml";
+
+ try (InputStream is = new FileInputStream(xml_file)) {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setValidating(true);
+ factory.setFeature(FEATURE_SECURE_PROCESSING, true);
+ System.setProperty(SP_MAX_OCCUR_LIMIT, String.valueOf(10000));
+ SAXParser parser = factory.newSAXParser();
+ parser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA_NS_URI);
+ parser.setProperty(JAXP_SCHEMA_SOURCE, new File(schema_file));
+ MyErrorHandler eh = new MyErrorHandler();
+ parser.parse(is, eh);
+ assertFalse(eh.isAnyError());
+ } catch (ParserConfigurationException | SAXException | IOException e) {
+ failUnexpected(e);
+ }
+ }
+
+ /**
+ * Use a DocumentBuilder to create a DOM object and see if Secure Processing
+ * feature affects the entity expansion.
+ */
+ @Test
+ public void testEntityExpansionDOMPos() {
+ try {
+ DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
+ dfactory.setFeature(FEATURE_SECURE_PROCESSING, true);
+ System.setProperty(SP_ENTITY_EXPANSION_LIMIT, String.valueOf(10000));
+ DocumentBuilder dBuilder = dfactory.newDocumentBuilder();
+ MyErrorHandler eh = new MyErrorHandler();
+ dBuilder.setErrorHandler(eh);
+ dBuilder.parse(ENTITY_XML);
+ assertFalse(eh.isAnyError());
+ } catch (ParserConfigurationException | IOException | SAXException e) {
+ failUnexpected(e);
+ }
+ }
+
+ /**
+ * Use a DocumentBuilder to create a DOM object and see how does the Secure
+ * Processing feature and entityExpansionLimit value affects output.
+ * Negative test that when entityExpansionLimit is too small.
+ */
+ @Test(expectedExceptions = SAXParseException.class)
+ public void testEntityExpansionDOMNeg() throws SAXParseException {
+ try {
+ DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
+ dfactory.setFeature(FEATURE_SECURE_PROCESSING, true);
+ System.setProperty(SP_ENTITY_EXPANSION_LIMIT, String.valueOf(2));
+ DocumentBuilder dBuilder = dfactory.newDocumentBuilder();
+ MyErrorHandler eh = new MyErrorHandler();
+ dBuilder.setErrorHandler(eh);
+ dBuilder.parse(ENTITY_XML);
+ } catch (SAXParseException e) {
+ throw e;
+ } catch (ParserConfigurationException | IOException | SAXException e) {
+ failUnexpected(e);
+ }
+ }
+
+ /**
+ * Test xi:include with a SAXParserFactory.
+ */
+ @Test
+ public void testXIncludeSAXPos() {
+ String resultFile = CLASS_DIR + "doc_xinclude.out";
+ String goldFile = GOLDEN_DIR + "doc_xincludeGold.xml";
+ String xmlFile = XML_DIR + "doc_xinclude.xml";
+
+ try {
+ try(FileOutputStream fos = new FileOutputStream(resultFile)) {
+ XInclHandler xh = new XInclHandler(fos, null);
+ SAXParserFactory spf = SAXParserFactory.newInstance();
+ spf.setNamespaceAware(true);
+ spf.setXIncludeAware(true);
+ spf.setFeature(FEATURE_NAME, true);
+ spf.newSAXParser().parse(new File(xmlFile), xh);
+ }
+ assertTrue(compareDocumentWithGold(goldFile, resultFile));
+ } catch (ParserConfigurationException | SAXException | IOException e) {
+ failUnexpected(e);
+ } finally {
+ try {
+ Path resultPath = Paths.get(resultFile);
+ if (Files.exists(resultPath)) {
+ Files.delete(resultPath);
+ }
+ } catch (IOException ex) {
+ failCleanup(ex, resultFile);
+ }
+ }
+ }
+
+ /**
+ * Test the simple case of including a document using xi:include using a
+ * DocumentBuilder.
+ */
+ @Test
+ public void testXIncludeDOMPos() {
+ String resultFile = CLASS_DIR + "doc_xincludeDOM.out";
+ String goldFile = GOLDEN_DIR + "doc_xincludeGold.xml";
+ String xmlFile = XML_DIR + "doc_xinclude.xml";
+ try {
+ try (FileOutputStream fos = new FileOutputStream(resultFile)) {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setXIncludeAware(true);
+ dbf.setNamespaceAware(true);
+
+ Document doc = dbf.newDocumentBuilder().parse(new File(xmlFile));
+ doc.setXmlStandalone(true);
+
+ TransformerFactory.newInstance().newTransformer().
+ transform(new DOMSource(doc), new StreamResult(fos));
+ }
+ assertTrue(compareDocumentWithGold(goldFile, resultFile));
+ } catch (ParserConfigurationException | SAXException | IOException
+ | TransformerException e) {
+ failUnexpected(e);
+ } finally {
+ try {
+ Path resultPath = Paths.get(resultFile);
+ if (Files.exists(resultPath)) {
+ Files.delete(resultPath);
+ }
+ } catch (IOException ex) {
+ failCleanup(ex, resultFile);
+ }
+ }
+ }
+
+ /**
+ * Test the simple case of including a document using xi:include within a
+ * xi:fallback using a DocumentBuilder.
+ */
+ @Test
+ public void testXIncludeFallbackDOMPos() {
+ String resultFile = CLASS_DIR + "doc_fallbackDOM.out";
+ String goldFile = GOLDEN_DIR + "doc_fallbackGold.xml";
+ String xmlFile = XML_DIR + "doc_fallback.xml";
+ try{
+ try (FileOutputStream fos = new FileOutputStream(resultFile)) {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setXIncludeAware(true);
+ dbf.setNamespaceAware(true);
+
+ Document doc = dbf.newDocumentBuilder().parse(new File(xmlFile));
+ doc.setXmlStandalone(true);
+ TransformerFactory.newInstance().newTransformer()
+ .transform(new DOMSource(doc), new StreamResult(fos));
+ }
+ assertTrue(compareDocumentWithGold(goldFile, resultFile));
+ } catch (ParserConfigurationException | SAXException | IOException
+ | TransformerException e) {
+ failUnexpected(e);
+ } finally {
+ try {
+ Path resultPath = Paths.get(resultFile);
+ if (Files.exists(resultPath)) {
+ Files.delete(resultPath);
+ }
+ } catch (IOException ex) {
+ failCleanup(ex, resultFile);
+ }
+ }
+ }
+
+ /**
+ * Test for xi:fallback where the fall back text is parsed as text. This
+ * test uses a nested xi:include for the fallback test.
+ */
+ @Test
+ public void testXIncludeFallbackTextPos() {
+ String resultFile = CLASS_DIR + "doc_fallback_text.out";
+ String goldFile = GOLDEN_DIR + "doc_fallback_textGold.xml";
+ String xmlFile = XML_DIR + "doc_fallback_text.xml";
+
+ try{
+ try (FileOutputStream fos = new FileOutputStream(resultFile)) {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setXIncludeAware(true);
+ dbf.setNamespaceAware(true);
+
+ Document doc = dbf.newDocumentBuilder().parse(new File(xmlFile));
+ doc.setXmlStandalone(true);
+ TransformerFactory.newInstance().newTransformer()
+ .transform(new DOMSource(doc), new StreamResult(fos));
+ }
+ assertTrue(compareDocumentWithGold(goldFile, resultFile));
+ } catch (ParserConfigurationException | SAXException | IOException
+ | TransformerException e) {
+ failUnexpected(e);
+ } finally {
+ try {
+ Path resultPath = Paths.get(resultFile);
+ if (Files.exists(resultPath)) {
+ Files.delete(resultPath);
+ }
+ } catch (IOException ex) {
+ failCleanup(ex, resultFile);
+ }
+ }
+ }
+
+ /**
+ * Test the XPointer element() framework with XInclude.
+ */
+ @Test
+ public void testXpointerElementPos() {
+ String resultFile = CLASS_DIR + "doc_xpointer_element.out";
+ String goldFile = GOLDEN_DIR + "doc_xpointerGold.xml";
+ String xmlFile = XML_DIR + "doc_xpointer_element.xml";
+
+ try{
+ try (FileOutputStream fos = new FileOutputStream(resultFile)) {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setXIncludeAware(true);
+ dbf.setNamespaceAware(true);
+
+ DocumentBuilder db = dbf.newDocumentBuilder();
+
+ TransformerFactory.newInstance().newTransformer()
+ .transform(new DOMSource(db.parse(new File(xmlFile))),
+ new StreamResult(fos));
+ }
+ assertTrue(compareDocumentWithGold(goldFile, resultFile));
+ } catch (ParserConfigurationException | SAXException | IOException
+ | TransformerException e) {
+ failUnexpected(e);
+ } finally {
+ try {
+ Path resultPath = Paths.get(resultFile);
+ if (Files.exists(resultPath)) {
+ Files.delete(resultPath);
+ }
+ } catch (IOException ex) {
+ failCleanup(ex, resultFile);
+ }
+ }
+ }
+
+ /**
+ * Test the XPointer framework with a SAX object.
+ */
+ @Test
+ public void testXPointerPos() {
+ String resultFile = CLASS_DIR + "doc_xpointer.out";
+ String goldFile = GOLDEN_DIR + "doc_xpointerGold.xml";
+ String xmlFile = XML_DIR + "doc_xpointer.xml";
+
+ try{
+ try (FileOutputStream fos = new FileOutputStream(resultFile)) {
+ SAXParserFactory spf = SAXParserFactory.newInstance();
+ spf.setNamespaceAware(true);
+ spf.setXIncludeAware(true);
+ spf.setFeature(FEATURE_NAME, true);
+ // parse the file
+ spf.newSAXParser().parse(new File(xmlFile), new XInclHandler(fos, null));
+ }
+ assertTrue(compareDocumentWithGold(goldFile, resultFile));
+ } catch (ParserConfigurationException | SAXException | IOException e) {
+ failUnexpected(e);
+ } finally {
+ try {
+ Path resultPath = Paths.get(resultFile);
+ if (Files.exists(resultPath)) {
+ Files.delete(resultPath);
+ }
+ } catch (IOException ex) {
+ failCleanup(ex, resultFile);
+ }
+ }
+ }
+
+ /**
+ * Test if xi:include may reference the doc containing the include if the
+ * parse type is text.
+ */
+ @Test
+ public void testXIncludeLoopPos() {
+ String resultFile = CLASS_DIR + "doc_xinc_loops.out";
+ String goldFile = GOLDEN_DIR + "doc_xinc_loopGold.xml";
+ String xmlFile = XML_DIR + "doc_xinc_loops.xml";
+
+ try{
+ try (FileOutputStream fos = new FileOutputStream(resultFile)) {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setXIncludeAware(true);
+ dbf.setNamespaceAware(true);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.parse(new File(xmlFile));
+ doc.normalizeDocument();
+ doc.setXmlStandalone(true);
+
+ TransformerFactory.newInstance().newTransformer()
+ .transform(new DOMSource(doc), new StreamResult(fos));
+ }
+ assertTrue(compareDocumentWithGold(goldFile, resultFile));
+ } catch (ParserConfigurationException | SAXException | IOException
+ | TransformerException e) {
+ failUnexpected(e);
+ } finally {
+ try {
+ Path resultPath = Paths.get(resultFile);
+ if (Files.exists(resultPath)) {
+ Files.delete(resultPath);
+ }
+ } catch (IOException ex) {
+ failCleanup(ex, resultFile);
+ }
+ }
+ }
+
+ /**
+ * Test if two non nested xi:include elements can include the same document
+ * with an xi:include statement.
+ */
+ @Test
+ public void testXIncludeNestedPos() {
+ String resultFile = CLASS_DIR + "schedule.out";
+ String goldFile = GOLDEN_DIR + "scheduleGold.xml";
+ String xmlFile = XML_DIR + "schedule.xml";
+
+ try{
+ try (FileOutputStream fos = new FileOutputStream(resultFile)) {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setXIncludeAware(true);
+ dbf.setNamespaceAware(true);
+
+ Document doc = dbf.newDocumentBuilder().parse(new File(xmlFile));
+ doc.setXmlStandalone(true);
+ TransformerFactory.newInstance().newTransformer()
+ .transform(new DOMSource(doc), new StreamResult(fos));
+ }
+ assertTrue(compareDocumentWithGold(goldFile, resultFile));
+ } catch (ParserConfigurationException | SAXException | IOException
+ | TransformerException e) {
+ failUnexpected(e);
+ } finally {
+ try {
+ Path resultPath = Paths.get(resultFile);
+ if (Files.exists(resultPath)) {
+ Files.delete(resultPath);
+ }
+ } catch (IOException ex) {
+ failCleanup(ex, resultFile);
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/MyDOMErrorHandler.java Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,60 @@
+/*
+ * 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 test.auctionportal;
+
+import org.w3c.dom.DOMErrorHandler;
+import org.w3c.dom.DOMError;
+
+/**
+ * Error handler for recording DOM processing error.
+ */
+public class MyDOMErrorHandler implements DOMErrorHandler {
+ /**
+ * flag shows if there is any error.
+ */
+ private volatile boolean errorOccured = false;
+
+ /**
+ * Set errorOcurred to true when an error occurs.
+ * @param error The error object that describes the error. This object
+ * may be reused by the DOM implementation across multiple calls to
+ * the handleError method.
+ * @return true that processing may continue depending on.
+ */
+ @Override
+ public boolean handleError (DOMError error) {
+ System.err.println( "ERROR" + error.getMessage());
+ System.err.println( "ERROR" + error.getRelatedData());
+ errorOccured = true;
+ return true;
+ }
+
+ /**
+ * Showing if any error was handled.
+ * @return true if there is one or more error.
+ * false no error occurs.
+ */
+ public boolean isError() {
+ return errorOccured;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/MyDOMOutput.java Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,137 @@
+/*
+ * 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 test.auctionportal;
+
+import org.w3c.dom.ls.LSOutput;
+import java.io.OutputStream;
+import java.io.Writer;
+
+/**
+ * A Thread-safe LS output destination for DOM processing. LSOutput objects
+ * belong to the application. The DOM implementation will never modify them
+ * (though it may make copies and modify the copies, if necessary).
+ */
+public class MyDOMOutput implements LSOutput {
+ /**
+ * An attribute of a language and binding dependent type that represents a
+ * writable stream of bytes.
+ */
+ private OutputStream bytestream;
+
+ /**
+ * character encoding to use for the output.
+ */
+ private String encoding;
+
+ /**
+ * The system identifier.
+ */
+ private String sysId;
+
+ /**
+ * Writable stream to which 16-bit units can be output.
+ */
+ private Writer writer;
+
+ /**
+ * An attribute of a language and binding dependent type that represents a
+ * writable stream of bytes.
+ *
+ * @return a writable stream.
+ */
+ @Override
+ public OutputStream getByteStream() {
+ return bytestream;
+ }
+
+ /**
+ * An attribute of a language and binding dependent type that represents a
+ * writable stream to which 16-bit units can be output.
+ *
+ * @return writable stream instance.
+ */
+ @Override
+ public Writer getCharacterStream() {
+ return writer;
+ }
+
+ /**
+ * The character encoding to use for the output.
+ *
+ * @return the character encoding.
+ */
+ @Override
+ public String getEncoding() {
+ return encoding;
+ }
+
+ /**
+ * The system identifier for this output destination.
+ *
+ * @return system identifier.
+ */
+ @Override
+ public String getSystemId() {
+ return sysId;
+ }
+
+ /**
+ * Set writable stream of bytes.
+ *
+ * @param bs OutputStream instance
+ */
+ @Override
+ public void setByteStream(OutputStream bs) {
+ bytestream = bs;
+ }
+
+ /**
+ * Set 16 bits unit writable stream.
+ *
+ * @param bs a Writer instance
+ */
+ @Override
+ public void setCharacterStream(Writer cs) {
+ writer = cs;
+ }
+
+ /**
+ * Set character encoding to use for the output.
+ *
+ * @param encoding encoding set to the output
+ */
+ @Override
+ public void setEncoding(String encoding) {
+ this.encoding = encoding;
+ }
+
+ /**
+ * Set the system identifier for the output.
+ *
+ * @param sysId system identifier string.
+ */
+ @Override
+ public void setSystemId(String sysId) {
+ this.sysId = sysId;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/MyErrorHandler.java Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,100 @@
+/*
+ * 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 test.auctionportal;
+
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * ErrorHandler for error handling. Set state if any method in error, warning
+ * or fatalError was called.
+ */
+public final class MyErrorHandler extends DefaultHandler {
+ /**
+ * Enumeration for ErrorHandler's state.
+ */
+ private enum STATE { ERROR, FATAL, WARNING, NORMAL};
+
+ /**
+ * Set state as normal by default.
+ */
+ private volatile STATE state = STATE.NORMAL;
+
+ /**
+ * Keep exception for further investigation.
+ */
+ private volatile SAXParseException exception;
+
+ /**
+ * Save exception and set state to ERROR.
+ * @param e exception wrap error.
+ */
+ @Override
+ public void error (SAXParseException e) {
+ state = STATE.ERROR;
+ exception = e;
+ }
+
+ /**
+ * Save exception and set state to FATAL.
+ * @param e exception wrap error.
+ */
+ @Override
+ public void fatalError (SAXParseException e) {
+ state = STATE.FATAL;
+ exception = e;
+ }
+
+ /**
+ * Save exception and set state to WARNING.
+ * @param e exception wrap error.
+ */
+ @Override
+ public void warning (SAXParseException e) {
+ state = STATE.WARNING;
+ exception = e;
+ }
+
+ /**
+ * return ErrorHandle's state .
+ * @return true No error, fatalError and warning.
+ * false there is any error, fatalError or warning in processing.
+ */
+ public boolean isAnyError() {
+ if (state != STATE.NORMAL)
+ System.out.println(exception);
+ return state != STATE.NORMAL;
+ }
+
+ /**
+ * return whether fatalError is the only error.
+ * @return true fatalError is the only error.
+ * false there is no error, or other error besides fatalError.
+ */
+ public boolean isFatalError() {
+ if (state == STATE.FATAL)
+ System.out.println(exception);
+ return state == STATE.FATAL;
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/UserController.java Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,338 @@
+/*
+ * 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 test.auctionportal;
+
+import static com.sun.org.apache.xerces.internal.jaxp.JAXPConstants.JAXP_SCHEMA_LANGUAGE;
+import static org.testng.Assert.assertFalse;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import static jaxp.library.JAXPTestUtilities.compareDocumentWithGold;
+import static jaxp.library.JAXPTestUtilities.failCleanup;
+import static jaxp.library.JAXPTestUtilities.failUnexpected;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import org.testng.annotations.Test;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSParser;
+import org.w3c.dom.ls.LSSerializer;
+import org.xml.sax.SAXException;
+import static test.auctionportal.HiBidConstants.CLASS_DIR;
+import static test.auctionportal.HiBidConstants.GOLDEN_DIR;
+import static test.auctionportal.HiBidConstants.PORTAL_ACCOUNT_NS;
+import static test.auctionportal.HiBidConstants.XML_DIR;
+
+/**
+ * This is the user controller class for the Auction portal HiBid.com.
+ */
+public class UserController {
+ /**
+ * Checking when creating an XML document using DOM Level 2 validating
+ * it without having a schema source or a schema location It must throw a
+ * sax parse exception.
+ */
+ @Test
+ public void testCreateNewUser() {
+ String resultFile = CLASS_DIR + "accountInfoOut.xml";
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ dbf.setValidating(true);
+
+ DocumentBuilder docBuilder = dbf.newDocumentBuilder();
+ MyErrorHandler eh = new MyErrorHandler();
+ docBuilder.setErrorHandler(eh);
+
+ Document document = docBuilder.newDocument();
+
+ Element account = document.createElementNS(PORTAL_ACCOUNT_NS, "acc:Account");
+ Attr accountID = document.createAttributeNS(PORTAL_ACCOUNT_NS, "acc:accountID");
+ account.setAttributeNode(accountID);
+
+ account.appendChild(document.createElement("FirstName"));
+ account.appendChild(document.createElementNS(PORTAL_ACCOUNT_NS, "acc:LastName"));
+ account.appendChild(document.createElement("UserID"));
+
+ DOMImplementationLS impl
+ = (DOMImplementationLS) DOMImplementationRegistry
+ .newInstance().getDOMImplementation("LS");
+ LSSerializer writer = impl.createLSSerializer();
+ LSParser builder = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
+ FileOutputStream output = new FileOutputStream(resultFile);
+ MyDOMOutput domOutput = new MyDOMOutput();
+
+ domOutput.setByteStream(output);
+ writer.write(account, domOutput);
+ docBuilder.parse(resultFile);
+
+ assertTrue(eh.isAnyError());
+ } catch (ParserConfigurationException | ClassNotFoundException |
+ InstantiationException | IllegalAccessException
+ | ClassCastException | SAXException | IOException e) {
+ failUnexpected(e);
+ }
+ }
+
+ /**
+ * Checking conflicting namespaces and use renameNode and normalizeDocument.
+ * @see <a href="content/accountInfo.xml">accountInfo.xml</a>
+ */
+ @Test
+ public void testAddUser() {
+ String resultFile = CLASS_DIR + "accountRole.out";
+ String xmlFile = XML_DIR + "accountInfo.xml";
+
+ try {
+ // Copy schema for outputfile
+ Files.copy(Paths.get(XML_DIR, "accountInfo.xsd"),
+ Paths.get(CLASS_DIR, "accountInfo.xsd"),
+ StandardCopyOption.REPLACE_EXISTING);
+ MyErrorHandler eh = new MyErrorHandler();
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+
+ dbf.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA_NS_URI);
+ dbf.setNamespaceAware(true);
+ dbf.setValidating(true);
+
+ DocumentBuilder docBuilder = dbf.newDocumentBuilder();
+ docBuilder.setErrorHandler(eh);
+
+ Document document = docBuilder.parse(xmlFile);
+ Element sell = (Element) document.getElementsByTagNameNS(PORTAL_ACCOUNT_NS, "Sell").item(0);
+ Element role = (Element) sell.getParentNode();
+
+ Element buy = (Element) document.renameNode(sell, PORTAL_ACCOUNT_NS, "acc:Buy");
+ role.appendChild(buy);
+
+ DOMImplementationLS impl
+ = (DOMImplementationLS) DOMImplementationRegistry
+ .newInstance().getDOMImplementation("LS");
+ LSSerializer writer = impl.createLSSerializer();
+
+
+ try(FileOutputStream output = new FileOutputStream(resultFile)) {
+ MyDOMOutput mydomoutput = new MyDOMOutput();
+ mydomoutput.setByteStream(output);
+ writer.write(document, mydomoutput);
+ }
+
+ docBuilder.parse(resultFile);
+ assertFalse(eh.isAnyError());
+ } catch (ParserConfigurationException | SAXException | IOException
+ | ClassNotFoundException | InstantiationException
+ | IllegalAccessException | ClassCastException e) {
+ failUnexpected(e);
+ }
+ }
+
+ /**
+ * Checking Text content in XML file.
+ * @see <a href="content/accountInfo.xml">accountInfo.xml</a>
+ */
+ @Test
+ public void testMoreUserInfo() {
+ String xmlFile = XML_DIR + "accountInfo.xml";
+
+ try {
+ System.out.println("Checking additional user info");
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+
+ dbf.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA_NS_URI);
+ dbf.setNamespaceAware(true);
+ dbf.setValidating(true);
+
+ DocumentBuilder docBuilder = dbf.newDocumentBuilder();
+ MyErrorHandler eh = new MyErrorHandler();
+ docBuilder.setErrorHandler(eh);
+
+ Document document = docBuilder.parse(xmlFile);
+ Element account = (Element)document
+ .getElementsByTagNameNS(PORTAL_ACCOUNT_NS, "Account").item(0);
+ String textContent = account.getTextContent();
+ assertTrue(textContent.trim().regionMatches(0, "Rachel", 0, 6));
+ assertEquals(textContent, "RachelGreen744");
+
+ Attr accountID = account.getAttributeNodeNS(PORTAL_ACCOUNT_NS, "accountID");
+ assertTrue(accountID.getTextContent().trim().equals("1"));
+
+ assertFalse(eh.isAnyError());
+ } catch (ParserConfigurationException | SAXException | IOException e) {
+ failUnexpected(e);
+ }
+ }
+
+ /**
+ * This will check if adoptNode works will adoptNode from
+ * @see <a href="content/userInfo.xml">userInfo.xml</a>
+ * @see <a href="content/accountInfo.xml">accountInfo.xml</a>. This is
+ * adopting a node from the XML file which is validated by a DTD and
+ * into an XML file which is validated by the schema This covers Row 5
+ * for the table
+ * http://javaweb.sfbay/~jsuttor/JSR206/jsr-206-html/ch03s05.html. Filed
+ * bug 4893745 because there was a difference in behavior
+ */
+ @Test
+ public void testCreateUserAccount() {
+ System.out.println("Creating user account");
+ String userXmlFile = XML_DIR + "userInfo.xml";
+ String accountXmlFile = XML_DIR + "accountInfo.xml";
+
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ dbf.setValidating(true);
+
+ DocumentBuilder docBuilder = dbf.newDocumentBuilder();
+ MyErrorHandler eh = new MyErrorHandler();
+ docBuilder.setErrorHandler(eh);
+
+ Document document = docBuilder.parse(userXmlFile);
+ Element user = (Element) document.getElementsByTagName("FirstName").item(0);
+ // Set schema after parsing userInfo.xml. Otherwise it will conflict
+ // with DTD validation.
+ dbf.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA_NS_URI);
+ DocumentBuilder docBuilder1 = dbf.newDocumentBuilder();
+ docBuilder1.setErrorHandler(eh);
+ Document accDocument = docBuilder1.parse(accountXmlFile);
+
+ Element firstName = (Element) accDocument
+ .getElementsByTagNameNS(PORTAL_ACCOUNT_NS, "FirstName").item(0);
+ Element adoptedAccount = (Element) accDocument.adoptNode(user);
+
+ Element parent = (Element) firstName.getParentNode();
+ parent.replaceChild(adoptedAccount, firstName);
+
+ DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
+ DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
+ LSSerializer writer = impl.createLSSerializer();
+
+ MyDOMOutput mydomoutput = new MyDOMOutput();
+ mydomoutput.setByteStream(System.out);
+
+ writer.write(document, mydomoutput);
+ writer.write(accDocument, mydomoutput);
+
+ assertFalse(eh.isAnyError());
+ } catch (ParserConfigurationException | SAXException | IOException
+ | ClassNotFoundException | InstantiationException
+ | IllegalAccessException | ClassCastException e) {
+ failUnexpected(e);
+ }
+ }
+
+ /**
+ * Checking for Row 8 from the schema table when setting the schemaSource
+ * without the schemaLanguage must report an error.
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testUserError() throws IllegalArgumentException {
+ System.out.println("Creating an error in user account");
+
+ String xmlFile = XML_DIR + "userInfo.xml";
+ String schema = "http://java.sun.com/xml/jaxp/properties/schemaSource";
+ String schemaValue = "http://dummy.com/dummy.xsd";
+
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ dbf.setValidating(true);
+ dbf.setAttribute(schema, schemaValue);
+
+ DocumentBuilder docBuilder = dbf.newDocumentBuilder();
+ MyErrorHandler eh = new MyErrorHandler();
+ docBuilder.setErrorHandler(eh);
+ Document document = docBuilder.parse(xmlFile);
+ assertFalse(eh.isAnyError());
+ } catch (ParserConfigurationException | SAXException | IOException e) {
+ failUnexpected(e);
+ }
+ }
+
+ /**
+ * Checking for namespace normalization.
+ * @see <a href="content/screenName.xml">screenName.xml</a> has prefix of
+ * userName is bound to "http://hibid.com/user" namespace normalization
+ * will create a namespace of prefix us and attach userEmail.
+ */
+ @Test
+ public void testCheckScreenNameExists() {
+ String resultFile = CLASS_DIR + "screenName.out";
+ String xmlFile = XML_DIR + "screenName.xml";
+ String goldFile = GOLDEN_DIR + "screenNameGold.xml";
+
+ String nsTagName = "http://hibid.com/screenName";
+ String userNs = "http://hibid.com/user";
+
+ try (FileOutputStream output = new FileOutputStream(resultFile)) {
+ DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
+ DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
+ LSSerializer writer = impl.createLSSerializer();
+ LSParser builder = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
+ Document document = builder.parseURI(xmlFile);
+ NodeList nl = document.getElementsByTagNameNS(nsTagName, "screen-name");
+ assertEquals(nl.getLength(), 1);
+ Element screenName = (Element)nl.item(0);
+ Element userEmail = document.createElementNS(userNs, "userEmail");
+ assertTrue(userEmail.isDefaultNamespace(userNs));
+
+ Text email = document.createTextNode("myid@hibid.com");
+ userEmail.appendChild(email);
+ screenName.appendChild(userEmail);
+ document.normalizeDocument();
+
+ MyDOMOutput domoutput = new MyDOMOutput();
+ domoutput.setByteStream(output);
+ writer.write(document, domoutput);
+
+ assertTrue(compareDocumentWithGold(goldFile, resultFile));
+ } catch (ClassNotFoundException | InstantiationException
+ | IllegalAccessException | ClassCastException | IOException
+ | ParserConfigurationException | SAXException e) {
+ failUnexpected(e);
+ } finally {
+ try {
+ Path resultPath = Paths.get(resultFile);
+ if (Files.exists(resultPath)) {
+ Files.delete(resultPath);
+ }
+ } catch (IOException ex) {
+ failCleanup(ex, resultFile);
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/XInclHandler.java Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,382 @@
+/*
+ * 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 test.auctionportal;
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.util.stream.Collectors;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.ext.LexicalHandler;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * A SAX2 event handlers.
+ * This SAX2 ContentHandler receives callback event then print whole document
+ * that is parsed.
+ */
+public class XInclHandler extends DefaultHandler implements LexicalHandler {
+ /**
+ * Print writer.
+ */
+ private final PrintWriter fOut;
+
+ /**
+ * Canonical output.
+ */
+ private volatile boolean fCanonical;
+
+ /**
+ * Element depth.
+ */
+ private volatile int fElementDepth;
+
+ /**
+ * Sets whether output is canonical.
+ */
+ public void setCanonical(boolean canonical) {
+ fCanonical = canonical;
+ }
+
+ /**
+ * Sets the output stream for printing.
+ * @param stream OutputStream for message output.
+ * @param encoding File encoding for message output.
+ */
+ public XInclHandler(OutputStream stream, String encoding)
+ throws UnsupportedEncodingException {
+ // At least set one encoding.
+ if (encoding == null) {
+ encoding = "UTF8";
+ }
+
+ fOut = new PrintWriter(new OutputStreamWriter(stream, encoding), false);
+ }
+
+ /**
+ * Receive notification of the beginning of the document. Write the start
+ * document tag if it's not canonical mode.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ */
+ @Override
+ public void startDocument() throws SAXException {
+ fElementDepth = 0;
+
+ if (!fCanonical) {
+ writeFlush("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ }
+ }
+
+ /**
+ * Receive notification of a processing instruction.
+ * @param target The processing instruction target.
+ * @param data The processing instruction data, or null if
+ * none is supplied.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ */
+ @Override
+ public void processingInstruction (String target, String data)
+ throws SAXException {
+ if (fElementDepth > 0) {
+ StringBuilder instruction = new StringBuilder("<?").append(target);
+ if (data != null && data.length() > 0) {
+ instruction.append(' ').append(data);
+ }
+ instruction.append("?>");
+ writeFlush(instruction.toString());
+ }
+ }
+
+ /**
+ * Receive notification of the start of an element then write the normalized
+ * output to the file.
+ * @param uri The Namespace URI, or the empty string if the
+ * element has no Namespace URI or if Namespace
+ * processing is not being performed.
+ * @param localName The local name (without prefix), or the
+ * empty string if Namespace processing is not being
+ * performed.
+ * @param qName The qualified name (with prefix), or the
+ * empty string if qualified names are not available.
+ * @param attributes The attributes attached to the element. If
+ * there are no attributes, it shall be an empty
+ * Attributes object.
+ */
+ @Override
+ public void startElement(String uri, String local, String raw,
+ Attributes attrs) throws SAXException {
+ fElementDepth++;
+ StringBuilder start = new StringBuilder().append('<').append(raw);
+ if (attrs != null) {
+ for (int i = 0; i < attrs.getLength(); i++) {
+ start.append(' ').append(attrs.getQName(i)).append("=\"").
+ append(normalizeAndPrint(attrs.getValue(i))).append('"');
+ }
+ }
+ start.append('>');
+ writeFlush(start.toString());
+ }
+
+ /**
+ * Receive notification of character data inside an element and write
+ * normalized characters to file.
+ * @param ch The characters.
+ * @param start The start position in the character array.
+ * @param length The number of characters to use from the
+ * character array.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ */
+ @Override
+ public void characters(char ch[], int start, int length)
+ throws SAXException {
+ writeFlush(normalizeAndPrint(ch, start, length));
+ }
+
+ /**
+ * Receiving notification of ignorable whitespace in element content and
+ * writing normalized ignorable characters to file.
+ * @param ch The characters.
+ * @param start The start position in the character array.
+ * @param length The number of characters to use from the
+ * character array.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ */
+ @Override
+ public void ignorableWhitespace(char ch[], int start, int length)
+ throws SAXException {
+ characters(ch, start, length);
+ }
+
+ /**
+ * Receive notification of the end of an element and print end element.
+ *
+ * @param uri The Namespace URI, or the empty string if the
+ * element has no Namespace URI or if Namespace
+ * processing is not being performed.
+ * @param localName The local name (without prefix), or the
+ * empty string if Namespace processing is not being
+ * performed.
+ * @param qName The qualified name (with prefix), or the
+ * empty string if qualified names are not available.
+ */
+ @Override
+ public void endElement(String uri, String local, String raw)
+ throws SAXException {
+ fElementDepth--;
+ writeFlush("</" + raw + ">");
+ }
+
+ /**
+ * Receive notification of a parser warning and print it out.
+ * @param e The warning information encoded as an exception.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ */
+ @Override
+ public void warning(SAXParseException ex) throws SAXException {
+ printError("Warning", ex);
+ }
+
+ /**
+ * Receive notification of a parser error and print it out.
+ * @param e The error information encoded as an exception.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+
+ */
+ @Override
+ public void error(SAXParseException ex) throws SAXException {
+ printError("Error", ex);
+ }
+
+ /**
+ * Receive notification of a parser fatal error. Throw out fatal error
+ * following print fatal error message.
+ * @param e The fatal error information encoded as an exception.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+
+ */
+ @Override
+ public void fatalError(SAXParseException ex) throws SAXException {
+ printError("Fatal Error", ex);
+ throw ex;
+ }
+
+ /**
+ * Do nothing on start DTD.
+ * @param name The document type name.
+ * @param publicId The declared public identifier for the
+ * external DTD subset, or null if none was declared.
+ * @param systemId The declared system identifier for the
+ * external DTD subset, or null if none was declared.
+ * (Note that this is not resolved against the document
+ * base URI.)
+ * @exception SAXException The application may raise an
+ * exception.
+ */
+ @Override
+ public void startDTD(String name, String publicId, String systemId)
+ throws SAXException {
+ }
+
+ /**
+ * Do nothing on end DTD.
+ * @exception SAXException The application may raise an exception.
+ */
+ @Override
+ public void endDTD() throws SAXException {
+ }
+
+ /**
+ * Do nothing on start entity.
+ * @param name The name of the entity. If it is a parameter
+ * entity, the name will begin with '%', and if it is the
+ * external DTD subset, it will be "[dtd]".
+ * @exception SAXException The application may raise an exception.
+ */
+ @Override
+ public void startEntity(String name) throws SAXException {
+ }
+
+ /**
+ * Do nothing on end entity.
+ * @param name The name of the entity. If it is a parameter
+ * entity, the name will begin with '%', and if it is the
+ * external DTD subset, it will be "[dtd]".
+ * @exception SAXException The application may raise an exception.
+ */
+ @Override
+ public void endEntity(String name) throws SAXException {
+ }
+
+ /**
+ * Do nothing on start CDATA section.
+ * @exception SAXException The application may raise an exception.
+ */
+ @Override
+ public void startCDATA() throws SAXException {
+ }
+
+ /**
+ * Do nothing on end CDATA section.
+ * @exception SAXException The application may raise an exception.
+ */
+ @Override
+ public void endCDATA() throws SAXException {
+ }
+
+ /**
+ * Report an normalized XML comment when receive a comment in the document.
+ *
+ * @param ch An array holding the characters in the comment.
+ * @param start The starting position in the array.
+ * @param length The number of characters to use from the array.
+ * @exception SAXException The application may raise an exception.
+ */
+ @Override
+ public void comment(char ch[], int start, int length) throws SAXException {
+ if (!fCanonical && fElementDepth > 0) {
+ writeFlush("<!--" + normalizeAndPrint(ch, start, length) + "-->");
+ }
+ }
+
+ /**
+ * Normalizes and prints the given string.
+ * @param s String to be normalized
+ */
+ private String normalizeAndPrint(String s) {
+ return s.chars().mapToObj(c -> normalizeAndPrint((char)c)).
+ collect(Collectors.joining());
+ }
+
+ /**
+ * Normalizes and prints the given array of characters.
+ * @param ch The characters to be normalized.
+ * @param start The start position in the character array.
+ * @param length The number of characters to use from the
+ * character array.
+ */
+ private String normalizeAndPrint(char[] ch, int offset, int length) {
+ return normalizeAndPrint(new String(ch, offset, length));
+ }
+
+ /**
+ * Normalizes given character.
+ * @param c char to be normalized.
+ */
+ private String normalizeAndPrint(char c) {
+ switch (c) {
+ case '<':
+ return "<";
+ case '>':
+ return ">";
+ case '&':
+ return "&";
+ case '"':
+ return """;
+ case '\r':
+ case '\n':
+ return fCanonical ? "&#" + Integer.toString(c) + ";" : String.valueOf(c);
+ default:
+ return String.valueOf(c);
+ }
+ }
+
+ /**
+ * Prints the error message.
+ * @param type error type
+ * @param ex exception that need to be printed
+ */
+ private void printError(String type, SAXParseException ex) {
+ System.err.print("[" + type + "] ");
+ String systemId = ex.getSystemId();
+ if (systemId != null) {
+ int index = systemId.lastIndexOf('/');
+ if (index != -1)
+ systemId = systemId.substring(index + 1);
+ System.err.print(systemId);
+ }
+ System.err.print(':' + ex.getLineNumber());
+ System.err.print(':' + ex.getColumnNumber());
+ System.err.println(": " + ex.getMessage());
+ System.err.flush();
+ }
+
+ /**
+ * Write out and flush.
+ * @param out string to be written.
+ */
+ private void writeFlush(String out) {
+ fOut.print(out);
+ fOut.flush();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/accountInfo.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,11 @@
+<?xml version="1.0" ?>
+<acc:Account xmlns="http://www.auctionportal.org/Accounts"
+ xmlns:acc="http://www.auctionportal.org/Accounts"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.auctionportal.org/Accounts accountInfo.xsd" acc:accountID="1">
+
+ <FirstName>Rachel</FirstName>
+ <LastName>Green</LastName>
+ <UserID>744</UserID>
+ <Role><Sell/></Role>
+</acc:Account>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/accountInfo.xsd Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,61 @@
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.auctionportal.org/Accounts"
+ xmlns:acc="http://www.auctionportal.org/Accounts"
+ xmlns="http://www.auctionportal.org/Accounts" elementFormDefault="qualified">
+
+<xs:element name="Account">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="FirstName" type ="xs:string"/>
+ <xs:element name="MiddleInitial" type ="xs:string" minOccurs="0"/>
+ <xs:element ref="LastName"/>
+
+ <!-- This is to associate the account with the screenName
+ later will work on uniqueness with identity constraints
+ importing/including this schema in another one
+ -->
+ <xs:element name="UserID" type ="xs:nonNegativeInteger" />
+ <xs:element name="Role" type ="BuyOrSell" minOccurs="0" maxOccurs="1" />
+
+ <!-- This may not make sense but this is to test the date -->
+ <xs:element name="DateOfBirth" type ="DateType" minOccurs="0" maxOccurs="1" />
+ <xs:element name="EmailQname" type ="xs:QName" minOccurs="0" maxOccurs="1" />
+ <xs:element name="AptNo" type ="xs:unsignedShort" minOccurs="0" maxOccurs="1" />
+ <xs:element name="StreetNo" type ="xs:short" minOccurs="0" maxOccurs="1" />
+ </xs:sequence>
+ <xs:attribute ref="accountID"/>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="LastName" type ="xs:string"/>
+
+<!-- The accountID is same as UserID This is just to check how
+ global attributes are treated-->
+<xs:attribute name="accountID" type="xs:integer"/>
+
+<xs:complexType name="BuyOrSell">
+ <xs:choice>
+ <xs:element name="Buy" type="PlaceHolder"/>
+ <xs:element name="Sell" type="PlaceHolder"/>
+ </xs:choice>
+</xs:complexType>
+
+<!-- an empty complex type declared globally-->
+<xs:complexType name="PlaceHolder">
+</xs:complexType>
+
+
+<!-- This may all not make too much sense
+ but just to check the date features of schema-->
+<xs:complexType name="DateType">
+ <xs:sequence>
+ <!--<xs:all>-->
+ <xs:element name="YearMonth" type="xs:gYearMonth"/>
+ <xs:element name="MonthDay" type="xs:gMonthDay"/>
+ <xs:element name="Date" type="xs:date"/>
+ <!--</xs:all>-->
+ </xs:sequence>
+</xs:complexType>
+
+</xs:schema>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/activity.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,6 @@
+<?xml version="1.0" ?>
+<activity id="1" >
+ <name>Code</name>
+ <description>Some description</description>
+</activity>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/bookInfo.dtd Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,13 @@
+<!ELEMENT document ANY>
+<!ELEMENT title (#PCDATA)>
+<!ELEMENT publisher (#PCDATA)>
+<!ELEMENT book (#PCDATA)>
+<!ELEMENT bookurn (#PCDATA)>
+<!ELEMENT xmlns:pages (#PCDATA)>
+<!ATTLIST book price CDATA "$100">
+<!ATTLIST book author CDATA "Herold">
+<!ATTLIST book number ID #REQUIRED>
+<!ATTLIST bookurn xmlns CDATA "10">
+<!ATTLIST bookurn xmlns:isbn CDATA "10">
+<!ENTITY ws "Walter Sam Communications">
+<!ENTITY af "Alfred publication">
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/bookInfo.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,25 @@
+<?xml version="1.0" standalone="no" ?>
+<!DOCTYPE document SYSTEM "bookInfo.dtd">
+<document>
+ Publishers of the Music of New York Women Composers
+
+ <title>The Publishers </title>
+
+ <publisher>
+ Alfred Publishing
+ &ws;
+ 15535 Morrison
+ South Oaks CA 91403
+ </publisher>
+
+ <book price="$100" author = "Herold" number = "no_11">
+ eXtensible Markup Language
+ </book>
+
+ <bookurn xmlns='urn:loc.gov:books'
+ xmlns:isbn='urn:ISBN:0-395-36341-6'/>
+ <xmlns:pages />
+
+ Publishers are not noted in report by time.
+
+</document>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/coins.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<im:coin
+ xmlns:im="http://www.hibid.com/items"
+ xmlns="http://www.hibid.com/items"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:it="http://someimport.com">
+ <im:description>
+ <im:info> 1950 gold coin
+ </im:info>
+ </im:description>
+ <dates_data xmlns="http://www.hibid.com/items">
+ <it:mint>1950-04-04T00:00:00</it:mint>
+ <it:circulation> 1960
+ </it:circulation>
+ </dates_data>
+</im:coin>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/coins.xsd Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+
+
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.hibid.com/items"
+ xmlns="http://www.hibid.com/items"
+ xmlns:im="http://someimport.com"
+ elementFormDefault="qualified"
+ xmlns:it="http://www.hibid.com/items" >
+
+ <xs:import schemaLocation="coinsImportMe.xsd" namespace="http://someimport.com"/>
+
+
+
+ <xs:element name="coin">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="description" type="it:description" />
+ <xs:element name="dates_data" type="im:dates_data" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:complexType name="description">
+ <xs:sequence>
+ <xs:element name="info" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+
+
+ <xs:simpleType name="yearType">
+ <xs:restriction base="xs:int">
+ <xs:enumeration value="1930" />
+ <xs:enumeration value="1949" />
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:element name="YearInfo">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="reMintYear" type="yearType" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+
+</xs:schema>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/coinsImportMe.xsd Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+
+
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://someimport.com"
+ xmlns="http://someimport.com"
+ elementFormDefault="qualified"
+ xmlns:im="http://someimport.com" >
+
+
+ <xs:complexType name="dates_data">
+ <xs:sequence>
+ <xs:element name="mint" type="xs:dateTime" />
+ <xs:element name="circulation" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="designer">
+ <xs:sequence>
+ <xs:element name="name" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/data.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,18 @@
+<?xml version='1.0'?>
+<data id="employee">
+ <employee id="employee">
+ <name>timepass</name>
+ <sex>M</sex>
+ <age>10</age>
+ <complexion>Fair</complexion>
+ <figure>36-28-36</figure>
+ </employee>
+ <employee>
+ <name>COOOOL</name>
+ <sex>F</sex>
+ <age>20</age>
+ <complexion>Dark</complexion>
+ <figure>26-32-26</figure>
+ </employee>
+</data>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/doc_fallback.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,11 @@
+<?xml version='1.0'?>
+<document xmlns:xi="http://www.w3.org/2001/XInclude">
+ <p>The following is the source of the "task.xml" resource:</p>
+ <example>
+ <xi:include href="task.xml" parse="xml">
+ <xi:fallback >
+ <xi:include href="fallback.xml" parse="xml" />
+ </xi:fallback>
+ </xi:include>
+ </example>
+</document>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/doc_fallback_text.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,11 @@
+<?xml version='1.0'?>
+<document xmlns:xi="http://www.w3.org/2001/XInclude">
+ <p>The following is the source of the "tasks.xml" resource:</p>
+ <example>
+ <xi:include href="task.xml" parse="xml">
+ <xi:fallback >
+ <xi:include href="fallback_text.xml" parse="text" />
+ </xi:fallback>
+ </xi:include>
+ </example>
+</document>
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/doc_xinc_loops.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<root xmlns:xi="http://www.w3.org/2001/XInclude">
+ <p>The following is the outer XML file</p>
+ <example>
+
+ <xi:include href="task.xml" parse="xml">
+ <xi:fallback>
+ <xi:include href="doc_xinc_loops.xml" parse="text" />
+ </xi:fallback>
+ </xi:include>
+ </example>
+</root>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/doc_xinclude.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,6 @@
+<?xml version='1.0'?>
+<document xmlns:xi="http://www.w3.org/2001/XInclude">
+ <p>The following is the source of the "data.xml" resource:</p>
+ <example><xi:include href="tasks.xml" parse="xml"/></example>
+</document>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/doc_xpointer.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,6 @@
+<?xml version='1.0'?>
+<document xmlns:xi="http://www.w3.org/2001/XInclude">
+ <p>The following is the source of the "tasks.xml" resource:</p>
+ <example><xi:include href="tasks.xml" xpointer="element(/1/2/1)" parse="xml"/></example>
+</document>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/doc_xpointer_element.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,5 @@
+<?xml version='1.0'?>
+<document xmlns:xi="http://www.w3.org/2001/XInclude">
+ <p>The following is the source of the "tasks.xml" resource:</p>
+ <example><xi:include href="tasks.xml" xpointer="element(/1/2/1)" parse="xml"/></example>
+</document>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/document_xinclude.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,6 @@
+<?xml version='1.0'?>
+<document xmlns:xi="http://www.w3.org/2001/XInclude">
+ <p>The following is the source of the "data.xml" resource:</p>
+ <example><xi:include href="data.xml" parse="xml"/></example>
+</document>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/entity.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Document : entity.xml
+ Created on : August 6, 2003, 5:39 PM
+ Author : Prasad Subramanian
+ Description:
+ To create a base XML document to test the entiity expansion limit
+-->
+<!DOCTYPE status[
+<!ENTITY firstEntity "fe">
+<!ENTITY secondEntity "&firstEntity;&firstEntity;" >
+<!ENTITY thirdEntity "&secondEntity;&secondEntity;" >
+<!ENTITY fourthEntity "&thirdEntity;&thirdEntity;" >
+<!ENTITY fifthEntity "&fourthEntity;&fourthEntity;" >
+<!-- <!ENTITY sixthEntity "&fifthEntity;&fifthEntity;">
+<!ENTITY seventhEntity "&sixthEntity;&sixthEntity;" >
+<!ENTITY eighthEntity "&seventhEntity;&seventhEntity;" >
+<!ENTITY ninthEntity "&eighthEntity;&eighthEntity;" >
+<!ENTITY tenthEntity "&ninthEntity;&ninthEntity;" >
+<!ENTITY eleventhEntity "&tenthEntity;&tenthEntity;"> -->
+]>
+<report>
+ <tests>
+ <test>
+ <id>Test Id</id>
+ <name>Test Name</name>
+ <description>My Desc</description>
+ <status>&fifthEntity;</status>
+ </test>
+ </tests>
+</report>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/fallback.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<fallback> This is the fallback text </fallback>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/fallback_text.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,1 @@
+This is the fallback text as a text
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/inclusion.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<activities xmlns:xi="http://www.w3.org/2001/XInclude" >
+ <xi:include href="activity.xml" parse="xml" />
+</activities>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/itemsDuration.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+
+<item xmlns="http://www.hibid.com/items" itemID="i1" name="Warn Bros Pitcher" category="other" country="US">
+ <description> 20th century vase. Really unique . Really antique</description>
+ <ownerID>2</ownerID>
+ <sellStartDateTime> 2002-03-11T15:23:45</sellStartDateTime>
+ <sellStartDate> 2002-03-11</sellStartDate>
+ <sellStartTime> 15:23:45</sellStartTime>
+ <sellDuration>P365D</sellDuration>
+ <bidderID>a2</bidderID>
+ <bidPrice></bidPrice>
+ <elapsedTime></elapsedTime>
+
+</item>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/movies.xml.data Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-16" standalone="yes"?>
+<Collection>
+ <movies>
+ <movie>
+ <name>ઠકત</name>
+ <director>Vipul Shah</director>
+ <country>Indian</country>
+ <language>Gujarati</language>
+ <releaseDate>1997-03-02-08:00</releaseDate>
+ </movie>
+ </movies>
+</Collection>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/novels.xsd Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+xmlns="www.novels.com"
+xsi:schemaLocation=""www.novels.com" novels.xsd" >
+
+
+
+<xs:element name="novel" type="novelType" />
+
+<xs:complexType name="novelType">
+ <xs:sequence maxOccurs ="3" minOccurs="1">
+ <xs:element name="mystery" type="xs:string"/>
+ <xs:element name="links" type="linksType"/>
+ </xs:sequence>
+</xs:complexType>
+
+<xs:simpleType name="linksType">
+ <xs:restriction base="xs:anyURI">
+ <xs:enumeration value="http://www.links.com"/>
+ <xs:enumeration value="http://www.mystery.com"/>
+ <xs:enumeration value="http://www.hitchcock.com"/>
+ </xs:restriction>
+</xs:simpleType>
+
+</xs:schema>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/novelsInvalid.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<novel>
+ <mystery>Mystery of Whispering Mummy</mystery>
+ <links>http://www.links.com </links>
+
+ <mystery>Mystery of Vanishing Treasure</mystery>
+ <links>http://www.alfrdhitchcock.com </links>
+</novel>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/schedule.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schedule xmlns:xi="http://www.w3.org/2001/XInclude" >
+ <task xmlns:xi="http://www.w3.org/2001/XInclude">
+ <xi:include href="inclusion.xml" parse="xml" />
+ </task>
+ <task xmlns:xi="http://www.w3.org/2001/XInclude">
+ <xi:include href="inclusion.xml" parse="xml" />
+ </task>
+</schedule>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/screenName.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+
+
+<us:screen-names xmlns:us="http://hibid.com/screenName">
+ xmlns="http://hibid.com/screenName">
+ <us:screen-name>
+ <us:userName xmlns:us="http://hibid.com/user"> tom </us:userName>
+ <userNo>10 </userNo>
+ </us:screen-name>
+</us:screen-names>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/tasks.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,16 @@
+<?xml version="1.0" ?>
+<tasks>
+ <task id="task1" >
+ <owner>John doe</owner>
+ <startdate>10/02/2003</startdate>
+ <enddate>11/02/2003</enddate>
+ <description>This is task 1</description>
+ </task>
+ <task id="task2" >
+ <owner>Jane Doe</owner>
+ <startdate>10/02/2003</startdate>
+ <enddate>11/02/2003</enddate>
+ <description>This is task 2</description>
+ </task>
+</tasks>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/toys.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Document : toys.xml
+ Created on : August 11, 2003, 6:42 PM
+ Author : Prasad Subramanian
+ Description:
+-->
+
+<toys>
+ <toy>
+ <name>Lego-Model01</name>
+ <price>65.99</price>
+ </toy>
+ <toy>
+ <name>Lego-Model2</name>
+ <price>69.99</price>
+ </toy>
+ <toy>
+ <name>Lego-Model3</name>
+ <price>14.99</price>
+ </toy>
+ <toy>
+ <name>Barbie-Pink</name>
+ <price>12.99</price>
+ </toy>
+ <toy>
+ <name>Barbie-Blue</name>
+ <price>13.99</price>
+ </toy>
+ <toy>
+ <name>Barbie-White</name>
+ <price>13.99</price>
+ </toy>
+ <toy>
+ <name>Barbie-Plain</name>
+ <price>13.99</price>
+ </toy>
+</toys>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/toys.xsd Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="toys">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="toy" maxOccurs="200">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="name" type="xs:string" minOccurs="0"/>
+ <xs:element name="price" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/userAddress.xsd Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.hibid.com/useraccount"
+ xmlns="http://www.hibid.com/useraccount"
+ xmlns:user="http://www.hibid.com/useraccount" elementFormDefault="qualified">
+
+
+
+ <xs:complexType name="AddressType">
+ <xs:sequence>
+ <xs:element name="StreetInfo" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+
+
+</xs:schema>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/userDetails.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<user xmlns="http://www.hibid.com/useraccount"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.hibid.com/useraccount userDetails.xsd http://www.hibid.com/useraccount userAddress.xsd">
+ <Name>Bob </Name>
+ <addresses>
+ <homeAddress>
+ <StreetInfo>555 Beverly Hills Rd
+ </StreetInfo>
+ </homeAddress>
+ </addresses>
+
+</user>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/userDetails.xsd Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding = "utf-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.hibid.com/useraccount"
+ xmlns="http://www.hibid.com/useraccount"
+ xmlns:user="http://www.hibid.com/useraccount" elementFormDefault="qualified" >
+
+ <xs:include schemaLocation="userAddress.xsd"/>
+
+ <xs:simpleType name="charType">
+ <xs:restriction base="xs:NCName">
+ <xs:minLength value="1" />
+ <xs:maxLength value="1" />
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="_2CharsType">
+ <xs:restriction base="xs:string">
+ <xs:length value="2" fixed="true"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="_3digits">
+ <xs:restriction base="xs:string">
+ <xs:pattern value="[0-9]{3}" />
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="_7digits">
+ <xs:restriction base="xs:string">
+ <xs:pattern value="[0-9]{7}" />
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:complexType name="EmptyElement" />
+
+
+ <!-- *************************************
+ *** phone number type ****
+ *************************************
+ -->
+ <xs:complexType name="international_AreaCode_Type">
+ <xs:sequence>
+ <xs:element name="countryCode" type="_3digits"/>
+ <xs:element name="areaCode" type="_3digits"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="us_AreaCode_Type">
+ <xs:sequence>
+ <xs:element name="areaCode" type="_3digits"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="us_phonenumber_type">
+ <xs:complexContent>
+ <xs:extension base="us_AreaCode_Type">
+ <xs:sequence>
+ <xs:element name="localNumber" type="_7digits"/>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+ <xs:complexType name="international_phonenumber_type">
+ <xs:complexContent>
+ <xs:extension base="international_AreaCode_Type">
+ <xs:sequence>
+ <xs:element name="localNumber" type="_7digits"/>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+ <!-- *************************************
+ *** address type ****
+ *************************************
+ -->
+ <xs:simpleType name="stateAbrvType">
+ <xs:restriction base="_2CharsType">
+ <xs:pattern value="[A-Z]" />
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="us_zipCodeType">
+ <xs:restriction base="xs:string">
+ <xs:pattern value="[0-9]{5}(-[0-9]{4})?" />
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="state.zip_type">
+ <xs:union memberTypes="stateAbrvType us_zipCodeType"/>
+ </xs:simpleType>
+
+ <xs:simpleType name="CityInfo_type">
+ <xs:restriction base="xs:normalizedString">
+ <xs:whiteSpace value="collapse" />
+ </xs:restriction>
+ </xs:simpleType>
+
+
+ <!-- *************************************
+ *** user ****
+ *************************************
+ -->
+ <xs:element name="user">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Name" type="xs:string" minOccurs="0" />
+
+
+ <xs:element name="addresses">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="homeAddress" type="AddressType"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+
+
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/userInfo.dtd Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,6 @@
+<!ELEMENT userInfo (user+)>
+<!ELEMENT user (FirstName,LastName,UserID)>
+<!ELEMENT FirstName (#PCDATA)>
+<!ELEMENT LastName (#PCDATA)>
+<!ELEMENT UserID (#PCDATA)>
+<!ATTLIST user accountID CDATA "100">
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/content/userInfo.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,12 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE userInfo SYSTEM "userInfo.dtd">
+<userInfo>
+ <user accountID="a111">
+ <FirstName>King
+ </FirstName>
+ <LastName>Kong
+ </LastName>
+ <UserID>007
+ </UserID>
+ </user>
+</userInfo>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/golden/doc_fallbackGold.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?><document xmlns:xi="http://www.w3.org/2001/XInclude">
+ <p>The following is the source of the "task.xml" resource:</p>
+ <example>
+
+ <fallback xml:base="fallback.xml"> This is the fallback text </fallback>
+
+ </example>
+</document>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/golden/doc_fallback_textGold.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document xmlns:xi="http://www.w3.org/2001/XInclude">
+ <p>The following is the source of the "tasks.xml" resource:</p>
+ <example>
+
+ This is the fallback text as a text
+
+
+ </example>
+</document>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/golden/doc_xinc_loopGold.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<root xmlns:xi="http://www.w3.org/2001/XInclude">
+ <p>The following is the outer XML file</p>
+ <example>
+
+
+ <?xml version="1.0" encoding="UTF-8"?>
+<root xmlns:xi="http://www.w3.org/2001/XInclude">
+ <p>The following is the outer XML file</p>
+ <example>
+
+ <xi:include href="task.xml" parse="xml">
+ <xi:fallback>
+ <xi:include href="doc_xinc_loops.xml" parse="text" />
+ </xi:fallback>
+ </xi:include>
+ </example>
+</root>
+
+
+
+ </example>
+</root>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/golden/doc_xincludeGold.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,18 @@
+<?xml version='1.0' encoding="UTF-8"?><document xmlns:xi="http://www.w3.org/2001/XInclude">
+ <p>The following is the source of the "data.xml" resource:</p>
+ <example><tasks xml:base="tasks.xml">
+ <task id="task1" >
+ <owner>John doe</owner>
+ <startdate>10/02/2003</startdate>
+ <enddate>11/02/2003</enddate>
+ <description>This is task 1</description>
+ </task>
+ <task id="task2" >
+ <owner>Jane Doe</owner>
+ <startdate>10/02/2003</startdate>
+ <enddate>11/02/2003</enddate>
+ <description>This is task 2</description>
+ </task>
+</tasks></example>
+</document>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/golden/doc_xpointerGold.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?><document xmlns:xi="http://www.w3.org/2001/XInclude">
+ <p>The following is the source of the "tasks.xml" resource:</p>
+ <example><owner xml:base="tasks.xml">Jane Doe</owner></example>
+</document>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/golden/scheduleGold.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?><schedule xmlns:xi="http://www.w3.org/2001/XInclude">
+ <task>
+ <activities xml:base="inclusion.xml">
+ <activity id="1" xml:base="activity.xml">
+ <name>Code</name>
+ <description>Some description</description>
+</activity>
+</activities>
+ </task>
+ <task>
+ <activities xml:base="inclusion.xml">
+ <activity id="1" xml:base="activity.xml">
+ <name>Code</name>
+ <description>Some description</description>
+</activity>
+</activities>
+ </task>
+</schedule>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/test/auctionportal/golden/screenNameGold.xml Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<us:screen-names xmlns:us="http://hibid.com/screenName">
+ xmlns="http://hibid.com/screenName">
+ <us:screen-name>
+ <us:userName xmlns:us="http://hibid.com/user"> tom </us:userName>
+ <userNo>10 </userNo>
+ <userEmail xmlns="http://hibid.com/user">myid@hibid.com</userEmail></us:screen-name>
+</us:screen-names>
--- a/jaxp/test/javax/xml/jaxp/libs/jaxp/library/JAXPTestUtilities.java Mon Nov 10 16:09:38 2014 -0800
+++ b/jaxp/test/javax/xml/jaxp/libs/jaxp/library/JAXPTestUtilities.java Tue Nov 11 14:27:13 2014 -0800
@@ -22,11 +22,23 @@
*/
package jaxp.library;
-
+import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.charset.UnsupportedCharsetException;
import java.nio.file.Files;
import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.stream.Collectors;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
import static org.testng.Assert.fail;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
/**
* This is an interface provide basic support for JAXP functional test.
@@ -59,6 +71,22 @@
public static final String TEMP_DIR = System.getProperty("java.io.tmpdir", ".");
/**
+ * BOM table for storing BOM header.
+ */
+ private final static Map<String, byte[]> bom = new HashMap();
+
+ /**
+ * Initialize all BOM headers.
+ */
+ static {
+ bom.put("UTF-8", new byte[]{(byte)0xEF, (byte) 0xBB, (byte) 0xBF});
+ bom.put("UTF-16BE", new byte[]{(byte)0xFE, (byte)0xFF});
+ bom.put("UTF-16LE", new byte[]{(byte)0xFF, (byte)0xFE});
+ bom.put("UTF-32BE", new byte[]{(byte)0x00, (byte)0x00, (byte)0xFE, (byte)0xFF});
+ bom.put("UTF-32LE", new byte[]{(byte)0xFF, (byte)0xFE, (byte)0x00, (byte)0x00});
+ }
+
+ /**
* Compare contents of golden file with test output file line by line.
* return true if they're identical.
* @param goldfile Golden output file name
@@ -75,6 +103,63 @@
}
/**
+ * Compare contents of golden file with test output file by their document
+ * representation.
+ * Here we ignore the white space and comments. return true if they're
+ * lexical identical.
+ * @param goldfile Golden output file name.
+ * @param resultFile Test output file name.
+ * @return true if two file's document representation are identical.
+ * false if two file's document representation are not identical.
+ * @throws javax.xml.parsers.ParserConfigurationException if the
+ * implementation is not available or cannot be instantiated.
+ * @throws SAXException If any parse errors occur.
+ * @throws IOException if an I/O error occurs reading from the file or a
+ * malformed or unmappable byte sequence is read .
+ */
+ public static boolean compareDocumentWithGold(String goldfile, String resultFile)
+ throws ParserConfigurationException, SAXException, IOException {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ factory.setCoalescing(true);
+ factory.setIgnoringElementContentWhitespace(true);
+ factory.setIgnoringComments(true);
+ DocumentBuilder db = factory.newDocumentBuilder();
+
+ Document goldD = db.parse(Paths.get(goldfile).toFile());
+ goldD.normalizeDocument();
+ Document resultD = db.parse(Paths.get(resultFile).toFile());
+ resultD.normalizeDocument();
+ return goldD.isEqualNode(resultD);
+ }
+ /**
+ * Convert stream to ByteArrayInputStream by given character set.
+ * @param charset target character set.
+ * @param file a file that contains no BOM head content.
+ * @return a ByteArrayInputStream contains BOM heads and bytes in original
+ * stream
+ * @throws IOException I/O operation failed or unsupported character set.
+ */
+ public static InputStream bomStream(String charset, String file)
+ throws IOException {
+ String localCharset = charset;
+ if (charset.equals("UTF-16") || charset.equals("UTF-32")) {
+ localCharset
+ += ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN ? "BE" : "LE";
+ }
+ if (!bom.containsKey(localCharset))
+ throw new UnsupportedCharsetException("Charset:" + localCharset);
+
+ byte[] content = Files.readAllLines(Paths.get(file)).stream().
+ collect(Collectors.joining()).getBytes(localCharset);
+ byte[] head = bom.get(localCharset);
+ ByteBuffer bb = ByteBuffer.allocate(content.length + head.length);
+ bb.put(head);
+ bb.put(content);
+ return new ByteArrayInputStream(bb.array());
+ }
+
+ /**
* Prints error message if an exception is thrown
* @param ex The exception is thrown by test.
*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/libs/test/auctionportal/HiBidConstants.java Tue Nov 11 14:27:13 2014 -0800
@@ -0,0 +1,68 @@
+/*
+ * 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 test.auctionportal;
+
+import static jaxp.library.JAXPTestUtilities.FILE_SEP;
+import static jaxp.library.JAXPTestUtilities.USER_DIR;
+
+/**
+ * This is the Base test class provide basic support for Auction portal test.
+ */
+public class HiBidConstants {
+ /**
+ * Current test directory.
+ */
+ public static final String CLASS_DIR
+ = System.getProperty("test.classes", ".") + FILE_SEP;
+
+ /**
+ * Package name that separates by slash.
+ */
+ public static final String PACKAGE_NAME = FILE_SEP +
+ HiBidConstants.class.getPackage().getName().replaceAll("[.]", FILE_SEP);
+
+
+ /**
+ * Java source directory.
+ */
+ public static final String SRC_DIR = System.getProperty("test.src", USER_DIR)
+ .replaceAll("\\" + System.getProperty("file.separator"), "/")
+ + PACKAGE_NAME + FILE_SEP;
+
+ /**
+ * Source XML file directory.
+ */
+ public static final String XML_DIR = SRC_DIR + "content" + FILE_SEP;
+
+ /**
+ * Golden output file directory.
+ * We pre-define all expected output in golden output file. Test verifies
+ * whether the standard output is same as content of golden file.
+ */
+ public static final String GOLDEN_DIR = SRC_DIR + "golden" + FILE_SEP;
+
+ /**
+ * Name space for account operation.
+ */
+ public static final String PORTAL_ACCOUNT_NS = "http://www.auctionportal.org/Accounts";
+}