In this chapter we learn how parts of a Wolframe application can be verified to work correctly. The basis for testing and debugging a Wolframe application is the command line tool wolfilter.
The command line program wolfilter allows you to call any Wolframe function or filter or mapping into a form structure on command line. The program is mapping stdin or if specified the contents of a file to stdout.
The option '--config' (or '-c') specifies the configuration to use, the only argument of the wolfilter program specifies the function to call or form to fill. If a dash '-' is specified as command then no command is called. The input is just mapped through the filters specified. In case of a form or filter mapping, no configuration has to be specified.
The following examples assume the input file name to be in.xml or in.json and the output file to be named out.xml or out.json respectively.
For the examples needing a configuration, we prepare the following simple configuration, just declaring the processing stuff, we need. Of course wolfilter can also work with any wolframe server configuration. The configuration will be referenced as 'test.conf'.
LoadModules { module mod_command_lua module mod_doctype_xml module mod_filter_libxml2 module mod_filter_json module mod_filter_token } Processor { program test.lua program myfilter.xslt program myform.sfrm }
The following example shows the mapping through a libxml2 filter. Filters are tested by passing a dash '-' command to execute. Because we do not need to load programs, we can call wolfilter without a test configuration.
cat in.xml | wolfilter -e libxml2 -m mod_filter_libxml2 - > out.xml
The following example shows the processing of the input through an xslt filter and mapping the output through a token filter that shows the tokenization of the input by the input filter. Because the referenced XSLT filter is defined as source in a program, we have to specify a configuration (test.conf) that declares the programs to load.
cat in.xml | wolfilter -i myfilter -o token -c test.conf - > out.xml
The following example shows the mapping through a form defined with simpleform DDL. Mapping through forms is tested by passing the name of the form as command to execute. Because forms have to be loaded as programs, we have to specify a configuration (test.conf) too.
cat in.xml | wolfilter -e libxml2 -c test.conf MyForm > out.xml
we assume here that the form to use is defined in myform.sfrm that is declared as program in the configuration and that the form is called MyForm.
The following example shows the execution of a function written in Lua. A JSON filter is used for input and output.
cat in.xml | wolfilter -e cjson -c test.conf MyFunc > out.json
we assume here that the exported function to call defined in myfunc.lua declared in test.conf and is called MyFunc.
Copyright © 2014 - Project Wolframe - All Rights Reserved