Author: mukulg
Date: Fri Nov 1 10:53:32 2019
New Revision: 1869243
URL: http://svn.apache.org/viewvc?rev=1869243&view=rev
Log:
adding few more xsd idc tests
Added:
xerces/java/trunk/tests/idc/idc_2.xsd
xerces/java/trunk/tests/idc/idc_2_invalid_1.xml
xerces/java/trunk/tests/idc/idc_2_invalid_2.xml
xerces/java/trunk/tests/idc/idc_2_valid_1.xml
xerces/java/trunk/tests/idc/idc_2_valid_2.xml
xerces/java/trunk/tests/idc/idc_3.xsd
xerces/java/trunk/tests/idc/idc_3_invalid_1.xml
xerces/java/trunk/tests/idc/idc_3_invalid_2.xml
xerces/java/trunk/tests/idc/idc_3_valid_1.xml
Modified:
xerces/java/trunk/tests/idc/IDConstraintTests.java
Modified: xerces/java/trunk/tests/idc/IDConstraintTests.java
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/tests/idc/IDConstraintTests.java?rev=1869243&r1=1869242&r2=1869243&view=diff
==============================================================================
--- xerces/java/trunk/tests/idc/IDConstraintTests.java (original)
+++ xerces/java/trunk/tests/idc/IDConstraintTests.java Fri Nov 1 10:53:32 2019
@@ -136,5 +136,137 @@ public class IDConstraintTests extends X
assertTrue(false);
}
}
+
+ public void testIDConstraint5() {
+ String xmlfile = "tests/idc/idc_2_valid_1.xml";
+ String schemapath = "tests/idc/idc_2.xsd";
+ try {
+ Schema s = fSchemaFactory.newSchema(new StreamSource(schemapath));
+ Validator v = s.newValidator();
+ v.setErrorHandler(this);
+ v.validate(new StreamSource(xmlfile));
+ assertNull(fErrSysId);
+ assertNull(fFatErrSysId);
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+ public void testIDConstraint6() {
+ String xmlfile = "tests/idc/idc_2_valid_2.xml";
+ String schemapath = "tests/idc/idc_2.xsd";
+ try {
+ Schema s = fSchemaFactory.newSchema(new StreamSource(schemapath));
+ Validator v = s.newValidator();
+ v.setErrorHandler(this);
+ v.validate(new StreamSource(xmlfile));
+ assertNull(fErrSysId);
+ assertNull(fFatErrSysId);
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+ public void testIDConstraint7() {
+ String xmlfile = "tests/idc/idc_2_invalid_1.xml";
+ String schemapath = "tests/idc/idc_2.xsd";
+ try {
+ 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));
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+ public void testIDConstraint8() {
+ String xmlfile = "tests/idc/idc_2_invalid_2.xml";
+ String schemapath = "tests/idc/idc_2.xsd";
+ try {
+ 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));
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+ public void testIDConstraint9() {
+ String xmlfile = "tests/idc/idc_3_valid_1.xml";
+ String schemapath = "tests/idc/idc_3.xsd";
+ try {
+ Schema s = fSchemaFactory.newSchema(new StreamSource(schemapath));
+ Validator v = s.newValidator();
+ v.setErrorHandler(this);
+ v.validate(new StreamSource(xmlfile));
+ assertNull(fErrSysId);
+ assertNull(fFatErrSysId);
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+ public void testIDConstraint10() {
+ String xmlfile = "tests/idc/idc_3_invalid_1.xml";
+ String schemapath = "tests/idc/idc_3.xsd";
+ try {
+ 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));
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+ public void testIDConstraint11() {
+ String xmlfile = "tests/idc/idc_3_invalid_2.xml";
+ String schemapath = "tests/idc/idc_3.xsd";
+ try {
+ 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));
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ assertTrue(false);
+ }
+ }
}
Added: xerces/java/trunk/tests/idc/idc_2.xsd
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/tests/idc/idc_2.xsd?rev=1869243&view=auto
==============================================================================
--- xerces/java/trunk/tests/idc/idc_2.xsd (added)
+++ xerces/java/trunk/tests/idc/idc_2.xsd Fri Nov 1 10:53:32 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/trunk/tests/idc/idc_2_invalid_1.xml
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/tests/idc/idc_2_invalid_1.xml?rev=1869243&view=auto
==============================================================================
--- xerces/java/trunk/tests/idc/idc_2_invalid_1.xml (added)
+++ xerces/java/trunk/tests/idc/idc_2_invalid_1.xml Fri Nov 1 10:53:32 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/trunk/tests/idc/idc_2_invalid_2.xml
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/tests/idc/idc_2_invalid_2.xml?rev=1869243&view=auto
==============================================================================
--- xerces/java/trunk/tests/idc/idc_2_invalid_2.xml (added)
+++ xerces/java/trunk/tests/idc/idc_2_invalid_2.xml Fri Nov 1 10:53:32 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/trunk/tests/idc/idc_2_valid_1.xml
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/tests/idc/idc_2_valid_1.xml?rev=1869243&view=auto
==============================================================================
--- xerces/java/trunk/tests/idc/idc_2_valid_1.xml (added)
+++ xerces/java/trunk/tests/idc/idc_2_valid_1.xml Fri Nov 1 10:53:32 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/trunk/tests/idc/idc_2_valid_2.xml
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/tests/idc/idc_2_valid_2.xml?rev=1869243&view=auto
==============================================================================
--- xerces/java/trunk/tests/idc/idc_2_valid_2.xml (added)
+++ xerces/java/trunk/tests/idc/idc_2_valid_2.xml Fri Nov 1 10:53:32 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/trunk/tests/idc/idc_3.xsd
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/tests/idc/idc_3.xsd?rev=1869243&view=auto
==============================================================================
--- xerces/java/trunk/tests/idc/idc_3.xsd (added)
+++ xerces/java/trunk/tests/idc/idc_3.xsd Fri Nov 1 10:53:32 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/trunk/tests/idc/idc_3_invalid_1.xml
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/tests/idc/idc_3_invalid_1.xml?rev=1869243&view=auto
==============================================================================
--- xerces/java/trunk/tests/idc/idc_3_invalid_1.xml (added)
+++ xerces/java/trunk/tests/idc/idc_3_invalid_1.xml Fri Nov 1 10:53:32 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/trunk/tests/idc/idc_3_invalid_2.xml
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/tests/idc/idc_3_invalid_2.xml?rev=1869243&view=auto
==============================================================================
--- xerces/java/trunk/tests/idc/idc_3_invalid_2.xml (added)
+++ xerces/java/trunk/tests/idc/idc_3_invalid_2.xml Fri Nov 1 10:53:32 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/trunk/tests/idc/idc_3_valid_1.xml
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/tests/idc/idc_3_valid_1.xml?rev=1869243&view=auto
==============================================================================
--- xerces/java/trunk/tests/idc/idc_3_valid_1.xml (added)
+++ xerces/java/trunk/tests/idc/idc_3_valid_1.xml Fri Nov 1 10:53:32 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
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]