[
https://issues.apache.org/jira/browse/XERCESJ-1432?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Michael Glavassevich reassigned XERCESJ-1432:
---------------------------------------------
Assignee: Mukul Gandhi
> defect for Assertions during Junit tests
> ----------------------------------------
>
> Key: XERCESJ-1432
> URL: https://issues.apache.org/jira/browse/XERCESJ-1432
> Project: Xerces2-J
> Issue Type: Bug
> Components: XML Schema 1.1 Structures
> Affects Versions: 2.9.1
> Environment: Windows, Junit
> Reporter: Kun Xu
> Assignee: Mukul Gandhi
> Priority: Minor
> Original Estimate: 0.17h
> Remaining Estimate: 0.17h
>
> When we do JUnit tests for Schema 1.1, assertions on derived simple type
> definitions as following will cause failures for other test cases.
> For example.
> <?xml version="1.1"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> <xs:simpleType name="baseType">
> <xs:restriction base="xs:string">
> <xs:maxLength value="25"/>
> <xs:assertion test="ends-with($value, 'xyz')"/>
> </xs:restriction>
> </xs:simpleType>
> <xs:simpleType name="derivedType">
> <xs:restriction base="baseType">
> <xs:assertion test="string-length($value) gt 3 "/>
> </xs:restriction>
> </xs:simpleType>
>
> <xs:element name="root" type="derivedType" />
>
> </xs:schema>
> The reason is that we put fschemaFactory into the schemafactory pool for the
> first two test cases (one DOM and one SAX), then for other test cases, we
> just reuse the schemafactory stored in the pool. When we have above schema
> which contains a base type including a assertion, we use a global vector
> "private Vector baseAsserts = new Vector();" to hold all the asserts up in
> the type hierarchy. We should clear up this vector after validating each test
> case.
> There are two options to fix it .
> @version $Id: XSDAbstractTraverser.java 912155 2010-02-20 17:20:39Z mrglavas $
> 1. clear it up in the reset method:
> void reset(SymbolTable symbolTable, boolean validateAnnotations, Locale
> locale) {
> baseAsserts.clear(); // clear vector baseAsserts
> fSymbolTable = symbolTable;
> fValidateAnnotations = validateAnnotations;
> fValidationState.setExtraChecking(false);
> fValidationState.setSymbolTable(symbolTable);
> fValidationState.setLocale(locale);
>
> fValidationState.setTypeValidatorHelper(fSchemaHandler.fTypeValidatorHelper);
> }
> 2. clear it up every time after we use it.
> // retrieve all assert definitions from all base types all the way up
> in the
> // type hierarchy. sets a global variable, 'baseAsserts' with all the
> base
> // asserts.
> if (fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
> getAssertsFromBaseTypes(baseValidator);
> // add all base assertions to the list of assertions to be
> processed
> if (baseAsserts.size() > 0) {
> if (assertData == null) {
> assertData = new Vector();
> }
> assertData.addAll(baseAsserts);
> baseAsserts.clear(); // clear vector baseAsserts
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]