Author: mukulg
Date: Fri Nov 1 03:47:28 2019
New Revision: 1869230
URL: http://svn.apache.org/viewvc?rev=1869230&view=rev
Log:
committing few xsd idc tests on trunk
Added:
xerces/java/trunk/tests/idc/
xerces/java/trunk/tests/idc/AllTests.java (with props)
xerces/java/trunk/tests/idc/IDConstraintTests.java (with props)
xerces/java/trunk/tests/idc/idc_1.xsd
xerces/java/trunk/tests/idc/idc_1_invalid_1.xml
xerces/java/trunk/tests/idc/idc_1_invalid_2.xml
xerces/java/trunk/tests/idc/idc_1_invalid_3.xml
xerces/java/trunk/tests/idc/idc_1_valid_1.xml
xerces/java/trunk/tests/util/
xerces/java/trunk/tests/util/FailureMesgFragments.java (with props)
xerces/java/trunk/tests/util/XercesAbstractTestCase.java (with props)
Modified:
xerces/java/trunk/build.xml
Modified: xerces/java/trunk/build.xml
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/build.xml?rev=1869230&r1=1869229&r2=1869230&view=diff
==============================================================================
--- xerces/java/trunk/build.xml (original)
+++ xerces/java/trunk/build.xml Fri Nov 1 03:47:28 2019
@@ -920,6 +920,12 @@ Authors:
classname="dom.dom3.Test"
failOnError="yes">
<jvmarg
value="-Xbootclasspath/p:${tools.dir}/${jar.apis}${path.separator}${tools.dir}/${jar.resolver}${path.separator}${tools.dir}/${jar.serializer}${path.separator}${build.dir}/classes"/>
+ </java>
+ <echo message="Running idc.AllTests ..." />
+ <java fork="yes"
+ classname="idc.AllTests"
+ failOnError="yes">
+ <jvmarg
value="-Xbootclasspath/p:${tools.dir}/${jar.apis}${path.separator}${tools.dir}/${jar.resolver}${path.separator}${tools.dir}/${jar.serializer}${path.separator}${tools.dir}/${jar.junit}${path.separator}${build.dir}/classes${path.separator}${build.dir}/tests"/>
</java>
</target>
Added: xerces/java/trunk/tests/idc/AllTests.java
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/tests/idc/AllTests.java?rev=1869230&view=auto
==============================================================================
--- xerces/java/trunk/tests/idc/AllTests.java (added)
+++ xerces/java/trunk/tests/idc/AllTests.java Fri Nov 1 03:47:28 2019
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package idc;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * XSD IDC constraints tests.
+ *
+ * @author Mukul Gandhi <[email protected]>
+ * @version $Id$
+ */
+public class AllTests {
+
+ public static void main(String[] args) {
+ TestRunner.run(AllTests.suite());
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Tests for XSD IDC constraints.");
+ suite.addTestSuite(IDConstraintTests.class);
+ return suite;
+ }
+
+}
Propchange: xerces/java/trunk/tests/idc/AllTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/trunk/tests/idc/AllTests.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/trunk/tests/idc/IDConstraintTests.java
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/tests/idc/IDConstraintTests.java?rev=1869230&view=auto
==============================================================================
--- xerces/java/trunk/tests/idc/IDConstraintTests.java (added)
+++ xerces/java/trunk/tests/idc/IDConstraintTests.java Fri Nov 1 03:47:28 2019
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package idc;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.Validator;
+
+import util.FailureMesgFragments;
+import util.XercesAbstractTestCase;
+
+/**
+ * @author Mukul Gandhi <[email protected]>
+ * @version $Id$
+ */
+public class IDConstraintTests extends XercesAbstractTestCase {
+
+ public IDConstraintTests(String name) {
+ super(name);
+ }
+
+ public void testIDConstraint1() {
+ String xmlfile = "tests/idc/idc_1_valid_1.xml";
+ String schemapath = "tests/idc/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);
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+ public void testIDConstraint2() {
+ String xmlfile = "tests/idc/idc_1_invalid_1.xml";
+ String schemapath = "tests/idc/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));
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+ public void testIDConstraint3() {
+ String xmlfile = "tests/idc/idc_1_invalid_2.xml";
+ String schemapath = "tests/idc/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));
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+ public void testIDConstraint4() {
+ String xmlfile = "tests/idc/idc_1_invalid_3.xml";
+ String schemapath = "tests/idc/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));
+ } catch(Exception ex) {
+ ex.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+}
Propchange: xerces/java/trunk/tests/idc/IDConstraintTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/trunk/tests/idc/IDConstraintTests.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/trunk/tests/idc/idc_1.xsd
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/tests/idc/idc_1.xsd?rev=1869230&view=auto
==============================================================================
--- xerces/java/trunk/tests/idc/idc_1.xsd (added)
+++ xerces/java/trunk/tests/idc/idc_1.xsd Fri Nov 1 03:47:28 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/trunk/tests/idc/idc_1_invalid_1.xml
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/tests/idc/idc_1_invalid_1.xml?rev=1869230&view=auto
==============================================================================
--- xerces/java/trunk/tests/idc/idc_1_invalid_1.xml (added)
+++ xerces/java/trunk/tests/idc/idc_1_invalid_1.xml Fri Nov 1 03:47:28 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/trunk/tests/idc/idc_1_invalid_2.xml
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/tests/idc/idc_1_invalid_2.xml?rev=1869230&view=auto
==============================================================================
--- xerces/java/trunk/tests/idc/idc_1_invalid_2.xml (added)
+++ xerces/java/trunk/tests/idc/idc_1_invalid_2.xml Fri Nov 1 03:47:28 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/trunk/tests/idc/idc_1_invalid_3.xml
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/tests/idc/idc_1_invalid_3.xml?rev=1869230&view=auto
==============================================================================
--- xerces/java/trunk/tests/idc/idc_1_invalid_3.xml (added)
+++ xerces/java/trunk/tests/idc/idc_1_invalid_3.xml Fri Nov 1 03:47:28 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/trunk/tests/idc/idc_1_valid_1.xml
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/tests/idc/idc_1_valid_1.xml?rev=1869230&view=auto
==============================================================================
--- xerces/java/trunk/tests/idc/idc_1_valid_1.xml (added)
+++ xerces/java/trunk/tests/idc/idc_1_valid_1.xml Fri Nov 1 03:47:28 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
Added: xerces/java/trunk/tests/util/FailureMesgFragments.java
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/tests/util/FailureMesgFragments.java?rev=1869230&view=auto
==============================================================================
--- xerces/java/trunk/tests/util/FailureMesgFragments.java (added)
+++ xerces/java/trunk/tests/util/FailureMesgFragments.java Fri Nov 1 03:47:28
2019
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents ONE "error/fatal error/warning" message. Various fragments of
ONE "error/fatal error/warning" message
+ * can be stored in this object.
+ *
+ * @author Mukul Gandhi <[email protected]>
+ * @version $Id$
+ */
+public class FailureMesgFragments {
+
+ private List mesgFragments = null;
+
+ // class constructor
+ public FailureMesgFragments() {
+ mesgFragments = new ArrayList();
+ }
+
+ public void setMessageFragment(String mesgFragment) {
+ mesgFragments.add(mesgFragment);
+ }
+
+ public List getMessageFragments() {
+ return mesgFragments;
+ }
+
+}
Propchange: xerces/java/trunk/tests/util/FailureMesgFragments.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/trunk/tests/util/FailureMesgFragments.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/trunk/tests/util/XercesAbstractTestCase.java
URL:
http://svn.apache.org/viewvc/xerces/java/trunk/tests/util/XercesAbstractTestCase.java?rev=1869230&view=auto
==============================================================================
--- xerces/java/trunk/tests/util/XercesAbstractTestCase.java (added)
+++ xerces/java/trunk/tests/util/XercesAbstractTestCase.java Fri Nov 1
03:47:28 2019
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package util;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.XMLConstants;
+import javax.xml.validation.SchemaFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.xerces.xs.ElementPSVI;
+import org.apache.xerces.xs.XSSimpleTypeDefinition;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @author Mukul Gandhi <[email protected]>
+ * @version $Id$
+ */
+public class XercesAbstractTestCase extends TestCase implements ErrorHandler {
+
+ protected SchemaFactory fSchemaFactory = null;
+ protected String fErrSysId = null;
+ protected String fFatErrSysId = null;
+ protected String fWarningSysId = null;
+ protected String fErrorMessage = null;
+ // to maintain a collection of errors and/or warnings for ONE test case
execution
+ protected List failureList = null;
+ protected List warningList = null;
+
+ protected boolean checkOnlyWarnings = false;
+
+ protected static final String DEFAULT_SCHEMA_LANGUAGE =
XMLConstants.W3C_XML_SCHEMA_NS_URI;
+ protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID =
"http://apache.org/xml/features/validation/schema-full-checking";
+
+ public XercesAbstractTestCase(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ fSchemaFactory =
SchemaFactory.newInstance(DEFAULT_SCHEMA_LANGUAGE);
+ failureList = new ArrayList();
+ warningList = new ArrayList();
+ }
+
+ protected void tearDown() throws Exception {
+ fErrSysId = null;
+ fFatErrSysId = null;
+ failureList = null;
+ warningList = null;
+ checkOnlyWarnings = false;
+ }
+
+ public void error(SAXParseException exception) throws SAXException {
+ fErrSysId = exception.getSystemId();
+ fErrorMessage = exception.getMessage();
+ failureList.add(new Error(fErrSysId, fErrorMessage));
+ }
+
+ public void fatalError(SAXParseException exception) throws SAXException {
+ fFatErrSysId = exception.getSystemId();
+ fErrorMessage = exception.getMessage();
+ failureList.add(new FatalError(fErrSysId, fErrorMessage));
+ }
+
+ public void warning(SAXParseException exception) throws SAXException {
+ fWarningSysId = exception.getSystemId();
+ fErrorMessage = exception.getMessage();
+ warningList.add(new Warning(fWarningSysId, fErrorMessage));
+ }
+
+
+ /*
+ * Are error messages generated during the validation episode, as
specified in the test case.
+ */
+ public boolean areErrorMessagesConsistent(List expectedMsgList) {
+ boolean isErrorMesgsOk = true;
+ for (int mesgIdx = 0; mesgIdx < expectedMsgList.size();
mesgIdx++) {
+ FailureMesgFragments mesgFragments =
(FailureMesgFragments) expectedMsgList.get(mesgIdx);
+ if (!areMesgFragmentsOk(mesgFragments)) {
+ isErrorMesgsOk = false;
+ break;
+ }
+ }
+ return isErrorMesgsOk;
+ } // areErrorMessagesConsistent
+
+
+ /*
+ * Checks fragments of one error/failure message.
+ */
+ private boolean areMesgFragmentsOk(FailureMesgFragments mesgFragments) {
+
+ boolean areMesgFragsOk = false;
+
+ List mesgFragmentItems = mesgFragments.getMessageFragments();
+ Iterator iter = null;
+ if (checkOnlyWarnings) {
+ iter = warningList.iterator();
+ }
+ else {
+ iter = failureList.iterator();
+ }
+ for ( ; iter.hasNext(); ) {
+ Object failureInstance = iter.next();
+ String failureMesg = "";
+ if (failureInstance instanceof Error) {
+ failureMesg = ((Error)
failureInstance).getFailureMessage();
+ }
+ else if (failureInstance instanceof FatalError) {
+ failureMesg = ((FatalError)
failureInstance).getFailureMessage();
+ }
+ else if (failureInstance instanceof Warning) {
+ failureMesg = ((Warning)
failureInstance).getFailureMessage();
+ }
+ int matchCount = 0;
+ for (Iterator mesg_iter = mesgFragmentItems.iterator();
mesg_iter.hasNext(); ) {
+ String mesgFrag = (String) mesg_iter.next();
+ if (failureMesg.indexOf(mesgFrag) != -1) {
+ matchCount++;
+ }
+ }
+ if (matchCount == mesgFragmentItems.size()) {
+ areMesgFragsOk = true;
+ break;
+ }
+ }
+
+
+ return areMesgFragsOk;
+
+ } // areMesgFragmentsOk
+
+
+ protected String getMemberTypePsviInfo(ElementPSVI elmPsviInfo) {
+ String memTypeStr = null;
+ XSSimpleTypeDefinition memType =
elmPsviInfo.getMemberTypeDefinition();
+ if (memType != null) {
+ memTypeStr = memType.getName();
+ }
+ return memTypeStr;
+ } // getMemberTypePsviInfo
+
+
+ class XercesFailure {
+ String systemId;
+ String failureMessage;
+
+ public XercesFailure(String systemId, String failureMessage) {
+ this.systemId = systemId;
+ this.failureMessage = failureMessage;
+ }
+
+ public String getFailureMessage() {
+ return failureMessage;
+ }
+ }
+
+ class Error extends XercesFailure {
+ public Error(String systemId, String failureMessage) {
+ super(systemId, failureMessage);
+ }
+ }
+
+ class FatalError extends XercesFailure {
+ public FatalError(String systemId, String failureMessage) {
+ super(systemId, failureMessage);
+ }
+ }
+
+ class Warning extends XercesFailure {
+ public Warning(String systemId, String failureMessage) {
+ super(systemId, failureMessage);
+ }
+ }
+
+}
Propchange: xerces/java/trunk/tests/util/XercesAbstractTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/trunk/tests/util/XercesAbstractTestCase.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]