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 2022/04/18 13:23:49 UTC

svn commit: r1899981 - in /xerces/java/branches/xml-schema-1.1-tests: data/jira_bugs/1744_3.xsd data/jira_bugs/1744_4.xml data/jira_bugs/1744_4.xsd src/org/apache/xerces/tests/JiraBugsTests.java

Author: mukulg
Date: Mon Apr 18 13:23:49 2022
New Revision: 1899981

URL: http://svn.apache.org/viewvc?rev=1899981&view=rev
Log:
adding few test cases, for jira issue XERCESJ-1744

Added:
    xerces/java/branches/xml-schema-1.1-tests/data/jira_bugs/1744_3.xsd
    xerces/java/branches/xml-schema-1.1-tests/data/jira_bugs/1744_4.xml
    xerces/java/branches/xml-schema-1.1-tests/data/jira_bugs/1744_4.xsd
Modified:
    xerces/java/branches/xml-schema-1.1-tests/src/org/apache/xerces/tests/JiraBugsTests.java

Added: xerces/java/branches/xml-schema-1.1-tests/data/jira_bugs/1744_3.xsd
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-tests/data/jira_bugs/1744_3.xsd?rev=1899981&view=auto
==============================================================================
--- xerces/java/branches/xml-schema-1.1-tests/data/jira_bugs/1744_3.xsd (added)
+++ xerces/java/branches/xml-schema-1.1-tests/data/jira_bugs/1744_3.xsd Mon Apr 18 13:23:49 2022
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+    
+    <xs:element name="X">
+       <xs:complexType>
+          <xs:simpleContent>
+             <xs:extension base="xs:string">
+               <xs:attribute name="attr1">
+                 <xs:simpleType>
+                   <xs:list itemType="DATE_TYPE"/>
+                 </xs:simpleType>
+              </xs:attribute>
+            </xs:extension>
+          </xs:simpleContent>
+       </xs:complexType>
+    </xs:element>
+    
+    <xs:simpleType name="DATE_TYPE">
+       <xs:union memberTypes="DATE_TYPE1 DATE_TYPE2"/>
+    </xs:simpleType>
+    
+    <xs:simpleType name="DATE_TYPE1">
+       <xs:restriction base="xs:date">
+         <xs:assertion test="$value lt current-date()"/>
+       </xs:restriction>
+    </xs:simpleType>
+    
+    <xs:simpleType name="DATE_TYPE2">
+      <xs:restriction base="xs:date">
+         <xs:assertion test="$value gt current-date()"/>
+      </xs:restriction>
+    </xs:simpleType>
+
+</xs:schema>
\ No newline at end of file

Added: xerces/java/branches/xml-schema-1.1-tests/data/jira_bugs/1744_4.xml
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-tests/data/jira_bugs/1744_4.xml?rev=1899981&view=auto
==============================================================================
--- xerces/java/branches/xml-schema-1.1-tests/data/jira_bugs/1744_4.xml (added)
+++ xerces/java/branches/xml-schema-1.1-tests/data/jira_bugs/1744_4.xml Mon Apr 18 13:23:49 2022
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<X attr1="2012-10-07 7756-10-05"/>
\ No newline at end of file

Added: xerces/java/branches/xml-schema-1.1-tests/data/jira_bugs/1744_4.xsd
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-tests/data/jira_bugs/1744_4.xsd?rev=1899981&view=auto
==============================================================================
--- xerces/java/branches/xml-schema-1.1-tests/data/jira_bugs/1744_4.xsd (added)
+++ xerces/java/branches/xml-schema-1.1-tests/data/jira_bugs/1744_4.xsd Mon Apr 18 13:23:49 2022
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+    
+    <xs:element name="X">
+       <xs:complexType>
+          <xs:simpleContent>
+             <xs:extension base="xs:string">
+               <xs:attribute name="attr1">
+                 <xs:simpleType>
+                   <xs:list itemType="DATE_TYPE"/>
+                 </xs:simpleType>
+              </xs:attribute>
+            </xs:extension>
+          </xs:simpleContent>
+       </xs:complexType>
+    </xs:element>
+    
+    <xs:simpleType name="DATE_TYPE">
+       <xs:union memberTypes="DATE_TYPE1 DATE_TYPE2"/>
+    </xs:simpleType>
+    
+    <xs:simpleType name="DATE_TYPE1">
+       <xs:restriction base="xs:date">
+         <xs:assertion test="$value lt current-date()"/>
+       </xs:restriction>
+    </xs:simpleType>
+    
+    <xs:simpleType name="DATE_TYPE2">
+      <xs:restriction base="xs:date">
+         <xs:assertion test="$value lt current-date()"/>
+      </xs:restriction>
+    </xs:simpleType>
+
+</xs:schema>
\ No newline at end of file

Modified: xerces/java/branches/xml-schema-1.1-tests/src/org/apache/xerces/tests/JiraBugsTests.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-tests/src/org/apache/xerces/tests/JiraBugsTests.java?rev=1899981&r1=1899980&r2=1899981&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-tests/src/org/apache/xerces/tests/JiraBugsTests.java (original)
+++ xerces/java/branches/xml-schema-1.1-tests/src/org/apache/xerces/tests/JiraBugsTests.java Mon Apr 18 13:23:49 2022
@@ -796,5 +796,45 @@ public class JiraBugsTests extends Xerce
 		   assertTrue(false);
 		}
 	}
+	
+	public void testJira_1744_4() {
+		String xmlfile = fDataDir+"/jira_bugs/1744_4.xml";
+		String schemapath = fDataDir+"/jira_bugs/1744_3.xsd";		
+		try {
+		    Schema s = fSchemaFactory.newSchema(new File(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 testJira_1744_5() {
+		String xmlfile = fDataDir+"/jira_bugs/1744_4.xml";
+		String schemapath = fDataDir+"/jira_bugs/1744_4.xsd";		
+		try {
+			fSchemaFactory.setErrorHandler(this);
+		    Schema s = fSchemaFactory.newSchema(new File(schemapath));
+            Validator v = s.newValidator();
+		    v.setErrorHandler(this);
+            v.validate(new DOMSource(getDomDocument(xmlfile)));
+            assertTrue(failureList.size() == 1);
+		    // test expected error messages
+            List expectedMsgList = new ArrayList();
+            FailureMesgFragments mesgFragments = new FailureMesgFragments();
+            mesgFragments.setMessageFragment("cvc-datatype-valid.4.1.4: The value '2012-10-07 7756-10-05' of attribute "
+            		                         + "'attr1' on element 'X' is not valid with the required simple type. Value '7756-10-05' "
+            		                         + "is not valid with any member of union type 'DATE_TYPE'");
+            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