Skip to content

Commit

Permalink
Add test scenario into build
Browse files Browse the repository at this point in the history
  • Loading branch information
rkottmann committed Mar 1, 2018
1 parent 87af6fe commit b555a12
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 36 deletions.
104 changes: 69 additions & 35 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<!-- set global properties for this build -->
<!-- main build directories -->
<property name="src.dir" location="${basedir}/src"/>
<property name="test.src.dir" location="${src.dir}/test"/>
<property name="test.resource.dir" location="${test.dir}/resources"/>
<property name="lib.dir" location="${basedir}/lib"/>
<property name="build.dir" location="${basedir}/build"/>
<property name="download.dir" location="${build.dir}/download"/>
<property name="dist.dir" location="${basedir}/dist"/>
<property name="test.src.dir" location="${src.dir}/test"/>
<property name="test.build.dir" location="${build.dir}/test"/>
<!-- Naming -->
<property name="xrechnung.version" value="1.1"/>
<property name="dist.name" value="xrechnung-${xrechnung.version}-validation-configuration"/>
Expand All @@ -29,7 +29,7 @@
<target name="init" description="Initializes build directory structure and ISO timestamp">
<!-- Create timestamps -->
<tstamp>
<format property="build.date" pattern="yyyy-MM-dd" />
<format property="build.date" pattern="yyyy-MM-dd"/>
</tstamp>
<echo>Build date: ${build.date}</echo>
<!-- Create the build directory structure used by compile -->
Expand All @@ -38,47 +38,64 @@
<mkdir dir="${lib.dir}"/>
<mkdir dir="${dist.dir}"/>
</target>
<target name="init-test" depends="init" description="Initializes test directory structure">
<mkdir dir="${build.dir}/test"/>
</target>
<target name="prepare-saxon" depends="init" description="Download Saxon-HE and add jar to library directory">
<get src="https://sourceforge.net/projects/saxon/files/Saxon-HE/9.8/SaxonHE9-8-0-8J.zip/download" dest="${download.dir}/SaxonHE9-8-0-8J.zip" verbose="true" skipexisting="true" usetimestamp="true"/>

<target name="prepare-saxon" depends="init"
description="Download Saxon-HE and add jar to library directory">
<get
src="https://sourceforge.net/projects/saxon/files/Saxon-HE/9.8/SaxonHE9-8-0-8J.zip/download"
dest="${download.dir}/SaxonHE9-8-0-8J.zip" verbose="true" skipexisting="true"
usetimestamp="true"/>
<unzip src="${download.dir}/SaxonHE9-8-0-8J.zip" dest="${lib.dir}">
<patternset>
<include name="**/${saxon.jar}"/>
</patternset>
<flattenmapper/>
</unzip>
</target>
<target name="prepare-validationtool" depends="init" description="Download KoSIT validation tool and add jar to library directory">
<get src="https://github.com/itplr-kosit/validationtool/releases/download/validationtool-1_0_1/validationtool-dist-1.0.1-standalone.zip" dest="${download.dir}" verbose="true" skipexisting="true" usetimestamp="true"/>
<target name="prepare-validationtool" depends="init"
description="Download KoSIT validation tool and add jar to library directory">
<get
src="https://github.com/itplr-kosit/validationtool/releases/download/validationtool-1_0_1/validationtool-dist-1.0.1-standalone.zip"
dest="${download.dir}" verbose="true" skipexisting="true" usetimestamp="true"/>
<unzip src="${download.dir}/validationtool-dist-1.0.1-standalone.zip" dest="${lib.dir}">
<patternset>
<include name="**/${validationtool.jar}"/>
</patternset>
<flattenmapper/>
</unzip>
</target>
<target name="retrieve-cen-rules" depends="init" description="Download CEN business rules (schematron) to download directory">
<get src="https://github.com/CenPC434/validation/archive/${cen.rules.zip}" dest="${download.dir}" verbose="true" skipexisting="true" usetimestamp="true"/>
<target name="retrieve-cen-rules" depends="init"
description="Download CEN business rules (schematron) to download directory">
<get src="https://github.com/CenPC434/validation/archive/${cen.rules.zip}"
dest="${download.dir}" verbose="true" skipexisting="true" usetimestamp="true"/>
</target>
<target name="retrieve-xrechnung-rules" depends="init" description="Download XRechnung business rules (schematron) to download directory">
<get src="https://github.com/itplr-kosit/xrechnung-artefacts/releases/download/xrechnung-1_1-schematron-2017-12-19/${xrechnung.rules.zip}" dest="${download.dir}" verbose="true" skipexisting="true" usetimestamp="true"/>
<target name="retrieve-xrechnung-rules" depends="init"
description="Download XRechnung business rules (schematron) to download directory">
<get
src="https://github.com/itplr-kosit/xrechnung-artefacts/releases/download/xrechnung-1_1-schematron-2017-12-19/${xrechnung.rules.zip}"
dest="${download.dir}" verbose="true" skipexisting="true" usetimestamp="true"/>
</target>
<target name="retrieve-ubl-schema" depends="init" description="Download UBL schemas to download directory">
<get src="http://docs.oasis-open.org/ubl/os-UBL-2.1/${ubl.schema.zip}" dest="${download.dir}" verbose="true" skipexisting="true" usetimestamp="true"/>
<target name="retrieve-ubl-schema" depends="init"
description="Download UBL schemas to download directory">
<get src="http://docs.oasis-open.org/ubl/os-UBL-2.1/${ubl.schema.zip}"
dest="${download.dir}" verbose="true" skipexisting="true" usetimestamp="true"/>
</target>
<target name="retrieve-cii-schema" depends="init" description="Download UN/CEFACT CII schemas to download directory">
<get src="http://www.unece.org/fileadmin/DAM/cefact/xml_schemas/${cii.schema.zip}" dest="${download.dir}" verbose="true" skipexisting="true" usetimestamp="true"/>
<target name="retrieve-cii-schema" depends="init"
description="Download UN/CEFACT CII schemas to download directory">
<get src="http://www.unece.org/fileadmin/DAM/cefact/xml_schemas/${cii.schema.zip}"
dest="${download.dir}" verbose="true" skipexisting="true" usetimestamp="true"/>
<unzip src="${download.dir}/${cii.schema.zip}" dest="${download.dir}">
<patternset>
<include name="**/D16B*uncoupled.zip"/>
</patternset>
<mergemapper to="${cii.schema.uncoupled.zip}"/>
</unzip>
</target>
<target name="retrieve-all-schema-rules" depends="retrieve-ubl-schema,retrieve-cen-rules,retrieve-xrechnung-rules,retrieve-cii-schema" description="Retrieves all 3rd party XSDs and XSLTs"/>
<target name="compile" depends="retrieve-all-schema-rules,prepare-saxon" description="Compile XSDs and XSLTs into validation configuration conformat repository directory">
<target name="retrieve-all-schema-rules"
depends="retrieve-ubl-schema,retrieve-cen-rules,retrieve-xrechnung-rules,retrieve-cii-schema"
description="Retrieves all 3rd party XSDs and XSLTs"/>
<target name="compile" depends="retrieve-all-schema-rules,prepare-saxon"
description="Compile XSDs and XSLTs into validation configuration conformat repository directory">
<echo>Compiling Schemas and XSLTs ...</echo>
<copy file="scenarios.xml" todir="${repository.dir}"/>
<copy file="${src.dir}/default-report.xsl" todir="${resource.dir}"/>
Expand Down Expand Up @@ -117,24 +134,38 @@
</unzip>
<!-- according to https://www.saxonica.com/html/documentation/using-xsl/xsltfromant.html-->
<!-- customize CEN schematron rules for UBL -->
<xslt in="${download.dir}/EN16931-UBL-model.xslt" out="${resource.dir}/ubl/2.1/xsl/EN16931-UBL-validation.xsl" style="${src.dir}/remove-dead-apply-templates.xsl">
<classpath location="${lib.dir}/${saxon.jar}" />
<xslt in="${download.dir}/EN16931-UBL-model.xslt"
out="${resource.dir}/ubl/2.1/xsl/EN16931-UBL-validation.xsl"
style="${src.dir}/remove-dead-apply-templates.xsl">
<classpath location="${lib.dir}/${saxon.jar}"/>
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
<!-- customize CEN schematron rules for CII -->
<xslt in="${download.dir}/EN16931-CII-validation.xslt" out="${resource.dir}/cii/16b/xsl/EN16931-CII-validation.xsl" style="${src.dir}/remove-dead-apply-templates.xsl">
<classpath location="${lib.dir}/${saxon.jar}" />
<xslt in="${download.dir}/EN16931-CII-validation.xslt"
out="${resource.dir}/cii/16b/xsl/EN16931-CII-validation.xsl"
style="${src.dir}/remove-dead-apply-templates.xsl">
<classpath location="${lib.dir}/${saxon.jar}"/>
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
</target>
<target name="init-test" depends="init" description="Initializes test directory structure">
<mkdir dir="${build.dir}/test"/>
<!-- customize scenarios.xml fir testing purpose -->
<xslt in="${basedir}/scenarios.xml" out="${test.build.dir}/scenarios.xml"
style="${src.dir}/create-test-scenario.xsl">
<classpath location="${lib.dir}/${saxon.jar}"/>
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
</target>
<target name="test" depends="compile,init-test,prepare-validationtool" description="Test XRechnung Configuration">
<target name="test" depends="compile,init-test,prepare-validationtool"
description="Test XRechnung Configuration">
<echo>Creating validation reports ...</echo>
<java jar="${lib.dir}/${validationtool.jar}" failonerror="false" fork="yes" dir="${build.dir}">
<java jar="${lib.dir}/${validationtool.jar}" failonerror="yes" fork="yes" dir="${build.dir}">
<arg value="-s"/>
<arg value="scenarios.xml"/>
<!--
<arg value="-r"/><arg value="."/>
-->
<arg value="${test.build.dir}/scenarios.xml"/>

<arg value="-r"/>
<arg value="${build.dir}"/>
<arg value="-h"/>
<arg value="--check-assertions"/>
<arg value="${test.src.dir}/assertions.xml"/>
Expand All @@ -144,22 +175,25 @@
</java>
<echo>Schema validating reports ...</echo>
<schemavalidate fullchecking="yes" failonerror="yes">
<schema namespace="http://www.xoev.de/de/validator/varl/1" file="${reports.schema.dir}/report.xsd"/>
<schema namespace="http://www.xoev.de/de/validator/varl/1"
file="${reports.schema.dir}/report.xsd"/>
<fileset dir="${reports.dir}" includes="*.xml"/>
</schemavalidate>
<echo>Schematron validating reports ...</echo>
<xslt style="${src.dir}/report.sch.xsl" includes="${reports.dir}/*.xml" destdir="${reports.dir}">
<classpath location="${lib.dir}/${saxon.jar}" />
<xslt style="${src.dir}/report.sch.xsl" includes="${reports.dir}/*.xml"
destdir="${reports.dir}">
<classpath location="${lib.dir}/${saxon.jar}"/>
<factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>
</target>
<target name="dist" depends="init, compile" description="Generate the distribution">
<zip destfile="${dist.dir}/xrechnung_1.1_${build.date}.zip" basedir="${build.dir}" excludes="download/**,test"/>
<zip destfile="${dist.dir}/xrechnung_1.1_${build.date}.zip" basedir="${build.dir}"
excludes="download/**,test"/>
</target>
<target name="clean" description="clean up">
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build.dir}" verbose="true" includeEmptyDirs="true"/>
<delete dir="${dist.dir}"/>
<delete dir="${reports.dir}"/>
</target>
</project>
</project>
3 changes: 2 additions & 1 deletion scenarios.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
</createReport>
</scenario>
<scenario>
<name>EN16931 CIUS XRechnung (CII uncoupled)</name>
<name>EN16931 CIUS XRechnung (CII)</name>
<description><p>EN16931 CIUS XRechnung (CII uncoupled)</p></description>
<namespace prefix="rsm">urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100</namespace>
<namespace prefix="ram">urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100</namespace>
<match>/rsm:CrossIndustryInvoice[starts-with(rsm:ExchangedDocumentContext/ram:GuidelineSpecifiedDocumentContextParameter/ram:ID, 'urn:cen.eu:en16931:2017') or starts-with(rsm:ExchangedDocumentContext/ram:GuidelineSpecifiedDocumentContextParameter/ram:ID, 'urn:ce.eu:en16931:2017')]</match>
Expand Down

0 comments on commit b555a12

Please sign in to comment.