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 fc521603c Add ignoreUnexpectedValidationErrors Attribute for test
suite/cases
fc521603c is described below
commit fc521603c22df1d3b89502cb097dca4807421958
Author: olabusayoT <[email protected]>
AuthorDate: Tue Sep 17 12:16:26 2024 -0400
Add ignoreUnexpectedValidationErrors Attribute for test suite/cases
- remove validationError asserts and shouldValidate/expectValidationError
variables
- remove support for <tdml:validationErrors/>, it must have at least one
child
- specify DiagnosticType specific message when there are unexpected diags
- add/update tests
DAFFODIL-2927
---
.../resources/org/apache/daffodil/xsd/tdml.xsd | 9 +-
.../org/apache/daffodil/tdml/RunnerFactory.scala | 6 +-
.../org/apache/daffodil/tdml/TDMLRunner.scala | 86 ++++----
.../daffodil/processor/tdml/TestRunnerFactory.java | 1 +
.../tdml/testTDMLErrorsWarningsMatchAttribute.tdml | 20 ++
.../daffodil/processor/tdml/TestTDMLRunner2.scala | 4 +-
.../tdml/TestTDMLRunnerMatchAttributes.scala | 18 +-
.../tdml/TestTDMLRunnerValidationErrors.scala | 236 +++++++++++++++++++++
.../daffodil/section00/general/tunables.tdml | 2 -
.../section02/validation_errors/Validation.tdml | 1 -
10 files changed, 318 insertions(+), 65 deletions(-)
diff --git a/daffodil-lib/src/main/resources/org/apache/daffodil/xsd/tdml.xsd
b/daffodil-lib/src/main/resources/org/apache/daffodil/xsd/tdml.xsd
index 39d4eb9c6..6d4562f39 100644
--- a/daffodil-lib/src/main/resources/org/apache/daffodil/xsd/tdml.xsd
+++ b/daffodil-lib/src/main/resources/org/apache/daffodil/xsd/tdml.xsd
@@ -76,6 +76,7 @@
<attribute name="defaultConfig" type="xs:string" use="optional"/>
<attribute name="defaultImplementations" type="tns:implementationsType"
use="optional"/>
<attribute name="defaultIgnoreUnexpectedWarnings" type="xs:boolean"
use="optional"/>
+ <attribute name="defaultIgnoreUnexpectedValidationErrors"
type="xs:boolean" use="optional"/>
</complexType>
<unique name="unique-parserTestCase-name">
<selector xpath="parserTestCase"/>
@@ -186,7 +187,7 @@
<attribute name="validation" type="tns:validationType" use="optional"/>
<attribute name="implementations" type="tns:implementationsType"
use="optional"/>
<attribute name="ignoreUnexpectedWarnings" type="xs:boolean"
use="optional"/>
-
+ <attribute name="ignoreUnexpectedValidationErrors" type="xs:boolean"
use="optional"/>
</attributeGroup>
<simpleType name="roundTripType">
@@ -328,16 +329,14 @@
<complexType name="warningsType">
<sequence>
- <element ref="tns:warning" maxOccurs="unbounded" minOccurs="0"/>
- <!-- use <warnings/> to indicate no warnings should
occur. -->
+ <element ref="tns:warning" maxOccurs="unbounded" minOccurs="1"/>
</sequence>
<attributeGroup ref="tns:errorWarnAttribs"/>
</complexType>
<complexType name="validationErrorsType">
<sequence>
- <element ref="tns:error" maxOccurs="unbounded" minOccurs="0"/>
- <!-- use <validationErrors/> to indicate no validation
should occur. -->
+ <element ref="tns:error" maxOccurs="unbounded" minOccurs="1"/>
</sequence>
<attributeGroup ref="tns:errorWarnAttribs"/>
</complexType>
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 722bc4d41..019b7b968 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
@@ -150,7 +150,8 @@ class Runner private (
defaultRoundTripDefault: RoundTrip = Runner.defaultRoundTripDefaultDefault,
defaultValidationDefault: String = Runner.defaultValidationDefaultDefault,
defaultImplementationsDefault: Seq[String] =
Runner.defaultImplementationsDefaultDefault,
- defaultIgnoreUnexpectedWarningsDefault: Boolean = true
+ defaultIgnoreUnexpectedWarningsDefault: Boolean = true,
+ defaultIgnoreUnexpectedValidationErrorsDefault: Boolean = false
) {
/**
@@ -222,7 +223,8 @@ class Runner private (
defaultImplementationsDefault,
Runner.defaultShouldDoErrorComparisonOnCrossTests,
Runner.defaultShouldDoWarningComparisonOnCrossTests,
- defaultIgnoreUnexpectedWarningsDefault
+ defaultIgnoreUnexpectedWarningsDefault,
+ defaultIgnoreUnexpectedValidationErrorsDefault
)
}
ts
diff --git
a/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala
b/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala
index 152ed6360..0cfe487d4 100644
--- a/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala
+++ b/daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala
@@ -171,7 +171,10 @@ private[tdml] object DFDLTestSuite {
* during cross testing.
*
* defaultIgnoreUnexpectedWarningsDefault specifies whether a test should
ignore unexpected warnings (i.e it creates
- * warnings, but there is no tdml:warnings elements)
+ * warnings, but there is no tdml:warnings element)
+ *
+ * defaultIgnoreUnexpectedValidationErrorsDefault specifies whether a test
should ignore unexpected validation errors (i.e it creates
+ * validation errors, but there is no tdml:validationErrors element)
*/
class DFDLTestSuite private[tdml] (
@@ -185,7 +188,8 @@ class DFDLTestSuite private[tdml] (
val defaultImplementationsDefault: Seq[String],
val shouldDoErrorComparisonOnCrossTests: Boolean,
val shouldDoWarningComparisonOnCrossTests: Boolean,
- val defaultIgnoreUnexpectedWarningsDefault: Boolean
+ val defaultIgnoreUnexpectedWarningsDefault: Boolean,
+ val defaultIgnoreUnexpectedValidationErrorsDefault: Boolean
) {
val TMP_DIR = System.getProperty("java.io.tmpdir", ".")
@@ -423,6 +427,10 @@ class DFDLTestSuite private[tdml] (
val str = (ts \ "@defaultIgnoreUnexpectedWarnings").text
if (str == "") defaultIgnoreUnexpectedWarningsDefault else str.toBoolean
}
+ lazy val defaultIgnoreUnexpectedValidationErrors = {
+ val str = (ts \ "@defaultIgnoreUnexpectedValidationErrors").text
+ if (str == "") defaultIgnoreUnexpectedValidationErrorsDefault else
str.toBoolean
+ }
lazy val embeddedSchemas = {
val res = (ts \ "defineSchema").map { node => DefinedSchema(node, this) }
@@ -619,6 +627,8 @@ abstract class TestCase(testCaseXML: NodeSeq, val parent:
DFDLTestSuite) {
lazy val defaultRoundTrip: RoundTrip = parent.defaultRoundTrip
lazy val defaultValidationMode: ValidationMode.Type =
parent.defaultValidationMode
lazy val defaultIgnoreUnexpectedWarnings: Boolean =
parent.defaultIgnoreUnexpectedWarnings
+ lazy val defaultIgnoreUnexpectedValidationErrors: Boolean =
+ parent.defaultIgnoreUnexpectedValidationErrors
private lazy val defaultImplementations: Seq[String] =
parent.defaultImplementations
private lazy val tcImplementations = (testCaseXML \ "@implementations").text
@@ -730,6 +740,11 @@ abstract class TestCase(testCaseXML: NodeSeq, val parent:
DFDLTestSuite) {
lazy val ignoreUnexpectedWarnings: Boolean =
if (tcIgnoreUnexpectedWarnings == "") defaultIgnoreUnexpectedWarnings
else tcIgnoreUnexpectedWarnings.toBoolean
+ lazy val tcIgnoreUnexpectedValidationErrors: String =
+ (testCaseXML \ "@ignoreUnexpectedValidationErrors").text
+ lazy val ignoreUnexpectedValidationErrors: Boolean =
+ if (tcIgnoreUnexpectedValidationErrors == "")
defaultIgnoreUnexpectedValidationErrors
+ else tcIgnoreUnexpectedValidationErrors.toBoolean
lazy val description = (testCaseXML \ "@description").text
lazy val unsupported = (testCaseXML \ "@unsupported").text match {
@@ -742,20 +757,6 @@ abstract class TestCase(testCaseXML: NodeSeq, val parent:
DFDLTestSuite) {
case mode => ValidationMode.fromString(mode)
}
- lazy val shouldValidate = validationMode != ValidationMode.Off
- lazy val ignoreUnexpectedValidationErrors = if
(optExpectedValidationErrors.isDefined) {
- optExpectedValidationErrors.get.exists(
- _.hasDiagnostics
- ) // ignore unexpected validation errors will be false if
<tdml:validationErrors /> or true
- // if there are children under validationErrors
- } else {
- true // ignore unexpected validation errors if there is no
validationErrors element
- }
- lazy val expectsValidationError =
- if (optExpectedValidationErrors.isDefined)
- optExpectedValidationErrors.get.exists(_.hasDiagnostics)
- else false
-
protected def runProcessor(
compileResult: TDML.CompileResult,
expectedData: Option[InputStream],
@@ -1063,7 +1064,14 @@ case class ParserTestCase(ptc: NodeSeq, parentArg:
DFDLTestSuite)
(optExpectedInfoset, optExpectedErrors) match {
case (Some(_), None) => {
compileResult match {
- case Left(diags) => throw TDMLException(diags, implString)
+ case Left(diags) =>
+ checkDiagnosticMessages(
+ diags,
+ optExpectedErrors,
+ optExpectedWarnings,
+ optExpectedValidationErrors,
+ implString
+ )
case Right((diags, proc)) => {
processor = proc
runParseExpectSuccess(
@@ -1265,10 +1273,6 @@ case class ParserTestCase(ptc: NodeSeq, parentArg:
DFDLTestSuite)
optExpectedValidationErrors,
implString
)
- if (shouldValidate && !expectsValidationError)
- Assert.invariant(!actual.isValidationError)
- else if (expectsValidationError)
- Assert.invariant(actual.isValidationError)
}
/**
@@ -1691,11 +1695,6 @@ case class UnparserTestCase(ptc: NodeSeq, parentArg:
DFDLTestSuite)
val xmlNode = parseActual.getResult
VerifyTestCase.verifyParserTestData(xmlNode, inputInfoset, implString)
- if (shouldValidate && !expectsValidationError)
- Assert.invariant(!actual.isValidationError)
- else if (expectsValidationError)
- Assert.invariant(actual.isValidationError)
-
leftOverException.map {
throw _
} // if we get here, throw the left over data exception.
@@ -1867,9 +1866,7 @@ object VerifyTestCase {
val actualDiagsFilteredMessages = actualDiagsFiltered.map(_.toString())
// throw exception if we have no actualDiags, but have expected diagnostics
- val hasExpectedDiagnostics = (expectedDiags.isDefined
- && expectedDiags.get.exists(_.hasDiagnostics))
- if (hasExpectedDiagnostics && actualDiagsFiltered.isEmpty) {
+ if (expectedDiags.isDefined && actualDiagsFiltered.isEmpty) {
throw TDMLException(
""""Diagnostic message(s) were expected but not found."""" +
"\n" +
@@ -1884,12 +1881,15 @@ object VerifyTestCase {
)
}
- val hasUnexpectedDiags =
- (expectedDiags.isEmpty || !expectedDiags.get.exists(_.hasDiagnostics)) &&
- actualDiagsFiltered.nonEmpty
+ val hasUnexpectedDiags = expectedDiags.isEmpty &&
actualDiagsFiltered.nonEmpty
if (hasUnexpectedDiags && !ignoreUnexpectedDiags) {
+ val flagMessage = diagnosticType match {
+ case DiagnosticType.ValidationError =>
"ignoreUnexpectedValidationErrors = false and "
+ case DiagnosticType.Warning => "ignoreUnexpectedWarnings = false and "
+ case DiagnosticType.Error => ""
+ }
throw TDMLException(
- s"ignoreUnexpectedDiags = false and test does not expect
${diagnosticType} diagnostics, but created the following: " +
+ s"${flagMessage}test does not expect ${diagnosticType} diagnostics,
but created the following: " +
s"${actualDiagsFilteredMessages.mkString("\n")}",
implString
)
@@ -2858,14 +2858,7 @@ abstract class ErrorWarningBase(n: NodeSeq, parent:
TestCase) {
case class ExpectedErrors(node: NodeSeq, parent: TestCase)
extends ErrorWarningBase(node, parent) {
- val diagnosticNodes = {
- val nodes = (node \\ "error")
- if (nodes.isEmpty) {
- throw TDMLException("tdml:errors must have at least one child element",
None)
- } else {
- nodes
- }
- }
+ val diagnosticNodes = (node \\ "error")
override def isError = true
override def diagnosticType: DiagnosticType = DiagnosticType.Error
@@ -2874,14 +2867,7 @@ case class ExpectedErrors(node: NodeSeq, parent:
TestCase)
case class ExpectedWarnings(node: NodeSeq, parent: TestCase)
extends ErrorWarningBase(node, parent) {
- val diagnosticNodes = {
- val nodes = (node \\ "warning")
- if (nodes.isEmpty) {
- throw TDMLException("tdml:warnings must have at least one child
element", None)
- } else {
- nodes
- }
- }
+ val diagnosticNodes = (node \\ "warning")
override def isError = false
override def diagnosticType: DiagnosticType = DiagnosticType.Warning
@@ -2890,7 +2876,7 @@ case class ExpectedWarnings(node: NodeSeq, parent:
TestCase)
case class ExpectedValidationErrors(node: NodeSeq, parent: TestCase)
extends ErrorWarningBase(node, parent) {
- val diagnosticNodes = node \\ "error"
+ val diagnosticNodes = (node \\ "error")
override def isError = true
override def diagnosticType: DiagnosticType = DiagnosticType.ValidationError
diff --git
a/daffodil-tdml-processor/src/test/java/org/apache/daffodil/processor/tdml/TestRunnerFactory.java
b/daffodil-tdml-processor/src/test/java/org/apache/daffodil/processor/tdml/TestRunnerFactory.java
index 6506a87f3..1bca68026 100644
---
a/daffodil-tdml-processor/src/test/java/org/apache/daffodil/processor/tdml/TestRunnerFactory.java
+++
b/daffodil-tdml-processor/src/test/java/org/apache/daffodil/processor/tdml/TestRunnerFactory.java
@@ -51,6 +51,7 @@ public class TestRunnerFactory {
NoRoundTrip$.MODULE$,
"off",
JavaConverters.asScalaBufferConverter(Arrays.asList("daffodil",
"ibm")).asScala(),
+ false,
false);
runner.runOneTest("testPass");
runner.reset();
diff --git
a/daffodil-tdml-processor/src/test/resources/test/tdml/testTDMLErrorsWarningsMatchAttribute.tdml
b/daffodil-tdml-processor/src/test/resources/test/tdml/testTDMLErrorsWarningsMatchAttribute.tdml
index eeb6eafee..a699699ef 100644
---
a/daffodil-tdml-processor/src/test/resources/test/tdml/testTDMLErrorsWarningsMatchAttribute.tdml
+++
b/daffodil-tdml-processor/src/test/resources/test/tdml/testTDMLErrorsWarningsMatchAttribute.tdml
@@ -102,6 +102,8 @@
<xs:include
schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
<dfdl:format ref="ex:GeneralFormat" lengthKind="explicit"
occursCountKind="implicit"/>
+ <xs:element name="causesSDE" type="xs:boolean" dfdl:inputValueCalc="{
'whatever' }"/>
+
<xs:element name="causesUnparseError" dfdl:lengthKind="implicit">
<xs:complexType>
<xs:sequence>
@@ -163,6 +165,24 @@
</tdml:warnings>
</tdml:unparserTestCase>
+ <tdml:parserTestCase name="getsErrorExpectsNoErrors"
+ root="causesSDE" model="causesErrors">
+ <tdml:document></tdml:document>
+
+ <tdml:infoset>
+ <tdml:dfdlInfoset>
+ <ex:causesSDE>whatever</ex:causesSDE>
+ </tdml:dfdlInfoset>
+ </tdml:infoset>
+
+
+ <tdml:warnings>
+ <tdml:warning>Schema Definition Warning</tdml:warning>
+ <tdml:warning>AmbigElt</tdml:warning>
+ <tdml:warning>query-style</tdml:warning>
+ </tdml:warnings>
+ </tdml:parserTestCase>
+
<tdml:parserTestCase name="expectsAnyValidationError"
root="causesValidationError"
model="causesErrors" validation="on">
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 c187a25f7..c68931b47 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
@@ -153,7 +153,6 @@ class TestTDMLRunner2 {
</tns:array>
</tdml:dfdlInfoset>
</tdml:infoset>
- <tdml:validationErrors/>
</tdml:parserTestCase>
</tdml:testSuite>
@@ -259,7 +258,6 @@ class TestTDMLRunner2 {
</tns:array>
</tdml:dfdlInfoset>
</tdml:infoset>
- <tdml:validationErrors/>
</tdml:parserTestCase>
</tdml:testSuite>
@@ -271,7 +269,7 @@ class TestTDMLRunner2 {
val msg = e.getMessage()
assertTrue(
msg.contains(
- "ignoreUnexpectedDiags = false and test does not expect
ValidationError diagnostics"
+ "ignoreUnexpectedValidationErrors = false and test does not expect
ValidationError diagnostics"
)
)
}
diff --git
a/daffodil-tdml-processor/src/test/scala/org/apache/daffodil/processor/tdml/TestTDMLRunnerMatchAttributes.scala
b/daffodil-tdml-processor/src/test/scala/org/apache/daffodil/processor/tdml/TestTDMLRunnerMatchAttributes.scala
index 2945c6648..d5f2fbee7 100644
---
a/daffodil-tdml-processor/src/test/scala/org/apache/daffodil/processor/tdml/TestTDMLRunnerMatchAttributes.scala
+++
b/daffodil-tdml-processor/src/test/scala/org/apache/daffodil/processor/tdml/TestTDMLRunnerMatchAttributes.scala
@@ -59,7 +59,19 @@ class TestTDMLRunnerMatchAttributes {
val errMsg = e.getMessage()
assertTrue(
errMsg.contains(
- "ignoreUnexpectedDiags = false and test does not expect Warning
diagnostics"
+ "ignoreUnexpectedWarnings = false and test does not expect Warning
diagnostics"
+ )
+ )
+ }
+
+ @Test def test_getsErrorExpectsNoErrors() = {
+ val e = intercept[TDMLException] {
+ runner.runOneTest("getsErrorExpectsNoErrors")
+ }
+ val errMsg = e.getMessage()
+ assertTrue(
+ errMsg.contains(
+ "test does not expect Error diagnostics"
)
)
}
@@ -145,7 +157,9 @@ class TestTDMLRunnerMatchAttributes {
runner.reset
val msg = e.getMessage()
assertTrue(
- msg.contains("ignoreUnexpectedDiags = false and test does not expect
Warning diagnostics")
+ msg.contains(
+ "ignoreUnexpectedWarnings = false and test does not expect Warning
diagnostics"
+ )
)
}
diff --git
a/daffodil-tdml-processor/src/test/scala/org/apache/daffodil/processor/tdml/TestTDMLRunnerValidationErrors.scala
b/daffodil-tdml-processor/src/test/scala/org/apache/daffodil/processor/tdml/TestTDMLRunnerValidationErrors.scala
new file mode 100644
index 000000000..f3ed113d5
--- /dev/null
+++
b/daffodil-tdml-processor/src/test/scala/org/apache/daffodil/processor/tdml/TestTDMLRunnerValidationErrors.scala
@@ -0,0 +1,236 @@
+/*
+ * 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 org.apache.daffodil.processor.tdml
+
+import org.apache.daffodil.lib.Implicits.intercept
+import org.apache.daffodil.lib.xml.XMLUtils
+import org.apache.daffodil.tdml.Runner
+import org.apache.daffodil.tdml.TDMLException
+
+import org.junit.Assert.assertTrue
+import org.junit.Test
+
+class TestTDMLRunnerValidationErrors {
+
+ lazy val testSuite1 =
+ <ts:testSuite xmlns:dfdl={XMLUtils.DFDL_NAMESPACE} xmlns:xs={
+ XMLUtils.XSD_NAMESPACE
+ } xmlns:ex={XMLUtils.EXAMPLE_NAMESPACE} xmlns:ts={
+ XMLUtils.TDML_NAMESPACE
+ } suiteName="theSuiteName"
+ defaultValidation="on"
+ defaultIgnoreUnexpectedValidationErrors="false">
+ <ts:defineSchema name="schema1">
+ <xs:include
schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
+ <dfdl:format ref="ex:GeneralFormat"/>
+ <xs:element name="r" dfdl:lengthKind="delimited">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="YES"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+ </ts:defineSchema>
+
+ <ts:parserTestCase name="expectsNoValidationErrorGetsValidationError"
root="r" model="schema1" roundTrip="onePass">
+ <ts:infoset>
+ <ts:dfdlInfoset>
+ <ex:r>foo</ex:r>
+ </ts:dfdlInfoset>
+ </ts:infoset>
+ <ts:document>foo</ts:document>
+ </ts:parserTestCase>
+
+ <ts:parserTestCase name="expectsValidationErrorGetsNoValidationError"
root="r" model="schema1" roundTrip="onePass">
+ <ts:infoset>
+ <ts:dfdlInfoset>
+ <ex:r>YES</ex:r>
+ </ts:dfdlInfoset>
+ </ts:infoset>
+ <ts:document>YES</ts:document>
+
+ <ts:validationErrors>
+ <ts:error>Validation Error</ts:error>
+ <ts:error>r failed</ts:error>
+ </ts:validationErrors>
+ </ts:parserTestCase>
+
+ <ts:parserTestCase name="expectsValidationErrorGetsValidationError"
root="r" model="schema1" roundTrip="onePass">
+ <ts:infoset>
+ <ts:dfdlInfoset>
+ <ex:r>foo</ex:r>
+ </ts:dfdlInfoset>
+ </ts:infoset>
+ <ts:document>foo</ts:document>
+
+ <ts:validationErrors>
+ <ts:error>Validation Error</ts:error>
+ <ts:error>r failed</ts:error>
+ </ts:validationErrors>
+ </ts:parserTestCase>
+
+ <ts:parserTestCase name="expectsNoValidationErrorGetsNoValidationError"
root="r" model="schema1" roundTrip="onePass">
+ <ts:infoset>
+ <ts:dfdlInfoset>
+ <ex:r>YES</ex:r>
+ </ts:dfdlInfoset>
+ </ts:infoset>
+ <ts:document>YES</ts:document>
+ </ts:parserTestCase>
+
+ </ts:testSuite>
+
+ lazy val testSuite2 =
+ <ts:testSuite xmlns:dfdl={XMLUtils.DFDL_NAMESPACE} xmlns:xs={
+ XMLUtils.XSD_NAMESPACE
+ } xmlns:ex={XMLUtils.EXAMPLE_NAMESPACE} xmlns:ts={
+ XMLUtils.TDML_NAMESPACE
+ } suiteName="theSuiteName"
+ defaultValidation="on">
+ <ts:defineSchema name="schema1">
+ <xs:include
schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
+ <dfdl:format ref="ex:GeneralFormat"/>
+ <xs:element name="r" dfdl:lengthKind="delimited">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="YES"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+ </ts:defineSchema>
+
+ <ts:parserTestCase name="expectsNoValidationErrorGetsValidationError2"
+ root="r" model="schema1" roundTrip="onePass"
+ ignoreUnexpectedValidationErrors="true">
+ <ts:infoset>
+ <ts:dfdlInfoset>
+ <ex:r>foo</ex:r>
+ </ts:dfdlInfoset>
+ </ts:infoset>
+ <ts:document>foo</ts:document>
+ </ts:parserTestCase>
+
+ <ts:parserTestCase name="expectsNoValidationErrorGetsValidationError3"
+ root="r" model="schema1" roundTrip="onePass"
+ ignoreUnexpectedValidationErrors="false">
+ <ts:infoset>
+ <ts:dfdlInfoset>
+ <ex:r>foo</ex:r>
+ </ts:dfdlInfoset>
+ </ts:infoset>
+ <ts:document>foo</ts:document>
+ </ts:parserTestCase>
+ </ts:testSuite>
+
+ lazy val testSuite3 =
+ <ts:testSuite xmlns:dfdl={XMLUtils.DFDL_NAMESPACE} xmlns:xs={
+ XMLUtils.XSD_NAMESPACE
+ } xmlns:ex={XMLUtils.EXAMPLE_NAMESPACE} xmlns:ts={
+ XMLUtils.TDML_NAMESPACE
+ } suiteName="theSuiteName"
+ defaultValidation="on"
+ defaultIgnoreUnexpectedValidationErrors="false">
+ <ts:defineSchema name="schema1">
+ <xs:include
schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
+ <dfdl:format ref="ex:GeneralFormat"/>
+ <xs:element name="r" dfdl:lengthKind="delimited">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="YES"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+ </ts:defineSchema>
+
+ <ts:parserTestCase name="enforceNoValidationErrorsUnsupportedVersion"
root="r" model="schema1" roundTrip="onePass">
+ <ts:infoset>
+ <ts:dfdlInfoset>
+ <ex:r>YES</ex:r>
+ </ts:dfdlInfoset>
+ </ts:infoset>
+ <ts:document>YES</ts:document>
+ <ts:validationErrors/>
+ </ts:parserTestCase>
+
+
+ </ts:testSuite>
+
+ @Test def test_expectsNoValidationErrorGetsValidationError(): Unit = {
+ val runner = new Runner(testSuite1)
+ val e = intercept[TDMLException] {
+ runner.runOneTest("expectsNoValidationErrorGetsValidationError")
+ }
+ runner.reset
+ val msg = e.getMessage()
+ assertTrue(
+ msg.contains(
+ "ignoreUnexpectedValidationErrors = false and test does not expect
ValidationError diagnostics"
+ )
+ )
+ }
+ @Test def test_expectsNoValidationErrorGetsValidationError2(): Unit = {
+ val runner = new Runner(testSuite2)
+ runner.runOneTest("expectsNoValidationErrorGetsValidationError2")
+ }
+
+ @Test def test_expectsNoValidationErrorGetsValidationError3(): Unit = {
+ val runner = new Runner(testSuite2)
+ val e = intercept[TDMLException] {
+ runner.runOneTest("expectsNoValidationErrorGetsValidationError3")
+ }
+ runner.reset
+ val msg = e.getMessage()
+ assertTrue(
+ msg.contains(
+ "ignoreUnexpectedValidationErrors = false and test does not expect
ValidationError diagnostics"
+ )
+ )
+ }
+
+ @Test def test_expectsValidationErrorGetsNoValidationError(): Unit = {
+ val runner = new Runner(testSuite1)
+ val e = intercept[TDMLException] {
+ runner.runOneTest("expectsValidationErrorGetsNoValidationError")
+ }
+ runner.reset
+ val msg = e.getMessage()
+ assertTrue(msg.contains("Diagnostic message(s) were expected but not
found"))
+ }
+
+ @Test def test_expectsValidationErrorGetsValidationError(): Unit = {
+ val runner = new Runner(testSuite1)
+ runner.runOneTest("expectsValidationErrorGetsValidationError")
+ }
+
+ @Test def test_expectsNoValidationErrorGetsNoValidationError(): Unit = {
+ val runner = new Runner(testSuite1)
+ runner.runOneTest("expectsNoValidationErrorGetsNoValidationError")
+ }
+
+ @Test def test_enforceNoValidationErrorsUnsupportedVersion(): Unit = {
+ val runner = new Runner(testSuite3)
+ val e = intercept[TDMLException] {
+ runner.runOneTest("enforceNoValidationErrorsUnsupportedVersion")
+ }
+ runner.reset
+ val msg = e.getMessage()
+ assertTrue(msg.contains("content of element 'ts:validationErrors' is not
complete"))
+ assertTrue(msg.contains("error"))
+ assertTrue(msg.contains("is expected"))
+ }
+}
diff --git
a/daffodil-test/src/test/resources/org/apache/daffodil/section00/general/tunables.tdml
b/daffodil-test/src/test/resources/org/apache/daffodil/section00/general/tunables.tdml
index 09685424f..cc08e4448 100644
---
a/daffodil-test/src/test/resources/org/apache/daffodil/section00/general/tunables.tdml
+++
b/daffodil-test/src/test/resources/org/apache/daffodil/section00/general/tunables.tdml
@@ -871,7 +871,6 @@
<ex:int>201</ex:int>
</tdml:dfdlInfoset>
</tdml:infoset>
- <tdml:validationErrors /> <!-- make sure there are no validation errors -->
</tdml:parserTestCase>
<tdml:parserTestCase
@@ -903,7 +902,6 @@
<ex:int>200</ex:int>
</tdml:dfdlInfoset>
</tdml:infoset>
- <tdml:validationErrors /> <!-- make sure there are no validation errors -->
</tdml:parserTestCase>
</tdml:testSuite>
diff --git
a/daffodil-test/src/test/resources/org/apache/daffodil/section02/validation_errors/Validation.tdml
b/daffodil-test/src/test/resources/org/apache/daffodil/section02/validation_errors/Validation.tdml
index fe6ca88d7..85c421887 100644
---
a/daffodil-test/src/test/resources/org/apache/daffodil/section02/validation_errors/Validation.tdml
+++
b/daffodil-test/src/test/resources/org/apache/daffodil/section02/validation_errors/Validation.tdml
@@ -2484,7 +2484,6 @@
</a>
</tdml:dfdlInfoset>
</tdml:infoset>
- <tdml:validationErrors />
</tdml:parserTestCase>
<tdml:defineSchema name="runtimeSdeWithRestriction">