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/03/10 00:21:22 UTC
svn commit: r156710 [4/5] - in xmlbeans/trunk/test: cases/xbean/compile/som/
cases/xbean/misc/ cases/xbean/misc/jira/ src/compile/scomp/som/checkin/
src/compile/scomp/som/common/ src/compile/scomp/som/detailed/
src/misc/common/ src/misc/detailed/
Added: xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_98.xml
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_98.xml?view=auto&rev=156710
==============================================================================
--- xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_98.xml (added)
+++ xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_98.xml Wed Mar 9 15:20:56 2005
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<s:a-root v:schemaLocation="http://www.orthogony.net/xml/sample/structure xmlbeans_98.xsd" xmlns:s="http://www.orthogony.net/xml/sample/structure" xmlns:v="http://www.w3.org/2001/XMLSchema-instance">
+ <s:a-child qualified-data="data:IAmQualified" xmlns:data="http://www.orthogony.net/xml/sample/data"/>
+</s:a-root>
\ No newline at end of file
Added: xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_98.xsd
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_98.xsd?view=auto&rev=156710
==============================================================================
--- xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_98.xsd (added)
+++ xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_98.xsd Wed Mar 9 15:20:56 2005
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns="http://www.orthogony.net/xml/sample/structure" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.orthogony.net/xml/sample/structure" elementFormDefault="qualified" attributeFormDefault="unqualified">
+ <xs:complexType name="childType">
+ <xs:attribute name="qualified-data" type="xs:QName" use="required"/>
+ </xs:complexType>
+ <xs:element name="a-root">
+ <xs:annotation>
+ <xs:documentation>Comment describing your root element</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="a-child" type="childType" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
Added: xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_98_exp.xml
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_98_exp.xml?view=auto&rev=156710
==============================================================================
(empty)
Added: xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_99.xml
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_99.xml?view=auto&rev=156710
==============================================================================
--- xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_99.xml (added)
+++ xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_99.xml Wed Mar 9 15:20:56 2005
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<x:dummy xmlns:x="http://dufourrault"
+ xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
+ xsi:SchemaLocation="dummy.xsd">
+
+
+ <x:father>
+ <x:son>toto</x:son>
+ </x:father>
+
+ </x:dummy>
Added: xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_99.xsd
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_99.xsd?view=auto&rev=156710
==============================================================================
--- xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_99.xsd (added)
+++ xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_99.xsd Wed Mar 9 15:20:56 2005
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xs:schema targetNamespace="http://dufourrault"
+ xmlns:dr="http://dufourrault"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified">
+
+ <xs:element name="dummy">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="father" type="dr:father"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:complexType name="father">
+ <xs:sequence>
+ <xs:element name="son" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
Modified: xmlbeans/trunk/test/src/compile/scomp/som/checkin/PartialSOMCheckinTest.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/compile/scomp/som/checkin/PartialSOMCheckinTest.java?view=diff&r1=156709&r2=156710
==============================================================================
--- xmlbeans/trunk/test/src/compile/scomp/som/checkin/PartialSOMCheckinTest.java (original)
+++ xmlbeans/trunk/test/src/compile/scomp/som/checkin/PartialSOMCheckinTest.java Wed Mar 9 15:20:56 2005
@@ -79,7 +79,7 @@
// Step 1 : create a Schema Type System with the base 'bad' xsd and create the Schema Type System (STS) for it
String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("elemattr.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("elemattr.xsd_",
null,
"BaseSchemaTS",
sBaseSourceName);
@@ -114,7 +114,7 @@
// Step 2: create a Schema Type System with the new xsd file that has additions to this schema
- SchemaTypeSystem modifiedSTS = createNewSTS("elemattr_added.xsd",
+ SchemaTypeSystem modifiedSTS = createNewSTS("elemattr_added.xsd_",
baseSTS,
"ModifiedSchemaTS",
sBaseSourceName);
@@ -145,7 +145,7 @@
validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), modifiedSTS));
// Step 3: now creat the Schema Type System with the original XSD again
- SchemaTypeSystem finalSTS = createNewSTS("elemattr.xsd",
+ SchemaTypeSystem finalSTS = createNewSTS("elemattr.xsd_",
modifiedSTS,
"FinalSchemaTS",
sBaseSourceName);
@@ -171,7 +171,7 @@
// Step 1 : create a Schema Type System with the base 'good' xsd and create the Schema Type System (STS) for it
String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("elemattr_added.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("elemattr_added.xsd_",
null,
"BaseSchemaTS",
sBaseSourceName);
@@ -190,7 +190,7 @@
validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), baseSTS));
// Step 2: create a Schema Type System with the new xsd file with modifications to existing schema
- SchemaTypeSystem modifiedSTS = createNewSTS("elemattr_modified.xsd",
+ SchemaTypeSystem modifiedSTS = createNewSTS("elemattr_modified.xsd_",
baseSTS,
"ModifiedSchemaTS",
sBaseSourceName);
@@ -221,7 +221,7 @@
validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), modifiedSTS));
// Step 3: now creat the Schema Type System with the original XSD again
- SchemaTypeSystem finalSTS = createNewSTS("elemattr_added.xsd",
+ SchemaTypeSystem finalSTS = createNewSTS("elemattr_added.xsd_",
modifiedSTS,
"FinalSchemaTS",
sBaseSourceName);
@@ -249,7 +249,7 @@
// Step 1 : create a Schema Type System with the base 'good' xsd and create the Schema Type System (STS) for it
String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("elemattr_added.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("elemattr_added.xsd_",
null,
"BaseSchemaTS",
sBaseSourceName);
@@ -268,7 +268,7 @@
validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), baseSTS));
// Step 2: create a Schema Type System with the new xsd file that has deletions
- SchemaTypeSystem modifiedSTS = createNewSTS("elemattr.xsd",
+ SchemaTypeSystem modifiedSTS = createNewSTS("elemattr.xsd_",
baseSTS,
"ModifiedSchemaTS",
sBaseSourceName);
@@ -299,7 +299,7 @@
validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), modifiedSTS));
// Step 3: now creat the Schema Type System with the original XSD again
- SchemaTypeSystem finalSTS = createNewSTS("elemattr_added.xsd",
+ SchemaTypeSystem finalSTS = createNewSTS("elemattr_added.xsd_",
modifiedSTS,
"FinalSchemaTS",
sBaseSourceName);
@@ -327,7 +327,7 @@
System.out.println("Inside test case testAddDataTypes()");
// Step 1 : create a PSOM from an incomplete/invalid xsd (datatypes.xsd) with unresolved references to various types
String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("datatypes.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("datatypes.xsd_",
null,
"BaseSchemaTS",
sBaseSourceName);
@@ -380,7 +380,7 @@
getElementType(baseSTS, "testAllGroupElem"));
// Step 2 : create an incremental PSOM that is valid by loading datatypes_added.xsd
- SchemaTypeSystem modifiedSTS = createNewSTS("datatypes_added.xsd", baseSTS, "ModifiedSchemaTS", sBaseSourceName);
+ SchemaTypeSystem modifiedSTS = createNewSTS("datatypes_added.xsd_", baseSTS, "ModifiedSchemaTS", sBaseSourceName);
Assert.assertNotNull("Schema Type System created is Null.", modifiedSTS);
// no errors expected to be recovered - should be a valid SOM
@@ -433,7 +433,7 @@
// Step 3 : create an incremental STS with the file in step 1
- SchemaTypeSystem finalSTS = createNewSTS("datatypes.xsd",
+ SchemaTypeSystem finalSTS = createNewSTS("datatypes.xsd_",
modifiedSTS,
"FinalSchemaTS",
sBaseSourceName);
@@ -459,7 +459,7 @@
// Step 1: read a clean XSD file to get a valid SOM
String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("datatypes_added.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("datatypes_added.xsd_",
null,
"BaseSchemaTS",
sBaseSourceName);
@@ -511,7 +511,7 @@
//Step 2 : delete/remove types from the schema - should result in STS with unresolved refs
- SchemaTypeSystem modifiedSTS = createNewSTS("datatypes.xsd",
+ SchemaTypeSystem modifiedSTS = createNewSTS("datatypes.xsd_",
baseSTS,
"ModifiedSchemaTS",
sBaseSourceName);
@@ -559,7 +559,7 @@
Assert.assertEquals("Validation against instance should Failed ", false, validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), modifiedSTS));
// Step 3 : reaload the xsd in Step 1
- SchemaTypeSystem finalSTS = createNewSTS("datatypes_added.xsd",
+ SchemaTypeSystem finalSTS = createNewSTS("datatypes_added.xsd_",
modifiedSTS,
"FinalSchemaTS",
sBaseSourceName);
@@ -618,7 +618,7 @@
// Step 1: read in a clean XSD datatypes_added.xsd, to create a base schema with no unresolved components
String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("datatypes_added.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("datatypes_added.xsd_",
null,
"BaseSchemaTS",
sBaseSourceName);
@@ -653,7 +653,7 @@
//Step 2 : modify types from the schema - should result in STS with unresolved refs
//remove one of the constituent types for the union and test to see if union is anySimpleType
- SchemaTypeSystem modifiedSTS = createNewSTS("datatypes_modified.xsd",
+ SchemaTypeSystem modifiedSTS = createNewSTS("datatypes_modified.xsd_",
baseSTS,
"ModifiedSchemaTS",
sBaseSourceName);
@@ -680,7 +680,7 @@
validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), modifiedSTS));
// step 3: reload the original STS
- SchemaTypeSystem finalSTS = createNewSTS("datatypes_added.xsd",
+ SchemaTypeSystem finalSTS = createNewSTS("datatypes_added.xsd_",
modifiedSTS,
"FinalSchemaTS",
sBaseSourceName);
@@ -718,7 +718,7 @@
// Step 1: read in a clean XSD derived_types_added.xsd with base and derived types to create a base schema with no unresolved components
String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("derived_types_added.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("derived_types_added.xsd_",
null,
"BaseSchemaTS",
sBaseSourceName);
@@ -777,7 +777,7 @@
"RestrictionDerivedEmptyContentType", getElementType(baseSTS, "RestrictionDerivedEmptyContentTypeElem"));
// Step 2: create invalid PSOM with base type removed
- SchemaTypeSystem modifiedSTS = createNewSTS("derived_types.xsd",
+ SchemaTypeSystem modifiedSTS = createNewSTS("derived_types.xsd_",
baseSTS,
"ModifiedSchemaTS",
sBaseSourceName);
@@ -845,7 +845,7 @@
// step 3: reload the original STS
- SchemaTypeSystem finalSTS = createNewSTS("derived_types_added.xsd",
+ SchemaTypeSystem finalSTS = createNewSTS("derived_types_added.xsd_",
modifiedSTS,
"FinalSchemaTS",
sBaseSourceName);
@@ -877,7 +877,7 @@
// Step 1: start with invalid SOM - one that has derived types but the base types are not defined
String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("derived_types.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("derived_types.xsd_",
null,
"BaseSchemaTS",
sBaseSourceName);
@@ -913,7 +913,7 @@
getElementType(baseSTS, "ExtensionDerivedMixedContentTypeElem"));
// Step 2: create valid PSOM now from xsd with base types defined
- SchemaTypeSystem modifiedSTS = createNewSTS("derived_types_added.xsd",
+ SchemaTypeSystem modifiedSTS = createNewSTS("derived_types_added.xsd_",
baseSTS,
"ModifiedSchemaTS",
sBaseSourceName);
@@ -961,7 +961,7 @@
// Step 1: read in invalid XSD groups.xsd
String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("groups.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("groups.xsd_",
null,
"BaseSchemaTS",
sBaseSourceName);
@@ -991,7 +991,7 @@
getAttributeGroup(baseSTS, "AttributeGroup"));
// Step 2: create a SOM with valid xsd
- SchemaTypeSystem modifiedSTS = createNewSTS("groups_added.xsd",
+ SchemaTypeSystem modifiedSTS = createNewSTS("groups_added.xsd_",
baseSTS,
"BaseSchemaTS",
sBaseSourceName);
@@ -1029,7 +1029,7 @@
// step1: load an invalid PSOM by with incomplete/missing Subst Grp head elem definition
String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("groups.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("groups.xsd_",
null,
"BaseSchemaTS",
sBaseSourceName);
@@ -1069,7 +1069,7 @@
getAttributeGroup(baseSTS, "AttributeGroup"));
// Step 2: create a valid SOM and add to these
- SchemaTypeSystem modifiedSTS = createNewSTS("groups_added.xsd",
+ SchemaTypeSystem modifiedSTS = createNewSTS("groups_added.xsd_",
baseSTS,
"ModifiedSchemaTS",
sBaseSourceName);
@@ -1114,7 +1114,7 @@
// Step 1: read in a clean XSD groups_added.xsd
String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("groups_added.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("groups_added.xsd_",
null,
"BaseSchemaTS",
sBaseSourceName);
@@ -1151,7 +1151,7 @@
//Assert.assertEquals("Elem Type should be 'AttributeGroup'", "AttributeGroup", getAttributeGroup(baseSTS,"AttributeGroup"));
// step2: load an invalid PSOM by deleting the Subst Grp head elem definition
- SchemaTypeSystem modifiedSTS = createNewSTS("groups.xsd",
+ SchemaTypeSystem modifiedSTS = createNewSTS("groups.xsd_",
baseSTS,
"ModifiedSchemaTS",
sBaseSourceName);
@@ -1190,7 +1190,7 @@
getAttributeGroup(modifiedSTS, "AttributeGroup"));
// step 3: create a PSOM with the original xsd
- SchemaTypeSystem finalSTS = createNewSTS("groups_added.xsd",
+ SchemaTypeSystem finalSTS = createNewSTS("groups_added.xsd_",
modifiedSTS,
"FinalSchemaTS",
sBaseSourceName);
@@ -1230,7 +1230,7 @@
// Step 1: read in a clean XSD groups_added.xsd
String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("groups_added.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("groups_added.xsd_",
null,
"BaseSchemaTS",
sBaseSourceName);
@@ -1263,7 +1263,7 @@
getElementType(baseSTS, "SubGrpMemberElem2"));
// step2: load a modified xsd with type of head elem in subs grp changed
- SchemaTypeSystem modifiedSTS = createNewSTS("groups_modified.xsd",
+ SchemaTypeSystem modifiedSTS = createNewSTS("groups_modified.xsd_",
baseSTS,
"ModifiedSchemaTS",
sBaseSourceName);
@@ -1292,7 +1292,7 @@
getElementType(modifiedSTS, "SubGrpMemberElem2"));
// step3 : reload the original xsd
- SchemaTypeSystem finalSTS = createNewSTS("groups_added.xsd",
+ SchemaTypeSystem finalSTS = createNewSTS("groups_added.xsd_",
modifiedSTS,
"FinalSchemaTS",
sBaseSourceName);
@@ -1329,7 +1329,7 @@
// Step 1: read in a clean XSD groups_added.xsd
String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("constraints_added.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("constraints_added.xsd_",
null,
"BaseSchemaTS",
sBaseSourceName);
@@ -1363,7 +1363,7 @@
// The xsd includes these but the invalid SOM in this case is from a keyref definition referring to a
// non existant key
- SchemaTypeSystem modifiedSTS = createNewSTS("constraints.xsd",
+ SchemaTypeSystem modifiedSTS = createNewSTS("constraints.xsd_",
baseSTS,
"ModifiedSchemaTS",
sBaseSourceName);
@@ -1392,7 +1392,7 @@
lookForIdentityConstraint(modifiedSTS, "KeyConstraint"));
// Step 3 : recreate SOM in first step and compare it
- SchemaTypeSystem finalSTS = createNewSTS("constraints_added.xsd",
+ SchemaTypeSystem finalSTS = createNewSTS("constraints_added.xsd_",
modifiedSTS,
"FinalSchemaTS",
sBaseSourceName);
Modified: xmlbeans/trunk/test/src/compile/scomp/som/common/SomTestBase.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/compile/scomp/som/common/SomTestBase.java?view=diff&r1=156709&r2=156710
==============================================================================
--- xmlbeans/trunk/test/src/compile/scomp/som/common/SomTestBase.java (original)
+++ xmlbeans/trunk/test/src/compile/scomp/som/common/SomTestBase.java Wed Mar 9 15:20:56 2005
@@ -505,7 +505,13 @@
File xsdModified = getTestCaseFile(xsdFileName);
XmlObject xsdModifiedObj = XmlObject.Factory.parse(xsdModified);
System.out.println("Source Name for STS: " + xsdModifiedObj.documentProperties().getSourceName());
- xsdModifiedObj.documentProperties().setSourceName(sBaseSourceName);
+
+ // If null is passed for the basename, the basename is not set. Modified for namespace testcases.
+ // If a source name is specified, deferencing of location for schemaLocation attribute gets messed up.
+ if(sBaseSourceName != null)
+ {
+ xsdModifiedObj.documentProperties().setSourceName(sBaseSourceName);
+ }
Assert.assertNotNull("Xml Object creation failed", xsdModifiedObj);
XmlObject[] xobjArr = new XmlObject[]{xsdModifiedObj};
Modified: xmlbeans/trunk/test/src/compile/scomp/som/detailed/PartialSOMDetailedTest.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/compile/scomp/som/detailed/PartialSOMDetailedTest.java?view=diff&r1=156709&r2=156710
==============================================================================
--- xmlbeans/trunk/test/src/compile/scomp/som/detailed/PartialSOMDetailedTest.java (original)
+++ xmlbeans/trunk/test/src/compile/scomp/som/detailed/PartialSOMDetailedTest.java Wed Mar 9 15:20:56 2005
@@ -75,7 +75,7 @@
// Step 1 : create a PSOM from an incomplete/invalid xsd (datatypes.xsd) with unresolved references to various types
String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("datatypes.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("datatypes.xsd_",
null,
"BaseSchemaTS",
sBaseSourceName);
@@ -108,7 +108,7 @@
// Step 1: read in a clean XSD groups_added.xsd
String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("groups_added.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("groups_added.xsd_",
null,
"BaseSchemaTS",
sBaseSourceName);
@@ -139,7 +139,7 @@
getModelGroup(baseSTS, "NamedModelGroup"));
// step2: load an invalid PSOM by deleting the ModelGroup and AttributeGroup definitions commented
- SchemaTypeSystem modifiedSTS = createNewSTS("reusable_grps.xsd",
+ SchemaTypeSystem modifiedSTS = createNewSTS("reusable_grps.xsd_",
baseSTS,
"ModifiedSchemaTS",
sBaseSourceName);
@@ -165,7 +165,7 @@
getElementType(modifiedSTS, "AttributeGroupElem"));
// step 3: create a PSOM with the original xsd
- SchemaTypeSystem finalSTS = createNewSTS("groups_added.xsd",
+ SchemaTypeSystem finalSTS = createNewSTS("groups_added.xsd_",
modifiedSTS,
"FinalSchemaTS", sBaseSourceName);
Assert.assertNotNull("Schema Type System created is Null.", finalSTS);
@@ -197,7 +197,7 @@
// Step 1: read in a clean XSD datatypes_added.xsd, to create a base schema with no unresolved components
String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("datatypes_added.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("datatypes_added.xsd_",
null,
"BaseSchemaTS",
sBaseSourceName);
@@ -231,7 +231,7 @@
//Step 2 : modify types from the schema - should result in STS with unresolved refs
- SchemaTypeSystem modifiedSTS = createNewSTS("datatypes_modified.xsd",
+ SchemaTypeSystem modifiedSTS = createNewSTS("datatypes_modified.xsd_",
baseSTS,
"ModifiedSchemaTS",
sBaseSourceName);
@@ -260,7 +260,7 @@
validateInstance(getTestCaseFile("instance_simple_types_valid.xml"), modifiedSTS));
// step 3: reload the original STS
- SchemaTypeSystem finalSTS = createNewSTS("datatypes_added.xsd",
+ SchemaTypeSystem finalSTS = createNewSTS("datatypes_added.xsd_",
modifiedSTS,
"FinalSchemaTS",
sBaseSourceName);
@@ -298,7 +298,7 @@
// Step 1: read in a clean XSD derived_types_added.xsd with base and derived types to create a base schema with no unresolved components
String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("derived_types_added.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("derived_types_added.xsd_",
null,
"BaseSchemaTS",
sBaseSourceName);
@@ -324,7 +324,7 @@
"RestrictionSimpleContentBaseType", getElementType(baseSTS, "RestrictionSimpleContentBaseTypeElem"));
// Step 2: create invalid PSOM with base type removed
- SchemaTypeSystem modifiedSTS = createNewSTS("derived_types.xsd",
+ SchemaTypeSystem modifiedSTS = createNewSTS("derived_types.xsd_",
baseSTS,
"ModifiedSchemaTS",
sBaseSourceName);
@@ -360,7 +360,7 @@
// Step 1: read in a clean XSD groups_added.xsd
String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("groups_added.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("groups_added.xsd_",
null,
"BaseSchemaTS",
sBaseSourceName);
@@ -388,7 +388,7 @@
getAttributeGroup(baseSTS, "AttributeGroup"));
// step2: load a modified xsd with type of head elem in subs grp changed
- SchemaTypeSystem modifiedSTS = createNewSTS("reusable_grps_modified.xsd",
+ SchemaTypeSystem modifiedSTS = createNewSTS("reusable_grps_modified.xsd_",
baseSTS,
"ModifiedSchemaTS",
sBaseSourceName);
@@ -413,7 +413,7 @@
getAttributeGroup(modifiedSTS, "AttributeGroup"));
// step3 : reload the original xsd
- SchemaTypeSystem finalSTS = createNewSTS("groups_added.xsd",
+ SchemaTypeSystem finalSTS = createNewSTS("groups_added.xsd_",
modifiedSTS,
"FinalSchemaTS",
sBaseSourceName);
@@ -447,7 +447,7 @@
// Step 1: read in a clean XSD derived_types_added.xsd
String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("derived_types_added.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("derived_types_added.xsd_",
null,
"BaseSchemaTS",
sBaseSourceName);
@@ -513,7 +513,7 @@
// step 2 : change the base types now : derived_types_modified.xsd
- SchemaTypeSystem modifiedSTS = createNewSTS("derived_types_modifed.xsd",
+ SchemaTypeSystem modifiedSTS = createNewSTS("derived_types_modifed.xsd_",
baseSTS,
"ModifiedSchemaTS",
sBaseSourceName);
@@ -543,16 +543,14 @@
System.out.println("Inside test case testNameSpacesImportFile()");
// Step 1: read in an xsd that imports from another xsd file providing file name only
- // The absolute rul specified in tbe basename (if specified) is used to look for imported schemas.
- // Hence, setting the base name to a file url with path works. This would also work if no source name is specified
-
+ // The source name is not specified as this confuses the dereferecing of the location for the schemaLocation Attribute
+ // The absolute rul specified in tbe basename (if specified) would also work.
+
//String sBaseSourceName = "file:/D:/SVNNEW/xmlbeans/trunk/test/cases/xbean/compile/som/";
- String sBaseSourceName = "file:///" + casesRootDir.replace(File.separatorChar,'/');
- System.out.println("ok url is ::" + sBaseSourceName);
- SchemaTypeSystem baseSTS = createNewSTS("namespaces_import_fileonly.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("namespaces_import_fileonly.xsd_",
null,
"BaseSchemaTS",
- sBaseSourceName);
+ null);
Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
@@ -566,11 +564,11 @@
System.out.println("Inside test case testNameSpacesWithInclude()");
// Step 1: read in an xsd that includes another namespace in xsd file namespaces2.xsd
- String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("namespaces_include.xsd",
+ //String sBaseSourceName = "testsourcename";
+ SchemaTypeSystem baseSTS = createNewSTS("namespaces_include.xsd_",
null,
"BaseSchemaTS",
- sBaseSourceName);
+ null);
Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
@@ -588,6 +586,7 @@
}
+ /*
public void testNameSpacesImportFileWithPath() throws Exception
{
System.out.println("Inside test case testNameSpacesImportFileWithPath()");
@@ -627,7 +626,7 @@
inspectSOM(modifiedSTS, 2, 0, 1, 0);
}
-
+ */
}
Added: xmlbeans/trunk/test/src/misc/common/JiraTestBase.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/misc/common/JiraTestBase.java?view=auto&rev=156710
==============================================================================
--- xmlbeans/trunk/test/src/misc/common/JiraTestBase.java (added)
+++ xmlbeans/trunk/test/src/misc/common/JiraTestBase.java Wed Mar 9 15:20:56 2005
@@ -0,0 +1,401 @@
+/*
+ * Copyright (c) 2005 Your Corporation. All Rights Reserved.
+ */
+package misc.common;
+
+import junit.framework.TestCase;
+import junit.framework.Assert;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+
+import org.apache.xmlbeans.*;
+
+import javax.xml.namespace.QName;
+
+/**
+ *
+ */
+public class JiraTestBase extends TestCase
+{
+ public static final String P = File.separator;
+
+ public static String fwroot = getRootFile();
+ public static String caseroot = fwroot + P + "test" + P + "cases";
+ //location of files under "cases folder"
+ public static String JIRA_CASES = caseroot + P + "xbean" + P + "misc" +
+ P +
+ "jira" +
+ P;
+ public static File outputroot = new File(fwroot,
+ "build" + P + "test" + P +
+ "jiraoutput");
+
+
+ public static String scompTestFilesRoot = fwroot + P + "test" + P + "cases" + P + "xbean" + P + "misc" + P + "jira" + P;
+ public static String schemaCompOutputDirPath = fwroot + P + "build" + P + "test" + P + "output" + P + "jira" + P;
+ public static File schemaCompOutputDirFile = null;
+ public static File schemaCompSrcDir = null;
+ public static File schemaCompClassesDir = null;
+
+ public static final int THREAD_COUNT = 150;
+ public static final int ITERATION_COUNT = 2;
+ public LinkedList errorList;
+ public XmlOptions xmOpts;
+
+ public JiraTestBase(String name){
+ super(name);
+ errorList = new LinkedList();
+ xmOpts = new XmlOptions();
+ xmOpts.setErrorListener(errorList);
+ }
+
+ /**
+ * 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 + JIRA_CASES, str));
+ }
+
+ public static void deltree(File dir)
+ {
+ if (dir.exists()) {
+ if (dir.isDirectory()) {
+ String[] list = dir.list();
+ for (int i = 0; i < list.length; i++) {
+ deltree(new File(dir, list[i]));
+ }
+ }
+ if (!dir.delete()) {
+ System.out.println("Could not delete " + dir);
+ }
+ //throw new IllegalStateException("Could not delete " + dir);
+ }
+ }
+
+ /*
+ * Helper Methods
+ *
+ */
+ public static XmlObject compileXsdString(String XsdAsString) {
+ XmlObject xobj = null;
+ try {
+ xobj = XmlObject.Factory.parse(XsdAsString);
+ } catch (XmlException xme) {
+ if (!xme.getErrors().isEmpty()) {
+ for (Iterator itr = xme.getErrors().iterator(); itr.hasNext();) {
+ System.out.println("Parse Errors :" + itr.next());
+ }
+ }
+ } finally {
+ Assert.assertNotNull(xobj);
+ return xobj;
+ }
+ }
+
+ public static XmlObject compileXsdFile(String XsdFilePath) {
+ XmlObject xobj = null;
+ try {
+ xobj = XmlObject.Factory.parse(new File(XsdFilePath));
+ } catch (XmlException xme) {
+ if (!xme.getErrors().isEmpty()) {
+ for (Iterator itr = xme.getErrors().iterator(); itr.hasNext();) {
+ System.out.println("Parse Errors :" + itr.next());
+ }
+ }
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ ioe.getMessage();
+ } finally {
+ Assert.assertNotNull(xobj);
+ return xobj;
+ }
+ }
+
+
+ public boolean printOptionErrMsgs(Collection errors) {
+ // check list of errors/warnings/msgs and print them. Return true if errors found
+ boolean errFound = false;
+ if (!errors.isEmpty()) {
+ for (Iterator i = errors.iterator(); i.hasNext();) {
+ XmlError eacherr = (XmlError) i.next();
+ int errSeverity = eacherr.getSeverity();
+ if (errSeverity == XmlError.SEVERITY_ERROR) {
+ System.out.println("Err Msg (s) at line #" + eacherr.getLine() + ": " + eacherr.getMessage());
+ errFound = true;
+ } else if (errSeverity == XmlError.SEVERITY_WARNING) {
+ System.out.println("Warning Msg (s) at line #" + eacherr.getLine() + ": " + eacherr.getMessage());
+ } else if (errSeverity == XmlError.SEVERITY_INFO) {
+ System.out.println("Info Msg (s) at line #" + eacherr.getLine() + ": " + eacherr.getMessage());
+ }
+ }
+ errors.clear();
+ }
+ return errFound;
+ }
+
+ public void validateInstance(String[] schemas, String[] instances, QName docType) throws Exception {
+ SchemaTypeLoader stl = makeSchemaTypeLoader(schemas);
+ XmlOptions options = new XmlOptions();
+
+ if (docType != null) {
+ SchemaType docSchema = stl.findDocumentType(docType);
+ Assert.assertTrue(docSchema != null);
+ options.put(XmlOptions.DOCUMENT_TYPE, docSchema);
+ }
+
+ for (int i = 0; i < instances.length; i++) {
+ XmlObject x =
+ stl.parse((String) instances[i], null, options);
+
+ //if (!startOnDocument) {
+ // XmlCursor c = x.newCursor();
+ // c.toFirstChild();
+ // x = c.getObject();
+ // c.dispose();
+ //}
+
+ List xel = new ArrayList();
+
+ options.put(XmlOptions.ERROR_LISTENER, xel);
+
+ boolean isValid = x.validate(options);
+
+ if (!isValid) {
+ StringBuffer errorTxt = new StringBuffer("Invalid doc, expected a valid doc: ");
+ errorTxt.append("Instance(" + i + "): ");
+ errorTxt.append(x.xmlText());
+ errorTxt.append("Errors: ");
+ for (int j = 0; j < xel.size(); j++)
+ errorTxt.append(xel.get(j) + "\n");
+ System.err.println(errorTxt.toString());
+ throw new Exception("Instance not valid\n" + errorTxt.toString());
+ }
+ }
+ }
+
+ public SchemaTypeLoader makeSchemaTypeLoader(String[] schemas)
+ throws Exception {
+ XmlObject[] schemaDocs = new XmlObject[schemas.length];
+
+ for (int i = 0; i < schemas.length; i++) {
+ schemaDocs[i] =
+ XmlObject.Factory.parse(schemas[i]);
+ }
+
+ return XmlBeans.loadXsd(schemaDocs);
+ }
+
+ /**
+ * For Testing jira issue 46
+ */
+ public static class RegexThread extends TestThread
+ {
+ private xmlbeans46.UsPhoneNumberDocument phone;
+ Random rand;
+
+ public RegexThread()
+ {
+ super();
+ phone = xmlbeans46.UsPhoneNumberDocument.Factory.newInstance();
+ rand = new Random();
+ }
+
+ /**
+ * Validates a type that uses the following pattern
+ * <xs:restriction base="xs:string">
+ * <xs:pattern value="\d{3}\-\d{3}\-\d{4}"/>
+ * </xs:restriction>
+ */
+ public void run()
+ {
+ try {
+
+ for (int i = 0; i < 9; i++) {
+ int pre = rand.nextInt(999);
+ int mid = rand.nextInt(999);
+ int post = rand.nextInt(9999);
+ String testVal = ((pre > 100) ? String.valueOf(pre) : "128") + "-" +
+ ((mid > 100) ? String.valueOf(mid) : "256") + "-" +
+ ((post > 1000) ? String.valueOf(post) : "1024");
+
+ String xmlData = "<xb:usPhoneNumber xmlns:xb=\"http://xmlbeans_46\">" +
+ testVal +
+ "</xb:usPhoneNumber>";
+ //cannot repro using this method
+ //phone.setUsPhoneNumber(testVal);
+ //if (!phone.validate(xm)) {
+ // _throwable = new Throwable("Multi Threaded Regular " +
+ // "Expression did not validate - " + testVal);
+ // if (errors != null && errors.size() > 0)
+ // System.err.println("ERROR: " + errors);
+ //}
+
+ boolean validated = parseAndValidate(xmlData);
+ if (!validated) {
+ System.out.println("Not Valid!!!");
+ }
+ System.out.println("Validated " + testVal + " successfully ");
+ }
+ _result = true;
+
+ } catch (Throwable t) {
+ _throwable = t;
+ t.printStackTrace();
+ }
+ }
+
+ private boolean parseAndValidate(String val) throws XmlException
+ {
+ xmlbeans46.UsPhoneNumberDocument xml = xmlbeans46.UsPhoneNumberDocument.Factory.parse(val);
+ return validate(xml);
+ }
+
+ private boolean validate(xmlbeans46.UsPhoneNumberDocument rdd)
+ {
+ Collection errors = new ArrayList();
+ XmlOptions validateOptions = new XmlOptions();
+ validateOptions.setErrorListener(errors);
+ boolean valid = rdd.validate(validateOptions);
+ if (!valid) {
+ for (Iterator iterator = errors.iterator(); iterator.hasNext();) {
+ XmlError xmlError = (XmlError) iterator.next();
+ System.out.println("XML Error - " + xmlError.getMessage() + " at\n" + xmlError.getCursorLocation().xmlText());
+ }
+
+ }
+ return valid;
+ }
+ }
+
+
+ /**
+ * For Testing jira issue 84
+ */
+ public static class XPathThread extends TestThread
+ {
+ public XPathThread()
+ {
+ super();
+ }
+
+ public void run()
+ {
+
+ try {
+ for (int i = 0; i < ITERATION_COUNT; i++) {
+ switch (i % 2) {
+ case 0:
+ runStatusXPath();
+ break;
+ case 1:
+ runDocXPath();
+ break;
+ default:
+ System.out.println("Val: " + i);
+ break;
+ }
+
+ }
+ _result = true;
+
+ } catch (Throwable t) {
+ _throwable = t;
+ t.printStackTrace();
+ }
+ }
+
+ public void runStatusXPath()
+ {
+ try {
+ System.out.println("Testing Status");
+ String statusDoc = "<statusreport xmlns=\"http://openuri.org/enumtest\">\n" +
+ " <status name=\"first\" target=\"all\">all</status>\n" +
+ " <status name=\"second\" target=\"all\">few</status>\n" +
+ " <status name=\"third\" target=\"none\">most</status>\n" +
+ " <status name=\"first\" target=\"none\">none</status>\n" +
+ "</statusreport>";
+ XmlObject path = XmlObject.Factory.parse(statusDoc, xm);
+ XmlObject[] resSet = path.selectPath("//*:status");
+ Assert.assertTrue(resSet.length + "", resSet.length == 4);
+ resSet = path.selectPath("//*:status[@name='first']");
+ Assert.assertTrue(resSet.length == 2);
+
+ } catch (Throwable t) {
+ _throwable = t;
+ t.printStackTrace();
+ }
+ }
+
+ public void runDocXPath()
+ {
+ try {
+ System.out.println("Testing Doc");
+ String docDoc = "<?xml version=\"1.0\"?>\n" +
+ "<doc xmlns:ext=\"http://somebody.elses.extension\">\n" +
+ " <a test=\"test\" />\n" +
+ " <b attr1=\"a1\" attr2=\"a2\" \n" +
+ " xmlns:java=\"http://xml.apache.org/xslt/java\">\n" +
+ " <a>\n" +
+ " </a> \n" +
+ " </b>\n" +
+ "</doc><!-- --> ";
+ XmlObject path = XmlObject.Factory.parse(docDoc, xm);
+ XmlObject[] resSet = path.selectPath("//a");
+ Assert.assertTrue(resSet.length == 2);
+ resSet = path.selectPath("//b[@attr2]");
+ Assert.assertTrue(resSet.length == 1);
+
+ } catch (Throwable t) {
+ _throwable = t;
+ t.printStackTrace();
+ }
+ }
+ }
+
+ public static abstract class TestThread extends Thread
+ {
+ protected Throwable _throwable;
+ protected boolean _result;
+ protected XmlOptions xm;
+ protected ArrayList errors;
+
+ public TestThread()
+ {
+ xm = new XmlOptions();
+ ArrayList errors = new ArrayList();
+ xm.setErrorListener(errors);
+ xm.setValidateOnSet();
+ }
+
+ public Throwable getException()
+ {
+ return _throwable;
+ }
+
+ public boolean getResult()
+ {
+ return _result;
+ }
+
+
+ }
+
+
+}
Added: xmlbeans/trunk/test/src/misc/detailed/JiraRegression1_50Test.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/src/misc/detailed/JiraRegression1_50Test.java?view=auto&rev=156710
==============================================================================
--- xmlbeans/trunk/test/src/misc/detailed/JiraRegression1_50Test.java (added)
+++ xmlbeans/trunk/test/src/misc/detailed/JiraRegression1_50Test.java Wed Mar 9 15:20:56 2005
@@ -0,0 +1,618 @@
+/* Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package misc.detailed;
+
+import misc.common.JiraTestBase;
+
+import java.io.*;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Collections;
+
+import org.apache.xmlbeans.*;
+import org.apache.xmlbeans.impl.tool.SchemaCompiler;
+import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType;
+import org.xmlsoap.schemas.ws.x2004.x08.addressing.ReferencePropertiesType;
+import junit.framework.Assert;
+import xmlbeans06.Area;
+import xmlbeans06.StateProvince;
+
+import javax.xml.namespace.QName;
+
+import xmlbeans48.FeedInfoType;
+
+/**
+ *
+ */
+public class JiraRegression1_50Test extends JiraTestBase {
+
+ public JiraRegression1_50Test(String name) {
+ super(name);
+ }
+
+ public void setUp() {
+
+ // directories for the SchemaCompiler.Parameter class members
+ if (schemaCompSrcDir == null) {
+ schemaCompSrcDir = new File(schemaCompOutputDirPath + P + "src");
+ if (!schemaCompSrcDir.exists()) {
+ schemaCompSrcDir.mkdirs();
+ }
+ }
+ //&& (!schemaCompSrcDir.exists()))
+ if (schemaCompClassesDir == null) {
+ schemaCompClassesDir = new File(schemaCompOutputDirPath + P + "classes");
+ if (!schemaCompClassesDir.exists()) {
+ schemaCompClassesDir.mkdirs();
+ }
+ }
+
+ if (schemaCompOutputDirFile == null) {
+ schemaCompOutputDirFile = new File(schemaCompOutputDirPath + P);
+ if (!schemaCompOutputDirFile.exists()) {
+ schemaCompOutputDirFile.mkdirs();
+ }
+ }
+ }
+
+ /*
+ * [XMLBEANS-2] Problem with XmlError.forObject(String,int,XmlObject)
+ */
+ public void test_jira_xmlbeans02() throws Exception {
+ StringBuffer xmlstringbuf = new StringBuffer("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
+ xmlstringbuf.append("<test>");
+ xmlstringbuf.append("<testchild attr=\"abcd\"> Jira02 </testchild>");
+ xmlstringbuf.append("</test>");
+
+ XmlObject myxmlobj = null;
+ List errors = new ArrayList();
+ XmlOptions options = new XmlOptions().setErrorListener(errors);
+ try {
+ myxmlobj = XmlObject.Factory.parse(xmlstringbuf.toString(), options);
+ XmlCursor cur = myxmlobj.newCursor();
+ XmlError xmlerr = XmlError.forObject("This is my custom error message", XmlError.SEVERITY_ERROR, myxmlobj);
+
+ // call an API on the cursor : verification of cursor not being disposed
+ System.out.println("Cursor Text Value: " + cur.getTextValue());
+
+ } catch (XmlException xme) {
+ if (!xme.getErrors().isEmpty()) {
+ for (Iterator itr = xme.getErrors().iterator(); itr.hasNext();) {
+ System.out.println("Parse Errors :" + itr.next());
+ }
+ }
+
+ } catch (NullPointerException npe) {
+ Assert.fail("test_jira_xmlbeans02() : Null Pointer Exception thrown !");
+ }
+
+ printOptionErrMsgs(errors);
+ }
+
+ /*
+ * [XMLBEANS-4] xs:decimal size greater than 18 results in uncompilable java code
+ *
+ */
+ public void test_jira_xmlbeans04() {
+ List errors = new ArrayList();
+
+ SchemaCompiler.Parameters params = new SchemaCompiler.Parameters();
+ params.setXsdFiles(new File[]{new File(scompTestFilesRoot + "xmlbeans_04.xsd_")});
+ params.setErrorListener(errors);
+ params.setSrcDir(schemaCompSrcDir);
+ params.setClassesDir(schemaCompClassesDir);
+
+ SchemaCompiler.compile(params);
+ if (printOptionErrMsgs(errors)) {
+ Assert.fail("test_jira_xmlbeans04() : Errors found when executing scomp");
+ }
+ }
+
+ /*
+ * [XMLBEANS-6] getter for enumeration array throws ArrayStoreException
+ *
+ */
+ public void test_jira_xmlbeans06() throws Exception {
+ // refer xsd : xmlbeans_06.xsd, xbeans06.jar from scomp
+ try {
+ Area area = Area.Factory.newInstance();
+ area.addState(StateProvince.OR);
+ area.addState(StateProvince.WA);
+ StateProvince.Enum[] enumStates = area.getStateArray();
+ for (int i = 0; i < enumStates.length; i++) {
+ System.out.println("State Elem enums are :" + enumStates[i]);
+ }
+ } catch (ArrayStoreException ae) {
+ ae.getMessage();
+ ae.printStackTrace();
+ Assert.fail("Array Store Exception thrown for repro of Bug Jira06. Not expected");
+ }
+ }
+
+ /*
+ * [XMLBEANS-8] NullPointerException @SchemaTypeImpl.setShortJavaName when using scomp
+ *
+ */
+ public void test_jira_xmlbeans08() {
+ // invoking scomp via 'testbuild ant directive resilts in NPE for these schemas (xmlbeans_08a.xsd, xmlbeans_08.xsd
+ /*Assert.fail("scomp fails with NPE. The Error is : " +
+ "scomp:\n" +
+ " [echo] Compiling D:\\SVNNEW\\xmlbeans\\trunk/build/test/schemas/xbean/misc using compiler from: org.apache.xmlbeans.impl.tool.SchemaCompiler\n" +
+ " [java] xmlbeans_08a.xsd:8: error: rcase-RecurseLax.2: Invalid Restriction. The following particles of the derived <choice> cannot be mapped to the base <choice>'s particles: <element name=\"metadata@http://www.w3.org/2001/10/synthesis\">\n" +
+ " [java] Exception in thread \"main\" java.lang.NullPointerException\n" +
+ " [java] \tat org.apache.xmlbeans.impl.schema.SchemaTypeImpl.setShortJavaName(SchemaTypeImpl.java:535)\n" +
+ " [java] \tat org.apache.xmlbeans.impl.schema.StscJavaizer.assignJavaAnonymousTypeNames(StscJavaizer.java:357)\n" +
+ " [java] \tat org.apache.xmlbeans.impl.schema.StscJavaizer.javaizeType(StscJavaizer.java:267)\n" +
+ " [java] \tat org.apache.xmlbeans.impl.schema.StscJavaizer.javaizeType(StscJavaizer.java:223)\n" +
+ " [java] \tat org.apache.xmlbeans.impl.schema.StscJavaizer.javaizeAllTypes(StscJavaizer.java:63)\n" +
+ " [java] \tat org.apache.xmlbeans.impl.schema.SchemaTypeSystemCompiler.compileImpl(SchemaTypeSystemCompiler.java:310)\n" +
+ " [java] \tat org.apache.xmlbeans.impl.schema.SchemaTypeSystemCompiler.compile(SchemaTypeSystemCompiler.java:181)\n" +
+ " [java] \tat org.apache.xmlbeans.impl.tool.SchemaCompiler.loadTypeSystem(SchemaCompiler.java:947)\n" +
+ " [java] \tat org.apache.xmlbeans.impl.tool.SchemaCompiler.compile(SchemaCompiler.java:1067)\n" +
+ " [java] \tat org.apache.xmlbeans.impl.tool.SchemaCompiler.main(SchemaCompiler.java:367)\n" +
+ " [echo] jar.file: D:\\SVNNEW\\xmlbeans\\trunk/build/test/lib/schemajars/misc.jar");
+ */
+
+ List errors = new ArrayList();
+
+ SchemaCompiler.Parameters params = new SchemaCompiler.Parameters();
+ params.setXsdFiles(new File[]{new File(scompTestFilesRoot + "xmlbeans_08a.xsd_")});
+ params.setErrorListener(errors);
+ params.setSrcDir(schemaCompSrcDir);
+ params.setClassesDir(schemaCompClassesDir);
+
+ try {
+ SchemaCompiler.compile(params);
+ } catch (NullPointerException npe) {
+ if (!errors.isEmpty()) {
+ for (Iterator itr = errors.iterator(); itr.hasNext();) {
+ System.out.println("scomp errors: " + itr.next());
+ }
+ }
+
+ Assert.fail("test_jira_xmlbeans08() :Null Pointer Exception thrown with above errors!");
+ }
+
+ }
+
+ /*
+ * [XMLBEANS-9] Null Pointer Exception when running validate from cmd line
+ *
+ */
+ public void test_jira_xmlbeans09() throws Exception {
+ // Exec validate script from cmd line - Refer xmlbeans_09.xsd, xmlbeans_09.xml
+
+ StringBuffer sb = new StringBuffer(" ");
+ sb.append(System.getProperty("xbean.rootdir") + P + "bin" + P + "validate.cmd ");
+ sb.append(scompTestFilesRoot + "xmlbeans_09.xsd_" + " " + scompTestFilesRoot + "xmlbeans_09.xml");
+ Process validator_proc = null;
+ try {
+ validator_proc = Runtime.getRuntime().exec(sb.toString());
+ } catch (NullPointerException npe) {
+ Assert.fail("test_jira_xmlbeans09() : Null Pointer Exception when running validate for schema");
+ }
+
+ System.out.println("cmd:" + sb);
+ BufferedInputStream inbuf = new BufferedInputStream(validator_proc.getInputStream());
+ BufferedReader reader = new BufferedReader(new InputStreamReader(inbuf));
+ String eachline = reader.readLine();
+ try {
+
+ while (reader.readLine() != null) {
+ System.out.println("output: " + eachline);
+ }
+ } catch (IOException ioe) {
+ ioe.getMessage();
+ ioe.printStackTrace();
+ }
+
+ }
+
+ /*
+ * [XMLBEANS-11]: Calling getUnionMemberTypes() on SchemaType for non-union types results in NullPointerException
+ * status : fixed
+ */
+ public void test_jira_xmlbeans11() throws Exception {
+
+ StringBuffer xsdAsString = new StringBuffer("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
+ xsdAsString.append(" <!-- W3C Schema generated by XML Spy v4.3 U (http://www.xmlspy.com)\n");
+ xsdAsString.append(" --> \n");
+ xsdAsString.append(" <xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\">\n");
+ xsdAsString.append(" <xs:simpleType name=\"restrictsString\">\n");
+ xsdAsString.append(" <xs:restriction base=\"xs:string\">\n");
+ xsdAsString.append(" <xs:length value=\"10\" /> \n");
+ xsdAsString.append(" </xs:restriction>\n");
+ xsdAsString.append(" </xs:simpleType>\n");
+ xsdAsString.append(" </xs:schema>");
+
+ // load schema file as SchemaDocument XmlObject
+ SchemaDocument sd = SchemaDocument.Factory.parse(xsdAsString.toString());
+
+ // compile loaded XmlObject
+ SchemaTypeSystem sts = XmlBeans.compileXsd((XmlObject[]) Collections.singletonList(sd).toArray(new XmlObject[]{}),
+ XmlBeans.getContextTypeLoader(),
+ new XmlOptions());
+ sts.resolve();
+
+ SchemaType[] st = sts.globalTypes();
+
+ System.out.println("NUMBER OF GLOBAL TYPES: " + st.length);
+
+ try {
+ for (int i = 0; i < st.length; i++)
+ // check if it is union type
+ {
+ System.out.println("IS UNION TYPE: " + (st[i].getUnionMemberTypes() != null));
+ }
+ } catch (NullPointerException npe) {
+ Assert.fail("test_jira_xmlbeans11(): Null Pointer Exception thrown !");
+ }
+
+ }
+
+ /*
+ * [XMLBEANS-14]: newDomNode() throws NullPointerException
+ *
+ */
+ public void test_jira_xmlbeans14() throws Exception {
+ /*
+ <?xml version="1.0" encoding="UTF-8"?>
+ <xml-fragment><some:SomeName1 xmlns:some="Some uri">SomeValue1</some:SomeName1><some:SomeName xmlns:some="Some uri">Some
+ Value</some:SomeName></xml-fragment>Exception in thread "main" java.lang.NullPointerException
+ at org.apache.xmlbeans.impl.store.Saver$DomSaver.emitContainer(Saver.java:4514)
+ at org.apache.xmlbeans.impl.store.Saver.processContainer(Saver.java:775)
+ at org.apache.xmlbeans.impl.store.Saver.process(Saver.java:518)
+ at org.apache.xmlbeans.impl.store.Saver$DomSaver.exportDom(Saver.java:4461)
+ at org.apache.xmlbeans.impl.store.Cursor.newDomNode(Cursor.java:2954)
+ at org.apache.xmlbeans.impl.values.XmlObjectBase.newDomNode(XmlObjectBase.java:154)
+ at org.apache.xmlbeans.impl.values.XmlObjectBase.newDomNode(XmlObjectBase.java:151)
+ at MyClass.getNode(MyClass.java:27)
+ at MyClass.main(MyClass.java:44)
+ */
+
+ // the wsdl schema http://schemas.xmlsoap.org/ws/2004/08/addressing is compiled into xmlbeans_14.jar
+ EndpointReferenceType lEndPointXmlBeanObject = EndpointReferenceType.Factory.newInstance();
+ ReferencePropertiesType m_TargetObject = lEndPointXmlBeanObject.addNewReferenceProperties();
+
+ // add element
+ XmlCursor xCursor = m_TargetObject.newCursor();
+ xCursor.toFirstContentToken();
+ xCursor.insertElementWithText(new QName("Some uri", "SomeName"), "SomeValue");
+ xCursor.insertElementWithText(new QName("Some uri", "SomeName1"), "SomeValue1");
+ xCursor.dispose();
+
+ // debug
+ m_TargetObject.save(System.out);
+
+ // throws npe in v1
+ try {
+ m_TargetObject.newDomNode();
+ } catch (NullPointerException npe) {
+ Assert.fail("test_jira_xmlbeans14() : Null Pointer Exception when create Dom Node");
+ }
+
+ }
+
+
+ /*
+ * [XMLBEANS-16]: newDomNode creates a DOM with empty strings for namespace URIs for unprefixed
+ * attributes (rather than null)
+ * status : fails with crimson and not with Xerces
+ */
+ public void test_jira_xmlbeans16() throws Exception {
+ StringBuffer sb = new StringBuffer(100);
+ sb.append("<?xml version='1.0'?>\n");
+ sb.append("<test noprefix='nonamespace' \n");
+ sb.append(" ns:prefix='namespace' \n");
+ sb.append(" xmlns:ns='http://xml.apache.org/xmlbeans'>value</test>");
+
+ // Parse it using XMLBeans
+ XmlObject xdoc = XmlObject.Factory.parse(sb.toString());
+
+ // Convert to a DOM Element
+ Element firstChild = (Element) xdoc.newDomNode().getFirstChild();
+
+ // We expect to find a null namespace for the first attribute and 'ns' for the second
+ NamedNodeMap attributes = firstChild.getAttributes();
+ System.out.println("Prefix for attr noprefix is:" + attributes.getNamedItem("noprefix").getPrefix() + ":");
+ assertNull("Expected null namespace for attribute noprefix", attributes.getNamedItem("noprefix").getPrefix());
+ assertEquals("Wrong namespace for attribute prefix", "ns", attributes.getNamedItem("ns:prefix").getPrefix());
+
+ // We should be able to lookup 'prefix' by specifying the appropriate URI
+ String prefix = firstChild.getAttributeNS("http://xml.apache.org/xmlbeans", "prefix");
+ assertEquals("Wrong value for prefixed attribute", "namespace", prefix);
+
+ // And 'noprefix' by specifying a null namespace URI
+ String noprefix = firstChild.getAttributeNS(null, "noprefix");
+ assertEquals("Wrong value for unprefixed attribute", "nonamespace", noprefix); // This assertion fails under Crimson
+
+ }
+
+ /*
+ * [XMLBEANS-33]: insertions occur in improper order when subclassing schema types
+ *
+ */
+ public void test_jira_xmlbeans33() throws Exception {
+
+ xbeansJira33B.SubjectType subject =
+ xbeansJira33B.SubjectType.Factory.newInstance();
+ subject.addNewIDPProvidedNameIdentifier();
+ subject.addNewSubjectConfirmation().addConfirmationMethod("foo");
+ subject.addNewNameIdentifier();
+ XmlOptions options = new XmlOptions();
+ ArrayList list = new ArrayList();
+ options.setErrorListener(list);
+
+ boolean bResult = subject.validate(options);
+ System.out.println(bResult ? "valid" : "invalid");
+
+ // print out errors
+ for (int i = 0; i < list.size(); i++) {
+ System.out.println("Validation Error : " + list.get(i));
+ }
+ Assert.assertTrue("Validation Failed, should pass", bResult);
+
+ }
+
+ /*
+ * [XMLBEANS-34]: error compiling classes when using a schema with a redefined subelement
+ *
+ */
+ public void test_jira_xmlbeans34() throws Exception {
+ List errors = new ArrayList();
+
+ SchemaCompiler.Parameters params = new SchemaCompiler.Parameters();
+ params.setXsdFiles(new File[]{new File(scompTestFilesRoot + "xmlbeans_34b.xsd_")});
+ params.setErrorListener(errors);
+ params.setSrcDir(schemaCompSrcDir);
+ params.setClassesDir(schemaCompClassesDir);
+ params.setDownload(true);
+ params.setNoPvr(true);
+
+ SchemaCompiler.compile(params);
+ if (printOptionErrMsgs(errors)) {
+ Assert.fail("test_jira_xmlbeans34() : Errors found when executing scomp");
+ }
+
+ }
+
+ /*
+ * [XMLBEANS-35]: OutOfMemoryError with this schema : Circular reference to Model Groups
+ *
+ */
+ public void test_jira_xmlbeans35() {
+ XmlOptions options = new XmlOptions();
+ List errors = new ArrayList();
+ options.setErrorListener(errors);
+
+ try {
+ XmlObject xobjs [] = new XmlObject[]{compileXsdFile(scompTestFilesRoot + "xmlbeans_35.xsd_")};
+
+ SchemaTypeSystem sts = XmlBeans.compileXsd(xobjs, null, options);
+
+ sts.saveToDirectory(schemaCompOutputDirFile);
+ } catch (XmlException xme) {
+ if (!errors.isEmpty()) {
+ for (Iterator itr = errors.iterator(); itr.hasNext();) {
+ System.out.println("scomp errors: ");
+ }
+ }
+
+ }
+
+ if (printOptionErrMsgs(errors)) {
+ Assert.fail("test_jira_xmlbeans34() : Errors found when executing scomp");
+ }
+
+ Assert.fail("Fails due to Out of Memory");
+ }
+
+
+
+ /**
+ * BUGBUG: [XMLBEANS-38]
+ * [XMLBEANS-38] Does not support xs:key (keyRef NoIllegalEntries)
+ */
+ public void test_jira_xmlbeans38() throws Exception {
+ String keyrefXSD = "<?xml version=\"1.0\"?>" +
+ "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
+ "<xsd:element name=\"supermarket\">" +
+ "<xsd:complexType>" +
+ "<xsd:sequence> " +
+ "<xsd:element name=\"aisle\" maxOccurs=\"unbounded\"> \n" +
+ "<xsd:complexType> " +
+ "<xsd:sequence>" +
+ "<xsd:element name=\"item\" maxOccurs=\"unbounded\"> \n" +
+ "<xsd:complexType> " +
+ "<xsd:simpleContent>" +
+ "<xsd:extension base=\"xsd:string\"> \n" +
+ "<xsd:attribute name=\"code\" type=\"xsd:positiveInteger\"/> \n" +
+ "<xsd:attribute name=\"quantity\" type=\"xsd:positiveInteger\"/> \n" +
+ "<xsd:attribute name=\"price\" type=\"xsd:decimal\"/> \n" +
+ "</xsd:extension> \n" +
+ "</xsd:simpleContent> \n" +
+ "</xsd:complexType> \n" +
+ "</xsd:element> \n" +
+ "</xsd:sequence> \n" + //"<!-- Attribute Of Aisle --> \n" +
+ "<xsd:attribute name=\"name\" type=\"xsd:string\"/> \n" +
+ "<xsd:attribute name=\"number\" type=\"xsd:positiveInteger\"/> \n" + //"<!-- Of Aisle --> \n" +
+ "</xsd:complexType> \n" +
+ "<xsd:keyref name=\"NoIllegalEntries\" refer=\"itemKey\"> \n" +
+ "<xsd:selector xpath=\"item\"/> \n" +
+ "<xsd:field xpath=\"@code\"/> \n" +
+ "</xsd:keyref> \n" +
+ "</xsd:element> \n" +
+ "<xsd:element name=\"items\"> \n" +
+ "<xsd:complexType> \n" +
+ "<xsd:sequence> \n" +
+ "<xsd:element name=\"item\" maxOccurs=\"unbounded\"> \n" +
+ "<xsd:complexType> \n" +
+ "<xsd:simpleContent> \n" +
+ "<xsd:extension base=\"xsd:string\"> \n" +
+ "<xsd:attribute name=\"code\" type=\"xsd:positiveInteger\"/> \n" +
+ "</xsd:extension> \n" +
+ "</xsd:simpleContent> \n" +
+ "</xsd:complexType> \n" +
+ "</xsd:element> \n" +
+ "</xsd:sequence> \n" +
+ "</xsd:complexType> \n" +
+ "</xsd:element> \n" +
+ "</xsd:sequence> \n" +
+ "<xsd:attribute name=\"name\" type=\"xsd:string\"/> \n" +
+ "</xsd:complexType> \n" +
+ "<xsd:key name=\"itemKey\"> \n" +
+ "<xsd:selector xpath=\"items/item\"/> \n" +
+ "<xsd:field xpath=\"@code\"/> \n" +
+ "</xsd:key> \n" +
+ "</xsd:element> \n" +
+ "</xsd:schema>";
+
+
+ String keyRefInstance = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n" +
+ "<supermarket xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"C:\\tmp\\Supermarket.xsd\" name=\"String\"> \n" +
+ "<aisle name=\"String\" number=\"2\"> \n" +
+ "<item code=\"1234\" quantity=\"2\" price=\"3.1415926535897932384626433832795\">String</item> \n" +
+ "</aisle> \n" +
+ "<items> \n" +
+ "<item code=\"1234\">Java</item> \n" +
+ "</items> \n" +
+ "</supermarket>";
+
+ validateInstance(new String[]{keyrefXSD}, new String[]{keyRefInstance}, null);
+ }
+
+
+ /**
+ * Loads the class at runtime and inspects for appropriate methods
+ * Statically using methods (class.getGeneration()) would stop build
+ * if the bug resurfaced.
+ * <p/>
+ * [XMLBEANS-45] <xsd:redefine> tag is not supported
+ */
+ public void test_jira_XmlBeans45() throws Exception {
+ //this class is built during the build.schemas target
+ Class cls = Class.forName("xmlbeans45.PersonName");
+ //check for methods in class
+ //getGeneration()
+ if (cls.getMethod("getGeneration", null) == null)
+ throw new Exception("getGeneration() was not found in class");
+ //getTitle()
+ if (cls.getMethod("getTitle", null) == null)
+ throw new Exception("getTitle() was not found in class");
+ //getForenameArray()
+ if (cls.getMethod("getForenameArray", null) == null)
+ throw new Exception("getForenameArray() was not found in class");
+
+ }
+
+ /**
+ * Could not Repro this
+ * [XMLBEANS-46] Regex validation fails in multi-threaded, multi-processor environment
+ */
+ public void test_jira_XmlBeans46() throws Exception {
+ RegexThread[] threads = new RegexThread[45];
+
+ for (int i = 0; i < threads.length; i++) {
+ threads[i] = new RegexThread();
+ System.out.println("Thread[" + i + "]-starting ");
+ threads[i].start();
+ }
+
+ Thread.sleep(6000);
+ System.out.println("Done with RegEx Threading Test...");
+
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < threads.length; i++) {
+ if (threads[i].getException() != null)
+ sb.append(threads[i].getException().getMessage() + "\n");
+ }
+
+ if (sb.length() > 0)
+ throw new Exception("Threaded Regex Validation Failed\n" + sb.toString());
+ }
+
+
+ /**
+ * Incorrect XML
+ * [XMLBEANS-48] Bug with Root.fetch ( Splay parent, QName name, QNameSet set, int n )
+ */
+ public void test_jira_XmlBeans48() throws Exception {
+ String incorrectXml = "<sch:Feed xmlns:sch=\"http://xmlbeans_48\">" +
+ "<sch:Feed>" +
+ "<sch:Location>http://xmlbeans.apache.org</sch:Location>" +
+ "<sch:TimeEntered>2004-08-11T15:50:23.064-04:00</sch:TimeEntered>" +
+ "</sch:Feed>" +
+ "</sch:Feed>";
+
+ xmlbeans48.FeedDocument feedDoc = (xmlbeans48.FeedDocument) XmlObject.Factory.parse(incorrectXml);
+ FeedInfoType feedInfoType = feedDoc.getFeed();
+ String location = feedInfoType.getLocation();
+ System.out.println("Location: " + location);
+ if (location != null)
+ throw new Exception("Location value should not have been populated");
+
+ String correctXml = "<sch:Feed xmlns:sch=\"http://xmlbeans_48\">" +
+ "<sch:Location>http://xmlbeans.apache.org</sch:Location>" +
+ "<sch:TimeEntered>2004-08-11T15:50:23.064-04:00</sch:TimeEntered>" +
+ "</sch:Feed>";
+
+ feedDoc = (xmlbeans48.FeedDocument) XmlObject.Factory.parse(correctXml);
+ feedInfoType = feedDoc.getFeed();
+ location = feedInfoType.getLocation();
+ System.out.println("Location: " + location);
+ if (location == null)
+ throw new Exception("Location value should have been populated");
+ }
+
+ /*
+ * [XMLBEANS-49]: Schema compiler won't compile portlet.xsd from jsr168/pluto
+ *
+ */
+ public void test_jira_xmlbeans49() {
+ List errors = new ArrayList();
+ SchemaCompiler.Parameters params = new SchemaCompiler.Parameters();
+ params.setXsdFiles(new File[]{new File(scompTestFilesRoot + "xmlbeans_49.xsd_")});
+ params.setErrorListener(errors);
+ params.setSrcDir(schemaCompSrcDir);
+ params.setClassesDir(schemaCompClassesDir);
+
+ // needs network downloads enabled
+ params.setDownload(true);
+
+ try {
+ SchemaCompiler.compile(params);
+ } catch (Exception ex) {
+ if (!errors.isEmpty()) {
+ for (Iterator itr = errors.iterator(); itr.hasNext();) {
+ System.out.println("scomp errors: ");
+ }
+ }
+
+ Assert.fail("test_jira_xmlbeans49() :Exception thrown with above errors!");
+ }
+
+ // view errors
+ if (printOptionErrMsgs(errors)) {
+ Assert.fail("test_jira_xmlbeans49() : Errors found when executing scomp");
+ }
+ }
+
+
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org