Author: mukulg
Date: Tue Nov 12 05:59:26 2019
New Revision: 1869680
URL: http://svn.apache.org/viewvc?rev=1869680&view=rev
Log:
committing few new xsd test cases. also, modifying one of the previous test
case.
Added:
xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_ref_attr_1.xsd
xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_ref_attr_invalid_1.xml
xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_ref_attr_valid_1.xml
Modified:
xerces/java/branches/xs-1.1-tests/src/org/apache/xerces/tests/IDConstraintTests.java
xerces/java/branches/xs-1.1-tests/src/org/apache/xerces/tests/OpenContentTests.java
Added: xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_ref_attr_1.xsd
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_ref_attr_1.xsd?rev=1869680&view=auto
==============================================================================
--- xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_ref_attr_1.xsd
(added)
+++ xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_ref_attr_1.xsd Tue
Nov 12 05:59:26 2019
@@ -0,0 +1,27 @@
+<?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="a" type="xs:integer" maxOccurs="unbounded"/>
+ <xs:element name="b" type="xs:integer"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:key name="a_key">
+ <xs:selector xpath="a"/>
+ <xs:field xpath="."/>
+ </xs:key>
+ </xs:element>
+
+ <xs:element name="Y">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="a" type="xs:integer" maxOccurs="unbounded"/>
+ <xs:element name="b" type="xs:integer"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:key ref="a_key"/>
+ </xs:element>
+
+</xs:schema>
\ No newline at end of file
Added:
xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_ref_attr_invalid_1.xml
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_ref_attr_invalid_1.xml?rev=1869680&view=auto
==============================================================================
---
xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_ref_attr_invalid_1.xml
(added)
+++
xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_ref_attr_invalid_1.xml
Tue Nov 12 05:59:26 2019
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Y>
+ <a>2</a>
+ <a>3</a>
+ <a>2</a>
+ <b>12</b>
+</Y>
\ No newline at end of file
Added:
xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_ref_attr_valid_1.xml
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_ref_attr_valid_1.xml?rev=1869680&view=auto
==============================================================================
---
xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_ref_attr_valid_1.xml
(added)
+++
xerces/java/branches/xs-1.1-tests/data/idconstraints/idc_ref_attr_valid_1.xml
Tue Nov 12 05:59:26 2019
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Y>
+ <a>2</a>
+ <a>3</a>
+ <a>4</a>
+ <b>12</b>
+</Y>
\ 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=1869680&r1=1869679&r2=1869680&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
Tue Nov 12 05:59:26 2019
@@ -25,6 +25,8 @@ import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
+import org.xml.sax.SAXParseException;
+
/**
* @xerces.internal
*
@@ -1007,6 +1009,62 @@ public class IDConstraintTests extends X
expectedMsgList.add(mesgFragments);
assertTrue(areErrorMessagesConsistent(expectedMsgList));
} catch(Exception ex) {
+ ex.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+ public void testIDConstraint35() {
+ // run validation in XSD 1.0 mode
+ fSchemaFactory =
SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE);
+ String xmlfile =
fDataDir+"/idconstraints/idc_ref_attr_valid_1.xml";
+ String schemapath =
fDataDir+"/idconstraints/idc_ref_attr_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);
+ } catch(Exception ex) {
+ // schema is incorrect. an exception indicates, that this
test has 'passed'.
+ assertEquals(ex instanceof SAXParseException, true);
+ assertEquals("s4s-att-not-allowed: Attribute 'ref' cannot
appear in element 'key'.", ex.getMessage());
+ }
+ }
+
+ public void testIDConstraint36() {
+ String xmlfile =
fDataDir+"/idconstraints/idc_ref_attr_valid_1.xml";
+ String schemapath =
fDataDir+"/idconstraints/idc_ref_attr_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);
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+ public void testIDConstraint37() {
+ String xmlfile =
fDataDir+"/idconstraints/idc_ref_attr_invalid_1.xml";
+ String schemapath =
fDataDir+"/idconstraints/idc_ref_attr_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() == 1);
+ // test expected error messages
+ List expectedMsgList = new ArrayList();
+ FailureMesgFragments mesgFragments = new FailureMesgFragments();
+ mesgFragments.setMessageFragment("cvc-identity-constraint.4.2.2:
Duplicate key value [2] found for identity constraint \"a_key\" of element
\"Y\"");
+ expectedMsgList.add(mesgFragments);
+ assertTrue(areErrorMessagesConsistent(expectedMsgList));
+ } catch(Exception ex) {
ex.printStackTrace();
assertTrue(false);
}
Modified:
xerces/java/branches/xs-1.1-tests/src/org/apache/xerces/tests/OpenContentTests.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xs-1.1-tests/src/org/apache/xerces/tests/OpenContentTests.java?rev=1869680&r1=1869679&r2=1869680&view=diff
==============================================================================
---
xerces/java/branches/xs-1.1-tests/src/org/apache/xerces/tests/OpenContentTests.java
(original)
+++
xerces/java/branches/xs-1.1-tests/src/org/apache/xerces/tests/OpenContentTests.java
Tue Nov 12 05:59:26 2019
@@ -21,6 +21,8 @@ import javax.xml.transform.stream.Stream
import javax.xml.validation.Schema;
import javax.xml.validation.Validator;
+import org.xml.sax.SAXParseException;
+
/**
* @xerces.internal
*
@@ -140,10 +142,11 @@ public class OpenContentTests extends Xe
assertNull(fErrSysId);
assertNull(fFatErrSysId);
} catch(Exception ex) {
- ex.printStackTrace();
- // schema is incorrect. an exception indicates, that this
test
- // has 'passed'.
- assertTrue(true);
+ // schema is incorrect. an exception indicates, that this
test has 'passed'.
+ assertEquals(ex instanceof SAXParseException, true);
+ assertEquals("src-ct11.3: Complex Type Definition
Representation Error for type 'BookPublication'. "
+ + "If <openContent> is present and has
mode = none, then there must not be an <any> among "
+ + "the [children] of <openContent>.",
ex.getMessage());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]