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/11/15 06:29:22 UTC

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

Author: mukulg
Date: Fri Nov 15 06:29:22 2019
New Revision: 1869829

URL: http://svn.apache.org/viewvc?rev=1869829&view=rev
Log:
committing few xsd idc constraints tests on trunk and the branch xs-1.1-tests.

Added:
    xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_6.xsd
    xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_6_invalid_1.xml
    xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_6_valid_1.xml
    xerces/java/trunk/tests/idc/idc_6.xsd
    xerces/java/trunk/tests/idc/idc_6_invalid_1.xml
    xerces/java/trunk/tests/idc/idc_6_valid_1.xml
Modified:
    xerces/java/branches/xs-1.1-tests/src/org/apache/xerces/tests/IDConstraintTests.java
    xerces/java/trunk/tests/idc/IDConstraintTests.java

Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_6.xsd
URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_6.xsd?rev=1869829&view=auto
==============================================================================
--- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_6.xsd (added)
+++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_6.xsd Fri Nov 15 06:29:22 2019
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+    
+    <xs:element name="X">
+        <xs:complexType>
+            <xs:sequence>
+                <xs:element name="Y">
+                    <xs:complexType>
+                        <xs:sequence>
+                            <xs:element name="a" type="xs:integer" maxOccurs="unbounded"/>
+                        </xs:sequence>
+                    </xs:complexType>
+                </xs:element>
+                <xs:element name="b" type="xs:integer" maxOccurs="unbounded"/>
+            </xs:sequence>        
+        </xs:complexType>
+        <xs:key name="key_1">
+            <xs:selector xpath="Y/a | b"/>
+            <xs:field xpath="."/>
+        </xs:key>
+    </xs:element>
+    
+</xs:schema>

Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_6_invalid_1.xml
URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_6_invalid_1.xml?rev=1869829&view=auto
==============================================================================
--- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_6_invalid_1.xml (added)
+++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_6_invalid_1.xml Fri Nov 15 06:29:22 2019
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<X>
+  <Y>
+    <a>5</a>
+    <a>6</a>
+    <a>7</a>
+  </Y>
+  <b>8</b>
+  <b>7</b>
+  <b>10</b>
+</X>
\ No newline at end of file

Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_6_valid_1.xml
URL: http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_6_valid_1.xml?rev=1869829&view=auto
==============================================================================
--- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_6_valid_1.xml (added)
+++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_6_valid_1.xml Fri Nov 15 06:29:22 2019
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<X>
+  <Y>
+    <a>5</a>
+    <a>6</a>
+    <a>7</a>
+  </Y>
+  <b>8</b>
+  <b>9</b>
+  <b>10</b>
+</X>
\ 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=1869829&r1=1869828&r2=1869829&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 Fri Nov 15 06:29:22 2019
@@ -1069,6 +1069,74 @@ public class IDConstraintTests extends X
 		   assertTrue(false);
 		}
 	}
+	
+	public void testIDConstraint38() {
+		// run validation in XSD 1.0 mode
+		fSchemaFactory = SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE);
+		String xmlfile = fDataDir+"/idconstraints/idc_6_valid_1.xml";
+		String schemapath = fDataDir+"/idconstraints/idc_6.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 testIDConstraint39() {
+		// run validation in XSD 1.0 mode
+		fSchemaFactory = SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE);
+		String xmlfile = fDataDir+"/idconstraints/idc_6_invalid_1.xml";
+		String schemapath = fDataDir+"/idconstraints/idc_6.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 [7] found for identity constraint \"key_1\" of element \"X\"");
+            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 [7] found for identity constraint \"key_1\" of element \"X\"");
+            expectedMsgList.add(mesgFragments);
+            assertTrue(areErrorMessagesConsistent(expectedMsgList));
+		} catch(Exception ex) {
+		   ex.printStackTrace();
+		   assertTrue(false);
+		}
+	}
 
 }
 

Modified: xerces/java/trunk/tests/idc/IDConstraintTests.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/tests/idc/IDConstraintTests.java?rev=1869829&r1=1869828&r2=1869829&view=diff
==============================================================================
--- xerces/java/trunk/tests/idc/IDConstraintTests.java (original)
+++ xerces/java/trunk/tests/idc/IDConstraintTests.java Fri Nov 15 06:29:22 2019
@@ -400,5 +400,42 @@ public class IDConstraintTests extends X
            assertTrue(false);
         }
     }
+    
+    public void testIDConstraint19() {
+        String xmlfile = "tests/idc/idc_6_valid_1.xml";
+        String schemapath = "tests/idc/idc_6.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 testIDConstraint20() {        
+        String xmlfile = "tests/idc/idc_6_invalid_1.xml";
+        String schemapath = "tests/idc/idc_6.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 [7] found for identity constraint \"key_1\" of element \"X\"");
+            expectedMsgList.add(mesgFragments);            
+            assertTrue(areErrorMessagesConsistent(expectedMsgList));            
+        } catch(Exception ex) {
+           ex.printStackTrace();
+           assertTrue(false);
+        }
+    }
 
 }

Added: xerces/java/trunk/tests/idc/idc_6.xsd
URL: http://svn.apache.org/viewvc/xerces/java/trunk/tests/idc/idc_6.xsd?rev=1869829&view=auto
==============================================================================
--- xerces/java/trunk/tests/idc/idc_6.xsd (added)
+++ xerces/java/trunk/tests/idc/idc_6.xsd Fri Nov 15 06:29:22 2019
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+    
+    <xs:element name="X">
+        <xs:complexType>
+            <xs:sequence>
+                <xs:element name="Y">
+                    <xs:complexType>
+                        <xs:sequence>
+                            <xs:element name="a" type="xs:integer" maxOccurs="unbounded"/>
+                        </xs:sequence>
+                    </xs:complexType>
+                </xs:element>
+                <xs:element name="b" type="xs:integer" maxOccurs="unbounded"/>
+            </xs:sequence>        
+        </xs:complexType>
+        <xs:key name="key_1">
+            <xs:selector xpath="Y/a | b"/>
+            <xs:field xpath="."/>
+        </xs:key>
+    </xs:element>
+    
+</xs:schema>

Added: xerces/java/trunk/tests/idc/idc_6_invalid_1.xml
URL: http://svn.apache.org/viewvc/xerces/java/trunk/tests/idc/idc_6_invalid_1.xml?rev=1869829&view=auto
==============================================================================
--- xerces/java/trunk/tests/idc/idc_6_invalid_1.xml (added)
+++ xerces/java/trunk/tests/idc/idc_6_invalid_1.xml Fri Nov 15 06:29:22 2019
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<X>
+  <Y>
+    <a>5</a>
+    <a>6</a>
+    <a>7</a>
+  </Y>
+  <b>8</b>
+  <b>7</b>
+  <b>10</b>
+</X>
\ No newline at end of file

Added: xerces/java/trunk/tests/idc/idc_6_valid_1.xml
URL: http://svn.apache.org/viewvc/xerces/java/trunk/tests/idc/idc_6_valid_1.xml?rev=1869829&view=auto
==============================================================================
--- xerces/java/trunk/tests/idc/idc_6_valid_1.xml (added)
+++ xerces/java/trunk/tests/idc/idc_6_valid_1.xml Fri Nov 15 06:29:22 2019
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<X>
+  <Y>
+    <a>5</a>
+    <a>6</a>
+    <a>7</a>
+  </Y>
+  <b>8</b>
+  <b>9</b>
+  <b>10</b>
+</X>
\ No newline at end of file



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