You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by sl...@apache.org on 2023/01/24 20:31:01 UTC

[daffodil] branch main updated: Add test showing both name and ref defined causes an SDE

This is an automated email from the ASF dual-hosted git repository.

slawrence 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 c777dcfea Add test showing both name and ref defined causes an SDE
c777dcfea is described below

commit c777dcfea76ae4c52387f50f5b31bfd5ab8239da
Author: Steve Lawrence <sl...@apache.org>
AuthorDate: Tue Jan 24 14:32:53 2023 -0500

    Add test showing both name and ref defined causes an SDE
    
    Add a test to verify that an SDE is thrown if a schema uses both name
    and ref to define an element.
    
    DAFFODIL-768
---
 .../apache/daffodil/section00/general/general.tdml | 28 ++++++++++++++++++++++
 .../daffodil/section00/general/TestGeneral.scala   |  2 ++
 2 files changed, 30 insertions(+)

diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section00/general/general.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section00/general/general.tdml
index a3a50d9ae..498762603 100644
--- a/daffodil-test/src/test/resources/org/apache/daffodil/section00/general/general.tdml
+++ b/daffodil-test/src/test/resources/org/apache/daffodil/section00/general/general.tdml
@@ -217,4 +217,32 @@
         <tdml:error>in no namespace</tdml:error>
     </tdml:errors>
   </tdml:parserTestCase>
+
+  <tdml:defineSchema name="nameAndRef">
+    <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd" />
+    <dfdl:format ref="ex:GeneralFormat" />
+    <xs:element name="root1">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="nameAndRef" type="xs:string" ref="ex:root2" dfdl:lengthKind="delimited" />
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+    <xs:element name="root2" type="xs:string" dfdl:lengthKind="delimited" />
+  </tdml:defineSchema>
+
+  <tdml:parserTestCase name="nameAndRefError_01" root="root1" model="nameAndRef">
+
+    <tdml:document>
+      <tdml:documentPart type="text"></tdml:documentPart>
+    </tdml:document>
+
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+      <tdml:error>name</tdml:error>
+      <tdml:error>type</tdml:error>
+      <tdml:error>cannot appear</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
 </tdml:testSuite>
diff --git a/daffodil-test/src/test/scala/org/apache/daffodil/section00/general/TestGeneral.scala b/daffodil-test/src/test/scala/org/apache/daffodil/section00/general/TestGeneral.scala
index 6a32f78f6..aad36a54a 100644
--- a/daffodil-test/src/test/scala/org/apache/daffodil/section00/general/TestGeneral.scala
+++ b/daffodil-test/src/test/scala/org/apache/daffodil/section00/general/TestGeneral.scala
@@ -62,6 +62,8 @@ class TestGeneral {
   @Test def test_litNil1FullPath(): Unit = { runner.runOneTest("litNil1FullPath") }
   @Test def test_referentialIntegrity(): Unit = { runner.runOneTest("referentialIntegrity") }
 
+  @Test def test_nameAndRefError_01(): Unit = { runner.runOneTest("nameAndRefError_01") }
+
   // Test causes exception as the file is not found
   // @Test def test_fileDNE() { runner.runOneTest("fileDNE") }