This is an automated email from the ASF dual-hosted git repository.
olabusayo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil.git
The following commit(s) were added to refs/heads/main by this push:
new 855215765 Flip ignoreUnexpectedValidationErrors flag
855215765 is described below
commit 855215765f5e07aee80f130096c216fbbe8fff06
Author: olabusayoT <[email protected]>
AuthorDate: Fri Sep 20 10:58:37 2024 -0400
Flip ignoreUnexpectedValidationErrors flag
- we want to ignore unexpected validation error as the default
- add test depending on the default and show that it passes with unexpected
validation errors
DAFFODIL-2927
---
.../org/apache/daffodil/tdml/RunnerFactory.scala | 2 +-
.../daffodil/processor/tdml/TestTDMLRunner2.scala | 60 ++++++++++++++++++++--
2 files changed, 58 insertions(+), 4 deletions(-)
diff --git
a/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/RunnerFactory.scala
b/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/RunnerFactory.scala
index 019b7b968..7daed6688 100644
---
a/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/RunnerFactory.scala
+++
b/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/RunnerFactory.scala
@@ -151,7 +151,7 @@ class Runner private (
defaultValidationDefault: String = Runner.defaultValidationDefaultDefault,
defaultImplementationsDefault: Seq[String] =
Runner.defaultImplementationsDefaultDefault,
defaultIgnoreUnexpectedWarningsDefault: Boolean = true,
- defaultIgnoreUnexpectedValidationErrorsDefault: Boolean = false
+ defaultIgnoreUnexpectedValidationErrorsDefault: Boolean = true
) {
/**
diff --git
a/daffodil-tdml-processor/src/test/scala/org/apache/daffodil/processor/tdml/TestTDMLRunner2.scala
b/daffodil-tdml-processor/src/test/scala/org/apache/daffodil/processor/tdml/TestTDMLRunner2.scala
index c68931b47..691e29924 100644
---
a/daffodil-tdml-processor/src/test/scala/org/apache/daffodil/processor/tdml/TestTDMLRunner2.scala
+++
b/daffodil-tdml-processor/src/test/scala/org/apache/daffodil/processor/tdml/TestTDMLRunner2.scala
@@ -218,8 +218,9 @@ class TestTDMLRunner2 {
* Exception expected? Yes
*
* Reasoning: The data parses successfully and fails 'limited' validation.
- * However the test case itself does not expect a validation error. The
- * purpose is to alert the test writer to the fact that a validation occurred
+ * However the test case itself does not expect a validation error. Since
+ * ignoreUnexpectedValidationError is set to false, the test will thrown an
+ * Exception alerting the test writer to the fact that a validation occurred
* that was not 'captured' in the test case.
*/
@Test def testValidationLimitedValidationErrorNotCapturedShouldThrow() = {
@@ -239,7 +240,7 @@ class TestTDMLRunner2 {
</tdml:defineSchema>
<tdml:parserTestCase xmlns={
tdml
- } name="testValidation" root="array" model="mySchema"
validation="limited">
+ } name="testValidation" root="array" model="mySchema"
validation="limited" ignoreUnexpectedValidationErrors="false">
<tdml:document>
<tdml:documentPart
type="text"><![CDATA[1|2|3|4|5|6|7|8|9]]></tdml:documentPart>
</tdml:document>
@@ -274,6 +275,59 @@ class TestTDMLRunner2 {
)
}
+ /**
+ * Validation=Limited
+ * Should Parse Succeed? Yes
+ * Exception expected? No
+ *
+ * Reasoning: The data parses successfully and fails 'limited' validation.
+ * However the test case itself does not expect a validation error. Since
+ * the ignoreUnexpectedValidationError defaults to true, the unexpected
validation
+ * error will be ignored, and the test will poss
+ */
+ @Test def testValidationLimitedValidationErrorNotCaptured = {
+ val testSuite =
+ <tdml:testSuite suiteName="theSuiteName" xmlns:tns={tns}
xmlns:tdml={tdml} xmlns:dfdl={
+ dfdl
+ } xmlns:xsd={xsd} xmlns:xs={xsd} xmlns:xsi={xsi}>
+ <tdml:defineSchema name="mySchema">
+ <xs:include
schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
+ <dfdl:format ref="tns:GeneralFormat" initiator="" terminator=""
leadingSkip="0" trailingSkip="0" textBidi="no" floating="no" encoding="utf-8"
byteOrder="bigEndian" alignment="1" alignmentUnits="bytes" fillByte="f"
occursCountKind="parsed" truncateSpecifiedLengthString="no" ignoreCase="no"
representation="text" lengthKind="delimited" nilValueDelimiterPolicy="both"
emptyValueDelimiterPolicy="none" documentFinalTerminatorCanBeMissing="yes"
initiatedContent="no" separatorSuppressio [...]
+ <xsd:element name="array" type="tns:arrayType"
dfdl:lengthKind="implicit"/>
+ <xsd:complexType name="arrayType">
+ <xsd:sequence dfdl:separator="|">
+ <xsd:element name="data" type="xsd:int" minOccurs="2"
maxOccurs="5" dfdl:textNumberRep="standard" dfdl:lengthKind="delimited"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </tdml:defineSchema>
+ <tdml:parserTestCase xmlns={
+ tdml
+ } name="testValidation" root="array" model="mySchema"
validation="limited">
+ <tdml:document>
+ <tdml:documentPart
type="text"><![CDATA[1|2|3|4|5|6|7|8|9]]></tdml:documentPart>
+ </tdml:document>
+ <tdml:infoset>
+ <tdml:dfdlInfoset>
+ <tns:array>
+ <data>1</data>
+ <data>2</data>
+ <data>3</data>
+ <data>4</data>
+ <data>5</data>
+ <data>6</data>
+ <data>7</data>
+ <data>8</data>
+ <data>9</data>
+ </tns:array>
+ </tdml:dfdlInfoset>
+ </tdml:infoset>
+ </tdml:parserTestCase>
+ </tdml:testSuite>
+
+ val runner = Runner(testSuite)
+ runner.runOneTest("testValidation")
+ }
+
/**
* Scala's XML Literals don't do CDATA regions right.
*