You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by ce...@apache.org on 2005/01/27 22:52:38 UTC
svn commit: r128430 - in xmlbeans/trunk: . test/cases/xbean/compile/scomp/detailed test/cases/xbean/misc test/cases/xbean/xmlobject test/src/compile/scomp/checkin test/src/compile/scomp/common test/src/compile/scomp/common/mockobj test/src/compile/scomp/detailed test/src/compile/scomp/incr/schemaCompile/detailed test/src/dom/detailed test/src/misc/detailed test/src/xmlcursor/checkin test/src/xmlcursor/common test/src/xmlcursor/detailed test/src/xmlcursor/jsr173/common test/src/xmlobject/detailed test/tools/lib/xsl
Author: cezar
Date: Thu Jan 27 13:52:38 2005
New Revision: 128430
URL: http://svn.apache.org/viewcvs?view=rev&rev=128430
Log:
Contributed by: Jacob Danner - addition of tests for misc components including, schema compiler entry point, substitution groups, etc. Clean up of some test cases and moving of cases for modular build later
Added:
xmlbeans/trunk/test/cases/xbean/compile/scomp/detailed/
xmlbeans/trunk/test/cases/xbean/compile/scomp/detailed/laxDoc.xsd
xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_45a.xsd
- copied unchanged from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_45a.xsd
xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_45b.xsd
- copied unchanged from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_45b.xsd
xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_46.xsd
- copied unchanged from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_46.xsd
xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_48.xsd
- copied unchanged from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_48.xsd
xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_48b.xsd
- copied unchanged from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_48b.xsd
xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_57.xml
- copied unchanged from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_57.xml
xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_62.xml
- copied unchanged from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_62.xml
xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_64.xml
- copied unchanged from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_64.xml
xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_64.xsd
- copied unchanged from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_64.xsd
xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_68.xsd
- copied unchanged from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_68.xsd
xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_71.xml
- copied unchanged from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_71.xml
xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_71.xsd
- copied unchanged from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_71.xsd
xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_78.xml
xmlbeans/trunk/test/cases/xbean/xmlobject/substgroup2.xsd
xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java
xmlbeans/trunk/test/src/compile/scomp/common/mockobj/
xmlbeans/trunk/test/src/compile/scomp/common/mockobj/TestBindingConfig.java
xmlbeans/trunk/test/src/compile/scomp/common/mockobj/TestFiler.java
xmlbeans/trunk/test/src/compile/scomp/detailed/
xmlbeans/trunk/test/src/compile/scomp/detailed/DetailedCompTests.java
xmlbeans/trunk/test/src/compile/scomp/detailed/XmlBeanCompilationTests.java
xmlbeans/trunk/test/src/xmlobject/detailed/SubstGroupTests.java
Removed:
xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_45a.xsd
xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_45b.xsd
xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_46.xsd
xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_48.xsd
xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_48b.xsd
xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_57.xml
xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_62.xml
xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_64.xml
xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_64.xsd
xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_68.xsd
xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_71.xml
xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_71.xsd
Modified:
xmlbeans/trunk/test/src/compile/scomp/common/CompileCommon.java
xmlbeans/trunk/test/src/compile/scomp/common/CompileTestBase.java
xmlbeans/trunk/test/src/compile/scomp/incr/schemaCompile/detailed/IncrCompilationTests.java
xmlbeans/trunk/test/src/compile/scomp/incr/schemaCompile/detailed/ModelGroupTests.java
xmlbeans/trunk/test/src/compile/scomp/incr/schemaCompile/detailed/PerfTests.java
xmlbeans/trunk/test/src/dom/detailed/MultipleDocsTest.java
xmlbeans/trunk/test/src/misc/detailed/JiraRegressionsTest.java
xmlbeans/trunk/test/src/xmlcursor/checkin/AddToSelectionTest.java
xmlbeans/trunk/test/src/xmlcursor/common/BasicCursorTestCase.java
xmlbeans/trunk/test/src/xmlcursor/detailed/MoveXmlTest2.java
xmlbeans/trunk/test/src/xmlcursor/jsr173/common/AttributeTest.java
xmlbeans/trunk/test/src/xmlcursor/jsr173/common/CharactersTest.java
xmlbeans/trunk/test/src/xmlcursor/jsr173/common/ElementTest.java
xmlbeans/trunk/test/src/xmlcursor/jsr173/common/GeneralMethodsTest.java
xmlbeans/trunk/test/src/xmlcursor/jsr173/common/IsXXXTest.java
xmlbeans/trunk/test/src/xmlcursor/jsr173/common/NamespaceTest.java
xmlbeans/trunk/test/src/xmlcursor/jsr173/common/PITest.java
xmlbeans/trunk/test/src/xmlobject/detailed/TestsFromBugs.java
xmlbeans/trunk/test/tools/lib/xsl/TestReport.xsl
xmlbeans/trunk/testbuild.xml
Added: xmlbeans/trunk/test/cases/xbean/compile/scomp/detailed/laxDoc.xsd
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/compile/scomp/detailed/laxDoc.xsd?view=auto&rev=128430
==============================================================================
--- (empty file)
+++ xmlbeans/trunk/test/cases/xbean/compile/scomp/detailed/laxDoc.xsd Thu Jan 27 13:52:38 2005
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:lax.Doc.Compilation"
+ xmlns:tns="urn:lax.Doc.Compilation"
+ xmlns:pre="noResolutionNamespace"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified">
+
+ <xs:element name="ItemRequest" type="tns:ItemRequestType"/>
+ <xs:complexType name="ItemRequestType">
+ <xs:annotation>
+ <xs:documentation>
+ Ensure that XML content is allowed and not validated when the novdoc option is set
+ provided content is XHTML compliant and no elements use the schema namespaces
+
+ <tns:ItemRequest>
+ foobaz
+ </tns:ItemRequest>
+ <xs:complexType name="foobar">
+ <xs:sequence>
+ <xs:element name="foobaz" type="pre:String"/>
+ </xs:sequence>
+ </xs:complexType>
+ provided content is XHTML compliant and no elements use the schema namespaces
+ </xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="foobaz" type="xs:string">
+ <xs:annotation>
+ <xs:documentation>
+ Ensure that XML content is allowed and not validated when the novdoc option is set
+ provided content is XHTML compliant and no elements use the schema namespaces
+
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="baz" use="required"/>
+ </xs:complexType>
+</xs:schema>
+
+
Copied: xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_45a.xsd (from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_45a.xsd)
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_45a.xsd?view=diff&rev=128430&p1=xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_45a.xsd&r1=122659&p2=xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_45a.xsd&r2=128430
==============================================================================
Copied: xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_45b.xsd (from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_45b.xsd)
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_45b.xsd?view=diff&rev=128430&p1=xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_45b.xsd&r1=122659&p2=xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_45b.xsd&r2=128430
==============================================================================
Copied: xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_46.xsd (from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_46.xsd)
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_46.xsd?view=diff&rev=128430&p1=xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_46.xsd&r1=122659&p2=xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_46.xsd&r2=128430
==============================================================================
Copied: xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_48.xsd (from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_48.xsd)
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_48.xsd?view=diff&rev=128430&p1=xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_48.xsd&r1=122659&p2=xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_48.xsd&r2=128430
==============================================================================
Copied: xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_48b.xsd (from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_48b.xsd)
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_48b.xsd?view=diff&rev=128430&p1=xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_48b.xsd&r1=122659&p2=xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_48b.xsd&r2=128430
==============================================================================
Copied: xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_57.xml (from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_57.xml)
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_57.xml?view=diff&rev=128430&p1=xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_57.xml&r1=122659&p2=xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_57.xml&r2=128430
==============================================================================
Copied: xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_62.xml (from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_62.xml)
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_62.xml?view=diff&rev=128430&p1=xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_62.xml&r1=122659&p2=xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_62.xml&r2=128430
==============================================================================
Copied: xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_64.xml (from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_64.xml)
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_64.xml?view=diff&rev=128430&p1=xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_64.xml&r1=122659&p2=xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_64.xml&r2=128430
==============================================================================
Copied: xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_64.xsd (from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_64.xsd)
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_64.xsd?view=diff&rev=128430&p1=xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_64.xsd&r1=122659&p2=xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_64.xsd&r2=128430
==============================================================================
Copied: xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_68.xsd (from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_68.xsd)
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_68.xsd?view=diff&rev=128430&p1=xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_68.xsd&r1=122659&p2=xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_68.xsd&r2=128430
==============================================================================
Copied: xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_71.xml (from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_71.xml)
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_71.xml?view=diff&rev=128430&p1=xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_71.xml&r1=122659&p2=xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_71.xml&r2=128430
==============================================================================
Copied: xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_71.xsd (from r122659, xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_71.xsd)
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_71.xsd?view=diff&rev=128430&p1=xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_71.xsd&r1=122659&p2=xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_71.xsd&r2=128430
==============================================================================
Added: xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_78.xml
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_78.xml?view=auto&rev=128430
==============================================================================
--- (empty file)
+++ xmlbeans/trunk/test/cases/xbean/misc/xmlbeans_78.xml Thu Jan 27 13:52:38 2005
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<SOAP-ENV:Envelope
+ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <SOAP-ENV:Body>
+ <ItemLookupResponse xmlns="http://foobaz.com/">
+ <OperationRequest>
+ <HTTPHeaders>
+ <Header Name="UserAgent" Value="XFire Client +http://xfire.codehaus.org"/>
+ </HTTPHeaders>
+ <RequestId>123456</RequestId>
+ <Arguments>
+ <Argument Name="Service" Value="AWSECommerceService"/>
+ </Arguments>
+ <RequestProcessingTime>1234</RequestProcessingTime>
+ </OperationRequest>
+ <Items>
+ <Request>
+ <IsValid>True</IsValid>
+ <ItemLookupRequest>
+ <IdType>xyz</IdType>
+ <ItemId>123</ItemId>
+ </ItemLookupRequest>
+ </Request>
+ <Item>
+ <ASIN>123</ASIN>
+ <DetailPageURL>http://xmlbeans.apache.org</DetailPageURL>
+ <ItemAttributes>
+ <Author>Apache</Author>
+ <Author>xmlbeans</Author>
+ <ProductGroup>Book</ProductGroup>
+ <Title>XmlBeans Apache Org</Title>
+ </ItemAttributes>
+ </Item>
+ </Items>
+ </ItemLookupResponse>
+ </SOAP-ENV:Body>
+</SOAP-ENV:Envelope>
\ No newline at end of file
Added: xmlbeans/trunk/test/cases/xbean/xmlobject/substgroup2.xsd
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/xmlobject/substgroup2.xsd?view=auto&rev=128430
==============================================================================
--- (empty file)
+++ xmlbeans/trunk/test/cases/xbean/xmlobject/substgroup2.xsd Thu Jan 27 13:52:38 2005
@@ -0,0 +1,72 @@
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://xmlobject/substgroup"
+ xmlns:tns="http://xmlobject/substgroup">
+
+ <xsd:complexType name="OrderItem">
+ <xsd:sequence>
+ <xsd:element ref="tns:item"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+
+
+ <xsd:element name="item" type="tns:ItemType"/>
+ <xsd:complexType name="ItemType">
+ <xsd:sequence>
+ <xsd:element name="sku" type="xsd:integer"/>
+ <xsd:element name="name" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="beanBag" type="tns:BeanBagType"
+ substitutionGroup="tns:item"/>
+ <xsd:complexType name="BeanBagType">
+ <xsd:complexContent>
+ <xsd:extension base="tns:ItemType">
+ <xsd:sequence>
+ <xsd:element name="size" type="tns:BeanBagSizeType"/>
+ </xsd:sequence>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+
+ <xsd:element name="chair" substitutionGroup="tns:item"/>
+ <xsd:element name="blockedchair" type="tns:ItemType" block="substitution"/>
+ <xsd:element name="blockedItem" substitutionGroup="tns:blockedchair" />
+
+ <xsd:element name="notachair" type="tns:ItemType"/>
+ <xsd:element name="footstool" type="xsd:string"/>
+
+ <xsd:complexType name="BeanBagSizeType">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute name="color" type="xsd:token"/>
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+
+ <xs:element name="string" type="xs:string"/>
+ <xs:element name="stringSub" substitutionGroup="tns:string"/>
+ <xs:complexType name="info">
+ <xs:sequence>
+ <xs:element ref="tns:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="customer" type="tns:info"/>
+ <xs:element name="employee" substitutionGroup="tns:customer"/>
+
+
+ <xs:element name="blockedString" type="xs:string" block="substitution"/>
+ <xs:element name="blockedStringSub" substitutionGroup="tns:blockedString"/>
+ <xs:complexType name="blockedInfo">
+ <xs:sequence>
+ <xs:element ref="tns:blockedString"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="blockedCustomer" type="tns:blockedInfo" block="substitution"/>
+ <xs:element name="blockedEmployee" substitutionGroup="tns:blockedCustomer"/>
+
+</xsd:schema>
+
Deleted: /xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_45a.xsd
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_45a.xsd?view=auto&rev=128429
==============================================================================
Deleted: /xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_45b.xsd
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_45b.xsd?view=auto&rev=128429
==============================================================================
Deleted: /xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_46.xsd
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_46.xsd?view=auto&rev=128429
==============================================================================
Deleted: /xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_48.xsd
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_48.xsd?view=auto&rev=128429
==============================================================================
Deleted: /xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_48b.xsd
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_48b.xsd?view=auto&rev=128429
==============================================================================
Deleted: /xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_57.xml
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_57.xml?view=auto&rev=128429
==============================================================================
Deleted: /xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_62.xml
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_62.xml?view=auto&rev=128429
==============================================================================
Deleted: /xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_64.xml
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_64.xml?view=auto&rev=128429
==============================================================================
Deleted: /xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_64.xsd
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_64.xsd?view=auto&rev=128429
==============================================================================
Deleted: /xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_68.xsd
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_68.xsd?view=auto&rev=128429
==============================================================================
Deleted: /xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_71.xml
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_71.xml?view=auto&rev=128429
==============================================================================
Deleted: /xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_71.xsd
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/xmlobject/xmlbeans_71.xsd?view=auto&rev=128429
==============================================================================
Added: xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java?view=auto&rev=128430
==============================================================================
--- (empty file)
+++ xmlbeans/trunk/test/src/compile/scomp/checkin/XmlBeansCompCheckinTests.java Thu Jan 27 13:52:38 2005
@@ -0,0 +1,293 @@
+package compile.scomp.checkin;
+
+import org.apache.xmlbeans.*;
+import compile.scomp.common.mockobj.TestFiler;
+import compile.scomp.common.CompileCommon;
+import compile.scomp.common.CompileTestBase;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Vector;
+import java.util.List;
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.Assert;
+
+/**
+ * @author jacobd
+ * Date: Jan 21, 2005
+ */
+public class XmlBeansCompCheckinTests extends CompileTestBase
+{ String P = File.separator;
+ public List xm_errors;
+ public XmlOptions xm_opts;
+ Vector expBinType;
+ Vector expSrcType;
+
+ public XmlBeansCompCheckinTests(String name)
+ {
+ super(name);
+ expBinType = new Vector();
+ expBinType.add("schema/system/apiCompile/atypedb57type.xsb");
+ expBinType.add("schema/system/apiCompile/elname429edoctype.xsb");
+ expBinType.add("schema/system/apiCompile/elnameelement.xsb");
+ expBinType.add("schema/system/apiCompile/index.xsb");
+ expBinType.add("schema/element/http_3A_2F_2Fbaz/elName.xsb");
+ expBinType.add("schema/type/http_3A_2F_2Fbaz/aType.xsb");
+ expBinType.add("schema/namespace/http_3A_2F_2Fbaz/xmlns.xsb");
+ expBinType.add("schema/javaname/baz/ElNameDocument.xsb");
+ expBinType.add("schema/javaname/baz/AType.xsb");
+ expBinType.add("schema/system/apiCompile/TypeSystemHolder.class");
+
+ expSrcType = new Vector();
+ expSrcType.add("baz.AType");
+ expSrcType.add("baz.impl.ATypeImpl");
+ expSrcType.add("baz.ElNameDocument");
+ expSrcType.add("baz.impl.ElNameDocumentImpl");
+
+ xm_errors = new ArrayList();
+ xm_opts = new XmlOptions();
+ xm_opts.setErrorListener(xm_errors);
+ xm_opts.setSavePrettyPrint();
+ }
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ if (xm_errors.size() > 0)
+ xm_errors.clear();
+ }
+
+ public void test_Filer_compilation() throws Exception
+ {
+ XmlObject obj1 = XmlObject.Factory.parse(forXsd);
+ XmlObject[] schemas = new XmlObject[]{obj1};
+
+ TestFiler f = new TestFiler();//FilerImpl(fClass, fSrc, repackage, true, false);
+ SchemaTypeSystem apiSts = XmlBeans.compileXmlBeans("apiCompile", null,
+ schemas, null, XmlBeans.getBuiltinTypeSystem(), f, xm_opts);
+
+
+ for (int i = 0; i < apiSts.globalElements().length; i++) {
+ System.out.println("El-" + apiSts.globalElements()[i].getName());
+ }
+ for (int i = 0; i < apiSts.globalTypes().length; i++) {
+ System.out.println("Type-" + apiSts.globalTypes()[i].getBaseType());
+ }
+
+ //apiSts = XmlBeans.compileXmlBeans("apiCompile", null,
+ // schemas, null, XmlBeans.getBuiltinTypeSystem(), f, xm_opts);
+
+ if (!f.isCreateBinaryFile())
+ throw new Exception("Binary File method not invoked");
+ if (!f.isCreateSourceFile())
+ throw new Exception("Source File method not invoked");
+
+ System.out.println("BIN");
+ CompileCommon.comparefNameVectors(f.getBinFileVec(), expBinType);
+ System.out.println("SRC");
+ CompileCommon.comparefNameVectors(f.getSrcFileVec(), expSrcType);
+
+ }
+
+ /**
+ * Verify Partial SOM cannot be saved to file system
+ *
+ * @throws Exception
+ */
+ public void test_sts_noSave() throws Exception
+ {
+ XmlObject obj1 = XmlObject.Factory.parse(forXsd);
+ XmlObject[] schemas = new XmlObject[]{obj1};
+ XmlObject obj2 = XmlObject.Factory.parse(incrXsd);
+ XmlObject[] schemas2 = new XmlObject[]{obj2};
+ XmlObject obj3 = XmlObject.Factory.parse(errXsd);
+ XmlObject[] schemas3 = new XmlObject[]{obj3};
+
+ SchemaTypeSystem sts;
+ TestFiler f = new TestFiler();
+ ArrayList err = new ArrayList();
+ XmlOptions opt = new XmlOptions().setErrorListener(err);
+ opt.put("COMPILE_PARTIAL_TYPESYSTEM");
+
+ try {
+ // since you can't save a partial SOM, don't bother passing in a Filer
+ sts = XmlBeans.compileXmlBeans(null,
+ null, schemas3, null,
+ XmlBeans.getBuiltinTypeSystem(), null, opt);
+ boolean psom_expError = false;
+ // print out the recovered xm_errors
+ if (!err.isEmpty()) {
+ System.out.println("Schema invalid: partial schema type system recovered");
+ for (Iterator i = err.iterator(); i.hasNext();) {
+ XmlError xErr = (XmlError) i.next();
+ System.out.println(xErr);
+
+ if ((xErr.getErrorCode().compareTo("src-resolve") == 0) &&
+ (xErr.getMessage().compareTo("type 'aType@http://baz' not found.") ==
+ 0))
+ psom_expError = true;
+ }
+ }
+ if (!psom_expError)
+ throw new Exception("Error Code was not as Expected");
+
+ } catch (XmlException e) {
+ //The above case should be recoverable so
+ // spit out debug statement and throw the error
+ System.out.println("Schema invalid: couldn't recover from xm_errors");
+ if (err.isEmpty())
+ System.err.println(e.getMessage());
+ else
+ for (Iterator i = err.iterator(); i.hasNext();)
+ System.err.println(i.next());
+ throw e;
+ }
+
+
+ //call some stupid methods on STS
+ printSTS(sts);
+
+ // Check using saveToDirectory on Partial SOM
+ try {
+ //setUp outputDirectory
+ File tempDir = new File(CompileCommon.outputroot, "psom_save");
+ tempDir.mkdirs();
+ tempDir.deleteOnExit();
+ Assert.assertTrue("Output Directory Init needed to be empty",
+ tempDir.listFiles().length == 0);
+
+ //This should not Work
+ sts.saveToDirectory(tempDir);
+ tempDir.exists();
+ //make sure nothing was written
+ Assert.assertTrue("Partial SOM output dir needed to be empty",
+ tempDir.listFiles().length == 0);
+
+ } catch (Exception e) {
+ throw e;
+ }
+
+ // Check using save(Filer) on Partial SOM
+ try {
+ //setUp outputDirectory
+ TestFiler tf = new TestFiler();
+ Assert.assertTrue("Filer Source should have been size 0",
+ tf.getBinFileVec().size() == 0);
+
+ //This should not Work
+ sts.save(tf);
+ //make sure nothing was written
+ Assert.assertTrue("Filer -Bin- Partial SOM " +
+ "output dir needed to be empty",
+ tf.getBinFileVec().size() == 0);
+ Assert.assertTrue("Filer -SRC- Partial SOM " +
+ "output dir needed to be empty",
+ tf.getSrcFileVec().size() == 0);
+
+ Assert.assertFalse("Filer Create Source File " +
+ "method should not have been invoked",
+ tf.isCreateSourceFile());
+
+ Assert.assertFalse("Filer Create Binary File " +
+ "method should not have been invoked",
+ tf.isCreateBinaryFile());
+ } catch (Exception e) {
+ throw e;
+ }
+
+ // Check using filer in partial SOM compilation
+ try {
+ TestFiler tf = new TestFiler();
+
+ Assert.assertTrue("Filer Source should have been size 0",
+ tf.getBinFileVec().size() == 0);
+
+ //reset data
+ sts = null;
+ err.clear();
+
+ //filer methods on partial SOM should not be returned
+ sts = XmlBeans.compileXmlBeans(null,
+ null, schemas3, null,
+ XmlBeans.getBuiltinTypeSystem(), tf, opt);
+
+ Assert.assertTrue("Errors was not empty", !err.isEmpty());
+ //make sure nothing was written
+ Assert.assertTrue("Filer -Bin- Partial SOM " +
+ "output dir needed to be empty",
+ tf.getBinFileVec().size() == 0);
+ Assert.assertTrue("Filer -SRC- Partial SOM " +
+ "output dir needed to be empty",
+ tf.getSrcFileVec().size() == 0);
+
+ Assert.assertFalse("Filer Create Source File " +
+ "method should not have been invoked",
+ tf.isCreateSourceFile());
+
+ Assert.assertFalse("Filer Create Binary File " +
+ "method should not have been invoked",
+ tf.isCreateBinaryFile());
+ } catch (Exception e) {
+ throw e;
+ }
+
+
+ System.out.println("Save Verification passed");
+
+ }
+
+ /**
+ * ensure that entry point properly handles
+ * different configs with null values
+ */
+ public void test_entrypoint_nullVals() throws Exception
+ {
+ XmlObject obj1 = XmlObject.Factory.parse(forXsd);
+ XmlObject[] schemas = new XmlObject[]{obj1};
+
+ TestFiler f = new TestFiler();
+
+ SchemaTypeSystem apiSts = XmlBeans.compileXmlBeans(null, null,
+ schemas, null, XmlBeans.getBuiltinTypeSystem(), null, null);
+ System.out.println("Name: " + apiSts.getName());
+ printSTS(apiSts);
+
+ apiSts = XmlBeans.compileXmlBeans(null, null,
+ null, null, XmlBeans.getBuiltinTypeSystem(), null, null);
+ printSTS(apiSts);
+
+ boolean iArgExThrown = false;
+ try {
+ apiSts = XmlBeans.compileXmlBeans(null, null,
+ null, null, null, null, null);
+ printSTS(apiSts);
+
+ } catch (IllegalArgumentException iaEx) {
+ iArgExThrown = true;
+ System.err.println(iaEx.getMessage());
+ }
+
+ if (!iArgExThrown)
+ throw new Exception("All null values did not throw Illegal " +
+ "Argument Exception");
+
+ iArgExThrown = false;
+ try {
+ apiSts = XmlBeans.compileXmlBeans(null, null,
+ schemas, null, null, null, null);
+ printSTS(apiSts);
+ } catch (IllegalArgumentException iaEx) {
+ iArgExThrown = true;
+ System.err.println(iaEx.getMessage());
+ }
+
+ if (!iArgExThrown)
+ throw new Exception("XSD[] and null values did not throw Illegal " +
+ "Argument Exception");
+
+ }
+
+}
Modified: xmlbeans/trunk/test/src/compile/scomp/common/CompileCommon.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/compile/scomp/common/CompileCommon.java?view=diff&rev=128430&p1=xmlbeans/trunk/test/src/compile/scomp/common/CompileCommon.java&r1=128429&p2=xmlbeans/trunk/test/src/compile/scomp/common/CompileCommon.java&r2=128430
==============================================================================
--- xmlbeans/trunk/test/src/compile/scomp/common/CompileCommon.java (original)
+++ xmlbeans/trunk/test/src/compile/scomp/common/CompileCommon.java Thu Jan 27 13:52:38 2005
@@ -19,6 +19,7 @@
import java.io.File;
import java.io.IOException;
import java.util.List;
+import java.util.Vector;
/**
* @author jacobd
@@ -28,22 +29,30 @@
public static final String P = File.separator;
- public static File fwroot = getRootFile();
- public static File caseroot = new File(fwroot, "test" + P + "cases");
+ public static String fwroot = getRootFile();
+ public static String caseroot = fwroot +P+"test" + P + "cases";
//location of files under "cases folder"
- public static String fileLocation = P + "xbean" + P + "compile" + P + "scomp" + P;
+ public static String fileLocation = caseroot+P + "xbean" + P + "compile" + P + "scomp" + P;
public static File outputroot = new File(fwroot, "build" + P + "test" + P + "output");
- public static File getRootFile() throws IllegalStateException {
- try {
- return new File(System.getProperty("xbean.rootdir")).getCanonicalFile();
- } catch (IOException e) {
- throw new IllegalStateException(e.toString());
- }
+
+ /**
+ * If System.property for 'xbean.rootdir' == null
+ * use '.' as basePath
+ * '.' should be where the build.xml file lives
+ * @return
+ * @throws IllegalStateException
+ */
+ public static String getRootFile() throws IllegalStateException {
+ String baseDir = System.getProperty("xbean.rootdir");
+ if(baseDir == null)
+ return new File(".").getAbsolutePath();
+ else
+ return new File(baseDir).getAbsolutePath();
}
public static File xbeanCase(String str) {
- return (new File(caseroot.getPath() + fileLocation, str));
+ return (new File(caseroot + fileLocation, str));
}
public static File xbeanOutput(String str) {
@@ -76,6 +85,29 @@
public static boolean isJDK14() {
return System.getProperty("java.version").startsWith("1.4");
+ }
+
+ /** compare contents of two vectors */
+ public static void comparefNameVectors(Vector act, Vector exp) throws Exception
+ {
+ if (exp == null)
+ throw new Exception("Exp was null");
+ if (act == null)
+ throw new Exception("Act was null");
+
+ if (exp.size() != act.size())
+ throw new Exception("Size was not the same");
+
+ //use Vector.equals to compare
+ if (!act.equals(exp))
+ throw new Exception("Expected FNames did Not Match");
+
+ //check sequence is as expected (not sure if vector.equals does this
+ for (int i = 0; i < exp.size(); i++) {
+ if (!exp.get(i).equals(act.get(i)))
+ throw new Exception("Item[" + i + "]-was not as expected" +
+ "ACT[" + i + "]-" + act.get(i) + " != EXP[" + i + "]-" + exp.get(i));
+ }
}
}
Modified: xmlbeans/trunk/test/src/compile/scomp/common/CompileTestBase.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/compile/scomp/common/CompileTestBase.java?view=diff&rev=128430&p1=xmlbeans/trunk/test/src/compile/scomp/common/CompileTestBase.java&r1=128429&p2=xmlbeans/trunk/test/src/compile/scomp/common/CompileTestBase.java&r2=128430
==============================================================================
--- xmlbeans/trunk/test/src/compile/scomp/common/CompileTestBase.java (original)
+++ xmlbeans/trunk/test/src/compile/scomp/common/CompileTestBase.java Thu Jan 27 13:52:38 2005
@@ -49,6 +49,43 @@
public List errors;
public XmlOptions xm;
+ //schemas to use
+ public String forXsd = "<xs:schema attributeFormDefault=\"unqualified\" " +
+ "elementFormDefault=\"qualified\" " +
+ "targetNamespace=\"http://baz\" " +
+ "xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"> " +
+ "<xs:element name=\"elName\" type=\"bas:aType\" " +
+ "xmlns:bas=\"http://baz\"/> <xs:complexType name=\"aType\"> " +
+ "<xs:simpleContent> " +
+ "<xs:extension base=\"xs:string\" " +
+ "xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"> " +
+ "<xs:attribute type=\"xs:string\" name=\"attrName\"/> " +
+ "</xs:extension> " +
+ "</xs:simpleContent> " +
+ "</xs:complexType> " +
+ "</xs:schema>";
+ public String incrXsd = "<xs:schema attributeFormDefault=\"unqualified\" " +
+ "elementFormDefault=\"qualified\" " +
+ "targetNamespace=\"http://bar\" " +
+ "xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"> " +
+ "<xs:element name=\"elName\" type=\"bas:aType\" " +
+ "xmlns:bas=\"http://baz\"/> <xs:complexType name=\"aType\"> " +
+ "<xs:simpleContent> " +
+ "<xs:extension base=\"xs:string\" " +
+ "xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"> " +
+ "<xs:attribute type=\"xs:string\" name=\"attrName\"/> " +
+ "</xs:extension> " +
+ "</xs:simpleContent> " +
+ "</xs:complexType> " +
+ "</xs:schema>";
+ public String errXsd = "<xs:schema attributeFormDefault=\"unqualified\" " +
+ "elementFormDefault=\"qualified\" " +
+ "targetNamespace=\"http://bar\" " +
+ "xmlns:tnf=\"http://baz\" " +
+ "xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"> " +
+ "<xs:element name=\"elErrName\" type=\"tnf:aType\" /> " +
+ "</xs:schema>";
+
public CompileTestBase(String name) {
super(name);
out = CompileCommon.xbeanOutput(outPath);
@@ -61,6 +98,18 @@
xm.setSavePrettyPrint();
}
+ public static File[] getClassPath()
+ {
+ String cp = System.getProperty("java.class.path");
+ String[] cpList = cp.split(File.pathSeparator);
+ File[] fList = new File[cpList.length];
+
+ for (int i = 0; i < cpList.length; i++) {
+ fList[i] = new File(cpList[i]);
+ }
+ return fList;
+ }
+
protected SchemaCompiler.Parameters getCompilerParams() {
SchemaCompiler.Parameters params = new SchemaCompiler.Parameters();
params.setDownload(true);
@@ -229,6 +278,7 @@
}
public void findElementbyQName(SchemaTypeSystem sts, QName[] lookup) throws Exception {
+
for (int i = 0; i < lookup.length; i++) {
if (sts.findElement(lookup[i]) == null)
throw new Exception("Element was expected but not found\n" + lookup[i]);
@@ -244,6 +294,52 @@
public String getSchemaBottom() {
return "</xs:schema>";
+ }
+
+ public void printSTS(SchemaTypeSystem sts)
+ {
+ System.out.println("*******************");
+ System.out.println("NAME: " + sts.getName());
+ SchemaGlobalElement[] sge = sts.globalElements();
+ for (int i = 0; i < sge.length; i++) {
+ System.out.println("Global Type: " + sge[i].getType());
+ System.out.println("GE Name: " + sge[i].getName());
+ System.out.println("GE Class: " + sge[i].getType());
+ System.out.println("GE SourceName: " + sge[i].getSourceName());
+ }
+
+ SchemaType[] st = sts.globalTypes();
+ for (int i = 0; i < st.length; i++) {
+ System.out.println("Type Name: " + st[i].getDocumentElementName());
+ System.out.println("GT Name: " + st[i].getName());
+ System.out.println("GT Class: " + st[i].getJavaClass());
+ System.out.println("GT SourceName: " + st[i].getSourceName());
+ }
+
+ System.out.println("*******************");
+ }
+
+ /**
+ *
+ * @param sge
+ * @param q
+ * @return
+ */
+ public boolean findGlobalElement(SchemaGlobalElement[] sge, QName q)
+ {
+ boolean sts1TypePresent = false;
+ for (int i = 0; i < sge.length; i++) {
+ if (sge[i].getName().getLocalPart().compareTo(
+ q.getLocalPart()) == 0 &&
+ sge[i].getName().getNamespaceURI().compareTo(
+ q.getNamespaceURI()) == 0) {
+ sts1TypePresent = true;
+ break;
+ }
+ System.out.println("QName: " + sge[i].getName());
+ }
+
+ return sts1TypePresent;
}
public void checkPerf(long initBase, long endBase,
Added: xmlbeans/trunk/test/src/compile/scomp/common/mockobj/TestBindingConfig.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/compile/scomp/common/mockobj/TestBindingConfig.java?view=auto&rev=128430
==============================================================================
--- (empty file)
+++ xmlbeans/trunk/test/src/compile/scomp/common/mockobj/TestBindingConfig.java Thu Jan 27 13:52:38 2005
@@ -0,0 +1,157 @@
+/* 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 compile.scomp.common.mockobj;
+
+import org.apache.xmlbeans.BindingConfig;
+import org.apache.xmlbeans.InterfaceExtension;
+import org.apache.xmlbeans.PrePostExtension;
+import org.apache.xmlbeans.impl.config.BindingConfigImpl;
+
+import org.apache.xmlbeans.impl.xb.xmlconfig.ConfigDocument.Config;
+import org.apache.xmlbeans.impl.xb.xmlconfig.Extensionconfig;
+import org.apache.xmlbeans.impl.xb.xmlconfig.Nsconfig;
+import org.apache.xmlbeans.impl.xb.xmlconfig.Qnameconfig;
+import org.apache.xmlbeans.impl.xb.xmlconfig.ConfigDocument;
+import org.apache.xmlbeans.BindingConfig;
+
+import javax.xml.namespace.QName;
+import java.io.File;
+
+/**
+ * User: jacobd
+ * Date: Dec 17, 2004
+ */
+public class TestBindingConfig extends BindingConfig
+{
+ BindingConfig bindingConfig;
+ private boolean islookupPackageForNamespace;
+ private boolean islookupPrefixForNamespace;
+ private boolean islookupSuffixForNamespace;
+ private boolean islookupJavanameForQName;
+ private boolean isgetInterfaceExtensions;
+ private boolean isgetInterfaceExtensionsString;
+ private boolean isgetPrePostExtensions;
+ private boolean isgetPrePostExtensionsString;
+
+ public TestBindingConfig(ConfigDocument.Config[] configs, File[] javaFiles, File[] classpath)
+ {
+
+ bindingConfig = BindingConfigImpl.forConfigDocuments(configs, javaFiles, classpath);
+ islookupPackageForNamespace = false;
+ islookupPrefixForNamespace = false;
+ islookupSuffixForNamespace = false;
+ islookupJavanameForQName = false;
+ isgetInterfaceExtensions = false;
+ isgetInterfaceExtensionsString = false;
+ isgetPrePostExtensions = false;
+ isgetPrePostExtensionsString = false;
+ }
+
+ public boolean isIslookupPackageForNamespace()
+ {
+ return islookupPackageForNamespace;
+ }
+
+ public boolean isIslookupPrefixForNamespace()
+ {
+ return islookupPrefixForNamespace;
+ }
+
+ public boolean isIslookupSuffixForNamespace()
+ {
+ return islookupSuffixForNamespace;
+ }
+
+ public boolean isIslookupJavanameForQName()
+ {
+ return islookupJavanameForQName;
+ }
+
+ public boolean isIsgetInterfaceExtensions()
+ {
+ return isgetInterfaceExtensions;
+ }
+
+ public boolean isIsgetInterfaceExtensionsString()
+ {
+ return isgetInterfaceExtensionsString;
+ }
+
+ public boolean isIsgetPrePostExtensions()
+ {
+ return isgetPrePostExtensions;
+ }
+
+ public boolean isIsgetPrePostExtensionsString()
+ {
+ return isgetPrePostExtensionsString;
+ }
+
+ public String lookupPackageForNamespace(String s)
+ {
+ System.out.println("lookupPackageForNamespace: "+s);
+ islookupPackageForNamespace = true;
+ return bindingConfig.lookupPackageForNamespace(s);
+ }
+
+ public String lookupPrefixForNamespace(String s)
+ {
+ System.out.println("lookupPrefixForNamespace: "+s);
+ islookupPrefixForNamespace = true;
+ return bindingConfig.lookupPrefixForNamespace(s);
+ }
+
+ public String lookupSuffixForNamespace(String s)
+ {
+ System.out.println("lookupSuffixForNamespace: "+s);
+ islookupSuffixForNamespace = true;
+ return bindingConfig.lookupSuffixForNamespace(s);
+ }
+
+ public String lookupJavanameForQName(QName qName)
+ {
+ System.out.println("lookupJavanameForQName: "+qName);
+ islookupJavanameForQName = true;
+ return bindingConfig.lookupJavanameForQName(qName);
+ }
+
+ public InterfaceExtension[] getInterfaceExtensions()
+ {
+ System.out.println("getInterfaceExtensions ");
+ isgetInterfaceExtensions = true;
+ return bindingConfig.getInterfaceExtensions();
+ }
+
+ public InterfaceExtension[] getInterfaceExtensions(String s)
+ {
+ System.out.println("getInterfaceExtensions: "+s);
+ isgetInterfaceExtensionsString = true;
+ return bindingConfig.getInterfaceExtensions(s);
+ }
+
+ public PrePostExtension[] getPrePostExtensions()
+ {
+ System.out.println("getPrePostExtensions");
+ isgetPrePostExtensions = true;
+ return bindingConfig.getPrePostExtensions();
+ }
+
+ public PrePostExtension getPrePostExtension(String s)
+ {
+ System.out.println("getPrePostExtension: "+s);
+ isgetPrePostExtensionsString = true;
+ return bindingConfig.getPrePostExtension(s);
+ }
+}
Added: xmlbeans/trunk/test/src/compile/scomp/common/mockobj/TestFiler.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/compile/scomp/common/mockobj/TestFiler.java?view=auto&rev=128430
==============================================================================
--- (empty file)
+++ xmlbeans/trunk/test/src/compile/scomp/common/mockobj/TestFiler.java Thu Jan 27 13:52:38 2005
@@ -0,0 +1,87 @@
+/* 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 compile.scomp.common.mockobj;
+
+import org.apache.xmlbeans.Filer;
+import org.apache.xmlbeans.impl.schema.FilerImpl;
+
+import java.io.File;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Vector;
+
+/**
+ * User: jacobd
+ * Date: Dec 17, 2004
+ */
+public class TestFiler implements Filer
+{
+ private String P = File.separator;
+ private FilerImpl impl;
+ private boolean isCreateBinaryFile;
+ private boolean isCreateSourceFile;
+ private Vector binFileVec;
+ private Vector srcFileVec;
+
+ public TestFiler()
+ {
+ String base = new File("." + P + "build" + P + "test" + P + "output").getAbsolutePath() +
+ P + "filer" + P;
+ String sClass = base + "classes";
+ String sSrc = base + "src";
+ File fClass = new File(sClass);
+ File fSrc = new File(sSrc);
+ impl = new FilerImpl(fClass, fSrc, null, true, false);
+ binFileVec = new Vector();
+ srcFileVec = new Vector();
+ }
+
+ public OutputStream createBinaryFile(String typename) throws IOException
+ {
+ System.out.println("BFS: TypeName: " + typename);
+ isCreateBinaryFile = true;
+ binFileVec.add(typename);
+ return impl.createBinaryFile(typename);
+ }
+
+ public Writer createSourceFile(String typename) throws IOException
+ {
+ System.out.println("SF: TypeName: " + typename);
+ srcFileVec.add(typename);
+ isCreateSourceFile = true;
+ return impl.createSourceFile(typename);
+ }
+
+ public boolean isCreateBinaryFile()
+ {
+ return isCreateBinaryFile;
+ }
+
+ public boolean isCreateSourceFile()
+ {
+ return isCreateSourceFile;
+ }
+
+ public Vector getBinFileVec()
+ {
+ return binFileVec;
+ }
+
+ public Vector getSrcFileVec()
+ {
+ return srcFileVec;
+ }
+}
\ No newline at end of file
Added: xmlbeans/trunk/test/src/compile/scomp/detailed/DetailedCompTests.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/compile/scomp/detailed/DetailedCompTests.java?view=auto&rev=128430
==============================================================================
--- (empty file)
+++ xmlbeans/trunk/test/src/compile/scomp/detailed/DetailedCompTests.java Thu Jan 27 13:52:38 2005
@@ -0,0 +1,127 @@
+/* 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 compile.scomp.detailed;
+
+import junit.framework.TestCase;
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.xmlbeans.impl.common.QNameHelper;
+import org.apache.xmlbeans.impl.tool.SchemaCodeGenerator;
+import org.apache.xmlbeans.impl.tool.SchemaCompiler;
+import org.apache.xmlbeans.impl.tool.CodeGenUtil;
+import org.apache.xmlbeans.impl.tool.Diff;
+import org.w3.x2001.xmlSchema.SchemaDocument;
+import org.w3.x2001.xmlSchema.TopLevelComplexType;
+import org.apache.xmlbeans.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.*;
+
+import tools.util.TestRunUtil;
+import compile.scomp.common.CompileCommon;
+
+import javax.xml.namespace.QName;
+
+
+public class DetailedCompTests extends TestCase
+{
+ public DetailedCompTests(String name) { super(name); }
+ public static Test suite() { return new TestSuite(DetailedCompTests.class); }
+
+
+ /**
+ * This test requires laxDoc.xsd to be compiled and
+ * on the classpath ahead of time, otherwise documentation
+ * element processing would not occur
+ * @throws Exception
+ */
+ public void testLaxDocProcessing() throws Exception
+ {
+ QName q = new QName("urn:lax.Doc.Compilation", "ItemRequest");
+ ArrayList err = new ArrayList();
+ XmlOptions xm_opt = new XmlOptions().setErrorListener(err);
+ xm_opt.setSavePrettyPrint();
+
+ XmlObject xObj = XmlObject.Factory.parse(
+ new File(CompileCommon.fileLocation+"/detailed/laxDoc.xsd"));
+ XmlObject[] schemas = new XmlObject[]{xObj};
+
+
+ // ensure exception is thrown when
+ // xmloptions flag is not set
+ boolean valDocEx = false;
+ try{
+ SchemaTypeSystem sts = XmlBeans.compileXmlBeans(null, null,
+ schemas, null, XmlBeans.getBuiltinTypeSystem(), null, xm_opt);
+ }catch(XmlException xmlEx){
+ valDocEx = true;
+ System.err.println("Expected Error: "+xmlEx.getMessage());
+ } catch(Exception e){
+ throw e;
+ }
+
+ //check exception was thrown
+ if(!valDocEx)
+ throw new Exception("Documentation processing " +
+ "should have thrown and error");
+ // validate error code
+ valDocEx = false;
+ for (Iterator iterator = err.iterator(); iterator.hasNext();) {
+ XmlError xErr = (XmlError)iterator.next();
+ //System.out.println("ERROR: '"+ xErr+"'");
+ //any one of these are possible
+ if(xErr.getErrorCode().compareTo("cvc-complex-type.4") == 0 ||
+ xErr.getErrorCode().compareTo("cvc-complex-type.2.3") == 0 ||
+ xErr.getErrorCode().compareTo("cvc-complex-type.2.4c") == 0)
+ valDocEx = true;
+ }
+
+ if (!valDocEx)
+ throw new Exception("Expected Error code did not validate");
+
+ //reset errors
+ err.clear();
+
+ //ensure no exception when error
+ xm_opt = xm_opt.setCompileNoValidation();
+ try {
+ SchemaTypeSystem sts = XmlBeans.compileXmlBeans(null, null,
+ schemas, null, XmlBeans.getBuiltinTypeSystem(), null,
+ xm_opt);
+
+ if(!err.isEmpty())
+ throw new Exception("Error listener should be empty");
+
+ for (Iterator iterator = err.iterator(); iterator.hasNext();) {
+ System.out.println(iterator.next());
+ }
+
+ SchemaGlobalElement sge = sts.findElement(q);
+ System.out.println("QName: " + sge.getName());
+ System.out.println("Type: " + sge.getType());
+
+
+ } catch (Exception e) {
+ throw e;
+ }
+
+ }
+
+}
Added: xmlbeans/trunk/test/src/compile/scomp/detailed/XmlBeanCompilationTests.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/compile/scomp/detailed/XmlBeanCompilationTests.java?view=auto&rev=128430
==============================================================================
--- (empty file)
+++ xmlbeans/trunk/test/src/compile/scomp/detailed/XmlBeanCompilationTests.java Thu Jan 27 13:52:38 2005
@@ -0,0 +1,331 @@
+/* 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 compile.scomp.detailed;
+
+import junit.framework.Assert;
+import org.apache.xmlbeans.*;
+import org.apache.xmlbeans.impl.xb.xmlconfig.ConfigDocument;
+
+import java.io.*;
+import java.util.*;
+
+import compile.scomp.common.CompileCommon;
+import compile.scomp.common.CompileTestBase;
+import compile.scomp.common.mockobj.TestFiler;
+import compile.scomp.common.mockobj.TestBindingConfig;
+
+import javax.xml.namespace.QName;
+
+
+
+/**
+ * Ensure that several compilation mechanisms all generate
+ * the same schematypesystem
+ *
+ * @author jacobd
+ * Date: Aug 2, 2004
+ */
+public class XmlBeanCompilationTests extends CompileTestBase
+{
+ String P = File.separator;
+ public List xm_errors;
+ public XmlOptions xm_opts;
+ Vector expBinType;
+ Vector expSrcType;
+
+ public XmlBeanCompilationTests(String name)
+ {
+ super(name);
+ expBinType = new Vector();
+ expBinType.add("schema/system/apiCompile/atypedb57type.xsb");
+ expBinType.add("schema/system/apiCompile/elname429edoctype.xsb");
+ expBinType.add("schema/system/apiCompile/elnameelement.xsb");
+ expBinType.add("schema/system/apiCompile/index.xsb");
+ expBinType.add("schema/element/http_3A_2F_2Fbaz/elName.xsb");
+ expBinType.add("schema/type/http_3A_2F_2Fbaz/aType.xsb");
+ expBinType.add("schema/namespace/http_3A_2F_2Fbaz/xmlns.xsb");
+ expBinType.add("schema/javaname/baz/ElNameDocument.xsb");
+ expBinType.add("schema/javaname/baz/AType.xsb");
+ expBinType.add("schema/system/apiCompile/TypeSystemHolder.class");
+
+ expSrcType = new Vector();
+ expSrcType.add("baz.AType");
+ expSrcType.add("baz.impl.ATypeImpl");
+ expSrcType.add("baz.ElNameDocument");
+ expSrcType.add("baz.impl.ElNameDocumentImpl");
+
+ xm_errors = new ArrayList();
+ xm_opts = new XmlOptions();
+ xm_opts.setErrorListener(xm_errors);
+ xm_opts.setSavePrettyPrint();
+
+ }
+
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ if (xm_errors.size() > 0)
+ xm_errors.clear();
+ }
+
+ /**
+ * Filer != null for BindingConfig to be used
+ *
+ * @throws Exception
+ */
+ public void test_bindingconfig_extension_compilation() throws Exception
+ {
+ TestFiler f = new TestFiler();
+ //initialize all of the values
+ String extCaseDir = CompileCommon.caseroot + P +
+ "xbean" + P + "extensions" + P;
+ String extSrcDir = CompileCommon.caseroot + P +
+ ".." + P + "src" + P + "xmlobject" + P + "extensions" + P;
+ File[] cPath = CompileTestBase.getClassPath();
+ String dir = extCaseDir + P + "interfaceFeature" + P + "averageCase";
+ String dir2 = extCaseDir + P + "prePostFeature" + P +
+ "ValueRestriction";
+
+ ConfigDocument.Config bConf = ConfigDocument.Factory.parse(
+ new File(dir + P + "po.xsdconfig"))
+ .getConfig();
+ ConfigDocument.Config cConf = ConfigDocument.Factory.parse(
+ new File(dir2 + P + "company.xsdconfig"))
+ .getConfig();
+
+ String simpleConfig = "<xb:config " +
+ "xmlns:xb=\"http://xml.apache.org/xmlbeans/2004/02/xbean/config\"\n" +
+ " xmlns:ep=\"http://xbean.interface_feature/averageCase/PurchaseOrder\">\n" +
+ "<xb:namespace uri=\"http://xbean.interface_feature/averageCase/PurchaseOrder\">\n" +
+ "<xb:package>com.easypo</xb:package>\n" +
+ "</xb:namespace></xb:config>";
+ ConfigDocument.Config confDoc = ConfigDocument.Factory.parse(simpleConfig).getConfig();
+ ConfigDocument.Config[] confs = new ConfigDocument.Config[]{bConf, confDoc, cConf};
+
+ String fooHandlerPath = extSrcDir + P + "interfaceFeature" + P +
+ "averageCase" + P + "existing" + P + "FooHandler.java";
+ String iFooPath = extSrcDir + P + "interfaceFeature" + P +
+ "averageCase" + P + "existing" + P + "IFoo.java";
+ String iSetterPath = extSrcDir + P + "prePostFeature" + P +
+ "ValueRestriction" + P + "existing" + P + "ISetter.java";
+ String setterHandlerPath = extSrcDir + P + "prePostFeature" + P +
+ "ValueRestriction" + P + "existing" + P + "SetterHandler.java";
+
+
+ File[] fList = new File[]{new File(fooHandlerPath), new File(iFooPath),
+ new File(iSetterPath),
+ new File(setterHandlerPath)};
+
+ //use created BindingConfig
+ TestBindingConfig bind = new TestBindingConfig(confs, fList, cPath);
+
+ //set XSDs
+ XmlObject obj1 = XmlObject.Factory.parse(new File(dir + P + "po.xsd"));
+ XmlObject obj2 = XmlObject.Factory.parse(
+ new File(dir2 + P + "company.xsd"));
+ XmlObject[] schemas = new XmlObject[]{obj1, obj2};
+
+ //filer must be present on this method
+ SchemaTypeSystem apiSts = XmlBeans.compileXmlBeans("apiCompile", null,
+ schemas, bind, XmlBeans.getBuiltinTypeSystem(), f, xm_opts);
+
+ if (!bind.isIslookupPrefixForNamespace())
+ throw new Exception("isIslookupPrefixForNamespace not invoked");
+ if (!bind.isIslookupPackageForNamespace())
+ throw new Exception("isIslookupPackageForNamespace not invoked");
+ if (!bind.isIslookupSuffixForNamespace())
+ throw new Exception("isIslookupSuffixForNamespace not invoked");
+ if (!bind.isIslookupJavanameForQName())
+ throw new Exception("isIslookupJavanameForQName not invoked");
+ if (!bind.isIsgetInterfaceExtensionsString())
+ throw new Exception("isIsgetInterfaceExtensionsString not invoked");
+ if (!bind.isIsgetInterfaceExtensions())
+ throw new Exception("isIsgetInterfaceExtensions not invoked");
+ if (!bind.isIsgetPrePostExtensions())
+ throw new Exception("isIsgetPrePostExtensions not invoked");
+ if (!bind.isIsgetInterfaceExtensions())
+ throw new Exception("isIsgetInterfaceExtensions not invoked");
+ if (!bind.isIsgetPrePostExtensionsString())
+ throw new Exception("isIsgetPrePostExtensionsString not invoked");
+ }
+
+ /**
+ * Verify basic incremental compilation
+ * and compilation with partial SOM usages
+ */
+ public void test_incrCompile() throws Exception
+ {
+ XmlObject obj1 = XmlObject.Factory.parse(forXsd);
+ obj1.documentProperties().setSourceName("OBJ1");
+ XmlObject[] schemas = new XmlObject[]{obj1};
+ QName sts1 = new QName("http://baz", "elName");
+
+ XmlObject obj2 = XmlObject.Factory.parse(incrXsd);
+ obj2.documentProperties().setSourceName("OBJ2");
+ XmlObject[] schemas2 = new XmlObject[]{obj2};
+ QName sts2 = new QName("http://bar", "elName");
+
+ XmlObject obj3 = XmlObject.Factory.parse(errXsd);
+ obj3.documentProperties().setSourceName("OBJ3");
+ XmlObject[] schemas3 = new XmlObject[]{obj3};
+ QName sts3 = new QName("http://bar", "elErrName");
+
+ SchemaTypeSystem sts;
+ ArrayList err = new ArrayList();
+ XmlOptions opt = new XmlOptions().setErrorListener(err);
+ opt.put("COMPILE_PARTIAL_TYPESYSTEM");
+
+ //BASIC COMPILATION
+ sts = XmlBeans.compileXmlBeans(null,
+ null, schemas, null,
+ XmlBeans.getBuiltinTypeSystem(), null, opt);
+
+ Assert.assertTrue("Errors should have been empty", err.isEmpty());
+ // find element in the type System
+ if (!findGlobalElement(sts.globalElements(), sts1))
+ throw new Exception(
+ "Could Not find Type from first Type System: " + sts1);
+
+ //SIMPLE INCR COMPILATION
+ sts = XmlBeans.compileXmlBeans(null,
+ sts, schemas2, null,
+ XmlBeans.getBuiltinTypeSystem(), null, opt);
+ Assert.assertTrue("Errors should have been empty", err.isEmpty());
+ // find element in the type System
+
+ if (!findGlobalElement(sts.globalElements(), sts1))
+ throw new Exception("Could Not find Type from first Type System: " +
+ sts1);
+
+ if (!findGlobalElement(sts.globalElements(), sts2))
+ throw new Exception("Could Not find Type from 2nd Type System: " +
+ sts2);
+
+ System.out.println("Building over Existing");
+ //BUILDING OFF BASE SIMPLE INCR COMPILATION
+ sts = XmlBeans.compileXmlBeans(null,
+ sts, schemas2, null,
+ sts, null, opt);
+ Assert.assertTrue("Errors should have been empty", err.isEmpty());
+ // find element in the type System
+
+ if (!findGlobalElement(sts.globalElements(), sts1))
+ throw new Exception("Could Not find Type from first Type System: " +
+ sts1);
+
+ if (!findGlobalElement(sts.globalElements(), sts2))
+ throw new Exception("Could Not find Type from 2nd Type System: " +
+ sts2);
+
+ //INCR COMPILATION WITH RECOVERABLE ERROR
+ err.clear();
+ SchemaTypeSystem b = XmlBeans.compileXmlBeans(null,
+ sts, schemas3, null,
+ XmlBeans.getBuiltinTypeSystem(), null, opt);
+ // find element in the type System
+ if (!findGlobalElement(b.globalElements(), sts1))
+ throw new Exception("Could Not find Type from first Type System: " +
+ sts1);
+
+ if (!findGlobalElement(b.globalElements(), sts2))
+ throw new Exception("Could Not find Type from 2nd Type System: " +
+ sts2);
+
+ if (!findGlobalElement(b.globalElements(), sts3))
+ throw new Exception("Could Not find Type from 3rd Type System: " +
+ sts3);
+
+ printSTS(b);
+
+ //INSPECT ERRORS
+ boolean psom_expError = false;
+ // print out the recovered xm_errors
+ if (!err.isEmpty()) {
+ System.out.println(
+ "Schema invalid: partial schema type system recovered");
+ for (Iterator i = err.iterator(); i.hasNext();) {
+ XmlError xErr = (XmlError) i.next();
+ System.out.println(xErr);
+ //compare to the expected xm_errors
+ if ((xErr.getErrorCode().compareTo("src-resolve") == 0) &&
+ (xErr.getMessage().compareTo(
+ "type 'aType@http://baz' not found.") ==
+ 0))
+ psom_expError = true;
+ }
+ }
+ if (!psom_expError)
+ throw new Exception("Error Code was not as Expected");
+
+
+ }
+
+
+
+
+
+
+ /*public void test_diff_compilationMethods() throws IOException,
+ XmlException, Exception
+ {
+
+
+ //initialize the schema compiler
+ SchemaCompiler.Parameters params = new SchemaCompiler.Parameters();
+ params.setXsdFiles(new File[]{scompFile});
+ params.setSrcDir(scompDirFile);
+ params.setClassesDir(scompDirFile);
+
+ //save out schema for use in scomp later
+ XmlObject obj1 = XmlObject.Factory.parse(forXsd);
+ obj1.save(scompFile);
+
+ //scomp saved out schema
+ SchemaCompiler.compile(params);
+
+ //use new api to get typesystem
+ XmlObject[] schemas = new XmlObject[]{obj1};
+ SchemaTypeSystem apiSts = XmlBeans.compileXmlBeans("apiCompile", null,
+ schemas, null, XmlBeans.getBuiltinTypeSystem(), null, xm_opts);
+
+ //use alternative api to get typesystem
+ SchemaTypeSystem altSts = XmlBeans.compileXsd(schemas,
+ XmlBeans.getBuiltinTypeSystem(), null);
+
+ //save out sts for diff later
+ SchemaCodeGenerator.saveTypeSystem(apiSts, apiDirFile, null, null,
+ null);
+ SchemaCodeGenerator.saveTypeSystem(altSts, baseDirFile, null, null,
+ null);
+
+ //diff new api to old api
+ xm_errors = null;
+ xm_errors = new ArrayList();
+ Diff.dirsAsTypeSystems(apiDirFile, baseDirFile, xm_errors);
+ if (xm_errors.size() >= 1)
+ throw new Exception("API STS ERRORS: " + xm_errors.toString());
+
+ //diff scomp sts to new api
+ xm_errors = null;
+ xm_errors = new ArrayList();
+ Diff.dirsAsTypeSystems(apiDirFile, scompDirFile, xm_errors);
+ if (xm_errors.size() >= 1)
+ throw new Exception("API SCOMP ERRORS: " + xm_errors.toString());
+ } */
+
+
+}
Modified: xmlbeans/trunk/test/src/compile/scomp/incr/schemaCompile/detailed/IncrCompilationTests.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/compile/scomp/incr/schemaCompile/detailed/IncrCompilationTests.java?view=diff&rev=128430&p1=xmlbeans/trunk/test/src/compile/scomp/incr/schemaCompile/detailed/IncrCompilationTests.java&r1=128429&p2=xmlbeans/trunk/test/src/compile/scomp/incr/schemaCompile/detailed/IncrCompilationTests.java&r2=128430
==============================================================================
--- xmlbeans/trunk/test/src/compile/scomp/incr/schemaCompile/detailed/IncrCompilationTests.java (original)
+++ xmlbeans/trunk/test/src/compile/scomp/incr/schemaCompile/detailed/IncrCompilationTests.java Thu Jan 27 13:52:38 2005
@@ -70,8 +70,10 @@
xm.setSavePrettyPrint();
}
- public void tearDown() throws IOException {
- if (errors.size() > 0)
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ if (errors.size() > 0)
errors.clear();
}
Modified: xmlbeans/trunk/test/src/compile/scomp/incr/schemaCompile/detailed/ModelGroupTests.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/compile/scomp/incr/schemaCompile/detailed/ModelGroupTests.java?view=diff&rev=128430&p1=xmlbeans/trunk/test/src/compile/scomp/incr/schemaCompile/detailed/ModelGroupTests.java&r1=128429&p2=xmlbeans/trunk/test/src/compile/scomp/incr/schemaCompile/detailed/ModelGroupTests.java&r2=128430
==============================================================================
--- xmlbeans/trunk/test/src/compile/scomp/incr/schemaCompile/detailed/ModelGroupTests.java (original)
+++ xmlbeans/trunk/test/src/compile/scomp/incr/schemaCompile/detailed/ModelGroupTests.java Thu Jan 27 13:52:38 2005
@@ -70,7 +70,9 @@
xm.setSavePrettyPrint();
}
- public void tearDown() throws IOException {
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
if (errors.size() > 0)
errors.clear();
}
Modified: xmlbeans/trunk/test/src/compile/scomp/incr/schemaCompile/detailed/PerfTests.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/compile/scomp/incr/schemaCompile/detailed/PerfTests.java?view=diff&rev=128430&p1=xmlbeans/trunk/test/src/compile/scomp/incr/schemaCompile/detailed/PerfTests.java&r1=128429&p2=xmlbeans/trunk/test/src/compile/scomp/incr/schemaCompile/detailed/PerfTests.java&r2=128430
==============================================================================
--- xmlbeans/trunk/test/src/compile/scomp/incr/schemaCompile/detailed/PerfTests.java (original)
+++ xmlbeans/trunk/test/src/compile/scomp/incr/schemaCompile/detailed/PerfTests.java Thu Jan 27 13:52:38 2005
@@ -67,7 +67,9 @@
xm.setSavePrettyPrint();
}
- public void tearDown() throws IOException {
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
if (errors.size() > 0)
errors.clear();
}
Modified: xmlbeans/trunk/test/src/dom/detailed/MultipleDocsTest.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/dom/detailed/MultipleDocsTest.java?view=diff&rev=128430&p1=xmlbeans/trunk/test/src/dom/detailed/MultipleDocsTest.java&r1=128429&p2=xmlbeans/trunk/test/src/dom/detailed/MultipleDocsTest.java&r2=128430
==============================================================================
--- xmlbeans/trunk/test/src/dom/detailed/MultipleDocsTest.java (original)
+++ xmlbeans/trunk/test/src/dom/detailed/MultipleDocsTest.java Thu Jan 27 13:52:38 2005
@@ -73,8 +73,9 @@
}
}
- public void tearDown() throws Exception {
-
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
}
private class Worker extends Thread {
Modified: xmlbeans/trunk/test/src/misc/detailed/JiraRegressionsTest.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/misc/detailed/JiraRegressionsTest.java?view=diff&rev=128430&p1=xmlbeans/trunk/test/src/misc/detailed/JiraRegressionsTest.java&r1=128429&p2=xmlbeans/trunk/test/src/misc/detailed/JiraRegressionsTest.java&r2=128430
==============================================================================
--- xmlbeans/trunk/test/src/misc/detailed/JiraRegressionsTest.java (original)
+++ xmlbeans/trunk/test/src/misc/detailed/JiraRegressionsTest.java Thu Jan 27 13:52:38 2005
@@ -20,12 +20,9 @@
import junit.framework.TestCase;
import junit.framework.Assert;
import org.apache.xmlbeans.*;
-import org.apache.xmlbeans.impl.schema.StscState;
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.apache.internal.xmlbeans.wsdlsubst.DefinitionsDocument;
-import org.apache.xml.xmlbeans.x2004.x02.xbean.config.ConfigDocument;
-import org.w3.x2001.xmlSchema.SchemaDocument;
import org.oasisOpen.docs.wsdm.x2004.x04.muws05.schema.StateInformation;
import org.oasisOpen.docs.wsdm.x2004.x04.muws05.schema.ResourceStateDocument;
import org.w3c.dom.Document;
@@ -332,7 +329,7 @@
" </xb:extension>\n" +
" <xb:qname name=\"ep:purchase-order\" javaname=\"purchaseOrderXXX\"/>\n" +
"</xb:config> ";
- org.apache.xml.xmlbeans.x2004.x02.xbean.config.ConfigDocument config =
+ ConfigDocument config =
ConfigDocument.Factory.parse(xsdConfig);
xmOpts.setErrorListener(errorList);
if (config.validate(xmOpts)) {
Modified: xmlbeans/trunk/test/src/xmlcursor/checkin/AddToSelectionTest.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/xmlcursor/checkin/AddToSelectionTest.java?view=diff&rev=128430&p1=xmlbeans/trunk/test/src/xmlcursor/checkin/AddToSelectionTest.java&r1=128429&p2=xmlbeans/trunk/test/src/xmlcursor/checkin/AddToSelectionTest.java&r2=128430
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/checkin/AddToSelectionTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/checkin/AddToSelectionTest.java Thu Jan 27 13:52:38 2005
@@ -40,94 +40,104 @@
*
*
*/
+public class AddToSelectionTest extends BasicCursorTestCase
+{
-public class AddToSelectionTest extends BasicCursorTestCase {
+ static String sXml = "<foo><b>0</b><b>1</b><b>2</b><b attr=\"a3\">3</b><b>4</b><b>5</b><b>6</b></foo>";
- static String sXml="<foo><b>0</b><b>1</b><b>2</b><b attr=\"a3\">3</b><b>4</b><b>5</b><b>6</b></foo>";
-
- public AddToSelectionTest(String sName) {
- super(sName);
+ public AddToSelectionTest(String sName)
+ {
+ super(sName);
}
- public static Test suite() {
+ public static Test suite()
+ {
return new TestSuite(AddToSelectionTest.class);
}
- public void testAddToSelectionEnd(){
-
- m_xc.toEndDoc();
- m_xc.addToSelection();
- assertEquals(1,m_xc.getSelectionCount());
- }
-
- public void testAddToSelectionStart(){
- m_xc.toStartDoc();
- m_xc.addToSelection();
- assertEquals(1,m_xc.getSelectionCount());
- }
-
- public void testAddToSelectionAll()throws Exception {
- sXml = "<foo></foo>";
- m_xc=XmlObject.Factory.parse(sXml).newCursor();
- XmlCursor.TokenType tok;
- m_xc.addToSelection();
- while ((tok=m_xc.toNextToken())!=XmlCursor.TokenType.NONE){
- System.err.println(tok);
- m_xc.addToSelection();
- }
- assertEquals(4,m_xc.getSelectionCount());
-
- //check results
- XmlCursor m_xc1=XmlObject.Factory.parse(sXml).newCursor();
- m_xc.toSelection(0); //reset cursor
- int i=m_xc.getSelectionCount();
- while ((tok=m_xc1.toNextToken())!=XmlCursor.TokenType.NONE){
- //assertEquals(true,m_xc.hasNextSelection());
- assertEquals(m_xc.toNextToken(),tok);
- m_xc.toNextSelection();
- }
- //second cursor should be at the end of selections too...
- assertEquals(false,m_xc.toNextSelection());
- m_xc1.dispose();
- }
-
- public void testAddToSelectionSet(){
- //not set but bag semantics
- int expRes=100;
-
- m_xc.clearSelections();
- for (int i=0;i<100;i++){
- m_xc.toStartDoc();
- m_xc.addToSelection();
- }
- assertEquals(expRes,m_xc.getSelectionCount());
- }
-
- public void testAddAfterDispose(){
-
- m_xc.dispose();
- boolean error=false;
- try{
- m_xc.addToSelection();
- }catch(Throwable e){
- error=true;
- }
- assertEquals(true,error);
-
- }
-
-
- public void setUp()throws Exception{
- m_xc=XmlObject.Factory.parse(sXml).newCursor();
-
- }
- public void tearDown(){
- if (m_xc==null) return;
- try{
- m_xc.clearSelections();
- super.tearDown();
- }catch(IllegalStateException e){} //cursor disposed
+ public void testAddToSelectionEnd()
+ {
+ m_xc.toEndDoc();
+ m_xc.addToSelection();
+ assertEquals(1, m_xc.getSelectionCount());
+ }
+
+ public void testAddToSelectionStart()
+ {
+ m_xc.toStartDoc();
+ m_xc.addToSelection();
+ assertEquals(1, m_xc.getSelectionCount());
+ }
+
+ public void testAddToSelectionAll() throws Exception
+ {
+ sXml = "<foo></foo>";
+ m_xc = XmlObject.Factory.parse(sXml).newCursor();
+ XmlCursor.TokenType tok;
+ m_xc.addToSelection();
+ while ((tok = m_xc.toNextToken()) != XmlCursor.TokenType.NONE) {
+ System.err.println(tok);
+ m_xc.addToSelection();
+ }
+ assertEquals(4, m_xc.getSelectionCount());
+
+ //check results
+ XmlCursor m_xc1 = XmlObject.Factory.parse(sXml).newCursor();
+ m_xc.toSelection(0); //reset cursor
+ int i = m_xc.getSelectionCount();
+ while ((tok = m_xc1.toNextToken()) != XmlCursor.TokenType.NONE) {
+ //assertEquals(true,m_xc.hasNextSelection());
+ assertEquals(m_xc.toNextToken(), tok);
+ m_xc.toNextSelection();
+ }
+ //second cursor should be at the end of selections too...
+ assertEquals(false, m_xc.toNextSelection());
+ m_xc1.dispose();
+ }
+
+ public void testAddToSelectionSet()
+ {
+ //not set but bag semantics
+ int expRes = 100;
+
+ m_xc.clearSelections();
+ for (int i = 0; i < 100; i++) {
+ m_xc.toStartDoc();
+ m_xc.addToSelection();
+ }
+ assertEquals(expRes, m_xc.getSelectionCount());
+ }
+
+ public void testAddAfterDispose()
+ {
+ m_xc.dispose();
+ boolean error = false;
+ try {
+ m_xc.addToSelection();
+ } catch (Throwable e) {
+ error = true;
+ }
+ assertEquals(true, error);
+
+ }
+
+
+ public void setUp() throws Exception
+ {
+ m_xc = XmlObject.Factory.parse(sXml).newCursor();
+ super.setUp();
+ }
+
+ public void tearDown()
+ {
+ if (m_xc == null) return;
+ try {
+ m_xc.clearSelections();
+ super.tearDown();
+ } catch (IllegalStateException e) { //cursor disposed
+ } catch (Exception e) {
+ }
}
-
}
+
Modified: xmlbeans/trunk/test/src/xmlcursor/common/BasicCursorTestCase.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/xmlcursor/common/BasicCursorTestCase.java?view=diff&rev=128430&p1=xmlbeans/trunk/test/src/xmlcursor/common/BasicCursorTestCase.java&r1=128429&p2=xmlbeans/trunk/test/src/xmlcursor/common/BasicCursorTestCase.java&r2=128430
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/common/BasicCursorTestCase.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/common/BasicCursorTestCase.java Thu Jan 27 13:52:38 2005
@@ -41,7 +41,9 @@
protected void setUp() throws Exception {
}
- protected void tearDown() {
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
m_xo = null;
if (m_xc != null) {
m_xc.dispose();
Modified: xmlbeans/trunk/test/src/xmlcursor/detailed/MoveXmlTest2.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/xmlcursor/detailed/MoveXmlTest2.java?view=diff&rev=128430&p1=xmlbeans/trunk/test/src/xmlcursor/detailed/MoveXmlTest2.java&r1=128429&p2=xmlbeans/trunk/test/src/xmlcursor/detailed/MoveXmlTest2.java&r2=128430
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/detailed/MoveXmlTest2.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/detailed/MoveXmlTest2.java Thu Jan 27 13:52:38 2005
@@ -25,114 +25,122 @@
import xmlcursor.common.*;
-
/**
*
*
*/
-public class MoveXmlTest2 extends BasicCursorTestCase{
+public class MoveXmlTest2 extends BasicCursorTestCase
+ {
- static String sTestXml="<bk:book xmlns:bk='urn:loc.gov:books' at0=\"value0\"><!--BOOK COMMENT-->text0<author at0=\"v0\" at1=\"value1\"/></bk:book>";
- static String sTargetXml="<target></target>";
+ static String sTestXml = "<bk:book xmlns:bk='urn:loc.gov:books' at0=\"value0\"><!--BOOK COMMENT-->text0<author at0=\"v0\" at1=\"value1\"/></bk:book>";
+ static String sTargetXml = "<target></target>";
static XmlCursor m_xc1;
- public MoveXmlTest2(String sName) {
+
+ public MoveXmlTest2(String sName)
+ {
super(sName);
}
- public static Test suite() {
+ public static Test suite()
+ {
return new TestSuite(MoveXmlTest2.class);
}
- public void testNormalCase(){
- String sExpectedTrg1="<!--BOOK COMMENT--><target/>";
- String sExpectedSrc1="<bk:book at0=\"value0\" " +
- "xmlns:bk=\"urn:loc.gov:books\">" +
- "text0<author at0=\"v0\" at1=\"value1\"/></bk:book>";
-
-
- toNextTokenOfType(m_xc1,TokenType.START);
- toNextTokenOfType(m_xc,TokenType.COMMENT);
- m_xc.moveXml(m_xc1);
- toPrevTokenOfType(m_xc,TokenType.STARTDOC);
- toPrevTokenOfType(m_xc1,TokenType.STARTDOC);
- assertEquals(m_xc.xmlText(),sExpectedSrc1);
- assertEquals(m_xc1.xmlText(),sExpectedTrg1);
-
-
- sExpectedTrg1="<!--BOOK COMMENT--><target xmlns:bk=\"urn:loc.gov:books\"/>";
- sExpectedSrc1="<bk:book " +
- "at0=\"value0\" " +
- "xmlns:bk=\"urn:loc.gov:books\">" +
- "text0<author at0=\"v0\" at1=\"value1\"/>" +
- "</bk:book>";
-
- //copy the namespace declaration exlplicitly
- toNextTokenOfType(m_xc1,TokenType.END);
- toNextTokenOfType(m_xc, TokenType.NAMESPACE);
- m_xc.moveXml(m_xc1);
+ public void testNormalCase()
+ {
+ String sExpectedTrg1 = "<!--BOOK COMMENT--><target/>";
+ String sExpectedSrc1 = "<bk:book at0=\"value0\" " +
+ "xmlns:bk=\"urn:loc.gov:books\">" +
+ "text0<author at0=\"v0\" at1=\"value1\"/></bk:book>";
+
+
+ toNextTokenOfType(m_xc1, TokenType.START);
+ toNextTokenOfType(m_xc, TokenType.COMMENT);
+ m_xc.moveXml(m_xc1);
+ toPrevTokenOfType(m_xc, TokenType.STARTDOC);
+ toPrevTokenOfType(m_xc1, TokenType.STARTDOC);
+ assertEquals(m_xc.xmlText(), sExpectedSrc1);
+ assertEquals(m_xc1.xmlText(), sExpectedTrg1);
+
+
+ sExpectedTrg1 =
+ "<!--BOOK COMMENT--><target xmlns:bk=\"urn:loc.gov:books\"/>";
+ sExpectedSrc1 = "<bk:book " +
+ "at0=\"value0\" " +
+ "xmlns:bk=\"urn:loc.gov:books\">" +
+ "text0<author at0=\"v0\" at1=\"value1\"/>" +
+ "</bk:book>";
+
+ //copy the namespace declaration exlplicitly
+ toNextTokenOfType(m_xc1, TokenType.END);
+ toNextTokenOfType(m_xc, TokenType.NAMESPACE);
+ m_xc.moveXml(m_xc1);
- toPrevTokenOfType(m_xc,TokenType.STARTDOC);
- toPrevTokenOfType(m_xc1,TokenType.STARTDOC);
+ toPrevTokenOfType(m_xc, TokenType.STARTDOC);
+ toPrevTokenOfType(m_xc1, TokenType.STARTDOC);
- assertEquals(m_xc1.xmlText(),sExpectedTrg1);
- assertEquals(m_xc.xmlText(),sExpectedSrc1);
+ assertEquals(m_xc1.xmlText(), sExpectedTrg1);
+ assertEquals(m_xc.xmlText(), sExpectedSrc1);
}
//to here at END
- public void testMoveNoop(){
+ public void testMoveNoop()
+ {
- toNextTokenOfType(m_xc1,TokenType.START);
- toNextTokenOfType(m_xc,TokenType.END);
- try{
- m_xc.moveXml(m_xc1);
- fail(" need IllegalArgumentException");
- }catch(IllegalArgumentException e){}
- toPrevTokenOfType(m_xc,TokenType.STARTDOC);
- toPrevTokenOfType(m_xc1,TokenType.STARTDOC);
-
- toNextTokenOfType(m_xc1,TokenType.START);
- toNextTokenOfType(m_xc,TokenType.ENDDOC);
- try{
- m_xc.moveXml(m_xc1);
- fail(" need IllegalArgumentException");
- }catch(IllegalArgumentException e){}
- }
-
- public void testInvalidToCursorPos(){
- //position the cursor within a tag <a <movedXML/>...</a>
- toNextTokenOfType(m_xc,TokenType.START);//m_xc on book at0
- assertEquals(true,m_xc.toFirstAttribute()); //at0 in book
- toNextTokenOfType(m_xc1,TokenType.START);
- try{
- if(m_xc1.moveXml(m_xc)){
-
- fail("Should not be able to move the XML here ");
- }
- }catch(Exception e){
- System.err.println(e.getMessage());
- }
- }
-
- public void testMovedAttrNameCollision()throws Exception{
-
- m_xc1=XmlObject.Factory.parse(sTestXml).newCursor();
- toNextTokenOfType(m_xc,TokenType.START);//m_xc on book at0
- toNextTokenOfType(m_xc1,TokenType.START);
- toNextTokenOfType(m_xc1,TokenType.START);
- //toNextTokenOfType(m_xc1,TokenType.END);//to author
- assertEquals(true,m_xc1.toFirstAttribute());
- assertEquals(true,m_xc.toFirstAttribute()); //at0 in book
- if (m_xc.moveXml(m_xc1)){
- toPrevTokenOfType(m_xc1,TokenType.START);
- m_xc1.toFirstAttribute();
- assertEquals(m_xc1.getName().getLocalPart(),"at0");
- assertEquals(true, m_xc1.toNextAttribute());
- assertEquals(m_xc1.getName().getLocalPart(),"at0");
- }
- m_xc1.dispose();
+ toNextTokenOfType(m_xc1, TokenType.START);
+ toNextTokenOfType(m_xc, TokenType.END);
+ try {
+ m_xc.moveXml(m_xc1);
+ fail(" need IllegalArgumentException");
+ } catch (IllegalArgumentException e) {}
+ toPrevTokenOfType(m_xc, TokenType.STARTDOC);
+ toPrevTokenOfType(m_xc1, TokenType.STARTDOC);
+
+ toNextTokenOfType(m_xc1, TokenType.START);
+ toNextTokenOfType(m_xc, TokenType.ENDDOC);
+ try {
+ m_xc.moveXml(m_xc1);
+ fail(" need IllegalArgumentException");
+ } catch (IllegalArgumentException e) {}
+ }
+
+ public void testInvalidToCursorPos()
+ {
+ //position the cursor within a tag <a <movedXML/>...</a>
+ toNextTokenOfType(m_xc, TokenType.START);//m_xc on book at0
+ assertEquals(true, m_xc.toFirstAttribute()); //at0 in book
+ toNextTokenOfType(m_xc1, TokenType.START);
+ try {
+ if (m_xc1.moveXml(m_xc)) {
+
+ fail("Should not be able to move the XML here ");
+ }
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ }
+ }
+
+ public void testMovedAttrNameCollision() throws Exception
+ {
+
+ m_xc1 = XmlObject.Factory.parse(sTestXml).newCursor();
+ toNextTokenOfType(m_xc, TokenType.START);//m_xc on book at0
+ toNextTokenOfType(m_xc1, TokenType.START);
+ toNextTokenOfType(m_xc1, TokenType.START);
+ //toNextTokenOfType(m_xc1,TokenType.END);//to author
+ assertEquals(true, m_xc1.toFirstAttribute());
+ assertEquals(true, m_xc.toFirstAttribute()); //at0 in book
+ if (m_xc.moveXml(m_xc1)) {
+ toPrevTokenOfType(m_xc1, TokenType.START);
+ m_xc1.toFirstAttribute();
+ assertEquals(m_xc1.getName().getLocalPart(), "at0");
+ assertEquals(true, m_xc1.toNextAttribute());
+ assertEquals(m_xc1.getName().getLocalPart(), "at0");
+ }
+ m_xc1.dispose();
}
/**
@@ -140,60 +148,67 @@
* seems to be illegal semantics judging from beginElement
* $NOTE: legal here
*/
- public void testInvalidXml(){
- toNextTokenOfType(m_xc,TokenType.START);
- toNextTokenOfType(m_xc1,TokenType.START);
- assertEquals(true,m_xc.moveXml(m_xc1));
+ public void testInvalidXml()
+ {
+ toNextTokenOfType(m_xc, TokenType.START);
+ toNextTokenOfType(m_xc1, TokenType.START);
+ assertEquals(true, m_xc.moveXml(m_xc1));
}
- public void testNull(){
- toNextTokenOfType(m_xc,TokenType.START);
- try{
- m_xc.moveXml(null);
- fail("toHere null");
- }catch(Exception e){
- System.err.println(e.getMessage());
- }
+ public void testNull()
+ {
+ toNextTokenOfType(m_xc, TokenType.START);
+ try {
+ m_xc.moveXml(null);
+ fail("toHere null");
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ }
}
- public void testSelf(){
- String sExpectedResult=m_xc.xmlText();
- toNextTokenOfType(m_xc,TokenType.START);
- try{
-
- if(m_xc.moveXml(m_xc)){
- m_xc.toStartDoc();
- assertEquals(sExpectedResult,m_xc.xmlText());
- }
- }catch(Exception e){
- System.err.println(e.getMessage());
- }
- }
-
- public void setUp() throws Exception{
- m_xc=XmlObject.Factory.parse(sTestXml).newCursor();
- m_xc1=XmlObject.Factory.parse(sTargetXml).newCursor();
- }
- public void tearDown(){
- super.tearDown();
- if (m_xc1!=null){
- m_xc1.dispose();
- m_xc1=null;
- }
- }
-
- public static void main(String[] rgs){
- try{
- MoveXmlTest2 t=new MoveXmlTest2("");
- t.setUp();
- t.testSelf();
- }catch (Exception e){
- System.err.println("Error "+e.getMessage());
- e.printStackTrace();
- }
- }
+ public void testSelf()
+ {
+ String sExpectedResult = m_xc.xmlText();
+ toNextTokenOfType(m_xc, TokenType.START);
+ try {
+
+ if (m_xc.moveXml(m_xc)) {
+ m_xc.toStartDoc();
+ assertEquals(sExpectedResult, m_xc.xmlText());
+ }
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ }
+ }
+
+ public void setUp() throws Exception
+ {
+ m_xc = XmlObject.Factory.parse(sTestXml).newCursor();
+ m_xc1 = XmlObject.Factory.parse(sTargetXml).newCursor();
+ }
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ if (m_xc1 != null) {
+ m_xc1.dispose();
+ m_xc1 = null;
+ }
+ }
+
+ public static void main(String[] rgs)
+ {
+ try {
+ MoveXmlTest2 t = new MoveXmlTest2("");
+ t.setUp();
+ t.testSelf();
+ } catch (Exception e) {
+ System.err.println("Error " + e.getMessage());
+ e.printStackTrace();
+ }
+ }
}
Modified: xmlbeans/trunk/test/src/xmlcursor/jsr173/common/AttributeTest.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/xmlcursor/jsr173/common/AttributeTest.java?view=diff&rev=128430&p1=xmlbeans/trunk/test/src/xmlcursor/jsr173/common/AttributeTest.java&r1=128429&p2=xmlbeans/trunk/test/src/xmlcursor/jsr173/common/AttributeTest.java&r2=128430
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/jsr173/common/AttributeTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/jsr173/common/AttributeTest.java Thu Jan 27 13:52:38 2005
@@ -339,7 +339,9 @@
}
- public void tearDown() throws Exception {
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
if (m_stream != null)
m_stream.close();
}
Modified: xmlbeans/trunk/test/src/xmlcursor/jsr173/common/CharactersTest.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/xmlcursor/jsr173/common/CharactersTest.java?view=diff&rev=128430&p1=xmlbeans/trunk/test/src/xmlcursor/jsr173/common/CharactersTest.java&r1=128429&p2=xmlbeans/trunk/test/src/xmlcursor/jsr173/common/CharactersTest.java&r2=128430
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/jsr173/common/CharactersTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/jsr173/common/CharactersTest.java Thu Jan 27 13:52:38 2005
@@ -238,7 +238,9 @@
m_stream = getStream(cur);
}
- public void tearDown() throws Exception {
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
if (m_stream != null)
m_stream.close();
}
Modified: xmlbeans/trunk/test/src/xmlcursor/jsr173/common/ElementTest.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/xmlcursor/jsr173/common/ElementTest.java?view=diff&rev=128430&p1=xmlbeans/trunk/test/src/xmlcursor/jsr173/common/ElementTest.java&r1=128429&p2=xmlbeans/trunk/test/src/xmlcursor/jsr173/common/ElementTest.java&r2=128430
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/jsr173/common/ElementTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/jsr173/common/ElementTest.java Thu Jan 27 13:52:38 2005
@@ -142,7 +142,9 @@
}
- public void tearDown() throws Exception {
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
if (m_stream != null)
m_stream.close();
}
Modified: xmlbeans/trunk/test/src/xmlcursor/jsr173/common/GeneralMethodsTest.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/xmlcursor/jsr173/common/GeneralMethodsTest.java?view=diff&rev=128430&p1=xmlbeans/trunk/test/src/xmlcursor/jsr173/common/GeneralMethodsTest.java&r1=128429&p2=xmlbeans/trunk/test/src/xmlcursor/jsr173/common/GeneralMethodsTest.java&r2=128430
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/jsr173/common/GeneralMethodsTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/jsr173/common/GeneralMethodsTest.java Thu Jan 27 13:52:38 2005
@@ -127,7 +127,9 @@
}
- public void tearDown() throws Exception {
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
if (m_stream != null)
m_stream.close();
}
Modified: xmlbeans/trunk/test/src/xmlcursor/jsr173/common/IsXXXTest.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/xmlcursor/jsr173/common/IsXXXTest.java?view=diff&rev=128430&p1=xmlbeans/trunk/test/src/xmlcursor/jsr173/common/IsXXXTest.java&r1=128429&p2=xmlbeans/trunk/test/src/xmlcursor/jsr173/common/IsXXXTest.java&r2=128430
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/jsr173/common/IsXXXTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/jsr173/common/IsXXXTest.java Thu Jan 27 13:52:38 2005
@@ -155,7 +155,9 @@
m_stream = getStream(cur);
}
- public void tearDown() throws Exception {
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
if (m_stream != null)
m_stream.close();
}
Modified: xmlbeans/trunk/test/src/xmlcursor/jsr173/common/NamespaceTest.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/xmlcursor/jsr173/common/NamespaceTest.java?view=diff&rev=128430&p1=xmlbeans/trunk/test/src/xmlcursor/jsr173/common/NamespaceTest.java&r1=128429&p2=xmlbeans/trunk/test/src/xmlcursor/jsr173/common/NamespaceTest.java&r2=128430
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/jsr173/common/NamespaceTest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/jsr173/common/NamespaceTest.java Thu Jan 27 13:52:38 2005
@@ -273,7 +273,9 @@
m_stream=getStream( cur );
}
- public void tearDown() throws Exception {
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
if (m_stream != null)
m_stream.close();
}
Modified: xmlbeans/trunk/test/src/xmlcursor/jsr173/common/PITest.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/xmlcursor/jsr173/common/PITest.java?view=diff&rev=128430&p1=xmlbeans/trunk/test/src/xmlcursor/jsr173/common/PITest.java&r1=128429&p2=xmlbeans/trunk/test/src/xmlcursor/jsr173/common/PITest.java&r2=128430
==============================================================================
--- xmlbeans/trunk/test/src/xmlcursor/jsr173/common/PITest.java (original)
+++ xmlbeans/trunk/test/src/xmlcursor/jsr173/common/PITest.java Thu Jan 27 13:52:38 2005
@@ -65,7 +65,9 @@
m_stream = getStream( cur );
}
- public void tearDown() throws Exception {
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
if (m_stream != null)
m_stream.close();
}
Added: xmlbeans/trunk/test/src/xmlobject/detailed/SubstGroupTests.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/xmlobject/detailed/SubstGroupTests.java?view=auto&rev=128430
==============================================================================
--- (empty file)
+++ xmlbeans/trunk/test/src/xmlobject/detailed/SubstGroupTests.java Thu Jan 27 13:52:38 2005
@@ -0,0 +1,576 @@
+/* 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 xmlobject.detailed;
+
+import junit.framework.TestCase;
+import junit.framework.Assert;
+import org.apache.xmlbeans.*;
+import org.apache.xmlbeans.impl.tool.Diff;
+import org.apache.xmlbeans.impl.values.XmlValueDisconnectedException;
+import xmlobject.substgroup.*;
+
+import javax.xml.namespace.QName;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Collection;
+import java.math.BigInteger;
+
+import tools.xml.XmlComparator;
+
+public class SubstGroupTests extends TestCase
+{
+
+ private String URI = "http://xmlobject/substgroup";
+
+ public SubstGroupTests(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Convenience Method to return:
+ * <xsd:complexType name="ItemType">
+ * <xsd:sequence>
+ * <xsd:element name="sku" type="xsd:integer"/>
+ * <xsd:element name="name" type="xsd:string"/>
+ * </xsd:sequence>
+ * </xsd:complexType>
+ *
+ * @return
+ */
+ public ItemType getItemType()
+ {
+ xmlobject.substgroup.ItemType item = ItemType.Factory.newInstance();
+ item.setName("ItemType");
+ item.setSku(new BigInteger("12"));
+ return item;
+ }
+
+ /**
+ * Convenience Method to return:
+ * <xsd:element name="item" type="tns:ItemType"/>
+ *
+ * @return
+ */
+ public ItemDocument getItemDoc()
+ {
+ xmlobject.substgroup.ItemDocument item = ItemDocument.Factory.newInstance();
+ ItemType it = item.addNewItem();
+ it.setName("ItemDocument");
+ it.setSku(new BigInteger("12"));
+ item.setItem(it);
+ return item;
+ }
+
+
+ /**
+ * Convenience Method to return:
+ * <xsd:element name="chair" substitutionGroup="tns:item"/>
+ *
+ * @return
+ */
+ public ChairDocument getChairDoc()
+ {
+ xmlobject.substgroup.ChairDocument chair = ChairDocument.Factory.newInstance();
+ ItemType item = chair.addNewChair();
+ item.setName("Chair");
+ item.setSku(new BigInteger("12"));
+ chair.setChair(item);
+ return chair;
+ }
+
+ /**
+ * Convenience Method to return:
+ * <xsd:element name="notachair" type="tns:ItemType"/>
+ *
+ * @return
+ */
+ public NotachairDocument getNotaChairDoc()
+ {
+ xmlobject.substgroup.NotachairDocument nochair = NotachairDocument.Factory.newInstance();
+ ItemType item = nochair.addNewNotachair();
+ item.setName("NotAChair");
+ item.setSku(new BigInteger("12"));
+ nochair.setNotachair(item);
+ return nochair;
+ }
+
+ /**
+ * Convenience Method to return:
+ * <xsd:complexType name="BeanBagType">
+ * <xsd:complexContent>
+ * <xsd:extension base="tns:ItemType">
+ * <xsd:sequence>
+ * <xsd:element name="size" type="tns:BeanBagSizeType"/>
+ * </xsd:sequence>
+ * </xsd:extension>
+ * </xsd:complexContent>
+ * </xsd:complexType>
+ *
+ * @return
+ */
+ public BeanBagType getBeanBagType()
+ {
+ xmlobject.substgroup.BeanBagType bag = BeanBagType.Factory.newInstance();
+ BeanBagSizeType size = bag.addNewSize();
+ size.setColor("Blue");
+ bag.setSize(size);
+ bag.setName("BeanBagType");
+ bag.setSku(new BigInteger("17"));
+ return bag;
+ }
+
+ /**
+ * Convenience Method to return:
+ * <xsd:element name="beanBag" type="tns:BeanBagType"
+ * substitutionGroup="tns:item"/>
+ *
+ * @return
+ */
+ public BeanBagDocument getBeanBagDoc()
+ {
+ xmlobject.substgroup.BeanBagDocument bean = BeanBagDocument.Factory.newInstance();
+ BeanBagType item = bean.addNewBeanBag();
+ item.setName("BeanBagDoc");
+ item.setSku(new BigInteger("13"));
+ BeanBagSizeType size = item.addNewSize();
+ size.setColor("Blue");
+ item.setSize(size);
+ bean.setBeanBag(item);
+ return bean;
+ }
+
+ /**
+ * Convenience Method to return:
+ * <xsd:element name="beanBag" type="tns:BeanBagType"
+ * substitutionGroup="tns:item"/>
+ *
+ * @return
+ */
+ public BeanBagDocument getBeanBagDocItem()
+ {
+ xmlobject.substgroup.BeanBagDocument bean = BeanBagDocument.Factory.newInstance();
+ ItemType item = bean.addNewItem();
+ item.setName("BeanBagDocItem");
+ item.setSku(new BigInteger("14"));
+ bean.setItem(item);
+ return bean;
+ }
+
+ /**
+ * Convenience Method to return:
+ * <xsd:element name="beanBag" type="tns:BeanBagType"
+ * substitutionGroup="tns:item"/>
+ *
+ * @return
+ */
+ public BeanBagDocument getBeanBagDocBagType()
+ {
+ xmlobject.substgroup.BeanBagDocument bean = BeanBagDocument.Factory.newInstance();
+ ItemType item = bean.addNewBeanBag();
+ item.setName("BeanBagDocBeanBag");
+ item.setSku(new BigInteger("14"));
+ bean.setItem(item);
+ return bean;
+ }
+
+ /**
+ * Convenience Method to return:
+ * <xsd:element name="footstool" type="xsd:string"/> *
+ *
+ * @return
+ */
+ public FootstoolDocument getFootStoolDoc()
+ {
+ xmlobject.substgroup.FootstoolDocument foot = FootstoolDocument.Factory.newInstance();
+ foot.setFootstool("FootStool");
+ return foot;
+ }
+
+ /**
+ * TODO: Determine what the proper Return value is
+ *
+ * @throws Exception
+ */
+ public void test_invalidSubstitute() throws Exception
+ {
+ OrderItem order = OrderItem.Factory.newInstance();
+ ItemType item = order.addNewItem();
+ item.setName("ItemType");
+ item.setSku(new BigInteger("42"));
+
+ //FootstoolDocument fsd;
+ boolean cClassException = false;
+ try {
+
+ //on invalid substitute orignal value is returned.
+ FootstoolDocument fsd = (FootstoolDocument) item.substitute(
+ FootstoolDocument.type.getDocumentElementName(),
+ FootstoolDocument.type);
+ fail("Class Cast Exception was thrown on invalid substitute ");
+
+
+ } catch (ClassCastException ccEx) {
+ cClassException = true;
+ }
+
+ if (!cClassException)
+ throw new Exception("An Invalid Substitution did not throw " +
+ "a Class Cast Exception");
+
+ try {
+ XmlObject xm = item.substitute(
+ FootstoolDocument.type.getDocumentElementName(),
+ FootstoolDocument.type);
+
+ System.out.println("XM: " + xm.xmlText());
+ ArrayList err = new ArrayList();
+ XmlOptions xOpts = new XmlOptions().setErrorListener(err);
+ //no way this should happen
+ if (xm.validate(xOpts)) {
+ System.err.println("Invalid substitute validated");
+
+ for (Iterator iterator = err.iterator(); iterator.hasNext();) {
+ System.err.println("Error: " + iterator.next());
+ }
+ }
+
+ //invalid substitute should leave good state
+ System.out.println("Item: " + item.xmlText());
+
+ String exp = "<xml-fragment><sku>42</sku><name>ItemType</name></xml-fragment>";
+
+ Assert.assertTrue("text values should be the same",
+ exp.compareTo(xm.xmlText()) == 0);
+
+ } catch (Exception e) {
+ throw e;
+ }
+ }
+
+ public void test_validSubstitute() throws Exception
+ {
+ QName name = new QName(URI, "BeanBagType");
+ ItemDocument item = this.getItemDoc();
+ BeanBagDocument bean = this.getBeanBagDoc();
+ System.out.println("QNAme:" + ItemDocument.type.getName());
+ System.out.println("QNAme:" + name);
+ System.out.println("BEAN: " + item.xmlText());
+ ItemType xm = (ItemType) item.getItem().substitute(name, ItemType.type);
+ System.out.println(xm == item.getItem());
+ //ItemDocument xm_opts = (ItemDocument) bean.substitute(name, ItemDocument.type);
+ //Assert.assertTrue("Invalid substitute should result in null object);
+ ArrayList err = new ArrayList();
+ XmlOptions opts = new XmlOptions();
+ opts.setErrorListener(err);
+ System.out.println("xm_opts:" + xm.xmlText());
+ xm.validate(opts);
+ for (Iterator iterator = err.iterator(); iterator.hasNext();) {
+ System.out.println(iterator.next());
+
+ }
+ }
+
+ /* public void test_item_downcasts_valid() throws Exception
+ {
+ BigInteger bInt = new BigInteger("12");
+
+ xmlobject.substgroup.OrderItem order = OrderItem.Factory.newInstance();
+ ItemType item = order.addNewItem();
+
+ BeanBagType b2Type = (BeanBagType) item.substitute(
+ BeanBagDocument.type.getDocumentElementName(),
+ BeanBagType.type);
+
+ BeanBagSizeType bbSize = b2Type.addNewSize();
+ bbSize.setColor("Blue");
+ bbSize.setStringValue("Blue");
+ b2Type.setSku(bInt);
+ b2Type.setSize(bbSize);
+ b2Type.setName("BeanBagType");
+
+ ItemType nItem = order.getItem();
+ item =
+ (ItemType) nItem.substitute(
+ ItemDocument.type.getDocumentElementName(),
+ ItemType.type);
+ System.out.println(
+ "Item: " + item.xmlText(new XmlOptions().setSavePrettyPrint()));
+ ArrayList err = new ArrayList();
+ XmlOptions opts = new XmlOptions(
+ new XmlOptions().setErrorListener(err));
+
+ if (!item.validate(opts))
+ throw new Exception("Downcasting Failed Validation:\n" + err);
+
+ item.setName("ItemType");
+
+ if (!order.validate(opts))
+ throw new Exception("Downcasting Failed Validation:\n" + err);
+
+ }*/
+
+ /**
+ * Tests substition upcase, from item to Document, then ensure validation
+ *
+ * @throws Exception
+ */
+ public void test_valid_sub() throws Exception
+ {
+ String expectedXML = "<sub:beanBag xmlns:sub=\"http://xmlobject/substgroup\">" +
+ " <sku>12</sku>" +
+ " <name>BeanBagType</name>" +
+ " <size color=\"Blue\">Blue</size>" +
+ "</sub:beanBag>";
+ XmlObject xm = XmlObject.Factory.parse(expectedXML);
+ String itemName = "item";
+ BigInteger bInt = new BigInteger("12");
+
+ xmlobject.substgroup.OrderItem order = OrderItem.Factory.newInstance();
+ ItemType item = order.addNewItem();
+ item.setName(itemName);
+ item.setSku(bInt);
+
+ System.out.println("Order: " +
+ order.xmlText(new XmlOptions().setSavePrettyPrint()));
+ System.out.println("valid: " + order.validate());
+
+ BeanBagType b2Type = (BeanBagType) item.substitute(
+ BeanBagDocument.type.getDocumentElementName(),
+ BeanBagType.type);
+
+ Assert.assertTrue("Name Value was not as expected\nactual: " +
+ b2Type.getName() +
+ " exp: " +
+ itemName,
+ b2Type.getName().compareTo(itemName) == 0);
+ Assert.assertTrue("Integer Value was not as Excepted",
+ b2Type.getSku().compareTo(bInt) == 0);
+
+ BeanBagSizeType bbSize = b2Type.addNewSize();
+ bbSize.setColor("Blue");
+ bbSize.setStringValue("Blue");
+ b2Type.setSize(bbSize);
+ b2Type.setName("BeanBagType");
+
+ System.out.println("b2Type: " +
+ b2Type.xmlText(new XmlOptions().setSavePrettyPrint()));
+ System.out.println("b2Type: " + b2Type.validate());
+
+ System.out.println("Order: " +
+ order.xmlText(new XmlOptions().setSavePrettyPrint()));
+ System.out.println("ovalid: " + order.validate());
+
+ tools.xml.XmlComparator.Diagnostic diag = new tools.xml.XmlComparator.Diagnostic();
+
+ if (!XmlComparator.lenientlyCompareTwoXmlStrings(order.xmlText(),
+ xm.xmlText(), diag))
+ throw new Exception("Compare Values Fails\n" + diag.toString());
+ }
+
+
+ public void test_item_disconnect() throws Exception
+ {
+ String itemName = "item";
+ BigInteger bInt = new BigInteger("12");
+ boolean exThrown = false;
+
+ xmlobject.substgroup.OrderItem order = OrderItem.Factory.newInstance();
+ ItemType item = order.addNewItem();
+ item.setName(itemName);
+ item.setSku(bInt);
+
+ System.out.println("Order: " +
+ order.xmlText(new XmlOptions().setSavePrettyPrint()));
+ System.out.println("valid: " + order.validate());
+
+ BeanBagType b2Type = (BeanBagType) item.substitute(
+ BeanBagDocument.type.getDocumentElementName(),
+ BeanBagType.type);
+
+ try {
+ System.out.println("This should Fail: " + item.xmlText());
+ System.out.println("This should Fail: " + item.validate());
+ } catch (XmlValueDisconnectedException xmvEx) {
+ exThrown = true;
+ System.err.println(
+ "Failed as Expected - message: " + xmvEx.getMessage());
+ } catch (Exception e) {
+ throw e;
+ }
+
+ if (!exThrown)
+ throw new Exception(
+ "Value Disconnect Exception was not thrown as Expected");
+ }
+
+
+ public void test_item_downcasts_valid() throws Exception
+ {
+ BigInteger bInt = new BigInteger("12");
+ ArrayList err = new ArrayList();
+ XmlOptions opts = new XmlOptions(
+ new XmlOptions().setErrorListener(err));
+
+ xmlobject.substgroup.OrderItem order = OrderItem.Factory.newInstance();
+ ItemType item = order.addNewItem();
+
+ BeanBagType b2Type = (BeanBagType) item.substitute(
+ BeanBagDocument.type.getDocumentElementName(),
+ BeanBagType.type);
+
+ BeanBagSizeType bbSize = b2Type.addNewSize();
+ bbSize.setColor("Blue");
+ bbSize.setStringValue("Blue");
+ b2Type.setSku(bInt);
+ b2Type.setSize(bbSize);
+ b2Type.setName("BeanBagType");
+
+ ItemType nItem = order.getItem();
+
+ //nItem.validate(opts);
+ if (!nItem.validate(opts))
+ System.out.println(
+ "nItem - Downcasting Failed Validation:\n" + err);
+ err.clear();
+
+ item = (ItemType) nItem.substitute(
+ ItemDocument.type.getDocumentElementName(),
+ ItemType.type);
+
+ //System.out.println("Item1: " + item.xmlText());
+
+ if (!item.validate(opts))
+ System.out.println("Item - Downcasting Failed Validation:\n" + err);
+
+ XmlError[] xErr = getXmlErrors(err);
+ Assert.assertTrue("Length of xm_errors was greater than expected",
+ xErr.length == 1);
+ Assert.assertTrue("Error Code was not as Expected",
+ xErr[0].getErrorCode().compareTo("cvc-complex-type.2.4b") == 0);
+ err.clear();
+
+ String nName = "ItemType";
+ item.setName(nName);
+ System.out.println("Item2: " + item.xmlText());
+
+ if (!order.validate(opts))
+ System.out.println(
+ "Order - Downcasting Failed Validation:\n" + err);
+
+ //Check value was set
+ if (!(nName.compareTo(order.getItem().getName()) == 0))
+ throw new Exception("Name Value was not changed");
+
+ //Check Error message
+ String expText = "Element not allowed: size in element item@http://xmlobject/substgroup";
+ XmlError[] xErr2 = getXmlErrors(err);
+ Assert.assertTrue("Length of xm_errors was greater than expected",
+ xErr2.length == 1);
+ Assert.assertTrue("Error Code was not as Expected",
+ xErr2[0].getErrorCode().compareTo("cvc-complex-type.2.4b") ==
+ 0);
+ Assert.assertTrue("Error Message was not as expected",
+ xErr2[0].getMessage().compareTo(expText) == 0);
+
+ err.clear();
+ }
+
+ private XmlError[] getXmlErrors(ArrayList c)
+ {
+ XmlError[] errs = new XmlError[c.size()];
+ for (int i = 0; i < errs.length; i++) {
+ errs[i] = (XmlError) c.get(i);
+ }
+ return errs;
+ }
+
+ public void test_null_newName() throws Exception
+ {
+ boolean exThrown = false;
+ try {
+ xmlobject.substgroup.OrderItem order = OrderItem.Factory.newInstance();
+ order.substitute(null, OrderItem.type);
+ } catch (IllegalArgumentException iaEx) {
+ exThrown = true;
+ }
+ if (exThrown != true)
+ throw new Exception("Exception was not thrown");
+ }
+
+ public void test_null_newType() throws Exception
+ {
+ boolean exThrown = false;
+ try {
+ OrderItem order = OrderItem.Factory.newInstance();
+ order.substitute(OrderItem.type.getDocumentElementName(), null);
+
+ } catch (IllegalArgumentException iaEx) {
+ exThrown = true;
+ } catch (Exception e) {
+ throw e;
+ }
+
+ if (exThrown != true)
+ throw new Exception("Exception was not thrown");
+ }
+
+ public void test_unknownQName() throws Exception
+ {
+ boolean exThrown = false;
+ QName exp = new QName("http://www.w3.org/2001/XMLSchema", "anyType");
+ try {
+ OrderItem order = OrderItem.Factory.newInstance();
+ XmlObject xm = order.substitute(new QName("http://baz", "baz"),
+ OrderItem.type);
+
+ //Verify that the invalid substitution results in an anyType
+ Assert.assertTrue("Namespace URIs were not the same",
+ exp.getNamespaceURI().compareTo(
+ xm.type.getName().getNamespaceURI()) == 0);
+ Assert.assertTrue("Local Part was not as Expected",
+ xm.type.getName().getLocalPart().compareTo(
+ exp.getLocalPart()) == 0);
+
+ } catch (IllegalArgumentException iaEx) {
+ exThrown = true;
+ } catch (Exception e) {
+ throw e;
+ }
+
+ if (exThrown == true)
+ throw new Exception("Exception was not thrown");
+ }
+
+ public void test_null_Params() throws Exception
+ {
+ boolean exThrown = false;
+ try {
+ XmlObject xml = XmlObject.Factory.newInstance();
+ xml.substitute(null, null);
+ } catch (IllegalArgumentException iaEx) {
+ exThrown = true;
+ } catch (Exception e) {
+ throw e;
+ }
+
+ if (exThrown != true)
+ throw new Exception("Exception was not thrown");
+ }
+
+
+}
Modified: xmlbeans/trunk/test/src/xmlobject/detailed/TestsFromBugs.java
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/xmlobject/detailed/TestsFromBugs.java?view=diff&rev=128430&p1=xmlbeans/trunk/test/src/xmlobject/detailed/TestsFromBugs.java&r1=128429&p2=xmlbeans/trunk/test/src/xmlobject/detailed/TestsFromBugs.java&r2=128430
==============================================================================
--- xmlbeans/trunk/test/src/xmlobject/detailed/TestsFromBugs.java (original)
+++ xmlbeans/trunk/test/src/xmlobject/detailed/TestsFromBugs.java Thu Jan 27 13:52:38 2005
@@ -1,4 +1,3 @@
-
/* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,7 +15,7 @@
package xmlobject.detailed;
-import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.*;
import com.mytest.Bar;
import com.mytest.Foo;
import com.mytest.Info;
@@ -27,23 +26,24 @@
import java.io.File;
/**
- * Test file that implements test cases that come from closing bugs.
- *
- *
+ * Test file that implements test cases that come from closing bugs.
*/
-public class TestsFromBugs extends TestCase {
+public class TestsFromBugs extends TestCase
+{
File instance;
- public TestsFromBugs(String name) {
+ public TestsFromBugs(String name)
+ {
super(name);
}
/**
- * Radar Bug: 36156
- * Problem with Namespace leaking into siblings
+ * Radar Bug: 36156
+ * Problem with Namespace leaking into siblings
*/
public void test36156()
- throws Exception {
+ throws Exception
+ {
String str = "<x><y xmlns=\"bar\"><z xmlns=\"foo\"/></y><a/></x>";
XmlObject x = XmlObject.Factory.parse(str);
@@ -54,7 +54,8 @@
* Radar Bug: 36510
*/
public void test36510()
- throws Exception {
+ throws Exception
+ {
String str = "<test36510-app version='1.0' " +
"xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
" xsi:schemaLocation='http://test/xmlobject/test36510' " +
@@ -78,7 +79,8 @@
* Radar Bug: 40907
*/
public void test40907()
- throws Exception {
+ throws Exception
+ {
String str = "<myt:Test xmlns:myt=\"http://www.mytest.com\">" +
"<myt:foo>" +
"<myt:fooMember>this is foo member</myt:fooMember>" +
@@ -110,4 +112,86 @@
assertEquals("XML instance is not as expected", doc.xmlText(), str);
}
+
+ /**
+ * Simple Compilation Tests.
+ * Ensures method getSourceName is on SchemaComponent and
+ * can be called from SchemaGlobalElement and SchemaGlobalAttribute
+ * @throws Exception
+ */
+ public void test199585() throws Exception
+ {
+ String str = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\n" +
+ " targetNamespace=\"urn:lax.Doc.Compilation\"\n" +
+ " xmlns:tns=\"urn:lax.Doc.Compilation\"\n" +
+ " xmlns:pre=\"noResolutionNamespace\"\n" +
+ " elementFormDefault=\"qualified\"\n" +
+ " attributeFormDefault=\"unqualified\">\n" +
+ " <xs:element name=\"ItemRequest\" type=\"tns:ItemRequestType\"/>\n" +
+ " <xs:complexType name=\"ItemRequestType\">\n" +
+ " <xs:annotation>\n" +
+ " <xs:documentation>\n" +
+ " Ensure that XML content is allowed and not validated when the novdoc option is set\n" +
+ " provided content is XHTML compliant and no elements use the schema namespaces\n" +
+ " <tns:ItemRequest>\n" +
+ " foobaz\n" +
+ " </tns:ItemRequest>\n" +
+ " <xs:complexType name=\"foobar\">\n" +
+ " <xs:sequence>\n" +
+ " <xs:element name=\"foobaz\" type=\"pre:String\"/>\n" +
+ " </xs:sequence>\n" +
+ " </xs:complexType>\n" +
+ " provided content is XHTML compliant and no elements use the schema namespaces\n" +
+ " </xs:documentation>\n" +
+ " </xs:annotation>\n" +
+ " <xs:sequence>\n" +
+ " <xs:element name=\"foobaz\" type=\"xs:string\">\n" +
+ " <xs:annotation>\n" +
+ " <xs:documentation>\n" +
+ " Ensure that XML content is allowed and not validated when the novdoc option is set\n" +
+ " provided content is XHTML compliant and no elements use the schema namespaces\n" +
+ " </xs:documentation>\n" +
+ " </xs:annotation>\n" +
+ " </xs:element>\n" +
+ " </xs:sequence>\n" +
+ " <xs:attribute name=\"baz\" use=\"required\"/>\n" +
+ " </xs:complexType>\n" +
+ "</xs:schema>";
+
+ XmlObject[] schemas = new XmlObject[]{
+ XmlObject.Factory.parse(str)};
+
+ SchemaTypeSystem sts = XmlBeans.compileXmlBeans(null, null, schemas,
+ null, null, null, null);
+
+ //ensure SchemaGlobalElement has getSourceName Method
+ SchemaGlobalElement[] sge = sts.globalElements();
+ for (int i = 0; i < sge.length; i++) {
+ System.out.println("SGE SourceName: "+sge[i].getSourceName());
+
+ }
+ //ensure SchemaGlobalAttribute has getSourceName Method
+ SchemaGlobalAttribute[] sga = sts.globalAttributes();
+ for (int i = 0; i < sga.length; i++) {
+ System.out.println("SGE SourceName: " + sga[i].getSourceName());
+ }
+
+ //ensure SchemaGlobalElement is a subType of SchemaComponent
+ SchemaComponent[] sce = sts.globalElements();
+ for (int i = 0; i < sce.length; i++) {
+ System.out.println("SCE SourceName: " + sce[i].getSourceName());
+
+ }
+
+ //ensure SchemaGlobalAttribute is a subType of SchemaComponent
+ SchemaComponent[] sca = sts.globalElements();
+ for (int i = 0; i < sca.length; i++) {
+ System.out.println("SCA SourceName: " + sca[i].getSourceName());
+ }
+
+
+
+ }
+
}
Modified: xmlbeans/trunk/test/tools/lib/xsl/TestReport.xsl
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/tools/lib/xsl/TestReport.xsl?view=diff&rev=128430&p1=xmlbeans/trunk/test/tools/lib/xsl/TestReport.xsl&r1=128429&p2=xmlbeans/trunk/test/tools/lib/xsl/TestReport.xsl&r2=128430
==============================================================================
Binary files. No diff available.
Modified: xmlbeans/trunk/testbuild.xml
Url: http://svn.apache.org/viewcvs/xmlbeans/trunk/testbuild.xml?view=diff&rev=128430&p1=xmlbeans/trunk/testbuild.xml&r1=128429&p2=xmlbeans/trunk/testbuild.xml&r2=128430
==============================================================================
--- xmlbeans/trunk/testbuild.xml (original)
+++ xmlbeans/trunk/testbuild.xml Thu Jan 27 13:52:38 2005
@@ -45,17 +45,17 @@
<property name="asserts" value="on"/>
<!-- End of testenv.properties -->
-
- <target name="write.propertyfile">
+ <!--
+ <target name="write.propertyfile">-->
<!-- Write out the properties file -->
- <echoproperties destfile="testenv.properties">
+ <!--<echoproperties destfile="testenv.properties">
<propertyset>
<propertyref prefix="xbeans."/>
<propertyref prefix="build."/>
</propertyset>
</echoproperties>
</target>
-
+ -->
<!-- END: Properties Section -->
<!-- =============================================================== -->
@@ -230,8 +230,10 @@
${build.dir.test.schemas}/xbean/xmlcursor,
${build.dir.test.schemas}/xbean/xmlcursor/xstypes,
${build.dir.test.schemas}/xbean/dom,
+ ${build.dir.test.schemas}/xbean/misc,
+ ${build.dir.test.schemas}/xbean/compile/scomp/detailed,
${build.dir.test.schemas}/xbean/xmlobject,
- ${build.dir.test.schemas}/xbean/xmlobject/store,
+ ${build.dir.test.schemas}/xbean/xmlobject/store,
${build.dir.test.schemas}/xbean/xmltokensource,
${build.dir.test.schemas}/xbean/ValidatingStream,
${build.dir.test.schemas}/xbean/scomp"/>
@@ -509,8 +511,16 @@
basedir="${build.dir.test.tools}" update="false"
excludes="**/*.java"/>
</target>
+
+ <target name="check.testreport">
+ <condition property="check.testreport.exists">
+ <available file="${build.dir.test.lib}/TestReport.xsd.jar"/>
+ </condition>
+ </target>
+
+ <target name="testreport.xsd.jar" depends="check.testreport"
+ unless="check.testreport.exists">
- <target name="testreport.xsd.jar">
<java classname="${schema.compiler}"
classpathref="build.classpath"
fork="true">
@@ -996,7 +1006,7 @@
<target name="generate.html.report">
<loadfile property="css.file"
srcfile="${xbeans.test.tools.lib}/xsl/junit.css"
- failonerror="false"/>
+ failonerror="true"/>
<xslt in="${report.log.file}"
out="${report.file}"
style="${xbeans.test.tools.lib}/xsl/TestReport.xsl">
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org