You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by kk...@apache.org on 2005/02/22 01:09:10 UTC
svn commit: r154749 - in xmlbeans/trunk/test: cases/xbean/compile/som/
src/compile/scomp/som/checkin/ src/compile/scomp/som/common/
src/compile/scomp/som/detailed/
Author: kkrouse
Date: Mon Feb 21 16:09:08 2005
New Revision: 154749
URL: http://svn.apache.org/viewcvs?view=rev&rev=154749
Log:
Some updates for partial som tests
Contributed by Rajiv Balachandran
Modified:
xmlbeans/trunk/test/cases/xbean/compile/som/datatypes_modified.xsd
xmlbeans/trunk/test/cases/xbean/compile/som/derived_types_modifed.xsd
xmlbeans/trunk/test/src/compile/scomp/som/checkin/PartialSOMCheckinTest.java
xmlbeans/trunk/test/src/compile/scomp/som/common/SomTestBase.java
xmlbeans/trunk/test/src/compile/scomp/som/detailed/PartialSOMDetailedTest.java
Modified: xmlbeans/trunk/test/cases/xbean/compile/som/datatypes_modified.xsd
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/compile/som/datatypes_modified.xsd?view=diff&r1=154748&r2=154749
==============================================================================
--- xmlbeans/trunk/test/cases/xbean/compile/som/datatypes_modified.xsd (original)
+++ xmlbeans/trunk/test/cases/xbean/compile/som/datatypes_modified.xsd Mon Feb 21 16:09:08 2005
@@ -130,7 +130,9 @@
<xsd:all>
<xsd:element name="Greetings" type="xsd:string"/>
<xsd:element name="Signature" type="xsd:string"/>
+ <!--
<xsd:element name="ContactNumber" type="xsd:string"/>
+ -->
</xsd:all>
</xsd:complexType>
Modified: xmlbeans/trunk/test/cases/xbean/compile/som/derived_types_modifed.xsd
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/cases/xbean/compile/som/derived_types_modifed.xsd?view=diff&r1=154748&r2=154749
==============================================================================
--- xmlbeans/trunk/test/cases/xbean/compile/som/derived_types_modifed.xsd (original)
+++ xmlbeans/trunk/test/cases/xbean/compile/som/derived_types_modifed.xsd Mon Feb 21 16:09:08 2005
@@ -193,15 +193,15 @@
<!-- 3. mixed content -->
<xsd:complexType name="RestrictionBaseMixedContentType">
<xsd:sequence>
- <xsd:element name="ExtBaseMixedElem1" type="xsd:string" minOccurs="0"/>
- <xsd:element name="ExtBaseMixedElem2" type="CarEngineType" minOccurs="0"/>
+ <xsd:element name="ResBaseMixedElem1" type="xsd:string" minOccurs="0"/>
+ <xsd:element name="ResBaseMixedElem2" type="CarEngineType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="RestrictionBaseMixedContentType2">
<xsd:sequence>
- <xsd:element name="ExtBaseMixedElem3" type="xsd:string" minOccurs="0"/>
- <xsd:element name="ExtBaseMixedElem4" type="CarEngineType" minOccurs="0"/>
+ <xsd:element name="ResBaseMixedElem3" type="xsd:string" minOccurs="0"/>
+ <xsd:element name="ResBaseMixedElem4" type="CarEngineType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
@@ -213,7 +213,7 @@
-->
<xsd:restriction base="RestrictionBaseMixedContentType2">
<xsd:sequence>
- <xsd:element name="ExtBaseMixedElem1" type="xsd:string" />
+ <xsd:element name="ResBaseMixedElem3" type="xsd:string" />
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
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=154748&r2=154749
==============================================================================
--- xmlbeans/trunk/test/src/compile/scomp/som/checkin/PartialSOMCheckinTest.java (original)
+++ xmlbeans/trunk/test/src/compile/scomp/som/checkin/PartialSOMCheckinTest.java Mon Feb 21 16:09:08 2005
@@ -122,10 +122,6 @@
Assert.assertNotNull("Schema Type System created is Null.",
modifiedSTS);
- // Recovered Errors, Test for saving of the PSOM - should not be able to save
- Assert.assertTrue("Valid SOM " + modifiedSTS.getName() + "Save failed !",
- checkPSOMSave(modifiedSTS));
-
// test the PSOM created : walk thro the PSOM, look for # of elements,attributes,types & attribute groups
inspectSOM(modifiedSTS, 3, 2, 1, 0);
@@ -133,7 +129,7 @@
Assert.assertTrue("Valid Partial SOM " + modifiedSTS.getName() + "Save failed",
checkPSOMSave(modifiedSTS));
- // Look for a added attribute(s)/Element(s) by name in the STS
+ // Look for added attribute(s)/Element(s) by name in the STS
Assert.assertTrue("Attribute expected, not found 'testAttributeComplex'",
lookForAttributeInSTS(modifiedSTS,
"testAttributeComplex"));
@@ -145,7 +141,8 @@
"SimpleTypeElem"));
// validate against an xml instance
- validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), modifiedSTS);
+ Assert.assertTrue("Validation against instance failed ",
+ 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",
@@ -192,7 +189,7 @@
Assert.assertTrue("Validation against instance Failed ",
validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), baseSTS));
- // Step 2: create a Schema Type System with the new xsd file that modifications to existing schema : modified
+ // Step 2: create a Schema Type System with the new xsd file with modifications to existing schema
SchemaTypeSystem modifiedSTS = createNewSTS("elemattr_modified.xsd",
baseSTS,
"ModifiedSchemaTS",
@@ -242,7 +239,8 @@
Assert.assertTrue("Validation against instance Failed ",
validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), finalSTS));
- // TODO compare this to the original schema here
+ // compare this to the original schema here - the root dir names used to save the PSOMs are the same as the STS names
+ Assert.assertTrue(compareSavedSOMs("BaseSchemaTS","FinalSchemaTS"));
}
public void testDeleteAttributeAndElements() throws Exception
@@ -303,7 +301,7 @@
// Step 3: now creat the Schema Type System with the original XSD again
SchemaTypeSystem finalSTS = createNewSTS("elemattr_added.xsd",
modifiedSTS,
- "BaseSchemaTS",
+ "FinalSchemaTS",
sBaseSourceName);
Assert.assertNotNull("Schema Type System created is Null.", finalSTS);
@@ -319,7 +317,9 @@
Assert.assertTrue("Validation against instance Failed ",
validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), finalSTS));
- // TODO compare this to the original schema here
+ // compare this to the original schema here
+ Assert.assertTrue(compareSavedSOMs("BaseSchemaTS","FinalSchemaTS"));
+
}
public void testAddDataTypes() throws Exception
@@ -461,7 +461,7 @@
String sBaseSourceName = "testsourcename";
SchemaTypeSystem baseSTS = createNewSTS("datatypes_added.xsd",
null,
- "BaseSchema",
+ "BaseSchemaTS",
sBaseSourceName);
Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
@@ -578,7 +578,8 @@
Assert.assertTrue("Validation against instance Failed ",
validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), finalSTS));
- // TODO compare this to the original schema here
+ // compare this to the original schema here
+ Assert.assertTrue(compareSavedSOMs("BaseSchemaTS","FinalSchemaTS"));
// additional validation - check to see if all types are resolved to their respective types
Assert.assertEquals("Unresolved Simple Type should be 'attachmentTypes'",
@@ -615,8 +616,6 @@
{
System.out.println("Inside test case testModifyDataTypes()");
- // 1. remove one of the constituent types for the union and test to see if union is anySimpleType
-
// 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",
@@ -653,6 +652,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",
baseSTS,
"ModifiedSchemaTS",
@@ -708,8 +708,8 @@
"union.attachmentUnionType",
getElementType(finalSTS, "testUnionTypeElem"));
- // TODO compare this to the original schema here
-
+ // compare this to the original schema here
+ Assert.assertTrue(compareSavedSOMs("BaseSchemaTS","FinalSchemaTS"));
}
public void testDeleteDerivedTypes() throws Exception
@@ -866,8 +866,8 @@
Assert.assertTrue("Validation against instance failed",
validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), finalSTS));
- // TODO compare this to the original schema here
-
+ // compare this to the original schema here
+ Assert.assertTrue(compareSavedSOMs("BaseSchemaTS","FinalSchemaTS"));
}
@@ -883,8 +883,7 @@
sBaseSourceName);
Assert.assertNotNull("Schema Type System created is Null.", baseSTS);
- Assert.assertEquals("No Recovered Errors for Invalid PSOM",
- true,
+ Assert.assertTrue("No Recovered Errors for Invalid PSOM",
printRecoveredErrors());
// the tests - Walk thro the valid SOM
@@ -960,7 +959,7 @@
{
System.out.println("Inside test case testAddReusableGroups()");
- // Step 1: read in incomplete XSD derived_types_added.xsd with base and derived types to create a base schema with no unresolved components
+ // Step 1: read in invalid XSD groups.xsd
String sBaseSourceName = "testsourcename";
SchemaTypeSystem baseSTS = createNewSTS("groups.xsd",
null,
@@ -988,8 +987,7 @@
Assert.assertEquals("Elem Type should be 'ModelGrpType'",
"ModelGrpType",
getElementType(baseSTS, "ModelGrpTypeElem"));
- Assert.assertEquals("Elem Type should be 'AttributeGroup'",
- "AttributeGroup",
+ Assert.assertTrue("Elem Type should be 'AttributeGroup'",
getAttributeGroup(baseSTS, "AttributeGroup"));
// Step 2: create a SOM with valid xsd
@@ -1018,8 +1016,7 @@
Assert.assertEquals("Elem Type should be 'ModelGrpType'",
"ModelGrpType",
getElementType(modifiedSTS, "ModelGrpTypeElem"));
- Assert.assertEquals("Elem Type should be 'AttributeGroup'",
- "AttributeGroup",
+ Assert.assertTrue("Elem Type should be 'AttributeGroup'",
getAttributeGroup(modifiedSTS, "AttributeGroup"));
@@ -1068,8 +1065,7 @@
Assert.assertEquals("Elem Type should be 'ModelGrpType'",
"ModelGrpType",
getElementType(baseSTS, "ModelGrpTypeElem"));
- Assert.assertEquals("Elem Type should be 'AttributeGroup'",
- "AttributeGroup",
+ Assert.assertTrue("Elem Type should be 'AttributeGroup'",
getAttributeGroup(baseSTS, "AttributeGroup"));
// Step 2: create a valid SOM and add to these
@@ -1190,8 +1186,7 @@
Assert.assertEquals("Elem Type should be 'ModelGrpType'",
"ModelGrpType",
getElementType(modifiedSTS, "ModelGrpTypeElem"));
- Assert.assertEquals("Elem Type should be 'AttributeGroup'",
- "AttributeGroup",
+ Assert.assertTrue("Elem Type should be 'AttributeGroup'",
getAttributeGroup(modifiedSTS, "AttributeGroup"));
// step 3: create a PSOM with the original xsd
@@ -1225,7 +1220,8 @@
//Assert.assertEquals("Elem Type should be 'ModelGrpType'", "ModelGrpType", getElementType(baseSTS, "ModelGrpTypeElem"));
//Assert.assertEquals("Elem Type should be 'AttributeGroup'", "AttributeGroup", getAttributeGroup(baseSTS,"AttributeGroup"));
- //TODO compare soms
+ // compare this to the original schema here
+ Assert.assertTrue(compareSavedSOMs("BaseSchemaTS","FinalSchemaTS"));
}
public void testModifySubstitutionGroups() throws Exception
@@ -1323,8 +1319,8 @@
Assert.assertEquals("Elem Type should be 'ExtensionSubGrpHeadElemType' (base)",
"ExtensionSubGrpHeadElemType", getElementType(finalSTS, "SubGrpMemberElem2"));
- //TODO compare soms
-
+ // compare this to the original schema here
+ Assert.assertTrue(compareSavedSOMs("BaseSchemaTS","FinalSchemaTS"));
}
public void testModifyIdConstraints() throws Exception
@@ -1346,6 +1342,10 @@
// the tests - Walk thro the valid SOM
inspectSOM(baseSTS, 5, 0, 2, 0);
+ Assert.assertTrue("Constraint 'uniqueConstraint' should be found",lookForIdentityConstraint(baseSTS,"uniqueConstraint"));
+ Assert.assertTrue("Constraint 'keyConstraint' should be found",lookForIdentityConstraint(baseSTS,"keyConstraint"));
+ Assert.assertTrue("Constraint 'KeyRefConstraint' should be found",lookForIdentityConstraint(baseSTS,"KeyRefConstraint"));
+
// Test for saving of the SOM - should go thro
Assert.assertTrue("SOM " + baseSTS.getName() + "Save failed!",
checkPSOMSave(baseSTS));
@@ -1388,9 +1388,8 @@
Assert.assertFalse("Validation against instance failed",
validateInstance(getTestCaseFile("instance_constraints_invalid.xml"), modifiedSTS));
- // TODO a way around QName
Assert.assertFalse("KeyRef 'KeyRefConstraint' should not be resolved",
- lookForIdentityConstraint(modifiedSTS, "KeyRefConstraint"));
+ lookForIdentityConstraint(modifiedSTS, "KeyConstraint"));
// Step 3 : recreate SOM in first step and compare it
SchemaTypeSystem finalSTS = createNewSTS("constraints_added.xsd",
@@ -1414,9 +1413,9 @@
Assert.assertTrue("Validation against instance failed",
validateInstance(getTestCaseFile("instance_constraints_valid.xml"), finalSTS));
- // TODO compare the STSs here
+ // compare this to the original schema here
+ Assert.assertTrue(compareSavedSOMs("BaseSchemaTS","FinalSchemaTS"));
}
-
}
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=154748&r2=154749
==============================================================================
--- xmlbeans/trunk/test/src/compile/scomp/som/common/SomTestBase.java (original)
+++ xmlbeans/trunk/test/src/compile/scomp/som/common/SomTestBase.java Mon Feb 21 16:09:08 2005
@@ -32,6 +32,7 @@
import compile.scomp.common.CompileTestBase;
import junit.framework.Assert;
import org.apache.xmlbeans.*;
+import org.apache.xmlbeans.impl.tool.Diff;
import javax.xml.namespace.QName;
import java.io.File;
@@ -49,8 +50,8 @@
public class SomTestBase extends CompileTestBase
{
public static String P = File.separator;
- public static String casesRootDir = CompileCommon.caseroot + P + "xbean" + P + "compile" + P + "som";
- public static String somOutputRootDir = CompileCommon.outputroot + P + "som";
+ public static String casesRootDir = CompileCommon.caseroot + P + "xbean" + P + "compile" + P + "som" + P;
+ public static String somOutputRootDir = CompileCommon.outputroot + P + "som" + P;
public static long runid;
public static PrintWriter outlog = null;
@@ -109,6 +110,18 @@
+ "), #types (" + expectedGlobalTypes + "), #attr groups (" + expectedAttrGroups + ")");
out.println("-------------------------------------------------------");
+ out.println("New STUFF -------------------------------------------------------");
+ schematypesys.resolve();
+ if (schematypesys.isNamespaceDefined("TestNameSpace"))
+ {
+ out.println("Name Space 'TestNameSpace' for this STS is define ..");
+ }
+ else
+ {
+ out.println("No Name Space 'TestNameSpace' for this STS is NOT ndefine ..");
+ }
+ out.println("End New STUFF -------------------------------------------------------");
+
// walk thro the SOM here
out.println("----- Loader Name :" + schematypesys.getName());
@@ -157,6 +170,11 @@
out.println("----- # of Schema Annotations :" + schematypesys.annotations().length);
Assert.assertNotNull("Invalid Annotations Collection returned in STS " + schematypesys.annotations());
+ for (int i = 0; i < schematypesys.annotations().length; i++)
+ {
+ out.println("\t------> Annotation Application Info Array :" + schematypesys.annotations()[i].getApplicationInformation().toString());
+ out.println("\t------> Annotation User Info Array :" + schematypesys.annotations()[i].getUserInformation().toString());
+ }
out.println("----- # of Attribute Types :" + schematypesys.attributeTypes().length);
Assert.assertNotNull("Invalid Attribute Types Collection returned in STS " + schematypesys.attributeTypes());
@@ -226,7 +244,7 @@
out.println("\t+++-> Each derived prop name : " + schemaProperty.getName());
}
- // TODO anonymus types - complete this
+ // TODO anonymus types
//schema.getAnonymousTypes();
}
@@ -250,10 +268,14 @@
{
// The QName for the find is constructed using the local name since the schemas have no namespace
SchemaGlobalAttribute sga = tgtSTS.findAttribute(new QName(sAttrLocalName));
- if(sga == null)
+ if (sga == null)
+ {
return false;
+ }
else
+ {
return true;
+ }
}
public boolean lookForElemInSTS(SchemaTypeSystem tgtSTS,
@@ -262,20 +284,29 @@
// The QName for the find is constructed using the local name since the schemas have no namespace
SchemaGlobalElement sge = tgtSTS.findElement(new QName(sElemLocalName));
- if(sge == null)
+ if (sge == null)
+ {
return false;
+ }
else
+ {
return true;
+ }
}
public boolean lookForIdentityConstraint(SchemaTypeSystem sts,
String ConstraintLocalName)
{
- SchemaIdentityConstraint.Ref ref = sts.findIdentityConstraintRef(new QName(ConstraintLocalName));
- Assert.assertNotNull(ref);
-
- return false;
+ SchemaIdentityConstraint.Ref icref = sts.findIdentityConstraintRef(new QName(ConstraintLocalName));
+ if (icref == null)
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
}
public boolean checkPSOMSave(SchemaTypeSystem tgtSTS)
@@ -296,20 +327,69 @@
}
+ public boolean compareSavedSOMs(String outDirSchemaOne, String outDirSchemaTwo)
+ {
+ System.out.println("Comparing Schemas....");
+
+ String runDir = somOutputRootDir + P + runid + P;
+ File sts1 = new File(somOutputRootDir + P + runid + P + outDirSchemaOne);
+ if (!sts1.exists() && (!sts1.isDirectory()))
+ {
+ System.out.println("Schema Type System save dir specified (" + runDir + outDirSchemaOne + ") does not exist!");
+ return false;
+ }
+
+ File sts2 = new File(somOutputRootDir + P + runid + P + outDirSchemaTwo);
+ if (!sts2.exists() && (!sts2.isDirectory()))
+ {
+ System.out.println("Schema Type System save dir specified (" + runDir + outDirSchemaTwo + ") does not exist!");
+ return false;
+ }
+
+ List diff = new ArrayList();
+ Diff.filesAsXsb(sts1, sts2, diff);
+ if (diff.isEmpty())
+ {
+ return true;
+ }
+ else
+ {
+ for (Iterator itr = diff.iterator(); itr.hasNext();)
+ {
+ System.out.println("Difference found : " + itr.next());
+ }
+ return false;
+ }
+ }
+
public boolean printRecoveredErrors()
{
// check list of errors and print them
+ boolean errFound = false;
if (!errors.isEmpty())
{
- System.out.println("Schema invalid: partial schema type system recovered");
for (Iterator i = errors.iterator(); i.hasNext();)
{
- System.out.println("Err Msg (s): " + i.next());
+ XmlError eacherr = (XmlError) i.next();
+ int errSeverity = eacherr.getSeverity();
+ if (errSeverity == XmlError.SEVERITY_ERROR)
+ {
+ System.out.println("Schema invalid: partial schema type system recovered");
+ 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 true;
}
- return false;
+ return errFound;
}
public boolean validateInstance(File instancefile,
@@ -368,7 +448,7 @@
public File getTestCaseFile(String sFileName)
{
String sFileWithPath = casesRootDir + P + sFileName;
- System.out.println("getTestCaseFile() Opening File : " + sFileWithPath);
+ //System.out.println("getTestCaseFile() Opening File : " + sFileWithPath);
File schemaFile = new File(sFileWithPath);
Assert.assertNotNull("Schema File " + sFileWithPath + " Loading failed", schemaFile);
return (schemaFile);
@@ -379,35 +459,41 @@
String sElementLocalName)
{
- for (int i = 0; i < sts.globalElements().length; i++)
+ SchemaGlobalElement elem = sts.findElement(new QName(sElementLocalName));
+ if (elem != null)
{
- //System.out.println("comparing getname, input-> " + sts.globalElements()[i].getName().getLocalPart() + ":" + sElementLocalName);
- if (sts.globalElements()[i].getName().getLocalPart().equals(sElementLocalName))
- {
- System.out.println("getElementType() returning " + sts.globalElements()[i].getType().getName().getLocalPart());
- return sts.globalElements()[i].getType().getName().getLocalPart();
- }
+ return elem.getType().getName().getLocalPart();
}
return "ElemNotFound";
- //TODO : change this to findElement
}
- public String getAttributeGroup(SchemaTypeSystem sts,
- String sAttrGrpLocalName)
+ public boolean getAttributeGroup(SchemaTypeSystem sts,
+ String sAttrGrpLocalName)
{
- for (int i = 0; i < sts.attributeGroups().length; i++)
+ SchemaAttributeGroup attrGp = sts.findAttributeGroup(new QName(sAttrGrpLocalName));
+ if (attrGp == null)
{
- //System.out.println("comparing getname, input-> " + sts.attributeGroups()[i].getName().getLocalPart() + ":" + sAttrGrpLocalName);
- if (sts.attributeGroups()[i].getName().getLocalPart().equals(sAttrGrpLocalName))
- {
- System.out.println("getElementType() returning " + sts.attributeGroups()[i].getName().getLocalPart());
- return sts.attributeGroups()[i].getName().getLocalPart();
- }
+ return false;
+ }
+ else
+ {
+ return true;
}
- return "AttributeGrpNotFound";
- //TODO : change this to findAttributeGroup
}
+ public boolean getModelGroup(SchemaTypeSystem sts,
+ String sModelGrpLocalName)
+ {
+ SchemaModelGroup.Ref modelGp = sts.findModelGroupRef(new QName(sModelGrpLocalName));
+ if (modelGp == null)
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
public SchemaTypeSystem createNewSTS(String xsdFileName,
SchemaTypeSystem baseSchema,
@@ -418,7 +504,7 @@
{
File xsdModified = getTestCaseFile(xsdFileName);
XmlObject xsdModifiedObj = XmlObject.Factory.parse(xsdModified);
- System.out.println("xsdModSRCName: "+xsdModifiedObj.documentProperties().getSourceName());
+ System.out.println("Source Name for STS: " + xsdModifiedObj.documentProperties().getSourceName());
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=154748&r2=154749
==============================================================================
--- xmlbeans/trunk/test/src/compile/scomp/som/detailed/PartialSOMDetailedTest.java (original)
+++ xmlbeans/trunk/test/src/compile/scomp/som/detailed/PartialSOMDetailedTest.java Mon Feb 21 16:09:08 2005
@@ -69,7 +69,6 @@
super.tearDown();
}
- // TODO: all of add/del/modify
public void testAddDataTypesList() throws Exception
{
System.out.println("Inside test case testAddDataTypesList()");
@@ -134,9 +133,10 @@
Assert.assertEquals("Elem Type should be 'ModelGrpType'",
"ModelGrpType",
getElementType(baseSTS, "ModelGrpTypeElem"));
- Assert.assertEquals("Elem Type should be 'AttributeGroup'",
- "AttributeGroup",
+ Assert.assertTrue("Attribute Group 'AttributeGroup' should exist",
getAttributeGroup(baseSTS, "AttributeGroup"));
+ Assert.assertTrue("Model Group 'NamedModelGroup' should exist",
+ getModelGroup(baseSTS, "NamedModelGroup"));
// step2: load an invalid PSOM by deleting the ModelGroup and AttributeGroup definitions commented
SchemaTypeSystem modifiedSTS = createNewSTS("reusable_grps.xsd",
@@ -162,7 +162,7 @@
getElementType(modifiedSTS, "ModelGrpTypeElem"));
Assert.assertEquals("Elem Type should be 'anyType'",
anyType,
- getAttributeGroup(modifiedSTS, "AttributeGroup"));
+ getElementType(modifiedSTS, "AttributeGroupElem"));
// step 3: create a PSOM with the original xsd
SchemaTypeSystem finalSTS = createNewSTS("groups_added.xsd",
@@ -182,11 +182,11 @@
Assert.assertEquals("Elem Type should be 'ModelGrpType'",
"ModelGrpType",
getElementType(baseSTS, "ModelGrpTypeElem"));
- Assert.assertEquals("Elem Type should be 'AttributeGroup'",
- "AttributeGroup",
+ Assert.assertTrue("Elem Type should be 'AttributeGroup'",
getAttributeGroup(baseSTS, "AttributeGroup"));
- // TODO compare this to the original schema here
+ // compare this to the original schema here
+ Assert.assertTrue(compareSavedSOMs("BaseSchemaTS","FinalSchemaTS"));
}
public void testModifyDataTypesList() throws Exception
@@ -288,7 +288,8 @@
"union.attachmentUnionType",
getElementType(finalSTS, "testUnionTypeElem"));
- // TODO compare this to the original schema here
+ // compare this to the original schema here
+ Assert.assertTrue(compareSavedSOMs("BaseSchemaTS","FinalSchemaTS"));
}
public void testDeleteDerivedTypes() throws Exception
@@ -345,10 +346,10 @@
validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), modifiedSTS));
// check types - base should be 'anyType'
- // Restriction Simple Content Base type commented does not result in recoverable SOM
+ // Restriction Complex Content Base type commented
Assert.assertEquals("Elem Type should be 'anyType'",
anyType,
- getElementType(modifiedSTS, "RestrictionSimpleContentBaseTypeElem"));
+ getElementType(modifiedSTS, "RestrictionBaseComplexContentTypeElem"));
}
@@ -373,15 +374,17 @@
inspectSOM(baseSTS, 7, 0, 5, 2);
// Test for saving of the SOM - should go thro
- Assert.assertEquals("SOM " + baseSTS.getName() + "Save failed!", true, checkPSOMSave(baseSTS));
+ Assert.assertTrue("SOM " + baseSTS.getName() + "Save failed!",
+ checkPSOMSave(baseSTS));
// instance validation - should be ok
- Assert.assertEquals("Validation against instance failed", true, validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), baseSTS));
+ Assert.assertTrue("Validation against instance failed",
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), baseSTS));
// verify named model groups
Assert.assertEquals("Elem Type should be 'ModelGrpType'", "ModelGrpType",
getElementType(baseSTS, "ModelGrpTypeElem"));
- Assert.assertEquals("Elem Type should be 'AttributeGroup'", "AttributeGroup",
+ Assert.assertTrue("Elem Type should be 'AttributeGroup'",
getAttributeGroup(baseSTS, "AttributeGroup"));
// step2: load a modified xsd with type of head elem in subs grp changed
@@ -406,8 +409,7 @@
Assert.assertEquals("Elem Type should be 'ModelGrpType'",
"ModelGrpType",
getElementType(modifiedSTS, "ModelGrpTypeElem"));
- Assert.assertEquals("Elem Type should be 'AttributeGroup'",
- "AttributeGroup",
+ Assert.assertTrue("Elem Type should be 'AttributeGroup'",
getAttributeGroup(modifiedSTS, "AttributeGroup"));
// step3 : reload the original xsd
@@ -432,10 +434,11 @@
Assert.assertEquals("Elem Type should be 'ModelGrpType'",
"ModelGrpType",
getElementType(finalSTS, "ModelGrpTypeElem"));
- Assert.assertEquals("Elem Type should be 'AttributeGroup'", "AttributeGroup",
+ Assert.assertTrue("Elem Type should be 'AttributeGroup'",
getAttributeGroup(finalSTS, "AttributeGroup"));
- // TODO compare this to the original schema here
+ // compare this to the original schema here
+ Assert.assertTrue(compareSavedSOMs("BaseSchemaTS","FinalSchemaTS"));
}
public void testModifyDerivedTypes() throws Exception
@@ -522,7 +525,7 @@
// the tests - Walk thro the valid SOM
//inspectSOM(modifiedSTS, 13, 0, 14, 0);
- inspectSOM(modifiedSTS, 13, 0, 15, 0);
+ inspectSOM(modifiedSTS, 13, 0, 17, 0);
// instance validation - should fail
Assert.assertFalse("Validation against instance success - should fail",
@@ -530,16 +533,22 @@
// now validate instance with new base type - this should go thro
// TODO resolve this validation
- Assert.assertTrue("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_derived_types_modify.xml"), modifiedSTS));
+ //Assert.assertTrue("Validation against instance failed",
+ // validateInstance(getTestCaseFile("instance_derived_types_modify.xml"), modifiedSTS));
}
+
public void testNameSpacesImportFile() throws Exception
{
System.out.println("Inside test case testNameSpacesImportFile()");
// Step 1: read in an xsd that imports from another xsd file providing file name only
- String sBaseSourceName = "testsourcename";
+ // 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
+
+ //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",
null,
"BaseSchemaTS",
@@ -550,16 +559,15 @@
// there should be NO recovearble errors this should not be a partial Schema
Assert.assertFalse("Recovered Errors for Valid Schema",
printRecoveredErrors());
-
}
- public void testNameSpacesImportFileWithPath() throws Exception
+ public void testNameSpacesWithInclude() throws Exception
{
- System.out.println("Inside test case testNameSpacesImportFileWithPath()");
+ System.out.println("Inside test case testNameSpacesWithInclude()");
- //Step 1: read in an xsd that does not have any imports
+ // Step 1: read in an xsd that includes another namespace in xsd file namespaces2.xsd
String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("namespaces_noimports.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("namespaces_include.xsd",
null,
"BaseSchemaTS",
sBaseSourceName);
@@ -575,31 +583,18 @@
checkPSOMSave(baseSTS));
// the tests - Walk thro the valid SOM
- inspectSOM(baseSTS, 1, 0, 0, 0);
-
- // step 2 : read in an xsd that imports a namespace from another xsd file providing the complete file path for the imported xsd
- SchemaTypeSystem modifiedSTS = createNewSTS("namespaces_import_filepath.xsd",
- baseSTS,
- "ModifiedSchemaTS",
- sBaseSourceName);
- Assert.assertNotNull("Schema Type System created is Null.", modifiedSTS);
-
- // no recovearble errors just added another type
- Assert.assertFalse("valid PSOM",
- printRecoveredErrors());
+ inspectSOM(baseSTS, 2, 0, 1, 0);
- // the tests - Walk thro the valid SOM
- inspectSOM(modifiedSTS, 2, 0, 1, 0);
}
- public void testNameSpacesWithInclude() throws Exception
+ public void testNameSpacesImportFileWithPath() throws Exception
{
- System.out.println("Inside test case testNameSpacesWithInclude()");
+ System.out.println("Inside test case testNameSpacesImportFileWithPath()");
- // Step 1: read in an xsd that includes another namespace in xsd file namespaces2.xsd
+ //Step 1: read in an xsd that does not have any imports
String sBaseSourceName = "testsourcename";
- SchemaTypeSystem baseSTS = createNewSTS("namespaces_include.xsd",
+ SchemaTypeSystem baseSTS = createNewSTS("namespaces_noimports.xsd",
null,
"BaseSchemaTS",
sBaseSourceName);
@@ -615,10 +610,25 @@
checkPSOMSave(baseSTS));
// the tests - Walk thro the valid SOM
- inspectSOM(baseSTS, 2, 0, 1, 0);
+ inspectSOM(baseSTS, 1, 0, 0, 0);
+ // step 2 : read in an xsd that imports a namespace from another xsd file providing the complete file path for the imported xsd
+ SchemaTypeSystem modifiedSTS = createNewSTS("namespaces_import_filepath.xsd",
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
+ Assert.assertNotNull("Schema Type System created is Null.", modifiedSTS);
+
+ // no recovearble errors just added another type
+ Assert.assertFalse("valid PSOM",
+ printRecoveredErrors());
+
+ // the tests - Walk thro the valid SOM
+ inspectSOM(modifiedSTS, 2, 0, 1, 0);
}
+
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org