You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by dt...@apache.org on 2018/05/04 13:44:17 UTC
[incubator-daffodil] branch master updated: Added tests to verify
processing of escapeBlock escapeScheme where the escapeBlockEnd and
escapeEscapeBlock characters are the same.
This is an automated email from the ASF dual-hosted git repository.
dthompson pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-daffodil.git
The following commit(s) were added to refs/heads/master by this push:
new 438e5fe Added tests to verify processing of escapeBlock escapeScheme where the escapeBlockEnd and escapeEscapeBlock characters are the same.
438e5fe is described below
commit 438e5fe751fe566fbc57da5542ffbf373febeda1
Author: Dave Thompson <dt...@tresys.com>
AuthorDate: Fri Apr 20 14:39:31 2018 -0400
Added tests to verify processing of escapeBlock escapeScheme
where the escapeBlockEnd and escapeEscapeBlock characters are the same.
Added tests to verify processing of apostrophes (') within the document
and infoset data.
DAFFODIL-1923 DAFFODIL-1928
---
.../src/test/resources/test/tdml/tdmlQuoting.tdml | 63 ++-
.../org/apache/daffodil/tdml/TestTDMLRunner3.scala | 14 +
.../org/apache/daffodil/tdml/TestTDMLRunner2.scala | 443 ++++++++++++++++++-
.../apache/daffodil/tdml/TestTDMLRunnerNew.scala | 482 ---------------------
.../section07/escapeScheme/escapeScheme.tdml | 88 +++-
.../escapeScheme/TestEscapeSchemeDebug.scala | 6 +
6 files changed, 597 insertions(+), 499 deletions(-)
diff --git a/daffodil-tdml/src/test/resources/test/tdml/tdmlQuoting.tdml b/daffodil-tdml/src/test/resources/test/tdml/tdmlQuoting.tdml
index 2c7f6e8..d0378a5 100644
--- a/daffodil-tdml/src/test/resources/test/tdml/tdmlQuoting.tdml
+++ b/daffodil-tdml/src/test/resources/test/tdml/tdmlQuoting.tdml
@@ -22,7 +22,7 @@
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ex="http://example.com">
- <tdml:defineSchema name="quote">
+ <tdml:defineSchema name="quote">
<dfdl:format ref="ex:GeneralFormat" initiator=""
terminator="" textBidi="no" floating="no" encoding="utf-8" byteOrder="bigEndian"
@@ -33,10 +33,8 @@
initiatedContent="no" separatorSuppressionPolicy="never"
separatorPosition="infix" />
-
- <xsd:element name="doublequote" type="xsd:string"
- dfdl:lengthKind="pattern" dfdl:lengthPattern='["]{1,1}' />
-
+ <xsd:element name="doublequote" type="xsd:string"
+ dfdl:lengthKind="explicit" dfdl:length="1" />
</tdml:defineSchema>
@@ -53,4 +51,57 @@
</tdml:infoset>
</tdml:parserTestCase>
-</tdml:testSuite>
\ No newline at end of file
+
+ <!--
+ Test Name: apos_test1
+ Schema: apostrophe
+ Root: record
+ Purpose: This test demonstrates that tdml runner correctly processes apostrophes (') within the infoset data (DAFFODIL-1928).
+ -->
+
+ <tdml:defineSchema name="apostrophe">
+
+ <dfdl:format ref="ex:GeneralFormat" lengthKind="delimited" />
+
+ <xsd:element name="apostrophe" type="xsd:string"
+ dfdl:lengthKind="explicit" dfdl:length="1" />
+
+ </tdml:defineSchema>
+
+ <tdml:parserTestCase name="apos_test1"
+ root="apostrophe" model="apostrophe"
+ description="Can't deal properly with apostrophe (') marks within the document data in TDML " roundTrip="true">
+
+ <tdml:document>'</tdml:document>
+
+ <tdml:infoset>
+ <tdml:dfdlInfoset>
+ <apostrophe>'</apostrophe>
+ </tdml:dfdlInfoset>
+ </tdml:infoset>
+
+ </tdml:parserTestCase>
+
+ <!--
+ Test Name: apos_test2
+ Schema: apostrophe
+ Root: record
+ Purpose: This test demonstrates that tdml runner correctly processes apostrophes (') within the document data (DAFFODIL-1928).
+ -->
+
+ <tdml:parserTestCase name="apos_test2"
+ root="apostrophe" model="apostrophe"
+ description="Can't deal properly with apostrophe (') marks within the document data in TDML " roundTrip="true">
+
+ <tdml:document>'</tdml:document>
+
+ <tdml:infoset>
+ <tdml:dfdlInfoset>
+ <apostrophe>'</apostrophe>
+ </tdml:dfdlInfoset>
+ </tdml:infoset>
+
+ </tdml:parserTestCase>
+
+
+</tdml:testSuite>
diff --git a/daffodil-tdml/src/test/scala-debug/org/apache/daffodil/tdml/TestTDMLRunner3.scala b/daffodil-tdml/src/test/scala-debug/org/apache/daffodil/tdml/TestTDMLRunner3.scala
index 65c425a..0c45e67 100644
--- a/daffodil-tdml/src/test/scala-debug/org/apache/daffodil/tdml/TestTDMLRunner3.scala
+++ b/daffodil-tdml/src/test/scala-debug/org/apache/daffodil/tdml/TestTDMLRunner3.scala
@@ -55,4 +55,18 @@ class TestTDMLRunner3 {
val expected = "AAF9".replace(" ", "")
assertEquals(expected, hexDigits)
}
+
+ val testDir = "/test/tdml/"
+ val runner = Runner(testDir, "tdmlQuoting.tdml", validateTDMLFile = false)
+
+ /**
+ * Test illustrates problem with tdml runner correctly processes apostrophes (')
+ * in the html format (') within the document or infoset data. The aposrophes are
+ * stripped out of actual or expected values causing the comparison to fail.
+ *
+ * Bug DAFFODIL-1928
+ */
+ @Test def test_apos_test1() { runner.runOneTest("apos_test1") }
+ @Test def test_apos_test2() { runner.runOneTest("apos_test2") }
+
}
diff --git a/daffodil-tdml/src/test/scala/org/apache/daffodil/tdml/TestTDMLRunner2.scala b/daffodil-tdml/src/test/scala/org/apache/daffodil/tdml/TestTDMLRunner2.scala
index f24d45b..c5e0eae 100644
--- a/daffodil-tdml/src/test/scala/org/apache/daffodil/tdml/TestTDMLRunner2.scala
+++ b/daffodil-tdml/src/test/scala/org/apache/daffodil/tdml/TestTDMLRunner2.scala
@@ -17,12 +17,26 @@
package org.apache.daffodil.tdml
+import org.apache.daffodil.Implicits.using
import org.apache.daffodil.xml.XMLUtils
+import junit.framework.Assert.assertEquals
+import junit.framework.Assert.assertTrue
+import junit.framework.Assert.fail
import org.apache.daffodil.util._
import org.junit.Test
import org.apache.daffodil.Implicits._
+import org.junit.AfterClass
+
+object TestTDMLRunner2 {
+ val runner = Runner("/test/tdml/", "tdmlQuoting.tdml")
+
+ @AfterClass def shutDown {
+ runner.reset
+ }
+}
class TestTDMLRunner2 {
+ import TestTDMLRunner2._
val tdml = XMLUtils.TDML_NAMESPACE
val dfdl = XMLUtils.DFDL_NAMESPACE
@@ -32,6 +46,383 @@ class TestTDMLRunner2 {
val tns = example
// val sub = XMLUtils.DFDL_XMLSCHEMASUBSET_NAMESPACE
+ /**
+ * Validation=Off
+ * Should Parse Succeed? Yes
+ * Exception expected? Yes
+ *
+ * Reasoning: The data parses successfully and validation is 'off'.
+ * Demonstrates that when validation is off, no validation errors
+ * should be expected by the testcase.
+ */
+ @Test def testValidationOffValidationErrorGivenShouldError() = {
+ 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">
+ <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">
+ <tdml:document>
+ <tdml:documentPart type="text"><![CDATA[1|2|3|4|5|6|7|8|9]]></tdml:documentPart>
+ </tdml:document>
+ <tdml:infoset>
+ <tdml:dfdlInfoset>
+ <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>
+ </array>
+ </tdml:dfdlInfoset>
+ </tdml:infoset>
+ <tdml:validationErrors>
+ <tdml:error>Specifying this should throw exception</tdml:error>
+ </tdml:validationErrors>
+ </tdml:parserTestCase>
+ </tdml:testSuite>
+
+ lazy val ts = new DFDLTestSuite(testSuite)
+ val e = intercept[Exception] {
+ ts.runOneTest("testValidation")
+ }
+ val msg = e.getMessage()
+ if (!msg.contains("Test case invalid")) {
+ println(msg)
+ fail("message did not contain expected contents")
+ }
+ assertTrue(msg.contains("Test case invalid"))
+ assertTrue(msg.contains("Validation is off"))
+ assertTrue(msg.contains("test expects an error"))
+ }
+
+ /**
+ * Validation=Off
+ * Should Parse Succeed? Yes
+ * Exception expected? No
+ *
+ * Reasoning: The data parses successfully and validation is 'off'.
+ * Helps demonstrate the optionality of including the validation errors
+ * in the testcase. <verrors/> means no validation errors are expected.
+ */
+ @Test def testValidationOffValidationErrorGivenButEmptyNotError() = {
+ 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">
+ <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">
+ <tdml:document>
+ <tdml:documentPart type="text"><![CDATA[1|2|3|4|5|6|7|8|9]]></tdml:documentPart>
+ </tdml:document>
+ <tdml:infoset>
+ <tdml:dfdlInfoset>
+ <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>
+ </array>
+ </tdml:dfdlInfoset>
+ </tdml:infoset>
+ <tdml:validationErrors/>
+ </tdml:parserTestCase>
+ </tdml:testSuite>
+
+ lazy val ts = new DFDLTestSuite(testSuite)
+ ts.runOneTest("testValidation")
+ }
+
+ /**
+ * Validation=Off
+ * Should Parse Succeed? Yes
+ * Exception expected? No
+ *
+ * Reasoning: The data parses successfully and validation is 'off'.
+ * Helps demonstrate the optionality of including the validation errors
+ * in the testcase.
+ */
+ @Test def testValidationOffValidationErrorNotGivenNotError() = {
+ 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">
+ <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">
+ <tdml:document>
+ <tdml:documentPart type="text"><![CDATA[1|2|3|4|5|6|7|8|9]]></tdml:documentPart>
+ </tdml:document>
+ <tdml:infoset>
+ <tdml:dfdlInfoset>
+ <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>
+ </array>
+ </tdml:dfdlInfoset>
+ </tdml:infoset>
+ </tdml:parserTestCase>
+ </tdml:testSuite>
+
+ lazy val ts = new DFDLTestSuite(testSuite)
+ ts.runOneTest("testValidation")
+ }
+
+ /**
+ * Validation=Limited
+ * Should Parse Succeed? Yes
+ * 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
+ * that was not 'captured' in the test case.
+ */
+ @Test def testValidationLimitedValidationErrorNotCapturedShouldThrow() = {
+ 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">
+ <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>
+ <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>
+ </array>
+ </tdml:dfdlInfoset>
+ </tdml:infoset>
+ </tdml:parserTestCase>
+ </tdml:testSuite>
+
+ lazy val ts = new DFDLTestSuite(testSuite)
+ val e = intercept[Exception] {
+ ts.runOneTest("testValidation")
+ }
+ val msg = e.getMessage()
+ assertTrue(msg.contains("Validation errors found where none were expected"))
+ }
+
+ /**
+ * Scala's XML Literals don't do CDATA regions right.
+ *
+ * So to force the example tdml xml to have CDATA regions (which it would
+ * if these were being read from a file), we construct actual PCData
+ * xml nodes and splice them in where we would have written <![CDATA[...]]>
+ * in a real TDML file.
+ */
+ val cdataText = """(?x) # free form
+abc # a comment
+# a line with only a comment
+123 # another comment
+"""
+ val cdata = new scala.xml.PCData(cdataText)
+
+ /**
+ * Test to make sure we can use freeform regex and also use the comment syntax.
+ */
+ @Test def testRegexWithFreeFormAndComments1() = {
+ 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">
+ <dfdl:format ref="tns:GeneralFormat"/>
+ <xsd:element name="data" type="xsd:string" dfdl:lengthKind="pattern" dfdl:terminator="abcdef">
+ <xsd:annotation>
+ <xsd:appinfo source="http://www.ogf.org/dfdl/">
+ <dfdl:element>
+ <dfdl:property name="lengthPattern">{ cdata }</dfdl:property>
+ </dfdl:element>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ </tdml:defineSchema>
+ <tdml:parserTestCase xmlns={ tdml } name="testRegex" root="data" model="mySchema">
+ <tdml:document>
+ <tdml:documentPart type="text"><![CDATA[abcdef]]></tdml:documentPart>
+ </tdml:document>
+ <tdml:infoset>
+ <tdml:dfdlInfoset>
+ <data/>
+ </tdml:dfdlInfoset>
+ </tdml:infoset>
+ </tdml:parserTestCase>
+ </tdml:testSuite>
+
+ lazy val ts = new DFDLTestSuite(testSuite)
+ ts.runOneTest("testRegex")
+ }
+
+ @Test def testRegexWithFreeFormAndComments2() = {
+ 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">
+ <dfdl:format ref="tns:GeneralFormat"/>
+ <xsd:element name="data" type="xsd:string" dfdl:lengthKind="delimited">
+ <xsd:annotation>
+ <xsd:appinfo source="http://www.ogf.org/dfdl/">
+ <!-- This assert passes only if free form works, and comments work. -->
+ <dfdl:assert testKind='pattern'>{ cdata }</dfdl:assert>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ </tdml:defineSchema>
+ <tdml:parserTestCase xmlns={ tdml } name="testRegex" root="data" model="mySchema">
+ <tdml:document>
+ <tdml:documentPart type="text"><![CDATA[abc123]]></tdml:documentPart>
+ </tdml:document>
+ <tdml:infoset>
+ <tdml:dfdlInfoset>
+ <data>abc123</data>
+ </tdml:dfdlInfoset>
+ </tdml:infoset>
+ </tdml:parserTestCase>
+ </tdml:testSuite>
+
+ lazy val ts = new DFDLTestSuite(testSuite)
+ ts.runOneTest("testRegex")
+ }
+
+ /**
+ * Scala's xml literals read CDATA properly, but don't create a PCData node
+ * so if you write the data back out, the CDATA-non-normalized whitespace
+ * is lost. So in this test we forcibly construct the PCData node.
+ *
+ */
+ @Test def testRegexWithFreeFormAndComments3() = {
+
+ 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">
+ <dfdl:format ref="tns:GeneralFormat"/>
+ <xsd:element name="data" type="xsd:string" dfdl:lengthKind="delimited">
+ <xsd:annotation>
+ <xsd:appinfo source="http://www.ogf.org/dfdl/">
+ <!-- This assert passes only if free form works, and comments work. -->
+ <dfdl:assert testKind='pattern'>{ cdata }</dfdl:assert>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ </tdml:defineSchema>
+ <tdml:parserTestCase xmlns={ tdml } name="testRegex" root="data" model="mySchema">
+ <tdml:document>
+ <tdml:documentPart type="text"><![CDATA[abc123]]></tdml:documentPart>
+ </tdml:document>
+ <tdml:infoset>
+ <tdml:dfdlInfoset>
+ <data>abc123</data>
+ </tdml:dfdlInfoset>
+ </tdml:infoset>
+ </tdml:parserTestCase>
+ </tdml:testSuite>
+ val ts = new DFDLTestSuite(testSuite)
+ ts.runOneTest("testRegex")
+ }
+
+ @Test def testRegexWithFreeFormAndComments4() = {
+ val cdataText = """(?x) # free form
+abc # a comment
+# a line with only a comment
+123 # another comment
+"""
+ val cdata = new scala.xml.PCData(cdataText)
+ 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">
+ <dfdl:format ref="tns:GeneralFormat"/>
+ <xsd:element name="data" type="xsd:string" dfdl:lengthKind="delimited">
+ <xsd:annotation>
+ <xsd:appinfo source="http://www.ogf.org/dfdl/">
+ <!-- This assert passes only if free form works, and comments work. -->
+ <dfdl:assert testKind='pattern'>{ cdata }</dfdl:assert>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ </tdml:defineSchema>
+ <tdml:parserTestCase xmlns={ tdml } name="testRegex" root="data" model="mySchema">
+ <tdml:document>
+ <tdml:documentPart type="text"><![CDATA[abcdef]]></tdml:documentPart>
+ </tdml:document>
+ <tdml:errors>
+ <tdml:error>{ cdataText.trim }</tdml:error>
+ </tdml:errors>
+ </tdml:parserTestCase>
+ </tdml:testSuite>
+ val ts = new DFDLTestSuite(testSuite)
+ ts.runOneTest("testRegex")
+ }
+
+ @Test def testComplexDocument() = {
+ val doc = <tdml:document>
+ <tdml:documentPart type="bits">00101010</tdml:documentPart>
+ <tdml:documentPart type="bits">1</tdml:documentPart>
+ <tdml:documentPart type="bits">00000000 00000000 00000000 00000001</tdml:documentPart>
+ <tdml:documentPart type="bits">0</tdml:documentPart>
+ <tdml:documentPart type="bits">1</tdml:documentPart>
+ </tdml:document>
+ val docObj = new Document(doc, null)
+ val bits = docObj.documentBits
+ val expected = List("00101010", "10000000", "00000000", "00000000", "00000000", "10100000")
+ assertEquals(expected, bits)
+ }
+
+ @Test def testTDMLWithInvalidDFDLSchemaEmbedded() = {
+
+ val testDir = ""
+ val aa = testDir + "tdml-with-embedded-schema-errors.tdml"
+ lazy val runner = new DFDLTestSuite(Misc.getRequiredResource(aa), validateTDMLFile = false, validateDFDLSchemas = true)
+ runner.runOneTest("test1")
+ }
+
@Test def testTDMLUnparse() {
val testSuite = <ts:testSuite xmlns:ts={ tdml } xmlns:tns={ tns } xmlns:dfdl={ dfdl } xmlns:xs={ xsd } xmlns:xsi={ xsi } suiteName="theSuiteName">
<ts:defineSchema name="unparseTestSchema1">
@@ -51,16 +442,52 @@ class TestTDMLRunner2 {
ts.runOneTest("testTDMLUnparse")
}
- val testDir = "/test/tdml/"
- val t0 = testDir + "tdmlNamespaces.tdml"
- lazy val r = new DFDLTestSuite(Misc.getRequiredResource(t0))
-
- val aa = testDir + "tdmlQuoting.tdml"
- lazy val runner = new DFDLTestSuite(Misc.getRequiredResource(aa))
-
@Test def test_quote_test1() = {
- runner.setDebugging(true)
runner.runOneTest("quote_test1")
}
+ val tdmlWithEmbeddedSchema =
+ <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">
+ <dfdl:format ref="tns:GeneralFormat"/>
+ <xsd:element name="data" type="xsd:int" dfdl:lengthKind="explicit" dfdl:length="{ xs:unsignedInt(2) }"/>
+ </tdml:defineSchema>
+ <parserTestCase xmlns={ tdml } name="testEmbeddedSchemaWorks" root="data" model="mySchema">
+ <document>37</document>
+ <infoset>
+ <dfdlInfoset>
+ <data xmlns={ example }>37</data>
+ </dfdlInfoset>
+ </infoset>
+ </parserTestCase>
+ </tdml:testSuite>
+
+ // @Test // other places should test tracing.
+ def testTrace() {
+ val tmpTDMLFileName = getClass.getName() + ".tdml"
+ val testSuite = tdmlWithEmbeddedSchema
+ try {
+ using(new java.io.FileWriter(tmpTDMLFileName)) {
+ fw =>
+ fw.write(testSuite.toString())
+ }
+ lazy val ts = new DFDLTestSuite(new java.io.File(tmpTDMLFileName))
+ ts.trace
+ ts.runAllTests()
+ } finally {
+ val t = new java.io.File(tmpTDMLFileName)
+ t.delete()
+ }
+ }
+
+ /**
+ * Test illustrates problem with tdml runner correctly processes apostrophes (')
+ * in the html format (') within the document or infoset data. The aposrophes are stripped out of
+ * stripped out of actual or expected values causing the comparison to fail.
+ *
+ * Bug DAFFODIL-1928
+ */
+ // @Test def test_apos_test1() { runner.runOneTest("apos_test1") }
+ // @Test def test_apos_test2() { runner.runOneTest("apos_test2") }
+
}
diff --git a/daffodil-tdml/src/test/scala/org/apache/daffodil/tdml/TestTDMLRunnerNew.scala b/daffodil-tdml/src/test/scala/org/apache/daffodil/tdml/TestTDMLRunnerNew.scala
deleted file mode 100644
index 06b55cd..0000000
--- a/daffodil-tdml/src/test/scala/org/apache/daffodil/tdml/TestTDMLRunnerNew.scala
+++ /dev/null
@@ -1,482 +0,0 @@
-/*
- * 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.tdml
-
-import org.apache.daffodil.Implicits.using
-import org.apache.daffodil.xml.XMLUtils
-import junit.framework.Assert.assertEquals
-import junit.framework.Assert.assertTrue
-import junit.framework.Assert.fail
-import org.apache.daffodil.util._
-import org.junit.Test
-import org.apache.daffodil.Implicits._
-import org.junit.AfterClass
-
-object TestTDMLRunnerNew {
- val runner = Runner("/test/tdml/", "tdmlQuoting.tdml")
-
- @AfterClass def shutDown {
- runner.reset
- }
-}
-
-class TestTDMLRunnerNew {
- import TestTDMLRunnerNew._
-
- val tdml = XMLUtils.TDML_NAMESPACE
- val dfdl = XMLUtils.DFDL_NAMESPACE
- val xsi = XMLUtils.XSI_NAMESPACE
- val xsd = XMLUtils.XSD_NAMESPACE
- val example = XMLUtils.EXAMPLE_NAMESPACE
- val tns = example
- // val sub = XMLUtils.DFDL_XMLSCHEMASUBSET_NAMESPACE
-
- /**
- * Validation=Off
- * Should Parse Succeed? Yes
- * Exception expected? Yes
- *
- * Reasoning: The data parses successfully and validation is 'off'.
- * Demonstrates that when validation is off, no validation errors
- * should be expected by the testcase.
- */
- @Test def testValidationOffValidationErrorGivenShouldError() = {
- 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">
- <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">
- <tdml:document>
- <tdml:documentPart type="text"><![CDATA[1|2|3|4|5|6|7|8|9]]></tdml:documentPart>
- </tdml:document>
- <tdml:infoset>
- <tdml:dfdlInfoset>
- <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>
- </array>
- </tdml:dfdlInfoset>
- </tdml:infoset>
- <tdml:validationErrors>
- <tdml:error>Specifying this should throw exception</tdml:error>
- </tdml:validationErrors>
- </tdml:parserTestCase>
- </tdml:testSuite>
-
- lazy val ts = new DFDLTestSuite(testSuite)
- val e = intercept[Exception] {
- ts.runOneTest("testValidation")
- }
- val msg = e.getMessage()
- if (!msg.contains("Test case invalid")) {
- println(msg)
- fail("message did not contain expected contents")
- }
- assertTrue(msg.contains("Test case invalid"))
- assertTrue(msg.contains("Validation is off"))
- assertTrue(msg.contains("test expects an error"))
- }
-
- /**
- * Validation=Off
- * Should Parse Succeed? Yes
- * Exception expected? No
- *
- * Reasoning: The data parses successfully and validation is 'off'.
- * Helps demonstrate the optionality of including the validation errors
- * in the testcase. <verrors/> means no validation errors are expected.
- */
- @Test def testValidationOffValidationErrorGivenButEmptyNotError() = {
- 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">
- <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">
- <tdml:document>
- <tdml:documentPart type="text"><![CDATA[1|2|3|4|5|6|7|8|9]]></tdml:documentPart>
- </tdml:document>
- <tdml:infoset>
- <tdml:dfdlInfoset>
- <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>
- </array>
- </tdml:dfdlInfoset>
- </tdml:infoset>
- <tdml:validationErrors/>
- </tdml:parserTestCase>
- </tdml:testSuite>
-
- lazy val ts = new DFDLTestSuite(testSuite)
- ts.runOneTest("testValidation")
- }
-
- /**
- * Validation=Off
- * Should Parse Succeed? Yes
- * Exception expected? No
- *
- * Reasoning: The data parses successfully and validation is 'off'.
- * Helps demonstrate the optionality of including the validation errors
- * in the testcase.
- */
- @Test def testValidationOffValidationErrorNotGivenNotError() = {
- 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">
- <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">
- <tdml:document>
- <tdml:documentPart type="text"><![CDATA[1|2|3|4|5|6|7|8|9]]></tdml:documentPart>
- </tdml:document>
- <tdml:infoset>
- <tdml:dfdlInfoset>
- <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>
- </array>
- </tdml:dfdlInfoset>
- </tdml:infoset>
- </tdml:parserTestCase>
- </tdml:testSuite>
-
- lazy val ts = new DFDLTestSuite(testSuite)
- ts.runOneTest("testValidation")
- }
-
- /**
- * Validation=Limited
- * Should Parse Succeed? Yes
- * 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
- * that was not 'captured' in the test case.
- */
- @Test def testValidationLimitedValidationErrorNotCapturedShouldThrow() = {
- 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">
- <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>
- <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>
- </array>
- </tdml:dfdlInfoset>
- </tdml:infoset>
- </tdml:parserTestCase>
- </tdml:testSuite>
-
- lazy val ts = new DFDLTestSuite(testSuite)
- val e = intercept[Exception] {
- ts.runOneTest("testValidation")
- }
- val msg = e.getMessage()
- assertTrue(msg.contains("Validation errors found where none were expected"))
- }
-
- /**
- * Scala's XML Literals don't do CDATA regions right.
- *
- * So to force the example tdml xml to have CDATA regions (which it would
- * if these were being read from a file), we construct actual PCData
- * xml nodes and splice them in where we would have written <![CDATA[...]]>
- * in a real TDML file.
- */
- val cdataText = """(?x) # free form
-abc # a comment
-# a line with only a comment
-123 # another comment
-"""
- val cdata = new scala.xml.PCData(cdataText)
-
- /**
- * Test to make sure we can use freeform regex and also use the comment syntax.
- */
- @Test def testRegexWithFreeFormAndComments1() = {
- 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">
- <dfdl:format ref="tns:GeneralFormat"/>
- <xsd:element name="data" type="xsd:string" dfdl:lengthKind="pattern" dfdl:terminator="abcdef">
- <xsd:annotation>
- <xsd:appinfo source="http://www.ogf.org/dfdl/">
- <dfdl:element>
- <dfdl:property name="lengthPattern">{ cdata }</dfdl:property>
- </dfdl:element>
- </xsd:appinfo>
- </xsd:annotation>
- </xsd:element>
- </tdml:defineSchema>
- <tdml:parserTestCase xmlns={ tdml } name="testRegex" root="data" model="mySchema">
- <tdml:document>
- <tdml:documentPart type="text"><![CDATA[abcdef]]></tdml:documentPart>
- </tdml:document>
- <tdml:infoset>
- <tdml:dfdlInfoset>
- <data/>
- </tdml:dfdlInfoset>
- </tdml:infoset>
- </tdml:parserTestCase>
- </tdml:testSuite>
-
- lazy val ts = new DFDLTestSuite(testSuite)
- ts.runOneTest("testRegex")
- }
-
- @Test def testRegexWithFreeFormAndComments2() = {
- 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">
- <dfdl:format ref="tns:GeneralFormat"/>
- <xsd:element name="data" type="xsd:string" dfdl:lengthKind="delimited">
- <xsd:annotation>
- <xsd:appinfo source="http://www.ogf.org/dfdl/">
- <!-- This assert passes only if free form works, and comments work. -->
- <dfdl:assert testKind='pattern'>{ cdata }</dfdl:assert>
- </xsd:appinfo>
- </xsd:annotation>
- </xsd:element>
- </tdml:defineSchema>
- <tdml:parserTestCase xmlns={ tdml } name="testRegex" root="data" model="mySchema">
- <tdml:document>
- <tdml:documentPart type="text"><![CDATA[abc123]]></tdml:documentPart>
- </tdml:document>
- <tdml:infoset>
- <tdml:dfdlInfoset>
- <data>abc123</data>
- </tdml:dfdlInfoset>
- </tdml:infoset>
- </tdml:parserTestCase>
- </tdml:testSuite>
-
- lazy val ts = new DFDLTestSuite(testSuite)
- ts.runOneTest("testRegex")
- }
-
- /**
- * Scala's xml literals read CDATA properly, but don't create a PCData node
- * so if you write the data back out, the CDATA-non-normalized whitespace
- * is lost. So in this test we forcibly construct the PCData node.
- *
- */
- @Test def testRegexWithFreeFormAndComments3() = {
-
- 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">
- <dfdl:format ref="tns:GeneralFormat"/>
- <xsd:element name="data" type="xsd:string" dfdl:lengthKind="delimited">
- <xsd:annotation>
- <xsd:appinfo source="http://www.ogf.org/dfdl/">
- <!-- This assert passes only if free form works, and comments work. -->
- <dfdl:assert testKind='pattern'>{ cdata }</dfdl:assert>
- </xsd:appinfo>
- </xsd:annotation>
- </xsd:element>
- </tdml:defineSchema>
- <tdml:parserTestCase xmlns={ tdml } name="testRegex" root="data" model="mySchema">
- <tdml:document>
- <tdml:documentPart type="text"><![CDATA[abc123]]></tdml:documentPart>
- </tdml:document>
- <tdml:infoset>
- <tdml:dfdlInfoset>
- <data>abc123</data>
- </tdml:dfdlInfoset>
- </tdml:infoset>
- </tdml:parserTestCase>
- </tdml:testSuite>
- val ts = new DFDLTestSuite(testSuite)
- ts.runOneTest("testRegex")
- }
-
- @Test def testRegexWithFreeFormAndComments4() = {
- val cdataText = """(?x) # free form
-abc # a comment
-# a line with only a comment
-123 # another comment
-"""
- val cdata = new scala.xml.PCData(cdataText)
- 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">
- <dfdl:format ref="tns:GeneralFormat"/>
- <xsd:element name="data" type="xsd:string" dfdl:lengthKind="delimited">
- <xsd:annotation>
- <xsd:appinfo source="http://www.ogf.org/dfdl/">
- <!-- This assert passes only if free form works, and comments work. -->
- <dfdl:assert testKind='pattern'>{ cdata }</dfdl:assert>
- </xsd:appinfo>
- </xsd:annotation>
- </xsd:element>
- </tdml:defineSchema>
- <tdml:parserTestCase xmlns={ tdml } name="testRegex" root="data" model="mySchema">
- <tdml:document>
- <tdml:documentPart type="text"><![CDATA[abcdef]]></tdml:documentPart>
- </tdml:document>
- <tdml:errors>
- <tdml:error>{ cdataText.trim }</tdml:error>
- </tdml:errors>
- </tdml:parserTestCase>
- </tdml:testSuite>
- val ts = new DFDLTestSuite(testSuite)
- ts.runOneTest("testRegex")
- }
-
- @Test def testComplexDocument() = {
- val doc = <tdml:document>
- <tdml:documentPart type="bits">00101010</tdml:documentPart>
- <tdml:documentPart type="bits">1</tdml:documentPart>
- <tdml:documentPart type="bits">00000000 00000000 00000000 00000001</tdml:documentPart>
- <tdml:documentPart type="bits">0</tdml:documentPart>
- <tdml:documentPart type="bits">1</tdml:documentPart>
- </tdml:document>
- val docObj = new Document(doc, null)
- val bits = docObj.documentBits
- val expected = List("00101010", "10000000", "00000000", "00000000", "00000000", "10100000")
- assertEquals(expected, bits)
- }
-
- @Test def testTDMLWithInvalidDFDLSchemaEmbedded() = {
-
- val testDir = ""
- val aa = testDir + "tdml-with-embedded-schema-errors.tdml"
- lazy val runner = new DFDLTestSuite(Misc.getRequiredResource(aa), validateTDMLFile = false, validateDFDLSchemas = true)
- runner.runOneTest("test1")
- }
-
- @Test def testTDMLUnparse() {
- val testSuite = <ts:testSuite xmlns:ts={ tdml } xmlns:tns={ tns } xmlns:dfdl={ dfdl } xmlns:xs={ xsd } xmlns:xsi={ xsi } suiteName="theSuiteName">
- <ts:defineSchema name="unparseTestSchema1">
- <dfdl:format ref="tns:GeneralFormat"/>
- <xs:element name="data" type="xs:string" dfdl:lengthKind="explicit" dfdl:length="{ 9 }"/>
- </ts:defineSchema>
- <ts:unparserTestCase ID="some identifier" name="testTDMLUnparse" root="data" model="unparseTestSchema1">
- <ts:infoset>
- <ts:dfdlInfoset>
- <data xmlns={ example }>123456789</data>
- </ts:dfdlInfoset>
- </ts:infoset>
- <ts:document>123456789</ts:document>
- </ts:unparserTestCase>
- </ts:testSuite>
- lazy val ts = new DFDLTestSuite(testSuite)
- ts.runOneTest("testTDMLUnparse")
- }
-
- @Test def test_quote_test1() = {
- runner.runOneTest("quote_test1")
- }
-
- val tdmlWithEmbeddedSchema =
- <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">
- <dfdl:format ref="tns:GeneralFormat"/>
- <xsd:element name="data" type="xsd:int" dfdl:lengthKind="explicit" dfdl:length="{ xs:unsignedInt(2) }"/>
- </tdml:defineSchema>
- <parserTestCase xmlns={ tdml } name="testEmbeddedSchemaWorks" root="data" model="mySchema">
- <document>37</document>
- <infoset>
- <dfdlInfoset>
- <data xmlns={ example }>37</data>
- </dfdlInfoset>
- </infoset>
- </parserTestCase>
- </tdml:testSuite>
-
- // @Test // other places should test tracing.
- def testTrace() {
- val tmpTDMLFileName = getClass.getName() + ".tdml"
- val testSuite = tdmlWithEmbeddedSchema
- try {
- using(new java.io.FileWriter(tmpTDMLFileName)) {
- fw =>
- fw.write(testSuite.toString())
- }
- lazy val ts = new DFDLTestSuite(new java.io.File(tmpTDMLFileName))
- ts.trace
- ts.runAllTests()
- } finally {
- val t = new java.io.File(tmpTDMLFileName)
- t.delete()
- }
- }
-}
diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section07/escapeScheme/escapeScheme.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section07/escapeScheme/escapeScheme.tdml
index c28270d..892bc5a 100644
--- a/daffodil-test/src/test/resources/org/apache/daffodil/section07/escapeScheme/escapeScheme.tdml
+++ b/daffodil-test/src/test/resources/org/apache/daffodil/section07/escapeScheme/escapeScheme.tdml
@@ -54,7 +54,7 @@
</xs:complexType>
</xs:element>
</defineSchema>
-
+
<defineSchema name="es2">
<dfdl:format ref="tns:GeneralFormat" lengthKind="delimited" />
<xs:element name="elem" dfdl:defineEscapeScheme=""/>
@@ -107,7 +107,7 @@
</xs:element>
</defineSchema>
-
+
<defineSchema name="emptyRef">
<dfdl:format ref="tns:GeneralFormat" lengthKind="delimited" />
@@ -520,5 +520,87 @@
</dfdlInfoset>
</infoset>
</parserTestCase>
-
+
+ <!--
+ Test Name: escBlkAllQuotes
+ Schema: eBlkAllQuotes
+ Root: record
+ Purpose: This test demonstrates that escapeSheme with escapeBlock where the escapeBlockStart, escapeBlockEnd and escapeEscapeCharacter characters are the same, all quotes (DAFFODIL-1923).
+ -->
+ <defineSchema name="eBlkAllQuotes">
+ <dfdl:format ref="tns:GeneralFormat" lengthKind="delimited" />
+
+ <dfdl:defineEscapeScheme name="eBlkAllQuotes">
+ <dfdl:escapeScheme escapeBlockStart="""
+ escapeBlockEnd=""" escapeKind="escapeBlock"
+ escapeEscapeCharacter=""" extraEscapedCharacters="" generateEscapeBlock="whenNeeded"/>
+ </dfdl:defineEscapeScheme>
+
+ <xs:element name="record">
+ <xs:complexType>
+ <xs:sequence dfdl:separator="," >
+ <xs:element name="item" type="xs:string" maxOccurs="unbounded"
+ dfdl:escapeSchemeRef="tns:eBlkAllQuotes" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </defineSchema>
+
+ <parserTestCase name="escBlkAllQuotes" model="eBlkAllQuotes"
+ description="Section 7 defineEscapeScheme - DFDL-7-079R" root="record" roundTrip="true">
+ <document>1,"Column ""Number"" Two",3,4,5</document>
+ <infoset>
+ <dfdlInfoset>
+ <tns:record>
+ <tns:item>1</tns:item>
+ <tns:item>Column "Number" Two</tns:item>
+ <tns:item>3</tns:item>
+ <tns:item>4</tns:item>
+ <tns:item>5</tns:item>
+ </tns:record>
+ </dfdlInfoset>
+ </infoset>
+ </parserTestCase>
+
+ <!--
+ Test Name: escBlkEndSame
+ Schema: eBlkEndSame
+ Root: record
+ Purpose: This test demonstrates that escapeSheme with escapeBlock where the escapeBlockEnd and escapeEscapeCharacter characters are the same (closing paren) but differnet from escapeBlockStart (DAFFODIL-1923).
+ -->
+ <defineSchema name="eBlkEndSame">
+ <dfdl:format ref="tns:GeneralFormat" lengthKind="delimited" />
+
+ <dfdl:defineEscapeScheme name="eBlkEndParen">
+ <dfdl:escapeScheme escapeBlockStart="("
+ escapeBlockEnd=")" escapeKind="escapeBlock"
+ escapeEscapeCharacter=")" extraEscapedCharacters="" generateEscapeBlock="whenNeeded"/>
+ </dfdl:defineEscapeScheme>
+
+ <xs:element name="record">
+ <xs:complexType>
+ <xs:sequence dfdl:separator="," >
+ <xs:element name="item" type="xs:string" maxOccurs="unbounded"
+ dfdl:escapeSchemeRef="tns:eBlkEndParen" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </defineSchema>
+
+ <parserTestCase name="escBlkEndSame" model="eBlkEndSame"
+ description="Section 7 defineEscapeScheme - DFDL-7-079R" root="record" roundTrip="true">
+ <document>1,(Column (Number)) Two),3,4,5</document>
+ <infoset>
+ <dfdlInfoset>
+ <tns:record>
+ <tns:item>1</tns:item>
+ <tns:item>Column (Number) Two</tns:item>
+ <tns:item>3</tns:item>
+ <tns:item>4</tns:item>
+ <tns:item>5</tns:item>
+ </tns:record>
+ </dfdlInfoset>
+ </infoset>
+ </parserTestCase>
+
</testSuite>
diff --git a/daffodil-test/src/test/scala-debug/org/apache/daffodil/section07/escapeScheme/TestEscapeSchemeDebug.scala b/daffodil-test/src/test/scala-debug/org/apache/daffodil/section07/escapeScheme/TestEscapeSchemeDebug.scala
index 65a59f4..9eb8117 100644
--- a/daffodil-test/src/test/scala-debug/org/apache/daffodil/section07/escapeScheme/TestEscapeSchemeDebug.scala
+++ b/daffodil-test/src/test/scala-debug/org/apache/daffodil/section07/escapeScheme/TestEscapeSchemeDebug.scala
@@ -48,4 +48,10 @@ class TestEscapeSchemeDebug {
//DFDL-961
@Test def test_scenario3_11_postfix() { runner2.runOneTest("scenario3_11_postfix") }
+
+
+ //DAFFODIL-1923
+ @Test def test_escBlkAllQuotes() { runner.runOneTest("escBlkAllQuotes") }
+ @Test def test_escBlkEndSame() { runner.runOneTest("escBlkEndSame") }
+
}
--
To stop receiving notification emails like this one, please contact
dthompson@apache.org.