Author: mukulg Date: Sat Nov 2 05:36:17 2019 New Revision: 1869284 URL: http://svn.apache.org/viewvc?rev=1869284&view=rev Log: adding few more xsd idc tests
Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2.xsd xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2_invalid_1.xml xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2_invalid_2.xml xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2_valid_1.xml xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2_valid_2.xml xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_3.xsd xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_3_invalid_1.xml xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_3_invalid_2.xml xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_3_valid_1.xml xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4.xsd xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4_invalid_1.xml xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4_invalid_2.xml xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4_valid_1.xml xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4_valid_2.xml xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_5.xsd xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_5_invalid_1.xml xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_5_invalid_2.xml xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_5_valid_1.xml Modified: xerces/java/branches/xs-1.1-tests/src/org/apache/xerces/tests/IDConstraintTests.java Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2.xsd URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2.xsd?rev=1869284&view=auto ============================================================================== --- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2.xsd (added) +++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2.xsd Sat Nov 2 05:36:17 2019 @@ -0,0 +1,21 @@ +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <xs:element name="root"> + <xs:complexType> + <xs:sequence> + <xs:element name="item" maxOccurs="unbounded"> + <xs:complexType> + <xs:sequence> + <xs:element name="val" type="xs:integer" minOccurs="0"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + <xs:unique name="unique_1"> + <xs:selector xpath="item"/> + <xs:field xpath="val"/> + </xs:unique> + </xs:element> + +</xs:schema> \ No newline at end of file Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2_invalid_1.xml URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2_invalid_1.xml?rev=1869284&view=auto ============================================================================== --- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2_invalid_1.xml (added) +++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2_invalid_1.xml Sat Nov 2 05:36:17 2019 @@ -0,0 +1,14 @@ +<root> + <item> + <val>3</val> + </item> + <item> + <val>4</val> + </item> + <item> + <val>3</val> + </item> + <item> + <val>6</val> + </item> +</root> \ No newline at end of file Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2_invalid_2.xml URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2_invalid_2.xml?rev=1869284&view=auto ============================================================================== --- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2_invalid_2.xml (added) +++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2_invalid_2.xml Sat Nov 2 05:36:17 2019 @@ -0,0 +1,14 @@ +<root> + <item> + <val>3</val> + </item> + <item> + + </item> + <item> + <val>3</val> + </item> + <item> + <val>6</val> + </item> +</root> \ No newline at end of file Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2_valid_1.xml URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2_valid_1.xml?rev=1869284&view=auto ============================================================================== --- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2_valid_1.xml (added) +++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2_valid_1.xml Sat Nov 2 05:36:17 2019 @@ -0,0 +1,14 @@ +<root> + <item> + <val>3</val> + </item> + <item> + <val>4</val> + </item> + <item> + <val>5</val> + </item> + <item> + <val>6</val> + </item> +</root> \ No newline at end of file Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2_valid_2.xml URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2_valid_2.xml?rev=1869284&view=auto ============================================================================== --- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2_valid_2.xml (added) +++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_2_valid_2.xml Sat Nov 2 05:36:17 2019 @@ -0,0 +1,14 @@ +<root> + <item> + <val>3</val> + </item> + <item> + <val>4</val> + </item> + <item> + + </item> + <item> + <val>6</val> + </item> +</root> \ No newline at end of file Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_3.xsd URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_3.xsd?rev=1869284&view=auto ============================================================================== --- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_3.xsd (added) +++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_3.xsd Sat Nov 2 05:36:17 2019 @@ -0,0 +1,21 @@ +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <xs:element name="root"> + <xs:complexType> + <xs:sequence> + <xs:element name="item" maxOccurs="unbounded"> + <xs:complexType> + <xs:sequence> + <xs:element name="val" type="xs:integer" minOccurs="0"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + <xs:key name="key_1"> + <xs:selector xpath="item"/> + <xs:field xpath="val"/> + </xs:key> + </xs:element> + +</xs:schema> \ No newline at end of file Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_3_invalid_1.xml URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_3_invalid_1.xml?rev=1869284&view=auto ============================================================================== --- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_3_invalid_1.xml (added) +++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_3_invalid_1.xml Sat Nov 2 05:36:17 2019 @@ -0,0 +1,14 @@ +<root> + <item> + <val>3</val> + </item> + <item> + <val>4</val> + </item> + <item> + <val>5</val> + </item> + <item> + <val>3</val> + </item> +</root> \ No newline at end of file Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_3_invalid_2.xml URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_3_invalid_2.xml?rev=1869284&view=auto ============================================================================== --- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_3_invalid_2.xml (added) +++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_3_invalid_2.xml Sat Nov 2 05:36:17 2019 @@ -0,0 +1,14 @@ +<root> + <item> + <val>3</val> + </item> + <item> + + </item> + <item> + <val>5</val> + </item> + <item> + <val>6</val> + </item> +</root> \ No newline at end of file Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_3_valid_1.xml URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_3_valid_1.xml?rev=1869284&view=auto ============================================================================== --- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_3_valid_1.xml (added) +++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_3_valid_1.xml Sat Nov 2 05:36:17 2019 @@ -0,0 +1,14 @@ +<root> + <item> + <val>3</val> + </item> + <item> + <val>4</val> + </item> + <item> + <val>5</val> + </item> + <item> + <val>6</val> + </item> +</root> \ No newline at end of file Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4.xsd URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4.xsd?rev=1869284&view=auto ============================================================================== --- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4.xsd (added) +++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4.xsd Sat Nov 2 05:36:17 2019 @@ -0,0 +1,19 @@ +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <xs:element name="root"> + <xs:complexType> + <xs:sequence> + <xs:element name="item" maxOccurs="unbounded"> + <xs:complexType> + <xs:attribute name="val" type="xs:integer"/> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + <xs:unique name="unique_1"> + <xs:selector xpath="item"/> + <xs:field xpath="@val"/> + </xs:unique> + </xs:element> + +</xs:schema> \ No newline at end of file Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4_invalid_1.xml URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4_invalid_1.xml?rev=1869284&view=auto ============================================================================== --- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4_invalid_1.xml (added) +++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4_invalid_1.xml Sat Nov 2 05:36:17 2019 @@ -0,0 +1,6 @@ +<root> + <item val="3"/> + <item val="4"/> + <item val="3"/> + <item val="6"/> +</root> \ No newline at end of file Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4_invalid_2.xml URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4_invalid_2.xml?rev=1869284&view=auto ============================================================================== --- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4_invalid_2.xml (added) +++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4_invalid_2.xml Sat Nov 2 05:36:17 2019 @@ -0,0 +1,6 @@ +<root> + <item val="3"/> + <item/> + <item val="3"/> + <item val="6"/> +</root> \ No newline at end of file Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4_valid_1.xml URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4_valid_1.xml?rev=1869284&view=auto ============================================================================== --- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4_valid_1.xml (added) +++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4_valid_1.xml Sat Nov 2 05:36:17 2019 @@ -0,0 +1,6 @@ +<root> + <item val="3"/> + <item val="4"/> + <item val="5"/> + <item val="6"/> +</root> \ No newline at end of file Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4_valid_2.xml URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4_valid_2.xml?rev=1869284&view=auto ============================================================================== --- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4_valid_2.xml (added) +++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_4_valid_2.xml Sat Nov 2 05:36:17 2019 @@ -0,0 +1,6 @@ +<root> + <item val="3"/> + <item val="4"/> + <item/> + <item val="6"/> +</root> \ No newline at end of file Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_5.xsd URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_5.xsd?rev=1869284&view=auto ============================================================================== --- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_5.xsd (added) +++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_5.xsd Sat Nov 2 05:36:17 2019 @@ -0,0 +1,19 @@ +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <xs:element name="root"> + <xs:complexType> + <xs:sequence> + <xs:element name="item" maxOccurs="unbounded"> + <xs:complexType> + <xs:attribute name="val" type="xs:integer"/> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + <xs:key name="key_1"> + <xs:selector xpath="item"/> + <xs:field xpath="@val"/> + </xs:key> + </xs:element> + +</xs:schema> \ No newline at end of file Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_5_invalid_1.xml URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_5_invalid_1.xml?rev=1869284&view=auto ============================================================================== --- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_5_invalid_1.xml (added) +++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_5_invalid_1.xml Sat Nov 2 05:36:17 2019 @@ -0,0 +1,6 @@ +<root> + <item val="3"/> + <item val="4"/> + <item val="5"/> + <item val="3"/> +</root> \ No newline at end of file Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_5_invalid_2.xml URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_5_invalid_2.xml?rev=1869284&view=auto ============================================================================== --- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_5_invalid_2.xml (added) +++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_5_invalid_2.xml Sat Nov 2 05:36:17 2019 @@ -0,0 +1,6 @@ +<root> + <item val="3"/> + <item/> + <item val="5"/> + <item val="6"/> +</root> \ No newline at end of file Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_5_valid_1.xml URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_5_valid_1.xml?rev=1869284&view=auto ============================================================================== --- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_5_valid_1.xml (added) +++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_5_valid_1.xml Sat Nov 2 05:36:17 2019 @@ -0,0 +1,6 @@ +<root> + <item val="3"/> + <item val="4"/> + <item val="5"/> + <item val="6"/> +</root> \ No newline at end of file Modified: xerces/java/branches/xs-1.1-tests/src/org/apache/xerces/tests/IDConstraintTests.java URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/src/org/apache/xerces/tests/IDConstraintTests.java?rev=1869284&r1=1869283&r2=1869284&view=diff ============================================================================== --- xerces/java/branches/xs-1.1-tests/src/org/apache/xerces/tests/IDConstraintTests.java (original) +++ xerces/java/branches/xs-1.1-tests/src/org/apache/xerces/tests/IDConstraintTests.java Sat Nov 2 05:36:17 2019 @@ -525,6 +525,492 @@ public class IDConstraintTests extends X assertTrue(false); } } + + public void testIDConstraint21() { + // run validation in XSD 1.0 mode + fSchemaFactory = SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE); + String xmlfile = fDataDir+"/idconstraints/idc_2_valid_1.xml"; + String schemapath = fDataDir+"/idconstraints/idc_2.xsd"; + try { + fSchemaFactory.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true); + Schema s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + Validator v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertNull(fErrSysId); + assertNull(fFatErrSysId); + + // run validation again with same input files, now in XSD 1.1 mode + tearDown(); + setUp(); + s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertNull(fErrSysId); + assertNull(fFatErrSysId); + } catch(Exception ex) { + ex.printStackTrace(); + assertTrue(false); + } + } + + public void testIDConstraint22() { + // run validation in XSD 1.0 mode + fSchemaFactory = SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE); + String xmlfile = fDataDir+"/idconstraints/idc_2_valid_2.xml"; + String schemapath = fDataDir+"/idconstraints/idc_2.xsd"; + try { + fSchemaFactory.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true); + Schema s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + Validator v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertNull(fErrSysId); + assertNull(fFatErrSysId); + + // run validation again with same input files, now in XSD 1.1 mode + tearDown(); + setUp(); + s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertNull(fErrSysId); + assertNull(fFatErrSysId); + } catch(Exception ex) { + ex.printStackTrace(); + assertTrue(false); + } + } + + public void testIDConstraint23() { + // run validation in XSD 1.0 mode + fSchemaFactory = SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE); + String xmlfile = fDataDir+"/idconstraints/idc_2_invalid_1.xml"; + String schemapath = fDataDir+"/idconstraints/idc_2.xsd"; + try { + fSchemaFactory.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true); + Schema s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + Validator v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertTrue(failureList.size() == 1); + // test expected error messages + List expectedMsgList = new ArrayList(); + FailureMesgFragments mesgFragments = new FailureMesgFragments(); + mesgFragments.setMessageFragment("cvc-identity-constraint.4.1: Duplicate unique value [3] found for identity constraint \"unique_1\" of element \"root\""); + expectedMsgList.add(mesgFragments); + assertTrue(areErrorMessagesConsistent(expectedMsgList)); + + // run validation again with same input files, now in XSD 1.1 mode + tearDown(); + setUp(); + s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertTrue(failureList.size() == 1); + // test expected error messages + expectedMsgList = new ArrayList(); + mesgFragments = new FailureMesgFragments(); + mesgFragments.setMessageFragment("cvc-identity-constraint.4.1: Duplicate unique value [3] found for identity constraint \"unique_1\" of element \"root\""); + expectedMsgList.add(mesgFragments); + assertTrue(areErrorMessagesConsistent(expectedMsgList)); + } catch(Exception ex) { + ex.printStackTrace(); + assertTrue(false); + } + } + + public void testIDConstraint24() { + // run validation in XSD 1.0 mode + fSchemaFactory = SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE); + String xmlfile = fDataDir+"/idconstraints/idc_2_invalid_2.xml"; + String schemapath = fDataDir+"/idconstraints/idc_2.xsd"; + try { + fSchemaFactory.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true); + Schema s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + Validator v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertTrue(failureList.size() == 1); + // test expected error messages + List expectedMsgList = new ArrayList(); + FailureMesgFragments mesgFragments = new FailureMesgFragments(); + mesgFragments.setMessageFragment("cvc-identity-constraint.4.1: Duplicate unique value [3] found for identity constraint \"unique_1\" of element \"root\""); + expectedMsgList.add(mesgFragments); + assertTrue(areErrorMessagesConsistent(expectedMsgList)); + + // run validation again with same input files, now in XSD 1.1 mode + tearDown(); + setUp(); + s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertTrue(failureList.size() == 1); + // test expected error messages + expectedMsgList = new ArrayList(); + mesgFragments = new FailureMesgFragments(); + mesgFragments.setMessageFragment("cvc-identity-constraint.4.1: Duplicate unique value [3] found for identity constraint \"unique_1\" of element \"root\""); + expectedMsgList.add(mesgFragments); + assertTrue(areErrorMessagesConsistent(expectedMsgList)); + } catch(Exception ex) { + ex.printStackTrace(); + assertTrue(false); + } + } + + public void testIDConstraint25() { + // run validation in XSD 1.0 mode + fSchemaFactory = SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE); + String xmlfile = fDataDir+"/idconstraints/idc_3_valid_1.xml"; + String schemapath = fDataDir+"/idconstraints/idc_3.xsd"; + try { + fSchemaFactory.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true); + Schema s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + Validator v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertNull(fErrSysId); + assertNull(fFatErrSysId); + + // run validation again with same input files, now in XSD 1.1 mode + tearDown(); + setUp(); + s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertNull(fErrSysId); + assertNull(fFatErrSysId); + } catch(Exception ex) { + ex.printStackTrace(); + assertTrue(false); + } + } + + public void testIDConstraint26() { + // run validation in XSD 1.0 mode + fSchemaFactory = SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE); + String xmlfile = fDataDir+"/idconstraints/idc_3_invalid_1.xml"; + String schemapath = fDataDir+"/idconstraints/idc_3.xsd"; + try { + fSchemaFactory.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true); + Schema s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + Validator v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertTrue(failureList.size() == 1); + // test expected error messages + List expectedMsgList = new ArrayList(); + FailureMesgFragments mesgFragments = new FailureMesgFragments(); + mesgFragments.setMessageFragment("cvc-identity-constraint.4.2.2: Duplicate key value [3] found for identity constraint \"key_1\" of element \"root\""); + expectedMsgList.add(mesgFragments); + assertTrue(areErrorMessagesConsistent(expectedMsgList)); + + // run validation again with same input files, now in XSD 1.1 mode + tearDown(); + setUp(); + s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertTrue(failureList.size() == 1); + // test expected error messages + expectedMsgList = new ArrayList(); + mesgFragments = new FailureMesgFragments(); + mesgFragments.setMessageFragment("cvc-identity-constraint.4.2.2: Duplicate key value [3] found for identity constraint \"key_1\" of element \"root\""); + expectedMsgList.add(mesgFragments); + assertTrue(areErrorMessagesConsistent(expectedMsgList)); + } catch(Exception ex) { + ex.printStackTrace(); + assertTrue(false); + } + } + + public void testIDConstraint27() { + // run validation in XSD 1.0 mode + fSchemaFactory = SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE); + String xmlfile = fDataDir+"/idconstraints/idc_3_invalid_2.xml"; + String schemapath = fDataDir+"/idconstraints/idc_3.xsd"; + try { + fSchemaFactory.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true); + Schema s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + Validator v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertTrue(failureList.size() == 1); + // test expected error messages + List expectedMsgList = new ArrayList(); + FailureMesgFragments mesgFragments = new FailureMesgFragments(); + mesgFragments.setMessageFragment("cvc-identity-constraint.4.2.1.a: Element \"root\" has no value for the key \"key_1\""); + expectedMsgList.add(mesgFragments); + assertTrue(areErrorMessagesConsistent(expectedMsgList)); + + // run validation again with same input files, now in XSD 1.1 mode + tearDown(); + setUp(); + s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertTrue(failureList.size() == 1); + // test expected error messages + expectedMsgList = new ArrayList(); + mesgFragments = new FailureMesgFragments(); + mesgFragments.setMessageFragment("cvc-identity-constraint.4.2.1.a: Element \"root\" has no value for the key \"key_1\""); + expectedMsgList.add(mesgFragments); + assertTrue(areErrorMessagesConsistent(expectedMsgList)); + } catch(Exception ex) { + ex.printStackTrace(); + assertTrue(false); + } + } + + public void testIDConstraint28() { + // run validation in XSD 1.0 mode + fSchemaFactory = SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE); + String xmlfile = fDataDir+"/idconstraints/idc_4_valid_1.xml"; + String schemapath = fDataDir+"/idconstraints/idc_4.xsd"; + try { + fSchemaFactory.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true); + Schema s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + Validator v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertNull(fErrSysId); + assertNull(fFatErrSysId); + + // run validation again with same input files, now in XSD 1.1 mode + tearDown(); + setUp(); + s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertNull(fErrSysId); + assertNull(fFatErrSysId); + } catch(Exception ex) { + ex.printStackTrace(); + assertTrue(false); + } + } + + public void testIDConstraint29() { + // run validation in XSD 1.0 mode + fSchemaFactory = SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE); + String xmlfile = fDataDir+"/idconstraints/idc_4_valid_2.xml"; + String schemapath = fDataDir+"/idconstraints/idc_4.xsd"; + try { + fSchemaFactory.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true); + Schema s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + Validator v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertNull(fErrSysId); + assertNull(fFatErrSysId); + + // run validation again with same input files, now in XSD 1.1 mode + tearDown(); + setUp(); + s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertNull(fErrSysId); + assertNull(fFatErrSysId); + } catch(Exception ex) { + ex.printStackTrace(); + assertTrue(false); + } + } + + public void testIDConstraint30() { + // run validation in XSD 1.0 mode + fSchemaFactory = SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE); + String xmlfile = fDataDir+"/idconstraints/idc_4_invalid_1.xml"; + String schemapath = fDataDir+"/idconstraints/idc_4.xsd"; + try { + fSchemaFactory.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true); + Schema s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + Validator v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertTrue(failureList.size() == 1); + // test expected error messages + List expectedMsgList = new ArrayList(); + FailureMesgFragments mesgFragments = new FailureMesgFragments(); + mesgFragments.setMessageFragment("cvc-identity-constraint.4.1: Duplicate unique value [3] found for identity constraint \"unique_1\" of element \"root\""); + expectedMsgList.add(mesgFragments); + assertTrue(areErrorMessagesConsistent(expectedMsgList)); + + // run validation again with same input files, now in XSD 1.1 mode + tearDown(); + setUp(); + s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertTrue(failureList.size() == 1); + // test expected error messages + expectedMsgList = new ArrayList(); + mesgFragments = new FailureMesgFragments(); + mesgFragments.setMessageFragment("cvc-identity-constraint.4.1: Duplicate unique value [3] found for identity constraint \"unique_1\" of element \"root\""); + expectedMsgList.add(mesgFragments); + assertTrue(areErrorMessagesConsistent(expectedMsgList)); + } catch(Exception ex) { + ex.printStackTrace(); + assertTrue(false); + } + } + + public void testIDConstraint31() { + // run validation in XSD 1.0 mode + fSchemaFactory = SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE); + String xmlfile = fDataDir+"/idconstraints/idc_4_invalid_2.xml"; + String schemapath = fDataDir+"/idconstraints/idc_4.xsd"; + try { + fSchemaFactory.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true); + Schema s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + Validator v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertTrue(failureList.size() == 1); + // test expected error messages + List expectedMsgList = new ArrayList(); + FailureMesgFragments mesgFragments = new FailureMesgFragments(); + mesgFragments.setMessageFragment("cvc-identity-constraint.4.1: Duplicate unique value [3] found for identity constraint \"unique_1\" of element \"root\""); + expectedMsgList.add(mesgFragments); + assertTrue(areErrorMessagesConsistent(expectedMsgList)); + + // run validation again with same input files, now in XSD 1.1 mode + tearDown(); + setUp(); + s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertTrue(failureList.size() == 1); + // test expected error messages + expectedMsgList = new ArrayList(); + mesgFragments = new FailureMesgFragments(); + mesgFragments.setMessageFragment("cvc-identity-constraint.4.1: Duplicate unique value [3] found for identity constraint \"unique_1\" of element \"root\""); + expectedMsgList.add(mesgFragments); + assertTrue(areErrorMessagesConsistent(expectedMsgList)); + } catch(Exception ex) { + ex.printStackTrace(); + assertTrue(false); + } + } + + public void testIDConstraint32() { + // run validation in XSD 1.0 mode + fSchemaFactory = SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE); + String xmlfile = fDataDir+"/idconstraints/idc_5_valid_1.xml"; + String schemapath = fDataDir+"/idconstraints/idc_5.xsd"; + try { + fSchemaFactory.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true); + Schema s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + Validator v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertNull(fErrSysId); + assertNull(fFatErrSysId); + + // run validation again with same input files, now in XSD 1.1 mode + tearDown(); + setUp(); + s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertNull(fErrSysId); + assertNull(fFatErrSysId); + } catch(Exception ex) { + ex.printStackTrace(); + assertTrue(false); + } + } + + public void testIDConstraint33() { + // run validation in XSD 1.0 mode + fSchemaFactory = SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE); + String xmlfile = fDataDir+"/idconstraints/idc_5_invalid_1.xml"; + String schemapath = fDataDir+"/idconstraints/idc_5.xsd"; + try { + fSchemaFactory.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true); + Schema s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + Validator v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertTrue(failureList.size() == 1); + // test expected error messages + List expectedMsgList = new ArrayList(); + FailureMesgFragments mesgFragments = new FailureMesgFragments(); + mesgFragments.setMessageFragment("cvc-identity-constraint.4.2.2: Duplicate key value [3] found for identity constraint \"key_1\" of element \"root\""); + expectedMsgList.add(mesgFragments); + assertTrue(areErrorMessagesConsistent(expectedMsgList)); + + // run validation again with same input files, now in XSD 1.1 mode + tearDown(); + setUp(); + s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertTrue(failureList.size() == 1); + // test expected error messages + expectedMsgList = new ArrayList(); + mesgFragments = new FailureMesgFragments(); + mesgFragments.setMessageFragment("cvc-identity-constraint.4.2.2: Duplicate key value [3] found for identity constraint \"key_1\" of element \"root\""); + expectedMsgList.add(mesgFragments); + assertTrue(areErrorMessagesConsistent(expectedMsgList)); + } catch(Exception ex) { + ex.printStackTrace(); + assertTrue(false); + } + } + + public void testIDConstraint34() { + // run validation in XSD 1.0 mode + fSchemaFactory = SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE); + String xmlfile = fDataDir+"/idconstraints/idc_5_invalid_2.xml"; + String schemapath = fDataDir+"/idconstraints/idc_5.xsd"; + try { + fSchemaFactory.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true); + Schema s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + Validator v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertTrue(failureList.size() == 1); + // test expected error messages + List expectedMsgList = new ArrayList(); + FailureMesgFragments mesgFragments = new FailureMesgFragments(); + mesgFragments.setMessageFragment("cvc-identity-constraint.4.2.1.a: Element \"root\" has no value for the key \"key_1\""); + expectedMsgList.add(mesgFragments); + assertTrue(areErrorMessagesConsistent(expectedMsgList)); + + // run validation again with same input files, now in XSD 1.1 mode + tearDown(); + setUp(); + s = fSchemaFactory.newSchema(new StreamSource(schemapath)); + v = s.newValidator(); + v.setErrorHandler(this); + v.validate(new StreamSource(xmlfile)); + assertTrue(failureList.size() == 1); + // test expected error messages + expectedMsgList = new ArrayList(); + mesgFragments = new FailureMesgFragments(); + mesgFragments.setMessageFragment("cvc-identity-constraint.4.2.1.a: Element \"root\" has no value for the key \"key_1\""); + expectedMsgList.add(mesgFragments); + assertTrue(areErrorMessagesConsistent(expectedMsgList)); + } catch(Exception ex) { + ex.printStackTrace(); + assertTrue(false); + } + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@xerces.apache.org For additional commands, e-mail: commits-h...@xerces.apache.org