xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ce...@apache.org
Subject svn commit: r156710 [5/5] - in xmlbeans/trunk/test: cases/xbean/compile/som/ cases/xbean/misc/ cases/xbean/misc/jira/ src/compile/scomp/som/checkin/ src/compile/scomp/som/common/ src/compile/scomp/som/detailed/ src/misc/common/ src/misc/detailed/
Date Wed, 09 Mar 2005 23:21:22 GMT
Added: xmlbeans/trunk/test/src/misc/detailed/JiraRegression50_100Test.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/misc/detailed/JiraRegression50_100Test.java?view=auto&rev=156710
==============================================================================
--- xmlbeans/trunk/test/src/misc/detailed/JiraRegression50_100Test.java (added)
+++ xmlbeans/trunk/test/src/misc/detailed/JiraRegression50_100Test.java Wed Mar  9 15:20:56
2005
@@ -0,0 +1,733 @@
+/*   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package misc.detailed;
+
+import junit.framework.Assert;
+import org.apache.xmlbeans.*;
+import org.apache.xmlbeans.impl.tool.SchemaCompiler;
+import org.apache.xmlbeans.impl.xb.xmlconfig.ConfigDocument;
+import org.apache.beehive.netui.tools.testrecorder.x2004.session.RecorderSessionDocument;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.Node;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.*;
+import java.net.URL;
+
+import tools.util.JarUtil;
+import test.xbean.xmlcursor.purchaseOrder.PurchaseOrderDocument;
+import testDateAttribute.TestElementWithDateAttributeDocument;
+import testDateAttribute.TestDatewTZone;
+import misc.common.JiraTestBase;
+import dufourrault.DummyDocument;
+import net.orthogony.xml.sample.structure.ARootDocument;
+import net.orthogony.xml.sample.structure.ChildType;
+
+
+public class JiraRegression50_100Test extends JiraTestBase
+{
+
+
+    public JiraRegression50_100Test(String name)
+    {
+     super(name);
+    }
+
+    ///**
+    // * [XMLBEANS-##]  <BUG TITLE>
+    // */
+    //public void test_jira_XmlBeans45() throws Exception
+    //{
+    //
+    //}
+
+
+
+
+    /**
+     * [XMLBEANS-52]   Validator loops when schema has certain conditions
+     */
+    public void test_jira_XmlBeans52() throws Exception{
+     //reusing code from method test_jira_XmlBeans48()
+     String correctXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n" +
+             "<!--Sample XML file generated by XMLSPY v5 rel. 4 U (http://www.xmlspy.com)--/>
\n" +
+             "<aList xmlns=\"http://pfa.dk/dummy/errorInXmlBeansValidation.xsd\" " +
+             "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
+             "xsi:schemaLocation=\"http://pfa.dk/dummy/errorInXmlBeansValidation.xsd \n"
+
+             "C:\\pfa\\techr3\\TransformationWorkbench\\schema\\errorInXmlBeansValidation.xsd\">
\n" +
+             "<myListEntry> \n" +
+             "<HelloWorld>Hello World</HelloWorld> \n" +
+             "</myListEntry> \n" +
+             "</aList> ";
+
+
+     }
+
+    /*
+    * [XMLBEANS-54]: problem with default value
+    *
+    */
+    public void test_jira_xmlbeans54() throws Exception {
+        List errors = new ArrayList();
+
+        SchemaCompiler.Parameters params = new SchemaCompiler.Parameters();
+        params.setXsdFiles(new File[]{new File(scompTestFilesRoot + "xmlbeans_54.xsd_")});
+        params.setErrorListener(errors);
+        params.setSrcDir(schemaCompSrcDir);
+        params.setClassesDir(schemaCompClassesDir);
+        params.setDownload(true);
+        params.setNoPvr(true);
+
+        // Runs out of Heap Memory
+        params.setMemoryMaximumSize("1024m");
+        params.setMemoryInitialSize("512m");
+
+        try {
+            SchemaCompiler.compile(params);
+        } catch (OutOfMemoryError ome) {
+            System.out.println(ome.getStackTrace());
+            System.out.println("test_jira_xmlbeans54() - out of Heap Memory");
+        }
+
+        if (printOptionErrMsgs(errors)) {
+            Assert.fail("test_jira_xmlbeans54() : Errors found when executing scomp");
+        }
+    }
+
+    /**
+     * [XMLBEANS-56] samples issue with easypo schema and config file
+     */
+    public void test_jira_XmlBeans56() throws Exception
+    {
+        String xsdConfig = "<xb:config " +
+                " xmlns:xb=\"http://xml.apache.org/xmlbeans/2004/02/xbean/config\"\n" +
+                "    xmlns:ep=\"http://openuri.org/easypo\">\n" +
+                "    <xb:namespace uri=\"http://openuri.org/easypo\">\n" +
+                "        <xb:package>com.easypo</xb:package>\n" +
+                "    </xb:namespace>\n" +
+                "    <xb:namespace uri=\"##any\">\n" +
+                "        <xb:prefix>Xml</xb:prefix>\n" +
+                "        <xb:suffix>Bean</xb:suffix>\n" +
+                "    </xb:namespace>\n" +
+                "    <xb:extension for=\"com.easypo.XmlCustomerBean\">\n" +
+                "        <xb:interface name=\"myPackage.Foo\">\n" +
+                "            <xb:staticHandler>myPackage.FooHandler</xb:staticHandler>\n"
+
+                "        </xb:interface>\n" +
+                "    </xb:extension>\n" +
+                "    <xb:qname name=\"ep:purchase-order\" javaname=\"purchaseOrderXXX\"/>\n"
+
+                "</xb:config> ";
+        ConfigDocument config =
+                ConfigDocument.Factory.parse(xsdConfig);
+        xmOpts.setErrorListener(errorList);
+        if (config.validate(xmOpts)) {
+            System.out.println("Config Validated");
+            return;
+        } else {
+            System.err.println("Config File did not validate");
+            for (Iterator iterator = errorList.iterator(); iterator.hasNext();) {
+                System.out.println("Error: " + iterator.next());
+            }
+            throw new Exception("Config File did not validate");
+        }
+
+    }
+
+    /**
+     * [XMLBEANS-57]   scomp failure for XSD namespace "DAV:"
+     */
+    public void test_jira_XmlBeans57() throws Exception
+    {
+        String P = File.separator;
+        String outputDir = fwroot + P + "build" +
+                P + "test" + P + "output" + P + "dav";
+
+        File srcDir = new File(outputDir + P + "src");
+        srcDir.mkdirs();
+        File classDir = new File(outputDir + P + "classes");
+        classDir.mkdirs();
+
+        SchemaCompiler.Parameters params = new SchemaCompiler.Parameters();
+        params.setXsdFiles(new File[]{new File(JIRA_CASES + "xmlbeans_57.xml")});
+        params.setErrorListener(errorList);
+        params.setSrcDir(srcDir);
+        params.setClassesDir(classDir);
+        SchemaCompiler.compile(params);
+        Collection errs = params.getErrorListener();
+        boolean outTextPresent = true;
+
+        if (errs.size() != 0) {
+            for (Iterator iterator = errs.iterator(); iterator.hasNext();) {
+                Object o = iterator.next();
+                String out = o.toString();
+                System.out.println("Dav: " + out);
+                if (out.startsWith("Compiled types to"))
+                    outTextPresent = false;
+            }
+        }
+
+        //cleanup gen'd dirs
+        srcDir.deleteOnExit();
+        classDir.deleteOnExit();
+
+        if (outTextPresent)
+            System.out.println("No errors when running schemacompiler with DAV namespace");
+        else
+            throw new Exception("There were errors while compiling XSD with DAV " +
+                    "namespace. See sys.out for more info");
+    }
+
+    /*
+    * [XMLBEANS-58]:resolving transitive <redefine>'d types...
+    * This is realted to xmlbeans36 - its the same case but the schemas seem to have been
updated at the w3c site.
+    * Hence adding a new testcase with the new schemas
+    */
+    public void test_jira_xmlbeans58() throws Exception {
+        List errors = new ArrayList();
+        SchemaCompiler.Parameters params = new SchemaCompiler.Parameters();
+
+        params.setUrlFiles(new URL[]{new URL("http://devresource.hp.com/drc/specifications/wsrf/interfaces/WS-BrokeredNotification-1-0.wsdl")});
+        params.setErrorListener(errors);
+        params.setSrcDir(schemaCompSrcDir);
+        params.setClassesDir(schemaCompClassesDir);
+        params.setDownload(true);
+
+        SchemaCompiler.compile(params);
+        if (printOptionErrMsgs(errors)) {
+            Assert.fail("test_jira_xmlbeans55() : Errors found when executing scomp");
+        }
+
+    }
+
+
+    /**
+     * [XMLBEANS-62]   Avoid class cast exception when compiling older schema namespace
+     */
+    public void test_jira_XmlBeans62() throws Exception
+    {
+        String P = File.separator;
+        String outputDir = System.getProperty("xbean.rootdir") + P + "build" +
+                P + "test" + P + "output" + P + "x1999";
+
+        File srcDir = new File(outputDir + P + "src");
+        srcDir.mkdirs();
+        File classDir = new File(outputDir + P + "classes");
+        classDir.mkdirs();
+
+        SchemaCompiler.Parameters params = new SchemaCompiler.Parameters();
+        params.setWsdlFiles(new File[]{new File(JIRA_CASES + "xmlbeans_62.xml")});
+        params.setErrorListener(errorList);
+        params.setSrcDir(srcDir);
+        params.setClassesDir(classDir);
+        SchemaCompiler.compile(params);
+        Collection errs = params.getErrorListener();
+        boolean warningPresent = false;
+        for (Iterator iterator = errs.iterator(); iterator.hasNext();) {
+            Object o = iterator.next();
+            String out = o.toString();
+            if (out.endsWith("did not have any schema documents in namespace 'http://www.w3.org/2001/XMLSchema'"))
;
+            warningPresent = true;
+        }
+
+        //cleanup gen'd dirs
+        srcDir.deleteOnExit();
+        classDir.deleteOnExit();
+
+        //validate error present
+        if (!warningPresent)
+            throw new Exception("Warning for 1999 schema was not found when compiling srcs");
+        else
+            System.out.println("Warning Present, test Passed");
+    }
+
+    /**
+     * [XMLBEANS-64] ArrayIndexOutOfBoundsException during validation
+     */
+    public void test_jira_XmlBeans64() throws Exception
+    {
+        // load the document
+        File inst = new File(JIRA_CASES + "xmlbeans_64.xml");
+        XmlObject doc = RecorderSessionDocument.Factory.parse(inst);
+        // validate
+        XmlOptions validateOptions = new XmlOptions();
+        validateOptions.setLoadLineNumbers();
+        ArrayList errorList = new ArrayList();
+        validateOptions.setErrorListener(errorList);
+        boolean isValid = doc.validate(validateOptions);
+
+        if (!isValid)
+            throw new Exception("Errors: " + errorList);
+    }
+
+    /**
+     * [XMLBEANS-66]   NullPointerException when restricting a union with one of the union
members
+     */
+    public void test_jira_XmlBeans66() throws Exception
+    {
+        String reproXsd = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n" +
+                "<xsd:schema targetNamespace=\"http://www.w3.org/2003/12/XQueryX\" \n"
+
+                "      xmlns=\"http://www.w3.org/2003/12/XQueryX\" \n" +
+                "      xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" \n" +
+                "      elementFormDefault=\"qualified\" \n" +
+                "      attributeFormDefault=\"qualified\"> \n" +
+                "  <!-- Kludge for anySimpleType --> \n" +
+                "  <xsd:simpleType name=\"constantValueType\"> \n" +
+                "    <xsd:union memberTypes=\"xsd:integer xsd:decimal xsd:string xsd:double\"/>
\n" +
+                "  </xsd:simpleType> \n" +
+                "  <!-- constant expressions. We have 4 different subclasses for this
--> \n" +
+                "  <xsd:complexType name=\"constantExpr\"> \n" +
+                "        <xsd:sequence> \n" +
+                "          <xsd:element name=\"value\" type=\"constantValueType\"/>
\n" +
+                "        </xsd:sequence> \n" +
+                "  </xsd:complexType> \n" +
+                "  <xsd:complexType name=\"integerConstantExpr\"> \n" +
+                "    <xsd:complexContent> \n" +
+                "      <xsd:restriction base=\"constantExpr\"> \n" +
+                "        <xsd:sequence> \n" +
+                "          <xsd:element name=\"value\" type=\"xsd:integer\"/> \n" +
+                "        </xsd:sequence> \n" +
+                "      </xsd:restriction> \n" +
+                "    </xsd:complexContent> \n" +
+                "  </xsd:complexType>" +
+                "<!-- added for element validation -->" +
+                "<xsd:element name=\"Kludge\" type=\"integerConstantExpr\" />\n" +
+                "</xsd:schema> ";
+
+        SchemaTypeLoader stl = makeSchemaTypeLoader(new String[]{reproXsd});
+        QName reproQName = new QName("http://www.w3.org/2003/12/XQueryX", "Kludge");
+        SchemaGlobalElement elVal = stl.findElement(reproQName);
+        Assert.assertTrue("Element is null or not found", (elVal != null));
+
+        String reproInst = "<Kludge xmlns=\"http://www.w3.org/2003/12/XQueryX\"><value>12</value></Kludge>";
+        validateInstance(new String[]{reproXsd}, new String[]{reproInst}, null);
+    }
+
+    /**
+     * [XMLBEANS-68] GDateBuilder outputs empty string when used without time or timezone
+     */
+    public void test_jira_XmlBeans68() throws Exception
+    {
+        Calendar cal = Calendar.getInstance();
+        GDateBuilder gdateBuilder = new GDateBuilder(cal);
+        gdateBuilder.clearTime();
+        gdateBuilder.clearTimeZone();
+        GDate gdate = gdateBuilder.toGDate();
+        TestDatewTZone xdate = TestDatewTZone.Factory.newInstance();
+        xdate.setGDateValue(gdate);
+        TestElementWithDateAttributeDocument doc =
+                TestElementWithDateAttributeDocument.Factory.newInstance();
+        TestElementWithDateAttributeDocument.TestElementWithDateAttribute root =
+                doc.addNewTestElementWithDateAttribute();
+
+        root.xsetSomeDate(xdate);
+        System.out.println("Doc: " + doc);
+        System.out.println("Date: " + xdate.getStringValue());
+
+        if (xdate.getStringValue().compareTo("") == 0 ||
+                xdate.getStringValue().length() <= 1)
+            throw new Exception("Date without TimeZone should not be empty");
+        if (root.getSomeDate().getTimeInMillis() != gdate.getCalendar().getTimeInMillis())
+            throw new Exception("Set Dates were not equal");
+    }
+
+    /**
+     * This issue needed an elementFormDefault=qualified added to the schema
+     * [XMLBEANS-71] when trying to retrieve data from a XMLBean with Input from a XML Document,
we cannot get any data from the Bean.
+     */
+    public void test_jira_XmlBeans71() throws Exception
+    {
+        //schema src lives in cases/xbean/xmlobject/xmlbeans_71.xsd
+        abc.BazResponseDocument doc = abc.BazResponseDocument.Factory.parse(JarUtil.getResourceFromJarasFile("xbean/misc/jira/xmlbeans_71.xml"),
xmOpts);
+        xmOpts.setErrorListener(errorList);
+        abc.BazResponseDocument.BazResponse baz = doc.getBazResponse();
+
+        if (!doc.validate(xmOpts))
+            System.out.println("DOC-ERRORS: " + errorList + "\n" + doc.xmlText());
+        else
+            System.out.println("DOC-XML:\n" + doc.xmlText());
+
+        errorList.removeAll(errorList);
+        xmOpts.setErrorListener(errorList);
+
+        if (!baz.validate(xmOpts))
+            System.out.println("BAZ-ERRORS: " + errorList + "\n" + baz.xmlText());
+        //throw new Exception("Response Document did not validate\n"+errorList);
+        else
+            System.out.println("BAZ-XML:\n" + baz.xmlText());
+
+        if (baz.getStatus().compareTo("SUCCESS") != 0)
+            throw new Exception("Status was not loaded properly");
+        else
+            System.out.println("Sucess was recieved correctly");
+    }
+
+
+    /**
+     * [XMLBEANS-72]   Document properties are lost
+     */
+    public void test_jira_XmlBeans72() throws Exception
+    {
+        String docTypeName = "struts-config";
+        String docTypePublicID = "-//Apache Software Foundation//DTD Struts Configuration
1.1//EN";
+        String docTypeSystemID = "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd";
+        String fileName = "xmlbeans72.xml";
+
+        //create instance and set doc properties
+        PurchaseOrderDocument po = PurchaseOrderDocument.Factory.newInstance();
+        org.apache.xmlbeans.XmlDocumentProperties docProps = po.documentProperties();
+        docProps.setDoctypeName(docTypeName);
+        docProps.setDoctypePublicId(docTypePublicID);
+        docProps.setDoctypeSystemId(docTypeSystemID);
+        po.addNewPurchaseOrder();
+        po.save(new File(fileName));
+
+        //parse saved out file and verify values set above are present
+        PurchaseOrderDocument po2 = PurchaseOrderDocument.Factory.parse(new File(fileName));
+        //XmlObject po2 = XmlObject.Factory.parse(new File(fileName));
+
+        org.apache.xmlbeans.XmlDocumentProperties doc2Props = po2.documentProperties();
+
+        //verify information using DOM
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        factory.setValidating(false);
+        factory.setNamespaceAware(true);
+        DocumentBuilder builder = factory.newDocumentBuilder();
+        Document document = builder.parse(new File(fileName));
+
+        DocumentType docType = document.getDoctype();
+
+        //System.out.println("Name: "+ doc2Props.getDoctypeName() +" = " + docType.getName());
+        //System.out.println("System: "+ doc2Props.getDoctypeSystemId() + " = " + docType.getSystemId());
+        //System.out.println("Public: "+ doc2Props.getDoctypePublicId()+ " = " + docType.getPublicId());
+
+        StringBuffer compareText = new StringBuffer();
+        //check values - compare to expected and DOM
+        if (doc2Props != null) {
+            if (doc2Props.getDoctypeName() == null ||
+                    doc2Props.getDoctypeName().compareTo(docTypeName) != 0 ||
+                    doc2Props.getDoctypeName().compareTo(docType.getName()) != 0)
+                compareText.append("docTypeName was not as " +
+                        "expected in the document properties " +
+                        doc2Props.getDoctypeName()+"\n");
+
+            if (doc2Props.getDoctypePublicId() == null ||
+                    doc2Props.getDoctypePublicId().compareTo(docTypePublicID) != 0 ||
+                    doc2Props.getDoctypePublicId().compareTo(docType.getPublicId()) != 0)
+                compareText.append("docTypePublicID was not as " +
+                        "expected in the document properties " +
+                        doc2Props.getDoctypePublicId()+"\n");
+
+            if (doc2Props.getDoctypeSystemId() == null ||
+                    doc2Props.getDoctypeSystemId().compareTo(docTypeSystemID) != 0 ||
+                    doc2Props.getDoctypeSystemId().compareTo(docType.getSystemId()) != 0)
+                compareText.append("docTypeSystemID was not as " +
+                        "expected in the document properties "+
+                        doc2Props.getDoctypeSystemId()+"\n" );
+        } else {
+            compareText.append("Document Properties were null, should have been set");
+        }
+
+        //cleanup
+        po2 = null;
+        po = null;
+        new File(fileName).deleteOnExit();
+
+        if (compareText.toString().length() > 1)
+            throw new Exception("Doc properties were not saved or read correctly\n" + compareText.toString());
+    }
+
+    /**
+     * BUGBUG: XMLBEANS-78 - NPE when processing XMLStreamReader Midstream
+     * XMLBEANS-78 - NPE when processing XMLStreamReader Midstream
+     *
+     * @throws Exception
+     */
+    public void test_jira_xmlbeans78() throws Exception
+    {
+        XMLInputFactory factory = XMLInputFactory.newInstance();
+        FileInputStream fis = new FileInputStream(new File(JIRA_CASES+ "xmlbeans_78.xml"));
+        XMLStreamReader reader = factory.createXMLStreamReader(fis);
+        skipToBody(reader);
+        XmlObject o = XmlObject.Factory.parse(reader);
+    }
+
+    /**
+     * Move reader to element of SOAP Body
+     *
+     * @param reader
+     * @throws javax.xml.stream.XMLStreamException
+     *
+     */
+    private void skipToBody(XMLStreamReader reader) throws javax.xml.stream.XMLStreamException
+    {
+        while (true) {
+            int event = reader.next();
+            switch (event) {
+                case XMLStreamReader.END_DOCUMENT:
+                    return;
+                case XMLStreamReader.START_ELEMENT:
+                    if (reader.getLocalName().equals("Body")) {
+                        return;
+                    }
+                    break;
+                default:
+                    break;
+            }
+        }
+    }
+
+    /**
+     * Repro case for jira issue
+     * XMLBEANS-80  problems in XPath selecting with namespaces and Predicates.
+     */
+    public void test_jira_xmlbeans80() throws Exception
+    {
+        String xpathDoc = "<?xml version=\"1.0\"?> \n" +
+                "<doc xmlns:ext=\"http://somebody.elses.extension\"> \n" +
+                "  <ext:a test=\"test\" /> \n" +
+                "  <b attr1=\"a1\" attr2=\"a2\" \n" +
+                "  xmlns:java=\"http://xml.apache.org/xslt/java\"> \n" +
+                "    <a> \n" +
+                "    </a> \n" +
+                "  </b> \n" +
+                "</doc> ";
+        XmlObject xb80 = XmlObject.Factory.parse(xpathDoc);
+        XmlObject[] resSet = xb80.selectPath("declare namespace " +
+                "ext='http://somebody.elses.extension'; $this//ext:a[@test='test']");
+
+        Assert.assertTrue(resSet.length == 1);
+        System.out.println("Result was: " + resSet[0].xmlText());
+    }
+
+    /**
+     * Repro case for jira issue
+     * XMLBEANS-81  Cursor selectPath() method not working with predicates
+     */
+    public void test_jira_xmlbeans81() throws Exception
+    {
+        String xpathDoc = "<MatchedRecords>" +
+                "  <MatchedRecord>" +
+                "     <TableName>" +
+                "ABC" +
+                "</TableName>" +
+                "  </MatchedRecord>" +
+                "  <MatchedRecord>" +
+                "     <TableName>\n" +
+                "       BCD \n" +
+                "     </TableName> \n" +
+                "  </MatchedRecord> \n" +
+                "</MatchedRecords> ";
+        XmlObject xb81 = XmlObject.Factory.parse(xpathDoc);
+        XmlObject[] resSet = xb81.selectPath("$this//MatchedRecord[TableName=\"ABC\"]/TableName");
+        assertEquals(resSet.length , 1);
+        XmlCursor cursor = xb81.newCursor();
+        cursor.selectPath("$this//MatchedRecord[TableName=\"ABC\"]/TableName");
+    }
+
+    /**
+     * XMLBeans-84 Cannot run XmlObject.selectPath using Jaxen in multi threaded environment
+     */
+    public void test_jira_XmlBeans84() throws Exception
+    {
+        XPathThread[] threads = new XPathThread[15];
+
+        for (int i = 0; i < threads.length; i++) {
+            threads[i] = new XPathThread();
+            System.out.println("Thread[" + i + "]-starting ");
+            threads[i].start();
+        }
+
+        Thread.sleep(6000);
+        System.out.println("Done with XPaths?...");
+
+        for (int i = 0; i < threads.length; i++) {
+            Assert.assertNull(threads[i].getException());
+        }
+
+    }
+
+    /*
+    * [XMLBEANS-88]:Cannot compile eBay schema
+    *
+    */
+    public void test_jira_xmlbeans88() throws Exception {
+        List errors = new ArrayList();
+        SchemaCompiler.Parameters params = new SchemaCompiler.Parameters();
+
+        params.setUrlFiles(new URL[]{new URL("http://developer.ebay.com/webservices/latest/eBaySvc.wsdl")});
+        params.setErrorListener(errors);
+        params.setSrcDir(schemaCompSrcDir);
+        params.setClassesDir(schemaCompClassesDir);
+        params.setDownload(true);
+
+        // ignore unique particle rule in order to compile this schema
+        params.setNoUpa(true);
+
+        // runs out of memory..
+        params.setMemoryMaximumSize("512m");
+
+        try {
+            SchemaCompiler.compile(params);
+        } catch (java.lang.OutOfMemoryError ome) {
+            System.out.println(ome.getCause());
+            System.out.println(ome.getMessage());
+            System.out.println(ome.getStackTrace());
+            Assert.fail("test_jira_xmlbeans88(): Out Of Memory Error");
+        } catch (Throwable t) {
+            t.getMessage();
+            System.out.println("Ok Some Exception is caught here");
+        }
+
+        if (printOptionErrMsgs(errors)) {
+            Assert.fail("test_jira_xmlbeans88() : Errors found when executing scomp");
+        }
+
+    }
+
+    /*
+    * [XMLBEANS-96]:XmlDocumentProperties missing version and encoding
+    *
+    */
+    public void test_jira_xmlbeans96() throws Exception {
+        StringBuffer xmlstringbuf = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"
?>");
+        xmlstringbuf.append("<test>");
+        xmlstringbuf.append("<testchild attr=\"abcd\"> Jira02 </testchild>");
+        xmlstringbuf.append("</test>");
+
+        XmlObject doc = XmlObject.Factory.parse(xmlstringbuf.toString());
+        XmlDocumentProperties props = doc.documentProperties();
+        Assert.assertEquals("test_jira_xmlbeans96() : Xml Version is not picked up", props.getVersion(),
"1.0");
+        Assert.assertEquals("test_jira_xmlbeans96() : Xml Encoding is not picked up", props.getEncoding(),
"UTF-8");
+
+    }
+
+
+
+    /**
+     * [XMLBEANS-98]   setSaveSuggestedPrefixes doesn't
+     * work for QName attribute values
+     *
+     * @throws Exception
+     */
+    public void test_jira_xmlbeans98() throws Exception {
+        String outfn = outputroot + "xmlbeans_98.xml";
+        String structnamespace = "http://www.orthogony.net/xml/sample/structure";
+        String datanamespace = "http://www.orthogony.net/xml/sample/data";
+        String schemaloc = "xmlbeans_98.xsd";
+        String xsinamespace = "http://www.w3.org/2001/XMLSchema-instance";
+
+        File out = new File(outfn);
+        XmlOptions options = new XmlOptions();
+
+        // associate namespaces with prefixes
+        Map prefixes = new HashMap();
+        prefixes.put(structnamespace, "s");
+        prefixes.put(datanamespace, "d");
+        prefixes.put(xsinamespace, "v");
+        options.setSaveSuggestedPrefixes(prefixes);
+        options.setSavePrettyPrint();
+
+        // create a sample document
+        ARootDocument doc = ARootDocument.Factory.newInstance();
+        ARootDocument.ARoot root = doc.addNewARoot();
+        ChildType child = root.addNewAChild();
+        // This is where the prefix map should take effect
+        child.setQualifiedData(new QName(datanamespace, "IAmQualified"));
+
+        // Add a schema location attribute to the doc element
+        XmlCursor c = root.newCursor();
+        c.toNextToken();
+        c.insertAttributeWithValue("schemaLocation", xsinamespace,
+                structnamespace + " " + schemaloc);
+
+        //String expXML = doc.xmlText(options.setSavePrettyPrint())
+        // save as XML text using the options
+        //System.out.println("OUT: \n"+doc.xmlText());
+        //doc.save(out, options);
+        doc.save(out, options);
+        XmlObject xObj = XmlObject.Factory.parse(out);
+
+        String expXText = "<s:a-root v:schemaLocation=\"http://www.orthogony.net/xml/sample/structure
xmlbeans_98.xsd\" xmlns:s=\"http://www.orthogony.net/xml/sample/structure\" xmlns:v=\"http://www.w3.org/2001/XMLSchema-instance\">\n"
+
+                "  <s:a-child qualified-data=\"data:IAmQualified\" xmlns:data=\"http://www.orthogony.net/xml/sample/data\"/>\n"
+
+                "</s:a-root>";
+        XmlObject txtXObj = XmlObject.Factory.parse(doc.xmlText());
+        System.out.println("xObj: " + xObj.xmlText());
+        //NamedNodeMap n = xObj.getDomNode().getAttributes();
+        //Assert.assertTrue("Length was not as expected", n.getLength() == 3);
+        Node no = xObj.getDomNode();//n.getNamedItem("a-root");
+        Assert.assertTrue("Expected Prefix was not present: " + no.getPrefix(), no.getPrefix().compareTo("s")
== 0);
+        //Assert.assertTrue("s prefix was not found " + no.lookupPrefix(structnamespace),
no.lookupPrefix(structnamespace).compareTo("s") == 0);
+        //Assert.assertTrue("d prefix was not found " + no.lookupPrefix(datanamespace), no.lookupPrefix(datanamespace).compareTo("s")
== 0);
+        //Assert.assertTrue("v prefix was not found " + no.lookupPrefix(xsinamespace), no.lookupPrefix(xsinamespace).compareTo("s")
== 0);
+
+
+        // throw new Exception(out.getCanonicalPath());
+
+    }
+
+    /**
+     * [XMLBEANS-99]   NPE/AssertionFailure in newDomNode()
+     *
+     * @throws Exception
+     */
+    public void test_jira_xmlbeans99_a() throws Exception {
+        //typed verification
+        DummyDocument doc = DummyDocument.Factory.parse(new File(JIRA_CASES + "xmlbeans_99.xml"));
+        org.w3c.dom.Node node = doc.newDomNode();
+        System.out.println("node = " + node);
+        //UnTyped Verification
+        XmlObject xObj = XmlObject.Factory.parse(new File(JIRA_CASES +
+                "xmlbeans_99.xml"));
+        org.w3c.dom.Node xNode = xObj.newDomNode();
+        System.out.println("xNode: " + xNode);
+    }
+
+    /*
+    * [XMLBEANS-99]: NPE/AssertionFailure in newDomNode()
+    * refer to [XMLBEANS-14]
+    */
+    public void test_jira_xmlbeans99_b() throws Exception {
+        StringBuffer xmlstringbuf = new StringBuffer("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"
?> \n");
+        xmlstringbuf.append("                <x:dummy xmlns:x=\"http://dufourrault\" xmlns:xsi=\"http://www.w3.org/2000/10/XMLSchema-instance\"
xsi:SchemaLocation=\"dummy.xsd\">\n");
+        xmlstringbuf.append("                    <x:father>\n");
+        xmlstringbuf.append("                     <x:son>toto</x:son> \n");
+        xmlstringbuf.append("                    </x:father>\n");
+        xmlstringbuf.append("              </x:dummy>");
+
+        try {
+            DummyDocument doc = DummyDocument.Factory.parse(xmlstringbuf.toString());
+            //Node node = doc.getDummy().getFather().newDomNode();
+            Node node = doc.newDomNode();
+            System.out.println("node = " + node);
+        } catch (NullPointerException npe) {
+            Assert.fail("test_jira_xmlbeans99() : Null Pointer Exception when create Dom
Node");
+        } catch (Exception e) {
+            Assert.fail("test_jira_xmlbeans99() : Exception when create Dom Node");
+        }
+    }
+
+
+
+
+
+}
+

Added: xmlbeans/trunk/test/src/misc/detailed/JiraRegressionTest101_150.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/misc/detailed/JiraRegressionTest101_150.java?view=auto&rev=156710
==============================================================================
--- xmlbeans/trunk/test/src/misc/detailed/JiraRegressionTest101_150.java (added)
+++ xmlbeans/trunk/test/src/misc/detailed/JiraRegressionTest101_150.java Wed Mar  9 15:20:56
2005
@@ -0,0 +1,99 @@
+package misc.detailed;
+
+import junit.framework.Assert;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.io.File;
+
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlError;
+import org.apache.xmlbeans.impl.tool.SchemaCompiler;
+import misc.common.JiraTestBase;
+
+/**
+ *
+ */
+public class JiraRegressionTest101_150 extends JiraTestBase
+{
+    public JiraRegressionTest101_150(String name)
+    {
+        super(name);
+    }
+
+    /**
+     * [XMLBEANS-103]   XMLBeans - QName thread cache, cause memory leaks
+     * @throws Exception
+     */
+    public void test_jira_xmlbeans102a() throws Exception{
+        // set the parameters similar to those in the bug
+        SchemaCompiler.Parameters params = new SchemaCompiler.Parameters();
+        params.setXsdFiles(new File[]{new File(JIRA_CASES + "xmlbeans_102.xsd")});
+        params.setOutputJar(new File(outputroot+P+"xmlbeans_102.jar"));
+        File outputDir = new File(outputroot + P + "xmlbeans_102");
+        outputDir.mkdirs();
+        params.setClassesDir(outputDir);
+        params.setSrcDir(outputDir);
+        // compile schema
+        SchemaCompiler.compile(params);
+        // check for jar - compilation success
+        if(!(new File(outputroot + P + "xmlbeans_102.jar").exists()) )
+            throw new Exception("Jar File was not found");
+        //cleanup
+        deltree(outputroot);
+    }
+
+    /*
+    * [XMLBEANS-102]: scomp - infinite loop during jar for specific xsd and params for netui_config.xsd
+    *
+    */
+    public void test_jira_xmlbeans102b() {
+        //Assert.fail("test_jira_xmlbeans102: Infinite loop after completion of parsing"
);
+
+        SchemaCompiler.Parameters params = new SchemaCompiler.Parameters();
+        params.setOutputJar(new File(schemaCompOutputDirPath + "jira102.jar"));
+        params.setClassesDir(schemaCompClassesDir);
+
+        params.setXsdFiles(new File[]{new File(scompTestFilesRoot + "xmlbeans_102_netui-config.xsd_")});
+        List errors = new ArrayList();
+        params.setErrorListener(errors);
+        params.setSrcDir(schemaCompSrcDir);
+        params.setClassesDir(schemaCompClassesDir);
+
+        SchemaCompiler.compile(params);
+        if (printOptionErrMsgs(errors)) {
+            Assert.fail("test_jira_xmlbeans102() : Errors found when executing scomp");
+        }
+
+    }
+
+    /**
+     * NPE while initializing a type system w/ a type that extends
+     * an a complex type from a different type system
+     *
+     * @throws Exception
+     */
+    public void test_jira_xmlbeans105() throws Exception {
+        //run untyped parse
+        XmlObject obj = XmlObject.Factory.parse(new File(JIRA_CASES + "xmlbeans_105.xml"));
+
+        //run Typed Parse
+        jira.xmlbeans105.ResourceUnknownFaultDocument rud =
+                jira.xmlbeans105.ResourceUnknownFaultDocument.Factory.parse(new File(JIRA_CASES
+ "xmlbeans_105.xml"));
+
+        // / we know the instance is invalid
+        // make sure the error message is what is expected
+        rud.validate(xmOpts);
+        Assert.assertTrue("More Errors than expected", errorList.size() == 1);
+        Assert.assertTrue("Did not recieve the expected error code: " + ((XmlError) errorList.get(0)).getErrorCode(),
+                ((XmlError) errorList.get(0)).getErrorCode().compareToIgnoreCase("cvc-complex-type.2.4a")
== 0);
+
+    }
+
+
+
+
+
+
+
+}

Modified: xmlbeans/trunk/test/src/misc/detailed/SampleRunner.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/misc/detailed/SampleRunner.java?view=diff&r1=156709&r2=156710
==============================================================================
--- xmlbeans/trunk/test/src/misc/detailed/SampleRunner.java (original)
+++ xmlbeans/trunk/test/src/misc/detailed/SampleRunner.java Wed Mar  9 15:20:56 2005
@@ -41,7 +41,7 @@
         proj.setName("Samples Task Tests");
         XMLBEANS_HOME = proj.getBaseDir().getAbsolutePath();
         samples = new ArrayList();
-        runSampleTest = new SamplesBuildFileTest("S2J Ant Task Wrapper");
+        runSampleTest = new SamplesBuildFileTest("Sample Ant Task Wrapper");
     }
 
     public void testSamples()



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org


Mime
View raw message