jw3 commented on a change in pull request #463: URL: https://github.com/apache/incubator-daffodil/pull/463#discussion_r560225908
########## File path: daffodil-cli/src/it/scala/org/apache/daffodil/schematron/TestEmbedded.scala ########## @@ -0,0 +1,105 @@ +/* + * 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.schematron + +import net.sf.expectit.matcher.Matchers.sequence +import net.sf.expectit.matcher.Matchers.contains +import org.junit.Test + +import java.util.UUID + +class TestEmbedded { + @Test def alwaysFails(): Unit = withShell(FailureErrorCodeResult) { + val data = mktmp(UUID.randomUUID.toString) + val schema = "xsd/always-fails-1.dfdl.xsd" + s"parse --validate schematron={{$schema}} -s {{$schema}} $data" -> anyLines(2) + } + + @Test def unitPriceWithoutValidation(): Unit = withShell() { + val data = mktmp("widget,monday,1,$5.00,$5.00") + val schema = "xsd/unit_price.dfdl.xsd" + s"parse -r list -s {{$schema}} $data" -> contains("</ex:list>\n") + } + + @Test def unitPriceWithValidation(): Unit = withShell(FailureErrorCodeResult, true) { + val data = mktmp("widget,monday,1,$5.00,$6.00") + val schema = "xsd/unit_price.dfdl.xsd" + s"parse -r list --validate schematron={{$schema}} -s {{$schema}} $data" -> sequence( + contains("</ex:list>\n"), + anyLines(3) + ) + } + + @Test def unitPriceWithValidationCheckMessage(): Unit = withShell(FailureErrorCodeResult, true) { + val data = mktmp("widget,monday,5,$5.00,$25.00||gadget,tuesday,1,$10.00,$11.00") + val schema = "xsd/unit_price.dfdl.xsd" + s"parse -r list --validate schematron={{$schema}} -s {{$schema}} $data" -> sequence( + contains("</ex:list>\n"), + contains("[error] Validation Error: wrong unit price for gadget, tuesday\n"), + anyLines(2) + ) + } + + @Test def extends1(): Unit = withShell() { + val data = mktmp("bob;l;smith") + val schema = "xsd/extends-1.dfdl.xsd" + s"parse --validate schematron={{$schema}} -s {{$schema}} $data" -> contains("</name>\n") + } + + @Test def extends2(): Unit = withShell() { + val data = mktmp("ob;;smith") + val schema = "xsd/extends-1.dfdl.xsd" + s"parse --validate schematron={{$schema}} -s {{$schema}} $data" -> contains("</name>\n") + } + + @Test def extends3(): Unit = withShell(FailureErrorCodeResult) { + val data = mktmp(";;smith") + val schema = "xsd/extends-1.dfdl.xsd" + s"parse --validate schematron={{$schema}} -s {{$schema}} $data" -> contains("</name>\n") + } + + @Test def extends4(): Unit = withShell(FailureErrorCodeResult) { + val data = mktmp("bob;l;") + val schema = "xsd/extends-1.dfdl.xsd" + s"parse --validate schematron={{$schema}} -s {{$schema}} $data" -> contains("</name>\n") + } + + @Test def extends5(): Unit = withShell(FailureErrorCodeResult) { + val data = mktmp(";l;") + val schema = "xsd/extends-1.dfdl.xsd" + s"parse --validate schematron={{$schema}} -s {{$schema}} $data" -> contains("</name>\n") + } + + @Test def testWithNs1(): Unit = withShell() { + val data = mktmp("0;1") + val schema = "xsd/with-ns-1.dfdl.xsd" + s"parse --validate schematron={{$schema}} -s {{$schema}} $data" -> contains("</myns:interval>\n") + } + + @Test def testWithNs2(): Unit = withShell(FailureErrorCodeResult) { + val data = mktmp("2;1") + val schema = "xsd/with-ns-1.dfdl.xsd" + s"parse --validate schematron={{$schema}} -s {{$schema}} $data" -> contains("</myns:interval>\n") + } + + @Test def testWithNs3(): Unit = withShell(FailureErrorCodeResult) { + val data = mktmp("0;0") + val schema = "xsd/with-ns-1.dfdl.xsd" + s"parse --validate schematron={{$schema}} -s {{$schema}} $data" -> contains("</myns:interval>\n") + } +} Review comment: Yes. What strted the entire abstraction of temp file creation was to set deleteOnExit() for all these, and I ended up forgetting it :laughing: done ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
