Skip to content

Commit

Permalink
Verify overlap check doesn't occur with default format
Browse files Browse the repository at this point in the history
- add test for verification

DAFFODIL-1842
  • Loading branch information
olabusayoT committed Nov 13, 2024
1 parent 60f87c6 commit ef1c788
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,46 @@
</tdml:infoset>
</tdml:parserTestCase>

<tdml:parserTestCase name="overlappingProperties1" root="outer" roundTrip="onePass"
model="/org/apache/daffodil/section07/property_syntax/property_syntax_overlap2.dfdl.xsd"
ignoreUnexpectedWarnings="false">
<tdml:document>hello</tdml:document>
<tdml:infoset>
<tdml:dfdlInfoset>
<outer>
<e1>hello</e1>
</outer>
</tdml:dfdlInfoset>
</tdml:infoset>
</tdml:parserTestCase>

<tdml:defineSchema name="PropertySyntaxOverlap">

<xs:include schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
<dfdl:format ref="ex:GeneralFormat" lengthKind="delimited"
lengthUnits="bytes" encoding="UTF-8" separator="" initiator=""
terminator="" occursCountKind="parsed" ignoreCase="no"
textNumberRep="standard" representation="text" initiatedContent="no" />

<xs:element name="e1" type="xs:string" dfdl:lengthUnits="bits"/>

<xs:element name="outer">
<xs:complexType>
<xs:sequence>
<xs:element ref="ex:e1" dfdl:lengthUnits="bytes"/>
</xs:sequence>
</xs:complexType>
</xs:element>

</tdml:defineSchema>

<tdml:parserTestCase name="overlappingProperties2" root="outer" roundTrip="onePass"
model="PropertySyntaxOverlap"
ignoreUnexpectedWarnings="false">
<tdml:document>hello</tdml:document>
<tdml:errors>
<tdml:error>Overlap is not allowed</tdml:error>
</tdml:errors>
</tdml:parserTestCase>

</tdml:testSuite>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?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.
-->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"
targetNamespace="urn:overlap1" xmlns:o1="urn:overlap1">

<xs:include schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>

<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:format ref="o1:GeneralFormat" lengthKind="delimited"
lengthUnits="bytes" encoding="UTF-8" separator="" initiator=""
terminator="" occursCountKind="parsed" ignoreCase="no"
textNumberRep="standard" representation="text" initiatedContent="no" />
</xs:appinfo>
</xs:annotation>

<xs:element name="e1" type="xs:string"/>

</xs:schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?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.
-->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"
targetNamespace="urn:overlap2" xmlns:o1="urn:overlap1" xmlns:o2="urn:overlap2">

<xs:include schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
<xs:import namespace="urn:overlap1" schemaLocation="/org/apache/daffodil/section07/property_syntax/property_syntax_overlap1.dfdl.xsd"/>

<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:format ref="o2:GeneralFormat" lengthKind="delimited"
lengthUnits="bits" encoding="UTF-8" separator="" initiator=""
terminator="" occursCountKind="parsed" ignoreCase="no"
textNumberRep="standard" representation="text" initiatedContent="no" />
</xs:appinfo>
</xs:annotation>

<xs:element name="outer">
<xs:complexType>
<xs:sequence>
<xs:element ref="o1:e1" dfdl:lengthUnits="characters" dfdl:length="5" dfdl:lengthKind="explicit"/>
</xs:sequence>
</xs:complexType>
</xs:element>

</xs:schema>
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ class TestPropertySyntax {
@Test def test_ignoredPropertiesWarning(): Unit = {
runner1.runOneTest("ignoredPropertiesWarning")
}
// DFDL-1842
@Test def test_overlappingProperties1(): Unit = {
runner1.runOneTest("overlappingProperties1")
}
@Test def test_overlappingProperties2(): Unit = {
runner1.runOneTest("overlappingProperties2")
}

@Test def test_badElementFormProperty(): Unit = {
runner1.runOneTest("badElementFormProperty")
Expand Down

0 comments on commit ef1c788

Please sign in to comment.