You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2021/06/29 22:01:46 UTC
svn commit: r1891149 [2/3] - in
/xmlbeans/trunk/src/test/java/compile/scomp/som:
checkin/PartialSOMCheckinTest.java common/SomTestBase.java
detailed/PartialSOMDetailedTest.java
Modified: xmlbeans/trunk/src/test/java/compile/scomp/som/checkin/PartialSOMCheckinTest.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/test/java/compile/scomp/som/checkin/PartialSOMCheckinTest.java?rev=1891149&r1=1891148&r2=1891149&view=diff
==============================================================================
--- xmlbeans/trunk/src/test/java/compile/scomp/som/checkin/PartialSOMCheckinTest.java (original)
+++ xmlbeans/trunk/src/test/java/compile/scomp/som/checkin/PartialSOMCheckinTest.java Tue Jun 29 22:01:46 2021
@@ -18,6 +18,7 @@ package compile.scomp.som.checkin;
import compile.scomp.som.common.SomTestBase;
import org.apache.xmlbeans.SchemaTypeSystem;
import org.apache.xmlbeans.XmlBeans;
+import org.apache.xmlbeans.XmlError;
import org.apache.xmlbeans.XmlOptions;
import org.junit.After;
import org.junit.Before;
@@ -26,24 +27,21 @@ import org.junit.Test;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
import static org.junit.Assert.*;
-public class PartialSOMCheckinTest extends SomTestBase
-{
+public class PartialSOMCheckinTest extends SomTestBase {
@Before
- public void setUp()
- {
+ public void setUp() {
// initialize the built in schema type
builtin = XmlBeans.getBuiltinTypeSystem();
// populate the XmlOptions
- if (errors == null)
- {
- errors = new ArrayList();
+ if (errors == null) {
+ errors = new ArrayList<>();
}
- if (options == null)
- {
+ if (options == null) {
options = (new XmlOptions()).setErrorListener(errors);
options.setCompileDownloadUrls();
options.setCompilePartialTypesystem();
@@ -60,88 +58,89 @@ public class PartialSOMCheckinTest exten
}
@After
- public void tearDown()
- {
+ public void tearDown() {
errors.clear();
}
@Test
- public void testAddAttributeAndElements() throws Exception
- {
+ public void testAddAttributeAndElements() throws Exception {
System.out.println("Inside test case testAddAttributeAndElements()");
// 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_",
- null,
- "BaseSchemaTS",
- sBaseSourceName);
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.",
- baseSTS);
+ baseSTS);
// the tests - Walk thro the SOM, save, validate against an xml instance
inspectSOM(baseSTS, 1, 1, 1, 0);
// test for recoverable errors
assertTrue("No Recovered Errors for Invalid Schema",
- printRecoveredErrors());
+ printRecoveredErrors());
// Test for saving of the PSOM - should not be able to save
assertFalse("Partial SOM " + baseSTS.getName() + "Save successful - should fail!",
- checkPSOMSave(baseSTS));
+ checkPSOMSave(baseSTS));
// instance validation - should fail
+ List<XmlError> errList = new ArrayList<>();
assertFalse("Validation against instance Success - should fail ",
- validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), baseSTS));
+ validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), baseSTS, errList));
+ assertEquals(3, errList.size());
+ assertTrue(errList.get(0).toString().contains("instance_elemattr_valid.xml:20:36: error: cvc-complex-type.3.2.1: Attribute not allowed (no wildcards allowed): testAttributeComplex in element TestRoot"));
// additional validation
assertFalse("Attribute found but not expected - 'testAttributeComplex'",
- lookForAttributeInSTS(baseSTS,
- "testAttributeComplex"));
+ lookForAttributeInSTS(baseSTS,
+ "testAttributeComplex"));
assertFalse("Element found but not expected 'ComplexTypeElem'",
- lookForElemInSTS(baseSTS,
- "ComplexTypeElem"));
+ lookForElemInSTS(baseSTS,
+ "ComplexTypeElem"));
assertFalse("Element found but not expected 'SimpleTypeElem'",
- lookForElemInSTS(baseSTS, "SimpleTypeElem"));
+ lookForElemInSTS(baseSTS, "SimpleTypeElem"));
// Step 2: create a Schema Type System with the new xsd file that has additions to this schema
SchemaTypeSystem modifiedSTS = createNewSTS("elemattr_added.xsd_",
- baseSTS,
- "ModifiedSchemaTS",
- sBaseSourceName);
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.",
- modifiedSTS);
+ modifiedSTS);
// test the PSOM created : walk thro the PSOM, look for # of elements,attributes,types & attribute groups
inspectSOM(modifiedSTS, 3, 2, 1, 0);
// Test for successful saving of the PSOM
assertTrue("Valid Partial SOM " + modifiedSTS.getName() + "Save failed",
- checkPSOMSave(modifiedSTS));
+ checkPSOMSave(modifiedSTS));
// Look for added attribute(s)/Element(s) by name in the STS
assertTrue("Attribute expected, not found 'testAttributeComplex'",
- lookForAttributeInSTS(modifiedSTS,
+ lookForAttributeInSTS(modifiedSTS,
"testAttributeComplex"));
assertTrue("Element expected, not found 'ComplexTypeElem'",
- lookForElemInSTS(modifiedSTS,
+ lookForElemInSTS(modifiedSTS,
"ComplexTypeElem"));
assertTrue("Element expected, not found 'SimpleTypeElem'",
- lookForElemInSTS(modifiedSTS,
- "SimpleTypeElem"));
+ lookForElemInSTS(modifiedSTS,
+ "SimpleTypeElem"));
// validate against an xml instance
assertTrue("Validation against instance failed ",
- validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), modifiedSTS));
+ 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_",
- modifiedSTS,
- "FinalSchemaTS",
- sBaseSourceName);
+ modifiedSTS,
+ "FinalSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", finalSTS);
@@ -150,25 +149,24 @@ public class PartialSOMCheckinTest exten
// Test for saving of the PSOM - should not be able to save
assertFalse("Partial SOM " + finalSTS.getName() + "Save successful - should fail!",
- checkPSOMSave(finalSTS));
+ checkPSOMSave(finalSTS));
// instance validation - should fail
assertFalse("Validation against instance Success - should fail ",
- validateInstance(getTestCaseFile("instance_elemattr.xml"), finalSTS));
+ validateInstance(getTestCaseFile("instance_elemattr.xml"), finalSTS));
}
@Test
- public void testModifyAttributeAndElements() throws Exception
- {
+ public void testModifyAttributeAndElements() throws Exception {
System.out.println("Inside test case testModifyAttributeAndElements()");
// 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_",
- null,
- "BaseSchemaTS",
- sBaseSourceName);
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", baseSTS);
@@ -177,48 +175,48 @@ public class PartialSOMCheckinTest exten
// validate successful save
assertTrue("Valid SOM " + baseSTS.getName() + "Save failed ",
- checkPSOMSave(baseSTS));
+ checkPSOMSave(baseSTS));
// validate against instance successfully
assertTrue("Validation against instance Failed ",
- validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), baseSTS));
+ 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_",
- baseSTS,
- "ModifiedSchemaTS",
- sBaseSourceName);
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", modifiedSTS);
// test for recoverable errors
assertTrue("No Recovered Errors for Invalid Schema",
- printRecoveredErrors());
+ printRecoveredErrors());
// test the PSOM created
inspectSOM(modifiedSTS, 2, 2, 1, 0); // walk thro the PSOM, look for # of elements,attributes,types & attribute groups
// Look for a modified attribute(s)/elements by name in the STS
assertTrue("Attribute expected, not found 'testAttributeComplex'",
- lookForAttributeInSTS(modifiedSTS, "testAttributeComplex"));
+ lookForAttributeInSTS(modifiedSTS, "testAttributeComplex"));
assertTrue("Element expected, not found 'ComplexTypeElem'",
- lookForElemInSTS(modifiedSTS, "ComplexTypeElem"));
+ lookForElemInSTS(modifiedSTS, "ComplexTypeElem"));
assertFalse("Element expected, not found 'SimpleTypeElem'",
- lookForElemInSTS(modifiedSTS, "SimpleTypeElem"));
+ lookForElemInSTS(modifiedSTS, "SimpleTypeElem"));
// Test for saving of the PSOM - should not be able to save
assertFalse("Partial SOM " + modifiedSTS.getName() + " Save successful- should fail",
- checkPSOMSave(modifiedSTS));
+ checkPSOMSave(modifiedSTS));
// validate against an xml instance - should fail
assertFalse("Validation against instance Success - should Fail",
- validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), modifiedSTS));
+ 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_",
- modifiedSTS,
- "FinalSchemaTS",
- sBaseSourceName);
+ modifiedSTS,
+ "FinalSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", finalSTS);
@@ -227,27 +225,26 @@ public class PartialSOMCheckinTest exten
// should be able to save as its a valid SOM
assertTrue("Partial SOM " + finalSTS.getName() + "Save failed for complete SOM",
- checkPSOMSave(finalSTS));
+ checkPSOMSave(finalSTS));
// validate against instance successfully
assertTrue("Validation against instance Failed ",
- validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), finalSTS));
+ validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), finalSTS));
// compare this to the original schema here - the root dir names used to save the PSOMs are the same as the STS names
- assertTrue(compareSavedSOMs("BaseSchemaTS","FinalSchemaTS"));
+ assertTrue(compareSavedSOMs("BaseSchemaTS", "FinalSchemaTS"));
}
@Test
- public void testDeleteAttributeAndElements() throws Exception
- {
+ public void testDeleteAttributeAndElements() throws Exception {
System.out.println("Inside test case testDeleteAttributeAndElements()");
// 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_",
- null,
- "BaseSchemaTS",
- sBaseSourceName);
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", baseSTS);
@@ -256,48 +253,48 @@ public class PartialSOMCheckinTest exten
// validate successful save
assertTrue("Valid SOM " + baseSTS.getName() + "Save failed ",
- checkPSOMSave(baseSTS));
+ checkPSOMSave(baseSTS));
// validate against instance successfully
assertTrue("Validation against instance Failed ",
- validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), baseSTS));
+ 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_",
- baseSTS,
- "ModifiedSchemaTS",
- sBaseSourceName);
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", modifiedSTS);
// test for recoverable errors
assertTrue("No Recovered Errors for Invalid Schema",
- printRecoveredErrors());
+ printRecoveredErrors());
// test the PSOM created
inspectSOM(modifiedSTS, 1, 1, 1, 0); // walk thro the PSOM, look for # of elements,attributes,types & attribute groups
// Test for saving of the PSOM - should not be able to save
assertFalse("Invalid PSOM " + modifiedSTS.getName() + " Save successful - Should fail",
- checkPSOMSave(modifiedSTS));
+ checkPSOMSave(modifiedSTS));
// verify types
assertFalse("Attribute found but not expected - 'testAttributeComplex'",
- lookForAttributeInSTS(modifiedSTS, "testAttributeComplex"));
+ lookForAttributeInSTS(modifiedSTS, "testAttributeComplex"));
assertFalse("Element found but not expected 'ComplexTypeElem'",
- lookForElemInSTS(modifiedSTS, "ComplexTypeElem"));
+ lookForElemInSTS(modifiedSTS, "ComplexTypeElem"));
assertFalse("Element found but not expected 'SimpleTypeElem'",
- lookForElemInSTS(modifiedSTS, "SimpleTypeElem"));
+ lookForElemInSTS(modifiedSTS, "SimpleTypeElem"));
// validate against an xml instance - should fail
assertFalse("Validation against success - should Fail ",
- validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), modifiedSTS));
+ 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_",
- modifiedSTS,
- "FinalSchemaTS",
- sBaseSourceName);
+ modifiedSTS,
+ "FinalSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", finalSTS);
@@ -306,74 +303,73 @@ public class PartialSOMCheckinTest exten
// should be able to save as its a valid SOM
assertTrue("Partial SOM " + finalSTS.getName() + "Save failed for complete SOM",
- checkPSOMSave(finalSTS));
+ checkPSOMSave(finalSTS));
// validate against instance
assertTrue("Validation against instance Failed ",
- validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), finalSTS));
+ validateInstance(getTestCaseFile("instance_elemattr_valid.xml"), finalSTS));
// compare this to the original schema here
- assertTrue(compareSavedSOMs("BaseSchemaTS","FinalSchemaTS"));
+ assertTrue(compareSavedSOMs("BaseSchemaTS", "FinalSchemaTS"));
}
@Test
- public void testAddDataTypes() throws Exception
- {
+ public void testAddDataTypes() throws Exception {
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_",
- null,
- "BaseSchemaTS",
- sBaseSourceName);
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", baseSTS);
// recovearble errors should exist
assertTrue("No Recovered Errors for Invalid Schema",
- printRecoveredErrors());
+ printRecoveredErrors());
// Walk thro the SOM (pass #Elems, #Attr, #Types, #AttrGroups)
inspectSOM(baseSTS, 12, 1, 4, 1);
// Test for saving of the PSOM - should not be able to save
assertFalse("Partial SOM " + baseSTS.getName() + "Save successful - should fail!",
- checkPSOMSave(baseSTS));
+ checkPSOMSave(baseSTS));
// instance validation - should fail
assertFalse("Validation against instance Success - should fail ",
- validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), baseSTS));
+ validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), baseSTS));
// additional validation - check to see if the unresolved references to types are 'anyType'
// validate unresolved types
assertEquals("Unresolved Simple Type should be 'anyType'",
- anyType,
- getElementType(baseSTS, "testAtomicTypeElem"));
+ anyType,
+ getElementType(baseSTS, "testAtomicTypeElem"));
assertEquals("Unresolved Simple Type should be 'anyType'",
- anyType,
- getElementType(baseSTS, "testUnionTypeElem"));
+ anyType,
+ getElementType(baseSTS, "testUnionTypeElem"));
// moved to detailed PSOMDetailedTest class
//Assert.assertEquals("Unresolved List Type should be 'anySimpleType'", anySimpleType, getElementType(baseSTS, "testListTypeElem"));
assertEquals("Unresolved Complex Type should be 'anyType'",
- anyType,
- getElementType(baseSTS, "testComplexTypeSimpleContentElem"));
+ anyType,
+ getElementType(baseSTS, "testComplexTypeSimpleContentElem"));
assertEquals("Unresolved Complex Type should be 'anyType'",
- anyType,
- getElementType(baseSTS, "testComplexTypeElementOnlyContentElem"));
+ anyType,
+ getElementType(baseSTS, "testComplexTypeElementOnlyContentElem"));
assertEquals("Unresolved Complex Type should be 'anyType'",
- anyType,
- getElementType(baseSTS, "testComplexTypeMixedElem"));
+ anyType,
+ getElementType(baseSTS, "testComplexTypeMixedElem"));
assertEquals("Unresolved Complex Type should be 'anyType'",
- anyType,
- getElementType(baseSTS, "testComplexTypeEmptyElem"));
+ anyType,
+ getElementType(baseSTS, "testComplexTypeEmptyElem"));
assertEquals("Unresolved Complex Type should be 'anyType'",
- anyType,
- getElementType(baseSTS, "testChoiceGroupElem"));
+ anyType,
+ getElementType(baseSTS, "testChoiceGroupElem"));
assertEquals("Unresolved Complex Type should be 'anyType'",
- anyType,
- getElementType(baseSTS, "testAllGroupElem"));
+ anyType,
+ 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);
@@ -381,58 +377,58 @@ public class PartialSOMCheckinTest exten
// no errors expected to be recovered - should be a valid SOM
assertFalse("Valid Schema Type System, Errors recovered",
- printRecoveredErrors());
+ printRecoveredErrors());
// test the PSOM created : walk thro the PSOM, look for # of elements,attributes,types & attribute groups
inspectSOM(modifiedSTS, 13, 1, 15, 1);
// test successful save
assertTrue("Valid SOM " + modifiedSTS.getName() + " Save failed",
- checkPSOMSave(modifiedSTS));
+ checkPSOMSave(modifiedSTS));
// validate against an xml valid instance - should succeed
assertTrue("Validation against instance Failed ",
- validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), modifiedSTS));
+ validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), modifiedSTS));
// validate against an xml invalid instance - should fail
assertFalse("Validation against instance Failed ",
- validateInstance(getTestCaseFile("instance_simple_types_invalid.xml"), modifiedSTS));
+ validateInstance(getTestCaseFile("instance_simple_types_invalid.xml"), modifiedSTS));
// additional validation - check to see if all types are resolved to their respective types
assertEquals("Unresolved Simple Type should be 'attachmentTypes'",
- "attachmentTypes",
- getElementType(modifiedSTS, "testAtomicTypeElem"));
+ "attachmentTypes",
+ getElementType(modifiedSTS, "testAtomicTypeElem"));
assertEquals("Unresolved Simple Type should be 'union.attachmentUnionType'",
- "union.attachmentUnionType",
- getElementType(modifiedSTS, "testUnionTypeElem"));
+ "union.attachmentUnionType",
+ getElementType(modifiedSTS, "testUnionTypeElem"));
assertEquals("Unresolved List Type should be 'attchmentExtensionListTypes'",
- "attchmentExtensionListTypes",
- getElementType(modifiedSTS, "testListTypeElem"));
+ "attchmentExtensionListTypes",
+ getElementType(modifiedSTS, "testListTypeElem"));
assertEquals("Unresolved Complex Type should be 'headerType'",
- "headerType",
- getElementType(modifiedSTS, "testComplexTypeSimpleContentElem"));
+ "headerType",
+ getElementType(modifiedSTS, "testComplexTypeSimpleContentElem"));
assertEquals("Unresolved Complex Type should be 'mailsType'",
- "mailsType",
- getElementType(modifiedSTS, "testComplexTypeElementOnlyContentElem"));
+ "mailsType",
+ getElementType(modifiedSTS, "testComplexTypeElementOnlyContentElem"));
assertEquals("Unresolved Complex Type should be 'mixedContentType'",
- "mixedContentType",
- getElementType(modifiedSTS, "testComplexTypeMixedElem"));
+ "mixedContentType",
+ getElementType(modifiedSTS, "testComplexTypeMixedElem"));
assertEquals("Unresolved Complex Type should be 'emptyContentType'",
- "emptyContentType",
- getElementType(modifiedSTS, "testComplexTypeEmptyElem"));
+ "emptyContentType",
+ getElementType(modifiedSTS, "testComplexTypeEmptyElem"));
assertEquals("Unresolved Complex Type should be 'choiceGroupType'",
- "choiceGroupType",
- getElementType(modifiedSTS, "testChoiceGroupElem"));
+ "choiceGroupType",
+ getElementType(modifiedSTS, "testChoiceGroupElem"));
assertEquals("Unresolved Complex Type should be 'allGroupType'",
- "allGroupType",
- getElementType(modifiedSTS, "testAllGroupElem"));
+ "allGroupType",
+ getElementType(modifiedSTS, "testAllGroupElem"));
// Step 3 : create an incremental STS with the file in step 1
SchemaTypeSystem finalSTS = createNewSTS("datatypes.xsd_",
- modifiedSTS,
- "FinalSchemaTS",
- sBaseSourceName);
+ modifiedSTS,
+ "FinalSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", finalSTS);
@@ -441,125 +437,124 @@ public class PartialSOMCheckinTest exten
// test save failure
assertFalse("Partial SOM " + finalSTS.getName() + "Save Success ",
- checkPSOMSave(finalSTS));
+ checkPSOMSave(finalSTS));
// instance validation - should fail
assertFalse("Validation against instance Success - should fail ",
- validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), finalSTS));
+ validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), finalSTS));
}
@Test
- public void testDeleteDataTypes() throws Exception
- {
+ public void testDeleteDataTypes() throws Exception {
System.out.println("Inside test case testDeleteDataTypes()");
// Step 1: read a clean XSD file to get a valid SOM
String sBaseSourceName = "testsourcename";
SchemaTypeSystem baseSTS = createNewSTS("datatypes_added.xsd_",
- null,
- "BaseSchemaTS",
- sBaseSourceName);
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", baseSTS);
// there should be NO recovearble errors
- assertEquals("Recovered Errors for Valid Schema", false, printRecoveredErrors());
+ assertFalse("Recovered Errors for Valid Schema", printRecoveredErrors());
// the tests - Walk thro the SOM, save, validate against an xml instance
inspectSOM(baseSTS, 13, 1, 15, 1);
// Recovered Errors, Test for saving of the PSOM - should go thro
assertTrue("SOM " + baseSTS.getName() + "Save failed!",
- checkPSOMSave(baseSTS));
+ checkPSOMSave(baseSTS));
// instance validation - should be ok
assertTrue("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), baseSTS));
+ validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), baseSTS));
// additional validation - check to see if all types are resolved to their respective types
assertEquals("Unresolved Simple Type should be 'attachmentTypes'",
- "attachmentTypes",
- getElementType(baseSTS, "testAtomicTypeElem"));
+ "attachmentTypes",
+ getElementType(baseSTS, "testAtomicTypeElem"));
assertEquals("Unresolved Simple Type should be 'union.attachmentUnionType'",
- "union.attachmentUnionType",
- getElementType(baseSTS, "testUnionTypeElem"));
+ "union.attachmentUnionType",
+ getElementType(baseSTS, "testUnionTypeElem"));
assertEquals("Unresolved List Type should be 'attchmentExtensionListTypes'",
- "attchmentExtensionListTypes",
- getElementType(baseSTS, "testListTypeElem"));
+ "attchmentExtensionListTypes",
+ getElementType(baseSTS, "testListTypeElem"));
assertEquals("Unresolved Complex Type should be 'headerType'",
- "headerType",
- getElementType(baseSTS, "testComplexTypeSimpleContentElem"));
+ "headerType",
+ getElementType(baseSTS, "testComplexTypeSimpleContentElem"));
assertEquals("Unresolved Complex Type should be 'mailsType'",
- "mailsType",
- getElementType(baseSTS, "testComplexTypeElementOnlyContentElem"));
+ "mailsType",
+ getElementType(baseSTS, "testComplexTypeElementOnlyContentElem"));
assertEquals("Unresolved Complex Type should be 'mixedContentType'",
- "mixedContentType",
- getElementType(baseSTS, "testComplexTypeMixedElem"));
+ "mixedContentType",
+ getElementType(baseSTS, "testComplexTypeMixedElem"));
assertEquals("Unresolved Complex Type should be 'emptyContentType'",
- "emptyContentType",
- getElementType(baseSTS, "testComplexTypeEmptyElem"));
+ "emptyContentType",
+ getElementType(baseSTS, "testComplexTypeEmptyElem"));
assertEquals("Unresolved Complex Type should be 'choiceGroupType'",
- "choiceGroupType",
- getElementType(baseSTS, "testChoiceGroupElem"));
+ "choiceGroupType",
+ getElementType(baseSTS, "testChoiceGroupElem"));
assertEquals("Unresolved Complex Type should be 'allGroupType'",
- "allGroupType",
- getElementType(baseSTS, "testAllGroupElem"));
+ "allGroupType",
+ getElementType(baseSTS, "testAllGroupElem"));
//Step 2 : delete/remove types from the schema - should result in STS with unresolved refs
SchemaTypeSystem modifiedSTS = createNewSTS("datatypes.xsd_",
- baseSTS,
- "ModifiedSchemaTS",
- sBaseSourceName);
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", modifiedSTS);
// PSOM - recovered errors are expected
- assertEquals("Valid Schema Type System, Errors recovered", true, printRecoveredErrors());
+ assertTrue("Valid Schema Type System, Errors recovered", printRecoveredErrors());
// test the PSOM created : walk thro the PSOM, look for # of elements,attributes,types & attribute groups
inspectSOM(modifiedSTS, 12, 1, 4, 1);
// Test for saving of the PSOM - should not be able to save
assertFalse("PSOM " + modifiedSTS.getName() + " Save should fail",
- checkPSOMSave(modifiedSTS));
+ checkPSOMSave(modifiedSTS));
// validate unresolved types
assertEquals("Unresolved Simple Type should be 'anyType'",
- anyType,
- getElementType(modifiedSTS, "testAtomicTypeElem"));
+ anyType,
+ getElementType(modifiedSTS, "testAtomicTypeElem"));
assertEquals("Unresolved Simple Type should be 'anyType'",
- anyType,
- getElementType(modifiedSTS, "testUnionTypeElem"));
+ anyType,
+ getElementType(modifiedSTS, "testUnionTypeElem"));
// moved to detailed PSOMDetailedTest class
// Assert.assertEquals("Unresolved List Type should be 'anySimpleType'", anySimpleType, getElementType(modifiedSTS, "testListTypeElem"));
assertEquals("Unresolved Complex Type should be 'anyType'",
- anyType,
- getElementType(modifiedSTS, "testComplexTypeSimpleContentElem"));
+ anyType,
+ getElementType(modifiedSTS, "testComplexTypeSimpleContentElem"));
assertEquals("Unresolved Complex Type should be 'anyType'",
- anyType,
- getElementType(modifiedSTS, "testComplexTypeElementOnlyContentElem"));
+ anyType,
+ getElementType(modifiedSTS, "testComplexTypeElementOnlyContentElem"));
assertEquals("Unresolved Complex Type should be 'anyType'",
- anyType,
- getElementType(modifiedSTS, "testComplexTypeMixedElem"));
+ anyType,
+ getElementType(modifiedSTS, "testComplexTypeMixedElem"));
assertEquals("Unresolved Complex Type should be 'anyType'",
- anyType,
- getElementType(modifiedSTS, "testComplexTypeEmptyElem"));
+ anyType,
+ getElementType(modifiedSTS, "testComplexTypeEmptyElem"));
assertEquals("Unresolved Complex Type should be 'anyType'",
- anyType,
- getElementType(modifiedSTS, "testChoiceGroupElem"));
+ anyType,
+ getElementType(modifiedSTS, "testChoiceGroupElem"));
assertEquals("Unresolved Complex Type should be 'anyType'",
- anyType,
- getElementType(modifiedSTS, "testAllGroupElem"));
+ anyType,
+ getElementType(modifiedSTS, "testAllGroupElem"));
// validate against an xml valid instance - should fail
- assertEquals("Validation against instance should Failed ", false, validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), modifiedSTS));
+ assertFalse("Validation against instance should Failed ", validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), modifiedSTS));
// Step 3 : reaload the xsd in Step 1
SchemaTypeSystem finalSTS = createNewSTS("datatypes_added.xsd_",
- modifiedSTS,
- "FinalSchemaTS",
- sBaseSourceName);
+ modifiedSTS,
+ "FinalSchemaTS",
+ sBaseSourceName);
// should be able to save as its a valid SOM
assertNotNull("Schema Type System created is Null.", finalSTS);
@@ -569,92 +564,91 @@ public class PartialSOMCheckinTest exten
// should be able to save as its a valid SOM
assertTrue("SOM " + finalSTS.getName() + "Save failed",
- checkPSOMSave(finalSTS));
+ checkPSOMSave(finalSTS));
// instance validation - should be fine
assertTrue("Validation against instance Failed ",
- validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), finalSTS));
+ validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), finalSTS));
// compare this to the original schema here
- assertTrue(compareSavedSOMs("BaseSchemaTS","FinalSchemaTS"));
+ assertTrue(compareSavedSOMs("BaseSchemaTS", "FinalSchemaTS"));
// additional validation - check to see if all types are resolved to their respective types
assertEquals("Unresolved Simple Type should be 'attachmentTypes'",
- "attachmentTypes",
- getElementType(baseSTS, "testAtomicTypeElem"));
+ "attachmentTypes",
+ getElementType(baseSTS, "testAtomicTypeElem"));
assertEquals("Unresolved Simple Type should be 'union.attachmentUnionType'",
- "union.attachmentUnionType",
- getElementType(baseSTS, "testUnionTypeElem"));
+ "union.attachmentUnionType",
+ getElementType(baseSTS, "testUnionTypeElem"));
assertEquals("Unresolved List Type should be 'attchmentExtensionListTypes'",
- "attchmentExtensionListTypes",
- getElementType(baseSTS, "testListTypeElem"));
+ "attchmentExtensionListTypes",
+ getElementType(baseSTS, "testListTypeElem"));
assertEquals("Unresolved Complex Type should be 'headerType'",
- "headerType",
- getElementType(baseSTS, "testComplexTypeSimpleContentElem"));
+ "headerType",
+ getElementType(baseSTS, "testComplexTypeSimpleContentElem"));
assertEquals("Unresolved Complex Type should be 'mailsType'",
- "mailsType",
- getElementType(baseSTS, "testComplexTypeElementOnlyContentElem"));
+ "mailsType",
+ getElementType(baseSTS, "testComplexTypeElementOnlyContentElem"));
assertEquals("Unresolved Complex Type should be 'mixedContentType'",
- "mixedContentType",
- getElementType(baseSTS, "testComplexTypeMixedElem"));
+ "mixedContentType",
+ getElementType(baseSTS, "testComplexTypeMixedElem"));
assertEquals("Unresolved Complex Type should be 'emptyContentType'",
- "emptyContentType",
- getElementType(baseSTS, "testComplexTypeEmptyElem"));
+ "emptyContentType",
+ getElementType(baseSTS, "testComplexTypeEmptyElem"));
assertEquals("Unresolved Complex Type should be 'choiceGroupType'",
- "choiceGroupType",
- getElementType(baseSTS, "testChoiceGroupElem"));
+ "choiceGroupType",
+ getElementType(baseSTS, "testChoiceGroupElem"));
assertEquals("Unresolved Complex Type should be 'allGroupType'",
- "allGroupType",
- getElementType(baseSTS, "testAllGroupElem"));
+ "allGroupType",
+ getElementType(baseSTS, "testAllGroupElem"));
}
@Test
- public void testModifyDataTypes() throws Exception
- {
+ public void testModifyDataTypes() throws Exception {
System.out.println("Inside test case testModifyDataTypes()");
// 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_",
- null,
- "BaseSchemaTS",
- sBaseSourceName);
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", baseSTS);
// there should be NO recovearble errors
assertFalse("Recovered Errors for Valid Schema",
- printRecoveredErrors());
+ printRecoveredErrors());
// the tests - Walk thro the valid SOM
inspectSOM(baseSTS, 13, 1, 15, 1);
// Recovered Errors, Test for saving of the SOM - should go thro
assertTrue("SOM " + baseSTS.getName() + "Save failed!",
- checkPSOMSave(baseSTS));
+ checkPSOMSave(baseSTS));
// instance validation - should be ok
assertTrue("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), baseSTS));
+ validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), baseSTS));
// check types before modify
assertEquals("Unresolved Simple Type should be 'attachmentTypes'",
- "attachmentTypes",
- getElementType(baseSTS, "testAtomicTypeElem"));
+ "attachmentTypes",
+ getElementType(baseSTS, "testAtomicTypeElem"));
assertEquals("Unresolved List Type should be 'attchmentExtensionListTypes'",
- "attchmentExtensionListTypes",
- getElementType(baseSTS, "testListTypeElem"));
+ "attchmentExtensionListTypes",
+ getElementType(baseSTS, "testListTypeElem"));
assertEquals("Unresolved Simple Type should be 'union.attachmentUnionType",
- "union.attachmentUnionType",
- getElementType(baseSTS, "testUnionTypeElem"));
+ "union.attachmentUnionType",
+ getElementType(baseSTS, "testUnionTypeElem"));
//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",
- sBaseSourceName);
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", modifiedSTS);
// test the PSOM created :walk thro the PSOM, look for # of elements,attributes,types & attribute groups
@@ -662,12 +656,12 @@ public class PartialSOMCheckinTest exten
// Test for saving of the PSOM - should not be able to save
assertFalse("PSOM " + modifiedSTS.getName() + " Save should fail",
- checkPSOMSave(modifiedSTS));
+ checkPSOMSave(modifiedSTS));
// validate unresolved types
assertEquals("Unresolved Simple Type - Atomic should be 'anyType'",
- anyType,
- getElementType(modifiedSTS, "testAtomicTypeElem"));
+ anyType,
+ getElementType(modifiedSTS, "testAtomicTypeElem"));
// moved to detailed PSOMDetailedTest class
//Assert.assertEquals("Unresolved List Type should be 'anySimpleType'", anySimpleType, getElementType(modifiedSTS, "testListTypeElem"));
@@ -675,13 +669,13 @@ public class PartialSOMCheckinTest exten
// validate against an xml valid instance - should fail
assertFalse("Validation against instance should Failed ",
- validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), modifiedSTS));
+ validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), modifiedSTS));
// step 3: reload the original STS
SchemaTypeSystem finalSTS = createNewSTS("datatypes_added.xsd_",
- modifiedSTS,
- "FinalSchemaTS",
- sBaseSourceName);
+ modifiedSTS,
+ "FinalSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", finalSTS);
// walk the SOM
@@ -689,128 +683,126 @@ public class PartialSOMCheckinTest exten
// validate successful save
assertTrue("SOM " + finalSTS.getName() + "Save failed",
- checkPSOMSave(finalSTS)); // should be able to save as its a valid SOM
+ checkPSOMSave(finalSTS)); // should be able to save as its a valid SOM
// validate instance - should validate
assertTrue("Validation against instance Failed ",
- validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), finalSTS));
+ validateInstance(getTestCaseFile("instance_datatypes_valid.xml"), finalSTS));
// check types after modify
assertEquals("Unresolved Simple Type should be 'attachmentTypes'",
- "attachmentTypes",
- getElementType(finalSTS, "testAtomicTypeElem"));
+ "attachmentTypes",
+ getElementType(finalSTS, "testAtomicTypeElem"));
assertEquals("Unresolved List Type should be 'attchmentExtensionListTypes'",
- "attchmentExtensionListTypes",
- getElementType(finalSTS, "testListTypeElem"));
+ "attchmentExtensionListTypes",
+ getElementType(finalSTS, "testListTypeElem"));
assertEquals("Unresolved Simple Type should be 'union.attachmentUnionType",
- "union.attachmentUnionType",
- getElementType(finalSTS, "testUnionTypeElem"));
+ "union.attachmentUnionType",
+ getElementType(finalSTS, "testUnionTypeElem"));
// compare this to the original schema here
- assertTrue(compareSavedSOMs("BaseSchemaTS","FinalSchemaTS"));
+ assertTrue(compareSavedSOMs("BaseSchemaTS", "FinalSchemaTS"));
}
@Test
- public void testDeleteDerivedTypes() throws Exception
- {
+ public void testDeleteDerivedTypes() throws Exception {
System.out.println("Inside test case testDeleteDerivedTypes()");
// 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_",
- null,
- "BaseSchemaTS",
- sBaseSourceName);
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", baseSTS);
// there should be NO recovearble errors
assertFalse("Recovered Errors for Valid Schema",
- printRecoveredErrors());
+ printRecoveredErrors());
// the tests - Walk thro the valid SOM
inspectSOM(baseSTS, 13, 0, 14, 0);
// Recovered Errors, Test for saving of the SOM - should go thro
assertTrue("Valid SOM " + baseSTS.getName() + "Save failed!",
- checkPSOMSave(baseSTS));
+ checkPSOMSave(baseSTS));
// instance validation - should be ok
assertTrue("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), baseSTS));
+ validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), baseSTS));
// check types before deletion of base types
assertEquals("Elem Type should be 'ExtensionBaseType' (base)",
- "ExtensionBaseType",
- getElementType(baseSTS, "ExtensionBaseTypeElem"));
+ "ExtensionBaseType",
+ getElementType(baseSTS, "ExtensionBaseTypeElem"));
assertEquals("Elem Type should be 'ExtensionDerivedComplexContentType' (derived)",
- "ExtensionDerivedComplexContentType",
- getElementType(baseSTS, "ExtensionDerivedComplexContentTypeElem"));
+ "ExtensionDerivedComplexContentType",
+ getElementType(baseSTS, "ExtensionDerivedComplexContentTypeElem"));
assertEquals("Elem Type should be 'ExtensionBaseMixedContentType' (base)",
- "ExtensionBaseMixedContentType",
- getElementType(baseSTS, "ExtensionBaseMixedContentTypElem"));
+ "ExtensionBaseMixedContentType",
+ getElementType(baseSTS, "ExtensionBaseMixedContentTypElem"));
assertEquals("Elem Type should be 'ExtensionDerivedMixedContentType' (derived)",
- "ExtensionDerivedMixedContentType",
- getElementType(baseSTS, "ExtensionDerivedMixedContentTypeElem"));
+ "ExtensionDerivedMixedContentType",
+ getElementType(baseSTS, "ExtensionDerivedMixedContentTypeElem"));
assertEquals("Elem Type should be 'RestrictionSimpleContentBaseType'",
- "RestrictionSimpleContentBaseType", getElementType(baseSTS, "RestrictionSimpleContentBaseTypeElem"));
+ "RestrictionSimpleContentBaseType", getElementType(baseSTS, "RestrictionSimpleContentBaseTypeElem"));
assertEquals("Elem Type should be 'RestrictionSimpleContentDerivedType'",
- "RestrictionSimpleContentDerivedType", getElementType(baseSTS, "RestrictionSimpleContentDerivedTypeElem"));
+ "RestrictionSimpleContentDerivedType", getElementType(baseSTS, "RestrictionSimpleContentDerivedTypeElem"));
assertEquals("Elem Type should be 'RestrictionBaseComplexContentType'",
- "RestrictionBaseComplexContentType",
- getElementType(baseSTS, "RestrictionBaseComplexContentTypeElem"));
+ "RestrictionBaseComplexContentType",
+ getElementType(baseSTS, "RestrictionBaseComplexContentTypeElem"));
assertEquals("Elem Type should be 'RestrictionDerivedComplexContentType'",
- "RestrictionDerivedComplexContentType",
- getElementType(baseSTS, "RestrictionDerivedComplexContentTypeElem"));
+ "RestrictionDerivedComplexContentType",
+ getElementType(baseSTS, "RestrictionDerivedComplexContentTypeElem"));
assertEquals("Elem Type should be 'RestrictionBaseMixedContentType'",
- "RestrictionBaseMixedContentType", getElementType(baseSTS, "RestrictionBaseMixedContentTypeElem"));
+ "RestrictionBaseMixedContentType", getElementType(baseSTS, "RestrictionBaseMixedContentTypeElem"));
assertEquals("Elem Type should be 'RestrictionDerivedMixedContentType'",
- "RestrictionDerivedMixedContentType", getElementType(baseSTS, "RestrictionDerivedMixedContentTypeElem"));
+ "RestrictionDerivedMixedContentType", getElementType(baseSTS, "RestrictionDerivedMixedContentTypeElem"));
assertEquals("Elem Type should be 'RestrictionBaseEmptyContentType'",
- "RestrictionBaseEmptyContentType", getElementType(baseSTS, "RestrictionBaseEmptyContentTypeElem"));
+ "RestrictionBaseEmptyContentType", getElementType(baseSTS, "RestrictionBaseEmptyContentTypeElem"));
assertEquals("Elem Type should be 'RestrictionDerivedEmptyContentType'",
- "RestrictionDerivedEmptyContentType", getElementType(baseSTS, "RestrictionDerivedEmptyContentTypeElem"));
+ "RestrictionDerivedEmptyContentType", getElementType(baseSTS, "RestrictionDerivedEmptyContentTypeElem"));
// Step 2: create invalid PSOM with base type removed
SchemaTypeSystem modifiedSTS = createNewSTS("derived_types.xsd_",
- baseSTS,
- "ModifiedSchemaTS",
- sBaseSourceName);
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", modifiedSTS);
// recovearble errors
assertTrue("No Recovered Errors for Invalid PSOM",
- printRecoveredErrors());
+ printRecoveredErrors());
// the tests - Walk thro the valid SOM
inspectSOM(modifiedSTS, 13, 0, 9, 0);
// Recovered Errors, Test for saving of the SOM
- assertEquals("SOM " + modifiedSTS.getName() + "Save Success - should fail!",
- false, checkPSOMSave(modifiedSTS));
+ assertFalse("SOM " + modifiedSTS.getName() + "Save Success - should fail!", checkPSOMSave(modifiedSTS));
// instance validation - should fail
assertFalse("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), modifiedSTS));
+ validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), modifiedSTS));
// check types - base should be 'anyType'
assertEquals("Elem Type should be 'anyType' (base)",
- anyType,
- getElementType(modifiedSTS, "ExtensionBaseTypeElem"));
+ anyType,
+ getElementType(modifiedSTS, "ExtensionBaseTypeElem"));
assertEquals("Elem Type should be 'ExtensionDerivedComplexContentType' (derived)",
- "ExtensionDerivedComplexContentType",
- getElementType(modifiedSTS, "ExtensionDerivedComplexContentTypeElem"));
+ "ExtensionDerivedComplexContentType",
+ getElementType(modifiedSTS, "ExtensionDerivedComplexContentTypeElem"));
assertEquals("Elem Type should be 'anyType' (base)",
- anyType,
- getElementType(modifiedSTS, "ExtensionBaseMixedContentTypElem"));
+ anyType,
+ getElementType(modifiedSTS, "ExtensionBaseMixedContentTypElem"));
assertEquals("Elem Type should be 'ExtensionDerivedComplexContentType' (derived)",
- "ExtensionDerivedMixedContentType",
- getElementType(modifiedSTS, "ExtensionDerivedMixedContentTypeElem"));
+ "ExtensionDerivedMixedContentType",
+ getElementType(modifiedSTS, "ExtensionDerivedMixedContentTypeElem"));
// Restriction Simple Content Base type commented does not result in recoverable SOM
// moved to Detailed Test
@@ -820,132 +812,131 @@ public class PartialSOMCheckinTest exten
//
assertEquals("Elem Type should be 'RestrictionSimpleContentDerivedType'",
- "RestrictionSimpleContentDerivedType",
- getElementType(modifiedSTS, "RestrictionSimpleContentDerivedTypeElem"));
+ "RestrictionSimpleContentDerivedType",
+ getElementType(modifiedSTS, "RestrictionSimpleContentDerivedTypeElem"));
assertEquals("Elem Type should be 'anyType'",
- anyType,
- getElementType(modifiedSTS, "RestrictionBaseComplexContentTypeElem"));
+ anyType,
+ getElementType(modifiedSTS, "RestrictionBaseComplexContentTypeElem"));
assertEquals("Elem Type should be 'RestrictionDerivedComplexContentType'",
- "RestrictionDerivedComplexContentType",
- getElementType(modifiedSTS, "RestrictionDerivedComplexContentTypeElem"));
+ "RestrictionDerivedComplexContentType",
+ getElementType(modifiedSTS, "RestrictionDerivedComplexContentTypeElem"));
assertEquals("Elem Type should be 'anyType'",
- anyType,
- getElementType(modifiedSTS, "RestrictionBaseMixedContentTypeElem"));
+ anyType,
+ getElementType(modifiedSTS, "RestrictionBaseMixedContentTypeElem"));
assertEquals("Elem Type should be 'RestrictionDerivedMixedContentType'",
- "RestrictionDerivedMixedContentType",
- getElementType(modifiedSTS, "RestrictionDerivedMixedContentTypeElem"));
+ "RestrictionDerivedMixedContentType",
+ getElementType(modifiedSTS, "RestrictionDerivedMixedContentTypeElem"));
assertEquals("Elem Type should be 'anyType'", anyType,
- getElementType(modifiedSTS, "RestrictionBaseEmptyContentTypeElem"));
+ getElementType(modifiedSTS, "RestrictionBaseEmptyContentTypeElem"));
assertEquals("Elem Type should be 'RestrictionDerivedEmptyContentType'",
- "RestrictionDerivedEmptyContentType", getElementType(modifiedSTS, "RestrictionDerivedEmptyContentTypeElem"));
+ "RestrictionDerivedEmptyContentType", getElementType(modifiedSTS, "RestrictionDerivedEmptyContentTypeElem"));
// step 3: reload the original STS
SchemaTypeSystem finalSTS = createNewSTS("derived_types_added.xsd_",
- modifiedSTS,
- "FinalSchemaTS",
- sBaseSourceName);
+ modifiedSTS,
+ "FinalSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", finalSTS);
// there should be NO recovearble errors
assertFalse("Recovered Errors for Valid Schema",
- printRecoveredErrors());
+ printRecoveredErrors());
// the tests - Walk thro the valid SOM
inspectSOM(finalSTS, 13, 0, 14, 0);
// Recovered Errors, Test for saving of the SOM - should go thro
assertTrue("SOM " + finalSTS.getName() + "Save failed!",
- checkPSOMSave(finalSTS));
+ checkPSOMSave(finalSTS));
// instance validation - should be ok
assertTrue("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), finalSTS));
+ validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), finalSTS));
// compare this to the original schema here
- assertTrue(compareSavedSOMs("BaseSchemaTS","FinalSchemaTS"));
+ assertTrue(compareSavedSOMs("BaseSchemaTS", "FinalSchemaTS"));
}
@Test
- public void testAddDerivedTypes() throws Exception
- {
+ public void testAddDerivedTypes() throws Exception {
System.out.println("Inside test case testAddDerivedTypes()");
// 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_",
- null,
- "BaseSchemaTS",
- sBaseSourceName);
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", baseSTS);
assertTrue("No Recovered Errors for Invalid PSOM",
- printRecoveredErrors());
+ printRecoveredErrors());
// the tests - Walk thro the valid SOM
inspectSOM(baseSTS, 13, 0, 9, 0);
// Recovered Errors, Test for saving of the SOM
assertFalse("SOM " + baseSTS.getName() + "Save Success - should fail!",
- checkPSOMSave(baseSTS));
+ checkPSOMSave(baseSTS));
// instance validation - should fail
assertFalse("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), baseSTS));
+ validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), baseSTS));
// check types - base should be 'anyType'
assertEquals("Elem Type should be 'anyType' (base)",
- anyType,
- getElementType(baseSTS, "ExtensionBaseTypeElem"));
+ anyType,
+ getElementType(baseSTS, "ExtensionBaseTypeElem"));
assertEquals("Elem Type should be 'ExtensionDerivedComplexContentType' (derived)",
- "ExtensionDerivedComplexContentType",
- getElementType(baseSTS, "ExtensionDerivedComplexContentTypeElem"));
+ "ExtensionDerivedComplexContentType",
+ getElementType(baseSTS, "ExtensionDerivedComplexContentTypeElem"));
assertEquals("Elem Type should be 'anyType' (base)",
- anyType,
- getElementType(baseSTS, "ExtensionBaseMixedContentTypElem"));
+ anyType,
+ getElementType(baseSTS, "ExtensionBaseMixedContentTypElem"));
assertEquals("Elem Type should be 'ExtensionDerivedComplexContentType' (derived)",
- "ExtensionDerivedMixedContentType",
- getElementType(baseSTS, "ExtensionDerivedMixedContentTypeElem"));
+ "ExtensionDerivedMixedContentType",
+ getElementType(baseSTS, "ExtensionDerivedMixedContentTypeElem"));
// Step 2: create valid PSOM now from xsd with base types defined
SchemaTypeSystem modifiedSTS = createNewSTS("derived_types_added.xsd_",
- baseSTS,
- "ModifiedSchemaTS",
- sBaseSourceName);
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", modifiedSTS);
// there should be NO recovearble errors
assertFalse("Recovered Errors for Valid Schema",
- printRecoveredErrors());
+ printRecoveredErrors());
// the tests - Walk thro the valid SOM
inspectSOM(modifiedSTS, 13, 0, 14, 0);
// Recovered Errors, Test for saving of the SOM - should go thro
assertTrue("SOM " + modifiedSTS.getName() + "Save failed!",
- checkPSOMSave(modifiedSTS));
+ checkPSOMSave(modifiedSTS));
// instance validation - should be ok
assertTrue("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), modifiedSTS));
+ validateInstance(getTestCaseFile("instance_derived_types_valid.xml"), modifiedSTS));
// check types before deletion of base types
assertEquals("Elem Type should be 'ExtensionBaseType' (base)",
- "ExtensionBaseType",
- getElementType(modifiedSTS, "ExtensionBaseTypeElem"));
+ "ExtensionBaseType",
+ getElementType(modifiedSTS, "ExtensionBaseTypeElem"));
assertEquals("Elem Type should be 'ExtensionDerivedComplexContentType' (derived)",
- "ExtensionDerivedComplexContentType",
- getElementType(modifiedSTS, "ExtensionDerivedComplexContentTypeElem"));
+ "ExtensionDerivedComplexContentType",
+ getElementType(modifiedSTS, "ExtensionDerivedComplexContentTypeElem"));
assertEquals("Elem Type should be 'ExtensionBaseMixedContentType' (base)",
- "ExtensionBaseMixedContentType",
- getElementType(modifiedSTS, "ExtensionBaseMixedContentTypElem"));
+ "ExtensionBaseMixedContentType",
+ getElementType(modifiedSTS, "ExtensionBaseMixedContentTypElem"));
assertEquals("Elem Type should be 'ExtensionDerivedMixedContentType' (derived)",
- "ExtensionDerivedMixedContentType",
- getElementType(modifiedSTS, "ExtensionDerivedMixedContentTypeElem"));
+ "ExtensionDerivedMixedContentType",
+ getElementType(modifiedSTS, "ExtensionDerivedMixedContentTypeElem"));
}
@@ -954,151 +945,149 @@ public class PartialSOMCheckinTest exten
//{}
//public void testModifyReusableGroups() throws Exception
@Test
- public void testAddReusableGroups() throws Exception
- {
+ public void testAddReusableGroups() throws Exception {
System.out.println("Inside test case testAddReusableGroups()");
// Step 1: read in invalid XSD groups.xsd
String sBaseSourceName = "testsourcename";
SchemaTypeSystem baseSTS = createNewSTS("groups.xsd_",
- null,
- "BaseSchemaTS",
- sBaseSourceName);
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", baseSTS);
// recovearble errors
assertTrue("Recovered Errors for Valid Schema",
- printRecoveredErrors());
+ printRecoveredErrors());
// the tests - Walk thro the valid SOM
inspectSOM(baseSTS, 7, 0, 4, 1);
// Recovered Errors, Test for saving of the SOM - should fail
assertFalse("Partial SOM " + baseSTS.getName() + "Save successful - should failed!",
- checkPSOMSave(baseSTS));
+ checkPSOMSave(baseSTS));
// instance validation - should fail
assertFalse("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), baseSTS));
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), baseSTS));
// verify types
// named model groups
assertEquals("Elem Type should be 'ModelGrpType'",
- "ModelGrpType",
- getElementType(baseSTS, "ModelGrpTypeElem"));
+ "ModelGrpType",
+ getElementType(baseSTS, "ModelGrpTypeElem"));
assertTrue("Elem Type should be 'AttributeGroup'",
- getAttributeGroup(baseSTS, "AttributeGroup"));
+ getAttributeGroup(baseSTS, "AttributeGroup"));
// Step 2: create a SOM with valid xsd
SchemaTypeSystem modifiedSTS = createNewSTS("groups_added.xsd_",
- baseSTS,
- "BaseSchemaTS",
- sBaseSourceName);
+ baseSTS,
+ "BaseSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", modifiedSTS);
// there should be NO recovearble errors
assertFalse("Recovered Errors for Valid Schema",
- printRecoveredErrors());
+ printRecoveredErrors());
// the tests - Walk thro the valid SOM
inspectSOM(modifiedSTS, 7, 0, 5, 2);
// Test for saving of the SOM - should go thro
assertTrue("SOM " + modifiedSTS.getName() + "Save failed!",
- checkPSOMSave(modifiedSTS));
+ checkPSOMSave(modifiedSTS));
// instance validation - should be ok
assertTrue("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), modifiedSTS));
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), modifiedSTS));
// verify named model groups
assertEquals("Elem Type should be 'ModelGrpType'",
- "ModelGrpType",
- getElementType(modifiedSTS, "ModelGrpTypeElem"));
+ "ModelGrpType",
+ getElementType(modifiedSTS, "ModelGrpTypeElem"));
assertTrue("Elem Type should be 'AttributeGroup'",
- getAttributeGroup(modifiedSTS, "AttributeGroup"));
+ getAttributeGroup(modifiedSTS, "AttributeGroup"));
}
@Test
- public void testAddSubstitutionGroups() throws Exception
- {
+ public void testAddSubstitutionGroups() throws Exception {
System.out.println("Inside test case testAddSubstitutionGroups()");
// step1: load an invalid PSOM by with incomplete/missing Subst Grp head elem definition
String sBaseSourceName = "testsourcename";
SchemaTypeSystem baseSTS = createNewSTS("groups.xsd_",
- null,
- "BaseSchemaTS",
- sBaseSourceName);
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", baseSTS);
// errors recovered
assertTrue("No Recovered Errors for recovered PSOM",
- printRecoveredErrors());
+ printRecoveredErrors());
// Recovered Errors, Test for saving of the SOM
assertFalse("SOM " + baseSTS.getName() + "Save Success - should fail!",
- checkPSOMSave(baseSTS));
+ checkPSOMSave(baseSTS));
// the tests - Walk thro the valid SOM
inspectSOM(baseSTS, 7, 0, 4, 1);
// instance validation - should fail
assertFalse("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), baseSTS));
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), baseSTS));
// verify types
assertEquals("Elem Type should be 'anyType'",
- anyType,
- getElementType(baseSTS, "SubGrpHeadElem"));
+ anyType,
+ getElementType(baseSTS, "SubGrpHeadElem"));
assertEquals("Elem Type should be 'anyType' (Member of Sub. Group)",
- anyType,
- getElementType(baseSTS, "SubGrpMemberElem1"));
+ anyType,
+ getElementType(baseSTS, "SubGrpMemberElem1"));
assertEquals("Elem Type should be 'ExtensionSubGrpHeadElemType' (base)",
- "ExtensionSubGrpHeadElemType",
- getElementType(baseSTS, "SubGrpMemberElem2"));
+ "ExtensionSubGrpHeadElemType",
+ getElementType(baseSTS, "SubGrpMemberElem2"));
// named model groups
assertEquals("Elem Type should be 'ModelGrpType'",
- "ModelGrpType",
- getElementType(baseSTS, "ModelGrpTypeElem"));
+ "ModelGrpType",
+ getElementType(baseSTS, "ModelGrpTypeElem"));
assertTrue("Elem Type should be 'AttributeGroup'",
- getAttributeGroup(baseSTS, "AttributeGroup"));
+ getAttributeGroup(baseSTS, "AttributeGroup"));
// Step 2: create a valid SOM and add to these
SchemaTypeSystem modifiedSTS = createNewSTS("groups_added.xsd_",
- baseSTS,
- "ModifiedSchemaTS",
- sBaseSourceName);
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", modifiedSTS);
// there should be NO recovearble errors
assertFalse("Recovered Errors for Valid Schema",
- printRecoveredErrors());
+ printRecoveredErrors());
// the tests - Walk thro the valid SOM
inspectSOM(modifiedSTS, 7, 0, 5, 2);
// Test for saving of the SOM - should go thro
assertTrue("SOM " + modifiedSTS.getName() + "Save failed!",
- checkPSOMSave(modifiedSTS));
+ checkPSOMSave(modifiedSTS));
// instance validation - should be ok
assertTrue("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), modifiedSTS));
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), modifiedSTS));
// verify types - substitution groups
assertEquals("Elem Type should be 'SubGrpHeadElemType' (base)",
- "SubGrpHeadElemType",
- getElementType(modifiedSTS, "SubGrpHeadElem"));
+ "SubGrpHeadElemType",
+ getElementType(modifiedSTS, "SubGrpHeadElem"));
assertEquals("Elem Type should be 'SubGrpHeadElemType' (derived)",
- "SubGrpHeadElemType",
- getElementType(modifiedSTS, "SubGrpMemberElem1"));
+ "SubGrpHeadElemType",
+ getElementType(modifiedSTS, "SubGrpMemberElem1"));
assertEquals("Elem Type should be 'ExtensionSubGrpHeadElemType' (base)",
- "ExtensionSubGrpHeadElemType",
- getElementType(modifiedSTS, "SubGrpMemberElem2"));
+ "ExtensionSubGrpHeadElemType",
+ getElementType(modifiedSTS, "SubGrpMemberElem2"));
// named model groups - moved to check in test
//Assert.assertEquals("Elem Type should be 'ModelGrpType'", "ModelGrpType", getElementType(baseSTS, "ModelGrpTypeElem"));
@@ -1106,43 +1095,42 @@ public class PartialSOMCheckinTest exten
}
@Test
- public void testDeleteSubstitutionGroups() throws Exception
- {
+ public void testDeleteSubstitutionGroups() throws Exception {
System.out.println("Inside test case testDeleteSubstitutionGroups()");
// Step 1: read in a clean XSD groups_added.xsd
String sBaseSourceName = "testsourcename";
SchemaTypeSystem baseSTS = createNewSTS("groups_added.xsd_",
- null,
- "BaseSchemaTS",
- sBaseSourceName);
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", baseSTS);
// there should be NO recovearble errors
assertFalse("Recovered Errors for Valid Schema",
- printRecoveredErrors());
+ printRecoveredErrors());
// the tests - Walk thro the valid SOM
inspectSOM(baseSTS, 7, 0, 5, 2);
// Test for saving of the SOM - should go thro
assertTrue("SOM " + baseSTS.getName() + "Save failed!",
- checkPSOMSave(baseSTS));
+ checkPSOMSave(baseSTS));
// instance validation - should be ok
assertTrue("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), baseSTS));
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), baseSTS));
// verify types - substitution groups
assertEquals("Elem Type should be 'SubGrpHeadElemType' (base)",
- "SubGrpHeadElemType",
- getElementType(baseSTS, "SubGrpHeadElem"));
+ "SubGrpHeadElemType",
+ getElementType(baseSTS, "SubGrpHeadElem"));
assertEquals("Elem Type should be 'SubGrpHeadElemType' (derived)",
- "SubGrpHeadElemType",
- getElementType(baseSTS, "SubGrpMemberElem1"));
+ "SubGrpHeadElemType",
+ getElementType(baseSTS, "SubGrpMemberElem1"));
assertEquals("Elem Type should be 'ExtensionSubGrpHeadElemType' (base)",
- "ExtensionSubGrpHeadElemType",
- getElementType(baseSTS, "SubGrpMemberElem2"));
+ "ExtensionSubGrpHeadElemType",
+ getElementType(baseSTS, "SubGrpMemberElem2"));
// named model groups
//Assert.assertEquals("Elem Type should be 'ModelGrpType'", "ModelGrpType", getElementType(baseSTS, "ModelGrpTypeElem"));
@@ -1150,213 +1138,209 @@ public class PartialSOMCheckinTest exten
// step2: load an invalid PSOM by deleting the Subst Grp head elem definition
SchemaTypeSystem modifiedSTS = createNewSTS("groups.xsd_",
- baseSTS,
- "ModifiedSchemaTS",
- sBaseSourceName);
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", modifiedSTS);
assertTrue("Recovered Errors for Valid Schema",
- printRecoveredErrors());
+ printRecoveredErrors());
// Recovered Errors, Test for saving of the SOM
assertFalse("SOM " + modifiedSTS.getName() + "Save Success - should fail!",
- checkPSOMSave(modifiedSTS));
+ checkPSOMSave(modifiedSTS));
// the tests - Walk thro the valid SOM
inspectSOM(modifiedSTS, 7, 0, 4, 1);
// instance validation - should fail
assertFalse("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), modifiedSTS));
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), modifiedSTS));
// verify types
assertEquals("Elem Type should be 'anyType'",
- anyType,
- getElementType(modifiedSTS, "SubGrpHeadElem"));
+ anyType,
+ getElementType(modifiedSTS, "SubGrpHeadElem"));
assertEquals("Elem Type should be 'anyType' (Member of Sub. Group)",
- anyType,
- getElementType(modifiedSTS, "SubGrpMemberElem1"));
+ anyType,
+ getElementType(modifiedSTS, "SubGrpMemberElem1"));
assertEquals("Elem Type should be 'ExtensionSubGrpHeadElemType' (base)",
- "ExtensionSubGrpHeadElemType",
- getElementType(modifiedSTS, "SubGrpMemberElem2"));
+ "ExtensionSubGrpHeadElemType",
+ getElementType(modifiedSTS, "SubGrpMemberElem2"));
// named model groups
assertEquals("Elem Type should be 'ModelGrpType'",
- "ModelGrpType",
- getElementType(modifiedSTS, "ModelGrpTypeElem"));
+ "ModelGrpType",
+ getElementType(modifiedSTS, "ModelGrpTypeElem"));
assertTrue("Elem Type should be 'AttributeGroup'",
- getAttributeGroup(modifiedSTS, "AttributeGroup"));
+ getAttributeGroup(modifiedSTS, "AttributeGroup"));
// step 3: create a PSOM with the original xsd
SchemaTypeSystem finalSTS = createNewSTS("groups_added.xsd_",
- modifiedSTS,
- "FinalSchemaTS",
- sBaseSourceName);
+ modifiedSTS,
+ "FinalSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", finalSTS);
// Test for saving of the SOM - should go thro
- assertEquals("SOM " + finalSTS.getName() + "Save failed!",
- true,
- checkPSOMSave(finalSTS));
+ assertTrue("SOM " + finalSTS.getName() + "Save failed!", checkPSOMSave(finalSTS));
// instance validation - should be ok
assertTrue("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), finalSTS));
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), finalSTS));
// verify types
assertEquals("Elem Type should be 'SubGrpHeadElemType' (base)",
- "SubGrpHeadElemType",
- getElementType(finalSTS, "SubGrpHeadElem"));
+ "SubGrpHeadElemType",
+ getElementType(finalSTS, "SubGrpHeadElem"));
assertEquals("Elem Type should be 'SubGrpHeadElemType' (derived)",
- "SubGrpHeadElemType",
- getElementType(finalSTS, "SubGrpMemberElem1"));
+ "SubGrpHeadElemType",
+ getElementType(finalSTS, "SubGrpMemberElem1"));
assertEquals("Elem Type should be 'ExtensionSubGrpHeadElemType' (base)",
- "ExtensionSubGrpHeadElemType",
- getElementType(finalSTS, "SubGrpMemberElem2"));
+ "ExtensionSubGrpHeadElemType",
+ getElementType(finalSTS, "SubGrpMemberElem2"));
// named model groups
//Assert.assertEquals("Elem Type should be 'ModelGrpType'", "ModelGrpType", getElementType(baseSTS, "ModelGrpTypeElem"));
//Assert.assertEquals("Elem Type should be 'AttributeGroup'", "AttributeGroup", getAttributeGroup(baseSTS,"AttributeGroup"));
// compare this to the original schema here
- assertTrue(compareSavedSOMs("BaseSchemaTS","FinalSchemaTS"));
+ assertTrue(compareSavedSOMs("BaseSchemaTS", "FinalSchemaTS"));
}
@Test
- public void testModifySubstitutionGroups() throws Exception
- {
+ public void testModifySubstitutionGroups() throws Exception {
System.out.println("Inside test case testModifySubstitutionGroups()");
// Step 1: read in a clean XSD groups_added.xsd
String sBaseSourceName = "testsourcename";
SchemaTypeSystem baseSTS = createNewSTS("groups_added.xsd_",
- null,
- "BaseSchemaTS",
- sBaseSourceName);
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", baseSTS);
// there should be NO recovearble errors
assertFalse("Recovered Errors for Valid Schema",
- printRecoveredErrors());
+ printRecoveredErrors());
// the tests - Walk thro the valid SOM
inspectSOM(baseSTS, 7, 0, 5, 2);
// Test for saving of the SOM - should go thro
assertTrue("SOM " + baseSTS.getName() + "Save failed!",
- checkPSOMSave(baseSTS));
+ checkPSOMSave(baseSTS));
// instance validation - should be ok
assertTrue("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), baseSTS));
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), baseSTS));
// verify types
assertEquals("Elem Type should be 'SubGrpHeadElemType' (base)",
- "SubGrpHeadElemType",
- getElementType(baseSTS, "SubGrpHeadElem"));
+ "SubGrpHeadElemType",
+ getElementType(baseSTS, "SubGrpHeadElem"));
assertEquals("Elem Type should be 'SubGrpHeadElemType' (derived)",
- "SubGrpHeadElemType",
- getElementType(baseSTS, "SubGrpMemberElem1"));
+ "SubGrpHeadElemType",
+ getElementType(baseSTS, "SubGrpMemberElem1"));
assertEquals("Elem Type should be 'ExtensionSubGrpHeadElemType' (base)",
- "ExtensionSubGrpHeadElemType",
- getElementType(baseSTS, "SubGrpMemberElem2"));
+ "ExtensionSubGrpHeadElemType",
+ getElementType(baseSTS, "SubGrpMemberElem2"));
// step2: load a modified xsd with type of head elem in subs grp changed
SchemaTypeSystem modifiedSTS = createNewSTS("groups_modified.xsd_",
- baseSTS,
- "ModifiedSchemaTS",
- sBaseSourceName);
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", modifiedSTS);
// Recovered Errors, Test for saving of the SOM - still a valid PSOM
assertTrue("SOM " + modifiedSTS.getName() + "Save Success - should fail!",
- checkPSOMSave(modifiedSTS));
+ checkPSOMSave(modifiedSTS));
// the tests - Walk thro the valid SOM
inspectSOM(modifiedSTS, 5, 0, 3, 0);
// instance validation - should fail
assertFalse("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), modifiedSTS));
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), modifiedSTS));
// verify types
assertEquals("Elem Type should be 'SubGrpHeadElemType2'",
- "SubGrpHeadElemType2",
- getElementType(modifiedSTS, "SubGrpHeadElem"));
+ "SubGrpHeadElemType2",
+ getElementType(modifiedSTS, "SubGrpHeadElem"));
assertEquals("Elem Type should be 'SubGrpHeadElemType2' (derived)",
- "SubGrpHeadElemType2",
- getElementType(modifiedSTS, "SubGrpMemberElem1"));
+ "SubGrpHeadElemType2",
+ getElementType(modifiedSTS, "SubGrpMemberElem1"));
assertEquals("Elem Type should be 'ExtensionSubGrpHeadElemType' (base)",
- "ExtensionSubGrpHeadElemType",
- getElementType(modifiedSTS, "SubGrpMemberElem2"));
+ "ExtensionSubGrpHeadElemType",
+ getElementType(modifiedSTS, "SubGrpMemberElem2"));
// step3 : reload the original xsd
SchemaTypeSystem finalSTS = createNewSTS("groups_added.xsd_",
- modifiedSTS,
- "FinalSchemaTS",
- sBaseSourceName);
+ modifiedSTS,
+ "FinalSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", finalSTS);
// Test for saving of the SOM - should go thro
assertTrue("SOM " + finalSTS.getName() + "Save failed!",
- checkPSOMSave(finalSTS));
+ checkPSOMSave(finalSTS));
// instance validation - should be ok
assertTrue("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), finalSTS));
+ validateInstance(getTestCaseFile("instance_subst_grps_valid.xml"), finalSTS));
// the tests - Walk thro the valid SOM
inspectSOM(finalSTS, 7, 0, 5, 2);
// verify types
assertEquals("Elem Type should be 'SubGrpHeadElemType' (base)",
- "SubGrpHeadElemType",
- getElementType(finalSTS, "SubGrpHeadElem"));
+ "SubGrpHeadElemType",
+ getElementType(finalSTS, "SubGrpHeadElem"));
assertEquals("Elem Type should be 'SubGrpHeadElemType' (derived)",
- "SubGrpHeadElemType",
- getElementType(finalSTS, "SubGrpMemberElem1"));
+ "SubGrpHeadElemType",
+ getElementType(finalSTS, "SubGrpMemberElem1"));
assertEquals("Elem Type should be 'ExtensionSubGrpHeadElemType' (base)",
- "ExtensionSubGrpHeadElemType", getElementType(finalSTS, "SubGrpMemberElem2"));
+ "ExtensionSubGrpHeadElemType", getElementType(finalSTS, "SubGrpMemberElem2"));
// compare this to the original schema here
- assertTrue(compareSavedSOMs("BaseSchemaTS","FinalSchemaTS"));
+ assertTrue(compareSavedSOMs("BaseSchemaTS", "FinalSchemaTS"));
}
@Test
- public void testModifyIdConstraints() throws Exception
- {
+ public void testModifyIdConstraints() throws Exception {
System.out.println("Inside test case testModifyIdConstraints()");
// Step 1: read in a clean XSD groups_added.xsd
String sBaseSourceName = "testsourcename";
SchemaTypeSystem baseSTS = createNewSTS("constraints_added.xsd_",
- null,
- "BaseSchemaTS",
- sBaseSourceName);
+ null,
+ "BaseSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", baseSTS);
// there should be NO recovearble errors
assertFalse("Recovered Errors for Valid Schema",
- printRecoveredErrors());
+ printRecoveredErrors());
// the tests - Walk thro the valid SOM
inspectSOM(baseSTS, 5, 0, 2, 0);
- assertTrue("Constraint 'uniqueConstraint' should be found",lookForIdentityConstraint(baseSTS,"uniqueConstraint"));
- assertTrue("Constraint 'keyConstraint' should be found",lookForIdentityConstraint(baseSTS,"keyConstraint"));
- assertTrue("Constraint 'KeyRefConstraint' should be found",lookForIdentityConstraint(baseSTS,"KeyRefConstraint"));
+ assertTrue("Constraint 'uniqueConstraint' should be found", lookForIdentityConstraint(baseSTS, "uniqueConstraint"));
+ assertTrue("Constraint 'keyConstraint' should be found", lookForIdentityConstraint(baseSTS, "keyConstraint"));
+ assertTrue("Constraint 'KeyRefConstraint' should be found", lookForIdentityConstraint(baseSTS, "KeyRefConstraint"));
// Test for saving of the SOM - should go thro
assertTrue("SOM " + baseSTS.getName() + "Save failed!",
- checkPSOMSave(baseSTS));
+ checkPSOMSave(baseSTS));
// instance validation against valid instance- should be ok
assertTrue("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_constraints_valid.xml"), baseSTS));
+ validateInstance(getTestCaseFile("instance_constraints_valid.xml"), baseSTS));
// validation against instance which violates the Constraints - should fail
assertFalse("Validation against invalid should fail",
- validateInstance(getTestCaseFile("instance_constraints_invalid.xml"), baseSTS));
+ validateInstance(getTestCaseFile("instance_constraints_invalid.xml"), baseSTS));
// Step 2: create an incremental PSOM with the constraint commented out
// Note: Partial SOMs cannot be created for Unique/Key constraints. They generate valid complete SOMs.
@@ -1364,57 +1348,57 @@ public class PartialSOMCheckinTest exten
// non existant key
SchemaTypeSystem modifiedSTS = createNewSTS("constraints.xsd_",
- baseSTS,
- "ModifiedSchemaTS",
- sBaseSourceName);
+ baseSTS,
+ "ModifiedSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", modifiedSTS);
// recovearble errors
assertTrue("Recovered Errors for Valid Schema",
- printRecoveredErrors());
+ printRecoveredErrors());
// Recovered Errors, Test for saving of the SOM
assertFalse("valid PSOM " + modifiedSTS.getName() + "Save failed !",
- checkPSOMSave(modifiedSTS));
+ checkPSOMSave(modifiedSTS));
// the tests - Walk thro the valid SOM
inspectSOM(modifiedSTS, 5, 0, 2, 0);
// instance validation - should fail
assertFalse("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_constraints_valid.xml"), modifiedSTS));
+ validateInstance(getTestCaseFile("instance_constraints_valid.xml"), modifiedSTS));
// Invalid instance validation - should fail bcos of Unique constraint definition missing
assertFalse("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_constraints_invalid.xml"), modifiedSTS));
+ validateInstance(getTestCaseFile("instance_constraints_invalid.xml"), modifiedSTS));
assertFalse("KeyRef 'KeyRefConstraint' should not be resolved",
- lookForIdentityConstraint(modifiedSTS, "KeyConstraint"));
+ lookForIdentityConstraint(modifiedSTS, "KeyConstraint"));
// Step 3 : recreate SOM in first step and compare it
SchemaTypeSystem finalSTS = createNewSTS("constraints_added.xsd_",
- modifiedSTS,
- "FinalSchemaTS",
- sBaseSourceName);
+ modifiedSTS,
+ "FinalSchemaTS",
+ sBaseSourceName);
assertNotNull("Schema Type System created is Null.", finalSTS);
// there should be NO recovearble errors
assertFalse("Recovered Errors for Valid Schema",
- printRecoveredErrors());
+ printRecoveredErrors());
// the tests - Walk thro the valid SOM
inspectSOM(finalSTS, 5, 0, 2, 0);
// Test for saving of the SOM - should go thro
assertTrue("SOM " + finalSTS.getName() + "Save failed!",
- checkPSOMSave(finalSTS));
+ checkPSOMSave(finalSTS));
// instance validation against valid instance- should be ok
assertTrue("Validation against instance failed",
- validateInstance(getTestCaseFile("instance_constraints_valid.xml"), finalSTS));
+ validateInstance(getTestCaseFile("instance_constraints_valid.xml"), finalSTS));
// compare this to the original schema here
- assertTrue(compareSavedSOMs("BaseSchemaTS","FinalSchemaTS"));
+ assertTrue(compareSavedSOMs("BaseSchemaTS", "FinalSchemaTS"));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org