You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mu...@apache.org on 2019/10/31 06:36:10 UTC

svn commit: r1869199 - in /xerces/java/branches/xs-1.1-tests: data/idconstraints/ src/org/apache/xerces/tests/

Author: mukulg
Date: Thu Oct 31 06:36:10 2019
New Revision: 1869199

URL: http://svn.apache.org/viewvc?rev=1869199&view=rev
Log:
committing few xsd idc constraints test cases

Added:
    xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1.xsd
    xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1_invalid_1.xml
    xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1_invalid_2.xml
    xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1_invalid_3.xml
    xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1_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_1.xsd
URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1.xsd?rev=1869199&view=auto
==============================================================================
--- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1.xsd (added)
+++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1.xsd Thu Oct 31 06:36:10 2019
@@ -0,0 +1,62 @@
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+   <xs:element name="root">
+      <xs:complexType>
+         <xs:sequence>
+            <xs:element name="nffg" maxOccurs="unbounded">
+               <xs:complexType>
+                  <xs:sequence>
+                     <xs:element name="nodes">
+                        <xs:complexType>
+                           <xs:sequence>
+                              <xs:element name="node" maxOccurs="unbounded">
+                                 <xs:complexType>
+                                    <xs:sequence>
+                                       <xs:element name="nodeName" type="xs:string"/>
+                                    </xs:sequence>
+                                    <xs:attribute name="functionalType" type="xs:string" use="required"/>
+                                 </xs:complexType>
+                              </xs:element>
+                           </xs:sequence>
+                        </xs:complexType>
+                     </xs:element>
+                     <xs:element name="links">
+                        <xs:complexType>
+                           <xs:sequence>
+                              <xs:element name="link" maxOccurs="unbounded">
+                                 <xs:complexType>
+                                    <xs:sequence>
+                                       <xs:element name="sourceNode" type="xs:string"/>
+                                       <xs:element name="destNode" type="xs:string"/>
+                                    </xs:sequence>
+                                 </xs:complexType>
+                              </xs:element>
+                           </xs:sequence>
+                        </xs:complexType>
+                     </xs:element>
+                  </xs:sequence>
+                  <xs:attribute name="nffgName" type="xs:string" use="required"/>
+                  <xs:attribute name="deployTime" type="xs:dateTime" use="required"/>
+               </xs:complexType>               
+               <xs:key name="nodeName_key">
+                  <xs:selector xpath="nodes/node"/>
+                  <xs:field xpath="nodeName"/>
+               </xs:key>
+               <xs:keyref name="srcNodeRef_key" refer="nodeName_key">
+                  <xs:selector xpath="links/link"/>
+                  <xs:field xpath="sourceNode"/>
+               </xs:keyref>
+               <xs:keyref name="destNodeRef_key" refer="nodeName_key">
+                  <xs:selector xpath="links/link"/>
+                  <xs:field xpath="destNode"/>
+               </xs:keyref>
+            </xs:element>
+         </xs:sequence>
+      </xs:complexType>
+      <xs:key name="nffgName_key">
+         <xs:selector xpath="nffg"/>
+         <xs:field xpath="@nffgName"/>
+      </xs:key>
+   </xs:element>
+
+</xs:schema>
\ No newline at end of file

Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1_invalid_1.xml
URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1_invalid_1.xml?rev=1869199&view=auto
==============================================================================
--- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1_invalid_1.xml (added)
+++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1_invalid_1.xml Thu Oct 31 06:36:10 2019
@@ -0,0 +1,34 @@
+<root>
+    <nffg nffgName="nffg1" deployTime="1999-11-12T21:00:12">
+        <nodes>
+            <node functionalType="func1">
+                <nodeName>node1</nodeName>
+            </node>
+            <node functionalType="func2">
+                <nodeName>node3</nodeName>
+            </node>
+            <node functionalType="func2">
+                <nodeName>node4</nodeName>
+            </node>
+        </nodes>
+        <links>
+            <link>
+                <sourceNode>node1</sourceNode>
+                <destNode>node2</destNode>
+            </link>
+        </links>
+    </nffg>
+    <nffg nffgName="nffg1" deployTime="1999-11-12T22:00:12">
+        <nodes>
+            <node functionalType="func2">
+                <nodeName>node2</nodeName>
+            </node>
+        </nodes>
+        <links>
+            <link>
+                <sourceNode>node1</sourceNode>
+                <destNode>node2</destNode>
+            </link>
+        </links>
+    </nffg>
+</root>
\ No newline at end of file

Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1_invalid_2.xml
URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1_invalid_2.xml?rev=1869199&view=auto
==============================================================================
--- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1_invalid_2.xml (added)
+++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1_invalid_2.xml Thu Oct 31 06:36:10 2019
@@ -0,0 +1,34 @@
+<root>
+    <nffg nffgName="nffg1" deployTime="1999-11-12T21:00:12">
+        <nodes>
+            <node functionalType="func1">
+                <nodeName>node1</nodeName>
+            </node>
+            <node functionalType="func2">
+                <nodeName>node3</nodeName>
+            </node>
+            <node functionalType="func2">
+                <nodeName>node1</nodeName>
+            </node>
+        </nodes>
+        <links>
+            <link>
+                <sourceNode>node1</sourceNode>
+                <destNode>node2</destNode>
+            </link>
+        </links>
+    </nffg>
+    <nffg nffgName="nffg2" deployTime="1999-11-12T22:00:12">
+        <nodes>
+            <node functionalType="func2">
+                <nodeName>node2</nodeName>
+            </node>
+        </nodes>
+        <links>
+            <link>
+                <sourceNode>node1</sourceNode>
+                <destNode>node2</destNode>
+            </link>
+        </links>
+    </nffg>
+</root>
\ No newline at end of file

Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1_invalid_3.xml
URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1_invalid_3.xml?rev=1869199&view=auto
==============================================================================
--- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1_invalid_3.xml (added)
+++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1_invalid_3.xml Thu Oct 31 06:36:10 2019
@@ -0,0 +1,37 @@
+<root>
+    <nffg nffgName="nffg1" deployTime="1999-11-12T21:00:12">
+        <nodes>
+            <node functionalType="func1">
+                <nodeName>node1</nodeName>
+            </node>
+            <node functionalType="func2">
+                <nodeName>node3</nodeName>
+            </node>
+            <node functionalType="func2">
+                <nodeName>node1</nodeName>
+            </node>
+        </nodes>
+        <links>
+            <link>
+                <sourceNode>node1</sourceNode>
+                <destNode>node2</destNode>
+            </link>
+        </links>
+    </nffg>
+    <nffg nffgName="nffg2" deployTime="1999-11-12T22:00:12">
+        <nodes>
+            <node functionalType="func2">
+                <nodeName>node2</nodeName>
+            </node>
+            <node functionalType="func2">
+	        <nodeName>node2</nodeName>
+            </node>
+        </nodes>
+        <links>
+            <link>
+                <sourceNode>node1</sourceNode>
+                <destNode>node2</destNode>
+            </link>
+        </links>
+    </nffg>
+</root>
\ No newline at end of file

Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1_valid_1.xml
URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1_valid_1.xml?rev=1869199&view=auto
==============================================================================
--- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1_valid_1.xml (added)
+++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_1_valid_1.xml Thu Oct 31 06:36:10 2019
@@ -0,0 +1,37 @@
+<root>
+    <nffg nffgName="nffg1" deployTime="1999-11-12T21:00:12">
+        <nodes>
+            <node functionalType="func1">
+                <nodeName>node1</nodeName>
+            </node>
+            <node functionalType="func2">
+                <nodeName>node3</nodeName>
+            </node>
+            <node functionalType="func2">
+                <nodeName>node4</nodeName>
+            </node>
+        </nodes>
+        <links>
+            <link>
+                <sourceNode>node1</sourceNode>
+                <destNode>node3</destNode>
+            </link>
+        </links>
+    </nffg>
+    <nffg nffgName="nffg2" deployTime="1999-11-12T22:00:12">
+        <nodes>
+            <node functionalType="func2">
+                <nodeName>node2</nodeName>
+            </node>
+            <node functionalType="func2">
+	        <nodeName>node3</nodeName>
+            </node>
+        </nodes>
+        <links>
+            <link>
+                <sourceNode>node3</sourceNode>
+                <destNode>node2</destNode>
+            </link>
+        </links>
+    </nffg>
+</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=1869199&r1=1869198&r2=1869199&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 Thu Oct 31 06:36:10 2019
@@ -22,6 +22,7 @@ import java.util.List;
 
 import javax.xml.transform.stream.StreamSource;
 import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
 import javax.xml.validation.Validator;
 
 /**
@@ -332,6 +333,190 @@ public class IDConstraintTests extends X
             expectedMsgList.add(mesgFragments);
             assertTrue(areErrorMessagesConsistent(expectedMsgList));
 		} catch(Exception ex) {
+		   ex.printStackTrace();
+		   assertTrue(false);
+		}
+	}
+	
+	public void testIDConstraint17() {
+		// run validation in XSD 1.0 mode
+		fSchemaFactory = SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE);
+		String xmlfile = fDataDir+"/idconstraints/idc_1_valid_1.xml";
+		String schemapath = fDataDir+"/idconstraints/idc_1.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);            
+            
+            // 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 testIDConstraint18() {
+		// run validation in XSD 1.0 mode
+		fSchemaFactory = SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE);
+		String xmlfile = fDataDir+"/idconstraints/idc_1_invalid_1.xml";
+		String schemapath = fDataDir+"/idconstraints/idc_1.xsd";	
+		try {
+		    Schema s = fSchemaFactory.newSchema(new StreamSource(schemapath));
+            Validator v = s.newValidator();
+		    v.setErrorHandler(this);
+            v.validate(new StreamSource(xmlfile));
+            assertTrue(failureList.size() == 3);
+            // test expected error messages
+            List expectedMsgList = new ArrayList();
+            FailureMesgFragments mesgFragments = new FailureMesgFragments();
+            mesgFragments.setMessageFragment("cvc-identity-constraint.4.3: Key 'destNodeRef_key' with value 'node2' not found for identity constraint of element 'nffg'");
+            expectedMsgList.add(mesgFragments);
+            mesgFragments = new FailureMesgFragments();
+            mesgFragments.setMessageFragment("cvc-identity-constraint.4.2.2: Duplicate key value [nffg1] found for identity constraint \"nffgName_key\" of element \"root\"");
+            expectedMsgList.add(mesgFragments);
+            mesgFragments = new FailureMesgFragments();
+            mesgFragments.setMessageFragment("cvc-identity-constraint.4.3: Key 'srcNodeRef_key' with value 'node1' not found for identity constraint of element 'nffg'");
+            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() == 3);
+            // test expected error messages
+            expectedMsgList = new ArrayList();
+            mesgFragments = new FailureMesgFragments();
+            mesgFragments.setMessageFragment("cvc-identity-constraint.4.3: Key 'destNodeRef_key' with value 'node2' not found for identity constraint of element 'nffg'");
+            expectedMsgList.add(mesgFragments);
+            mesgFragments = new FailureMesgFragments();
+            mesgFragments.setMessageFragment("cvc-identity-constraint.4.2.2: Duplicate key value [nffg1] found for identity constraint \"nffgName_key\" of element \"root\"");
+            expectedMsgList.add(mesgFragments);
+            mesgFragments = new FailureMesgFragments();
+            mesgFragments.setMessageFragment("cvc-identity-constraint.4.3: Key 'srcNodeRef_key' with value 'node1' not found for identity constraint of element 'nffg'");
+            expectedMsgList.add(mesgFragments);
+            assertTrue(areErrorMessagesConsistent(expectedMsgList));
+		} catch(Exception ex) {
+		   ex.printStackTrace();
+		   assertTrue(false);
+		}
+	}
+	
+	public void testIDConstraint19() {
+		// run validation in XSD 1.0 mode
+		fSchemaFactory = SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE);
+		String xmlfile = fDataDir+"/idconstraints/idc_1_invalid_2.xml";
+		String schemapath = fDataDir+"/idconstraints/idc_1.xsd";	
+		try {
+		    Schema s = fSchemaFactory.newSchema(new StreamSource(schemapath));
+            Validator v = s.newValidator();
+		    v.setErrorHandler(this);
+            v.validate(new StreamSource(xmlfile));
+            assertTrue(failureList.size() == 3);
+            // test expected error messages
+            List expectedMsgList = new ArrayList();
+            FailureMesgFragments mesgFragments = new FailureMesgFragments();
+            mesgFragments.setMessageFragment("cvc-identity-constraint.4.2.2: Duplicate key value [node1] found for identity constraint \"nodeName_key\" of element \"nffg\"");
+            expectedMsgList.add(mesgFragments);
+            mesgFragments = new FailureMesgFragments();
+            mesgFragments.setMessageFragment("cvc-identity-constraint.4.3: Key 'destNodeRef_key' with value 'node2' not found for identity constraint of element 'nffg'");
+            expectedMsgList.add(mesgFragments);
+            mesgFragments = new FailureMesgFragments();
+            mesgFragments.setMessageFragment("cvc-identity-constraint.4.3: Key 'srcNodeRef_key' with value 'node1' not found for identity constraint of element 'nffg'");
+            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() == 3);
+            // test expected error messages
+            expectedMsgList = new ArrayList();
+            mesgFragments = new FailureMesgFragments();
+            mesgFragments.setMessageFragment("cvc-identity-constraint.4.2.2: Duplicate key value [node1] found for identity constraint \"nodeName_key\" of element \"nffg\"");
+            expectedMsgList.add(mesgFragments);
+            mesgFragments = new FailureMesgFragments();
+            mesgFragments.setMessageFragment("cvc-identity-constraint.4.3: Key 'destNodeRef_key' with value 'node2' not found for identity constraint of element 'nffg'");
+            expectedMsgList.add(mesgFragments);
+            mesgFragments = new FailureMesgFragments();
+            mesgFragments.setMessageFragment("cvc-identity-constraint.4.3: Key 'srcNodeRef_key' with value 'node1' not found for identity constraint of element 'nffg'");
+            expectedMsgList.add(mesgFragments);
+            assertTrue(areErrorMessagesConsistent(expectedMsgList));
+		} catch(Exception ex) {
+		   ex.printStackTrace();
+		   assertTrue(false);
+		}
+	}
+	
+	public void testIDConstraint20() {
+		// run validation in XSD 1.0 mode
+		fSchemaFactory = SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE);
+		String xmlfile = fDataDir+"/idconstraints/idc_1_invalid_3.xml";
+		String schemapath = fDataDir+"/idconstraints/idc_1.xsd";	
+		try {
+		    Schema s = fSchemaFactory.newSchema(new StreamSource(schemapath));
+            Validator v = s.newValidator();
+		    v.setErrorHandler(this);
+            v.validate(new StreamSource(xmlfile));
+            assertTrue(failureList.size() == 4);
+            // test expected error messages
+            List expectedMsgList = new ArrayList();
+            FailureMesgFragments mesgFragments = new FailureMesgFragments();
+            mesgFragments.setMessageFragment("cvc-identity-constraint.4.2.2: Duplicate key value [node1] found for identity constraint \"nodeName_key\" of element \"nffg\"");
+            expectedMsgList.add(mesgFragments);
+            mesgFragments = new FailureMesgFragments();
+            mesgFragments.setMessageFragment("cvc-identity-constraint.4.3: Key 'destNodeRef_key' with value 'node2' not found for identity constraint of element 'nffg'");
+            expectedMsgList.add(mesgFragments);
+            mesgFragments = new FailureMesgFragments();
+            mesgFragments.setMessageFragment("cvc-identity-constraint.4.2.2: Duplicate key value [node2] found for identity constraint \"nodeName_key\" of element \"nffg\"");
+            expectedMsgList.add(mesgFragments);
+            mesgFragments = new FailureMesgFragments();
+            mesgFragments.setMessageFragment("cvc-identity-constraint.4.3: Key 'srcNodeRef_key' with value 'node1' not found for identity constraint of element 'nffg'");
+            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() == 4);
+            // test expected error messages
+            expectedMsgList = new ArrayList();
+            mesgFragments = new FailureMesgFragments();
+            mesgFragments.setMessageFragment("cvc-identity-constraint.4.2.2: Duplicate key value [node1] found for identity constraint \"nodeName_key\" of element \"nffg\"");
+            expectedMsgList.add(mesgFragments);
+            mesgFragments = new FailureMesgFragments();
+            mesgFragments.setMessageFragment("cvc-identity-constraint.4.3: Key 'destNodeRef_key' with value 'node2' not found for identity constraint of element 'nffg'");
+            expectedMsgList.add(mesgFragments);
+            mesgFragments = new FailureMesgFragments();
+            mesgFragments.setMessageFragment("cvc-identity-constraint.4.2.2: Duplicate key value [node2] found for identity constraint \"nodeName_key\" of element \"nffg\"");
+            expectedMsgList.add(mesgFragments);
+            mesgFragments = new FailureMesgFragments();
+            mesgFragments.setMessageFragment("cvc-identity-constraint.4.3: Key 'srcNodeRef_key' with value 'node1' not found for identity constraint of element 'nffg'");
+            expectedMsgList.add(mesgFragments);
+            assertTrue(areErrorMessagesConsistent(expectedMsgList));
+		} catch(Exception ex) {
 		   ex.printStackTrace();
 		   assertTrue(false);
 		}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org