aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-05-21 20:30:37 +0200
committerAdrian Kummerländer2014-05-21 20:30:37 +0200
commit283101c02a7e6a71f221fe731168e9b0096e3766 (patch)
tree8dfe46ba47aaad2edc66bfef14e45ac5864a7fb0 /test
parent35334241ce4b76b1b1a66219ce938f27fdf39031 (diff)
downloadInputXSLT-283101c02a7e6a71f221fe731168e9b0096e3766.tar
InputXSLT-283101c02a7e6a71f221fe731168e9b0096e3766.tar.gz
InputXSLT-283101c02a7e6a71f221fe731168e9b0096e3766.tar.bz2
InputXSLT-283101c02a7e6a71f221fe731168e9b0096e3766.tar.lz
InputXSLT-283101c02a7e6a71f221fe731168e9b0096e3766.tar.xz
InputXSLT-283101c02a7e6a71f221fe731168e9b0096e3766.tar.zst
InputXSLT-283101c02a7e6a71f221fe731168e9b0096e3766.zip
Added test case base template and improved transformer helper template
* test case base template contains the basic test case markup ** it was mostly created to include include-path resolution into the test cases * improved transformer helper template by separating the external function call into its own variable
Diffstat (limited to 'test')
-rwxr-xr-xtest/check.sh2
-rw-r--r--test/common/testcase.xsl22
-rw-r--r--test/default_params/reference.xml2
-rw-r--r--test/default_params/transformation.xsl25
-rw-r--r--test/read_directory/reference.xml2
-rw-r--r--test/read_directory/transformation.xsl19
-rw-r--r--test/read_file/reference.xml4
-rw-r--r--test/read_file/transformation.xsl15
-rw-r--r--test/read_xml_file/reference.xml2
-rw-r--r--test/read_xml_file/transformation.xsl19
-rw-r--r--test/transform/reference.xml2
-rw-r--r--test/transform/test.xsl2
-rw-r--r--test/transform/transformation.xsl48
13 files changed, 69 insertions, 95 deletions
diff --git a/test/check.sh b/test/check.sh
index fd537d7..84687bf 100755
--- a/test/check.sh
+++ b/test/check.sh
@@ -9,7 +9,7 @@ do
cd $testcase
rm -f actual.xml
- ./../../build/test --transformation transformation.xsl --target actual.xml
+ ./../../build/test --transformation transformation.xsl --target actual.xml --include ../common/
diff -u reference.xml actual.xml
if [ $? = 0 ]
diff --git a/test/common/testcase.xsl b/test/common/testcase.xsl
new file mode 100644
index 0000000..70bfa3a
--- /dev/null
+++ b/test/common/testcase.xsl
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:InputXSLT="function.inputxslt.application"
+ exclude-result-prefixes="InputXSLT"
+>
+
+<xsl:output
+ method="xml"
+ omit-xml-declaration="no"
+ encoding="UTF-8"
+ indent="yes"
+/>
+
+<xsl:template match="/">
+<test_case>
+ <xsl:call-template name="implementation"/>
+</test_case>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/test/default_params/reference.xml b/test/default_params/reference.xml
index fcdbacf..566064b 100644
--- a/test/default_params/reference.xml
+++ b/test/default_params/reference.xml
@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<test_case>
-<default_params>
<target_file>actual.xml</target_file>
<parent_directory>default_params</parent_directory>
-</default_params>
</test_case>
diff --git a/test/default_params/transformation.xsl b/test/default_params/transformation.xsl
index 1bbddef..0ffaea0 100644
--- a/test/default_params/transformation.xsl
+++ b/test/default_params/transformation.xsl
@@ -6,27 +6,18 @@
exclude-result-prefixes="InputXSLT"
>
-<xsl:output
- method="xml"
- omit-xml-declaration="no"
- encoding="UTF-8"
- indent="yes"
-/>
+<xsl:include href="[testcase.xsl]"/>
<xsl:param name="target-file"/>
<xsl:param name="parent-directory"/>
-<xsl:template match="/">
-<test_case>
- <default_params>
- <target_file>
- <xsl:value-of select="$target-file"/>
- </target_file>
- <parent_directory>
- <xsl:value-of select="$parent-directory"/>
- </parent_directory>
- </default_params>
-</test_case>
+<xsl:template name="implementation">
+ <target_file>
+ <xsl:value-of select="$target-file"/>
+ </target_file>
+ <parent_directory>
+ <xsl:value-of select="$parent-directory"/>
+ </parent_directory>
</xsl:template>
</xsl:stylesheet>
diff --git a/test/read_directory/reference.xml b/test/read_directory/reference.xml
index 8252569..a7192ea 100644
--- a/test/read_directory/reference.xml
+++ b/test/read_directory/reference.xml
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<test_case>
-<function_read_directory>
<item>common</item>
<item>default_params</item>
<item>read_directory</item>
<item>read_file</item>
<item>read_xml_file</item>
<item>transform</item>
-</function_read_directory>
</test_case>
diff --git a/test/read_directory/transformation.xsl b/test/read_directory/transformation.xsl
index d3c21f1..3a4d162 100644
--- a/test/read_directory/transformation.xsl
+++ b/test/read_directory/transformation.xsl
@@ -6,21 +6,12 @@
exclude-result-prefixes="InputXSLT"
>
-<xsl:output
- method="xml"
- omit-xml-declaration="no"
- encoding="UTF-8"
- indent="yes"
-/>
+<xsl:include href="[testcase.xsl]"/>
-<xsl:template match="/">
-<test_case>
- <function_read_directory>
- <xsl:for-each select="InputXSLT:read-directory('../')[@type='directory']">
- <item><xsl:value-of select="."/></item>
- </xsl:for-each>
- </function_read_directory>
-</test_case>
+<xsl:template name="implementation">
+ <xsl:for-each select="InputXSLT:read-directory('../')[@type='directory']">
+ <item><xsl:value-of select="."/></item>
+ </xsl:for-each>
</xsl:template>
</xsl:stylesheet>
diff --git a/test/read_file/reference.xml b/test/read_file/reference.xml
index 7cbcc95..0bca6f7 100644
--- a/test/read_file/reference.xml
+++ b/test/read_file/reference.xml
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
-<test_case>
-<function_read_file>&lt;?xml version="1.0"?&gt;
+<test_case>&lt;?xml version="1.0"?&gt;
&lt;tester&gt;
&lt;eintrag&gt;Hello 1&lt;/eintrag&gt;
&lt;eintrag&gt;Hello 2&lt;/eintrag&gt;
&lt;eintrag&gt;Hello 3&lt;/eintrag&gt;
&lt;eintrag&gt;Hello 4&lt;/eintrag&gt;
&lt;/tester&gt;
-</function_read_file>
</test_case>
diff --git a/test/read_file/transformation.xsl b/test/read_file/transformation.xsl
index 96b8976..e17734e 100644
--- a/test/read_file/transformation.xsl
+++ b/test/read_file/transformation.xsl
@@ -6,19 +6,10 @@
exclude-result-prefixes="InputXSLT"
>
-<xsl:output
- method="xml"
- omit-xml-declaration="no"
- encoding="UTF-8"
- indent="yes"
-/>
+<xsl:include href="[testcase.xsl]"/>
-<xsl:template match="/">
-<test_case>
- <function_read_file>
- <xsl:value-of select="InputXSLT:read-file('../common/test.txt')"/>
- </function_read_file>
-</test_case>
+<xsl:template name="implementation">
+ <xsl:value-of select="InputXSLT:read-file('../common/test.txt')"/>
</xsl:template>
</xsl:stylesheet>
diff --git a/test/read_xml_file/reference.xml b/test/read_xml_file/reference.xml
index d82dc9c..26b5f82 100644
--- a/test/read_xml_file/reference.xml
+++ b/test/read_xml_file/reference.xml
@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<test_case>
-<function_read_xml_file>
<item>Hello 1</item>
<item>Hello 2</item>
<item>Hello 3</item>
<item>Hello 4</item>
-</function_read_xml_file>
</test_case>
diff --git a/test/read_xml_file/transformation.xsl b/test/read_xml_file/transformation.xsl
index ba6fed1..e0a3794 100644
--- a/test/read_xml_file/transformation.xsl
+++ b/test/read_xml_file/transformation.xsl
@@ -6,21 +6,12 @@
exclude-result-prefixes="InputXSLT"
>
-<xsl:output
- method="xml"
- omit-xml-declaration="no"
- encoding="UTF-8"
- indent="yes"
-/>
+<xsl:include href="[testcase.xsl]"/>
-<xsl:template match="/">
-<test_case>
- <function_read_xml_file>
- <xsl:for-each select="InputXSLT:read-xml-file('../common/test.txt')/tester/eintrag">
- <item><xsl:value-of select="."/></item>
- </xsl:for-each>
- </function_read_xml_file>
-</test_case>
+<xsl:template name="implementation">
+ <xsl:for-each select="InputXSLT:read-xml-file('../common/test.txt')/tester/eintrag">
+ <item><xsl:value-of select="."/></item>
+ </xsl:for-each>
</xsl:template>
</xsl:stylesheet>
diff --git a/test/transform/reference.xml b/test/transform/reference.xml
index b98f978..5d45081 100644
--- a/test/transform/reference.xml
+++ b/test/transform/reference.xml
@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<test_case>
-<transform>
<transform_test>
<parameter_value>42</parameter_value>
</transform_test>
-</transform>
</test_case>
diff --git a/test/transform/test.xsl b/test/transform/test.xsl
index 9a1ea7a..7d4cac0 100644
--- a/test/transform/test.xsl
+++ b/test/transform/test.xsl
@@ -4,7 +4,7 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:InputXSLT="function.inputxslt.application"
- exclude-result-prefixes="InputXSLT xalan"
+ exclude-result-prefixes="xalan InputXSLT"
>
<xsl:output
diff --git a/test/transform/transformation.xsl b/test/transform/transformation.xsl
index 24f4df7..fc41eb3 100644
--- a/test/transform/transformation.xsl
+++ b/test/transform/transformation.xsl
@@ -2,44 +2,42 @@
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:dyn="http://exslt.org/dynamic"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:InputXSLT="function.inputxslt.application"
- exclude-result-prefixes="InputXSLT xalan"
+ exclude-result-prefixes="dyn xalan InputXSLT"
>
-<xsl:output
- method="xml"
- omit-xml-declaration="no"
- encoding="UTF-8"
- indent="yes"
-/>
+<xsl:include href="[testcase.xsl]"/>
<xsl:template name="transformer">
<xsl:param name="transformation"/>
<xsl:param name="target"/>
<xsl:param name="parameters"/>
- <xsl:variable name="result" select="
- InputXSLT:transform($transformation, $target, xalan:nodeset($parameters))
- "/>
+ <xsl:variable name="command">
+ InputXSLT:transform(
+ $transformation,
+ $target,
+ xalan:nodeset($parameters)
+ )
+ </xsl:variable>
+
+ <xsl:variable name="result" select="dyn:evaluate($command)"/>
</xsl:template>
-<xsl:template match="/">
-<test_case>
- <transform>
- <xsl:call-template name="transformer">
- <xsl:with-param name="transformation">test.xsl</xsl:with-param>
- <xsl:with-param name="target">test_actual.xml</xsl:with-param>
- <xsl:with-param name="parameters">
- <test>21</test>
- </xsl:with-param>
- </xsl:call-template>
+<xsl:template name="implementation">
+ <xsl:call-template name="transformer">
+ <xsl:with-param name="transformation">test.xsl</xsl:with-param>
+ <xsl:with-param name="target">test_actual.xml</xsl:with-param>
+ <xsl:with-param name="parameters">
+ <test>21</test>
+ </xsl:with-param>
+ </xsl:call-template>
- <xsl:copy-of select="
- InputXSLT:read-xml-file('test_actual.xml')/test_case/transform_test
- "/>
- </transform>
-</test_case>
+ <xsl:copy-of select="
+ InputXSLT:read-xml-file('test_actual.xml')/test_case/transform_test
+ "/>
</xsl:template>
</xsl:stylesheet>