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 2020/09/14 12:36:37 UTC

[incubator-daffodil] branch master updated (60675a3 -> fc3269c)

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

slawrence pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-daffodil.git.


    from 60675a3  Correctly expand varargs in String.format call
     new 055f5b4  Throw SDE in the case of a choice with no branches
     new 8eae1c2  Update per Steve's comments
     new fc3269c  Removed old test

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/daffodil/dsom/ChoiceGroup.scala     |  7 ++++
 .../daffodil/section15/choice_groups/choice.tdml   | 49 ++++++++++++++--------
 .../section15/choice_groups/noBranches.dfdl.xsd    | 43 -------------------
 .../section15/choice_groups/TestChoice.scala       |  5 +--
 4 files changed, 40 insertions(+), 64 deletions(-)
 delete mode 100644 daffodil-test/src/test/resources/org/apache/daffodil/section15/choice_groups/noBranches.dfdl.xsd


[incubator-daffodil] 02/03: Update per Steve's comments

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slawrence pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-daffodil.git

commit 8eae1c21b3a96a07035af9cb6669ebfc6e59da9a
Author: Steinberger <rs...@tresys.com>
AuthorDate: Fri Sep 11 12:35:53 2020 -0400

    Update per Steve's comments
    
    Reconfigured the test
    Update the if statement
---
 .../org/apache/daffodil/dsom/ChoiceGroup.scala     |  2 +-
 .../daffodil/section15/choice_groups/choice.tdml   | 54 +++++++++++-----------
 .../section15/choice_groups/TestChoice.scala       |  2 +
 3 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/dsom/ChoiceGroup.scala b/daffodil-core/src/main/scala/org/apache/daffodil/dsom/ChoiceGroup.scala
index ec88686..410d235 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/dsom/ChoiceGroup.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/dsom/ChoiceGroup.scala
@@ -203,7 +203,7 @@ abstract class ChoiceTermBase(
   }.value
 
   final lazy val noBranchesFound = LV('noBranchesFound) {
-    if(groupMembers.size.equals(0)) {
+    if (groupMembers.size == 0) {
       SDE("choice element must contain one or more branches")
     }
   }.value
diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section15/choice_groups/choice.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section15/choice_groups/choice.tdml
index e29e7ff..b9a8f5d 100644
--- a/daffodil-test/src/test/resources/org/apache/daffodil/section15/choice_groups/choice.tdml
+++ b/daffodil-test/src/test/resources/org/apache/daffodil/section15/choice_groups/choice.tdml
@@ -52,6 +52,18 @@
       </xs:complexType>
     </xs:element>
 
+    <xs:element name="ch2">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="redOrBlue" minOccurs="0" dfdl:occursCountKind="implicit">
+            <xs:complexType>
+              <xs:choice>
+              </xs:choice>
+            </xs:complexType>
+          </xs:element>
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
 
   </tdml:defineSchema>
 
@@ -71,6 +83,20 @@
 
   </tdml:parserTestCase>
 
+  <!--
+   Test Name: choice_noBranch
+   Schema: basic
+   Purpose: This test demonstrates the SDE where you have a choice with no branches.
+  -->
+
+  <tdml:parserTestCase name="choice_noBranch" root="ch2"
+                       model="basic">
+    <tdml:document>red</tdml:document>
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+      <tdml:error>choice element must contain one or more branches</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
 
   <tdml:defineSchema name="choice2">
     <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
@@ -1336,19 +1362,6 @@
         </xs:sequence>
       </xs:complexType>
 
-    <xs:element name="e0">
-      <xs:complexType>
-        <xs:sequence>
-          <xs:element name="redOrBlue" minOccurs="0" dfdl:occursCountKind="implicit">
-            <xs:complexType>
-              <xs:choice>
-              </xs:choice>
-            </xs:complexType>
-          </xs:element>
-        </xs:sequence>
-      </xs:complexType>
-    </xs:element>
-
       <xs:element name="e1">
         <xs:complexType>
           <xs:sequence dfdl:separator="/%NL;" dfdl:separatorPosition="postfix" dfdl:separatorSuppressionPolicy="trailingEmptyStrict">
@@ -1400,21 +1413,6 @@
   </tdml:defineSchema>
 
   <!--
-   Test Name: optionalChoice0
-   Schema: optionalChoices
-   Purpose: This test demonstrates the SDE where you have a choice with no branches.
-  -->
-
-  <tdml:parserTestCase name="optionalChoice00" root="e0"
-                       model="optionalChoices">
-    <tdml:document>red</tdml:document>
-    <tdml:errors>
-      <tdml:error>Schema Definition Error</tdml:error>
-      <tdml:error>choice element must contain one or more branches</tdml:error>
-    </tdml:errors>
-  </tdml:parserTestCase>
-
-  <!--
        Test Name: optionalChoice01
        Schema: optionalChoices
        Purpose: This test demonstrates the scenario where you have a choice of two initiated elements in an optional choice. In this case the first element should be selected.
diff --git a/daffodil-test/src/test/scala/org/apache/daffodil/section15/choice_groups/TestChoice.scala b/daffodil-test/src/test/scala/org/apache/daffodil/section15/choice_groups/TestChoice.scala
index 97dae26..44ac031 100644
--- a/daffodil-test/src/test/scala/org/apache/daffodil/section15/choice_groups/TestChoice.scala
+++ b/daffodil-test/src/test/scala/org/apache/daffodil/section15/choice_groups/TestChoice.scala
@@ -38,6 +38,8 @@ class TestChoice {
 
   import TestChoice._
 
+  @Test def test_choice_noBranch (): Unit = { runnerCH.runOneTest("choice_noBranch") }
+
   @Test def test_optionalChoice00(): Unit = { runnerCH.runOneTest("optionalChoice00") }
   @Test def test_optionalChoice01(): Unit = { runnerCH.runOneTest("optionalChoice01") }
   @Test def test_optionalChoice02(): Unit = { runnerCH.runOneTest("optionalChoice02") }


[incubator-daffodil] 03/03: Removed old test

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slawrence pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-daffodil.git

commit fc3269c892b1923db302b76d43a13ffefa535d29
Author: Steinberger <rs...@tresys.com>
AuthorDate: Fri Sep 11 13:24:44 2020 -0400

    Removed old test
---
 .../scala/org/apache/daffodil/section15/choice_groups/TestChoice.scala   | 1 -
 1 file changed, 1 deletion(-)

diff --git a/daffodil-test/src/test/scala/org/apache/daffodil/section15/choice_groups/TestChoice.scala b/daffodil-test/src/test/scala/org/apache/daffodil/section15/choice_groups/TestChoice.scala
index 44ac031..9fc7df1 100644
--- a/daffodil-test/src/test/scala/org/apache/daffodil/section15/choice_groups/TestChoice.scala
+++ b/daffodil-test/src/test/scala/org/apache/daffodil/section15/choice_groups/TestChoice.scala
@@ -40,7 +40,6 @@ class TestChoice {
 
   @Test def test_choice_noBranch (): Unit = { runnerCH.runOneTest("choice_noBranch") }
 
-  @Test def test_optionalChoice00(): Unit = { runnerCH.runOneTest("optionalChoice00") }
   @Test def test_optionalChoice01(): Unit = { runnerCH.runOneTest("optionalChoice01") }
   @Test def test_optionalChoice02(): Unit = { runnerCH.runOneTest("optionalChoice02") }
   @Test def test_optionalChoice03(): Unit = { runnerCH.runOneTest("optionalChoice03") }


[incubator-daffodil] 01/03: Throw SDE in the case of a choice with no branches

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slawrence pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-daffodil.git

commit 055f5b4136c794a33035baf2086c445a842a7469
Author: Steinberger <rs...@tresys.com>
AuthorDate: Fri Sep 11 10:10:40 2020 -0400

    Throw SDE in the case of a choice with no branches
    
    Section 15 of the spec satates that a choice that declares no branches
    in the DFDL schema is a schema definition error.
    
    Daffodil-1032
---
 .../org/apache/daffodil/dsom/ChoiceGroup.scala     |  7 +++
 .../daffodil/section15/choice_groups/choice.tdml   | 51 ++++++++++++++--------
 .../section15/choice_groups/noBranches.dfdl.xsd    | 43 ------------------
 .../section15/choice_groups/TestChoice.scala       |  4 +-
 4 files changed, 41 insertions(+), 64 deletions(-)

diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/dsom/ChoiceGroup.scala b/daffodil-core/src/main/scala/org/apache/daffodil/dsom/ChoiceGroup.scala
index 35a90fd..ec88686 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/dsom/ChoiceGroup.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/dsom/ChoiceGroup.scala
@@ -100,6 +100,7 @@ abstract class ChoiceTermBase(
   with ChoiceAGMixin
   with HasOptRepTypeMixinImpl {
 
+  requiredEvaluationsIfActivated(noBranchesFound)
   requiredEvaluationsIfActivated(branchesAreNonOptional)
   requiredEvaluationsIfActivated(branchesAreNotIVCElements)
   requiredEvaluationsIfActivated(modelGroupRuntimeData.preSerialization)
@@ -201,6 +202,12 @@ abstract class ChoiceTermBase(
     }
   }.value
 
+  final lazy val noBranchesFound = LV('noBranchesFound) {
+    if(groupMembers.size.equals(0)) {
+      SDE("choice element must contain one or more branches")
+    }
+  }.value
+
   /**
    * The DFDL Spec as of this writing 2015-06-02 says that branches cannot be optional, but then
    * specifies that what it means is that if a choice branch root is an element/element-ref, it
diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section15/choice_groups/choice.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section15/choice_groups/choice.tdml
index d549e03..e29e7ff 100644
--- a/daffodil-test/src/test/resources/org/apache/daffodil/section15/choice_groups/choice.tdml
+++ b/daffodil-test/src/test/resources/org/apache/daffodil/section15/choice_groups/choice.tdml
@@ -1320,19 +1320,6 @@
 
   </tdml:parserTestCase>
 
-  <tdml:parserTestCase name="choice_noBranch" root="choice_noBranches"
-    model="noBranches.dfdl.xsd"
-    description="Section 15 - Choice Groups - A choice that declares no branches in the DFDL schema is a schema definition error..">
-
-    <tdml:document><![CDATA[test]]></tdml:document>
-
-    <tdml:errors>
-      <tdml:error>Schema Definition Error</tdml:error>
-      <tdml:error>Placeholder</tdml:error>
-    </tdml:errors>
-
-  </tdml:parserTestCase>
-  
   <tdml:defineSchema name="optionalChoices">
     <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
     <dfdl:format ref="ex:GeneralFormat" lengthKind="delimited" />
@@ -1349,6 +1336,19 @@
         </xs:sequence>
       </xs:complexType>
 
+    <xs:element name="e0">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="redOrBlue" minOccurs="0" dfdl:occursCountKind="implicit">
+            <xs:complexType>
+              <xs:choice>
+              </xs:choice>
+            </xs:complexType>
+          </xs:element>
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
       <xs:element name="e1">
         <xs:complexType>
           <xs:sequence dfdl:separator="/%NL;" dfdl:separatorPosition="postfix" dfdl:separatorSuppressionPolicy="trailingEmptyStrict">
@@ -1399,11 +1399,26 @@
 
   </tdml:defineSchema>
 
-<!--
-     Test Name: optionalChoice01
-     Schema: optionalChoices
-     Purpose: This test demonstrates the scenario where you have a choice of two initiated elements in an optional choice. In this case the first element should be selected.
--->
+  <!--
+   Test Name: optionalChoice0
+   Schema: optionalChoices
+   Purpose: This test demonstrates the SDE where you have a choice with no branches.
+  -->
+
+  <tdml:parserTestCase name="optionalChoice00" root="e0"
+                       model="optionalChoices">
+    <tdml:document>red</tdml:document>
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+      <tdml:error>choice element must contain one or more branches</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
+  <!--
+       Test Name: optionalChoice01
+       Schema: optionalChoices
+       Purpose: This test demonstrates the scenario where you have a choice of two initiated elements in an optional choice. In this case the first element should be selected.
+  -->
   
   <tdml:parserTestCase name="optionalChoice01" root="e1"
     model="optionalChoices">
diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section15/choice_groups/noBranches.dfdl.xsd b/daffodil-test/src/test/resources/org/apache/daffodil/section15/choice_groups/noBranches.dfdl.xsd
deleted file mode 100644
index d35efc8..0000000
--- a/daffodil-test/src/test/resources/org/apache/daffodil/section15/choice_groups/noBranches.dfdl.xsd
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  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.
--->
-
-<schema xmlns="http://www.w3.org/2001/XMLSchema"
-  targetNamespace="http://www.example.org/example1/" xmlns:ex="http://www.example.org/example1/"
-  xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-
-  <include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
-
-  <annotation>
-    <appinfo source="http://www.ogf.org/dfdl/">
-      <dfdl:format ref="ex:GeneralFormat" initiator=""
-        leadingSkip="0" trailingSkip="0" separator=""
-        encoding="utf-8" occursCountKind="parsed" separatorSuppressionPolicy="anyEmpty"
-        textNumberRep="standard" ignoreCase="no" representation="text"
-        lengthUnits="characters" lengthKind="delimited" initiatedContent="no" />
-    </appinfo>
-  </annotation>
-  
-  <xs:element name="choice_noBranches">
-    <xs:complexType>
-      <xs:choice>
-      </xs:choice>
-    </xs:complexType>
-  </xs:element>
-
-</schema>
diff --git a/daffodil-test/src/test/scala/org/apache/daffodil/section15/choice_groups/TestChoice.scala b/daffodil-test/src/test/scala/org/apache/daffodil/section15/choice_groups/TestChoice.scala
index 6cb5687..97dae26 100644
--- a/daffodil-test/src/test/scala/org/apache/daffodil/section15/choice_groups/TestChoice.scala
+++ b/daffodil-test/src/test/scala/org/apache/daffodil/section15/choice_groups/TestChoice.scala
@@ -38,6 +38,7 @@ class TestChoice {
 
   import TestChoice._
 
+  @Test def test_optionalChoice00(): Unit = { runnerCH.runOneTest("optionalChoice00") }
   @Test def test_optionalChoice01(): Unit = { runnerCH.runOneTest("optionalChoice01") }
   @Test def test_optionalChoice02(): Unit = { runnerCH.runOneTest("optionalChoice02") }
   @Test def test_optionalChoice03(): Unit = { runnerCH.runOneTest("optionalChoice03") }
@@ -123,9 +124,6 @@ class TestChoice {
   @Test def test_direct_dispatch_16(): Unit = { runnerCH.runOneTest("direct_dispatch_16") }
   @Test def test_direct_dispatch_17(): Unit = { runnerCH.runOneTest("direct_dispatch_17") }
 
-  //@Test def test_choice_noBranch() { runnerCH.runOneTest("choice_noBranch") } - Test consumes no data, which causes a TDMLError
-
-
   @Test def test_explicit_01(): Unit = { runnerCE.runOneTest("explicit_01") }
   @Test def test_explicit_02(): Unit = { runnerCE.runOneTest("explicit_02") }
   @Test def test_explicit_03(): Unit = { runnerCE.runOneTest("explicit_03") }