SUT Sourceforge Project Page. Here you can download the SUT distribution and report bugs, request enhancements and so on.
You will also need:
SUT incorporates the Schematron reference implementation developed by Rick Jelliffe of the Academia Sinica Computing Centre.
W3C Schema can quickly become complex and difficult to determine if they are validating the correct vocabulary. The addition of embedded Schematron schema only makes this problem worse. Schema Unit Test (SUT) introduces a framework for testing XML Schema.
This framework has two parts.
The first is a namespace and vocabulary for embedding test cases into sample XML documents, designed to highlight what is legal and what is not legal in the vocabulary defined in the schema under test. This aspect is independent of what schema language is used and can in theory be applied to any schema language with automatic validation tools.
The second part is a Java implementation using JUnit for testing a W3C Schema with embedded Schematron schema. This implementation reads SUT test suite descriptions written in XML with embedded test cases as described above and then creates a JUnit test suite that can be executed inside JUnit in the usual way.
A SUT Test Suite is a well-formed XML file containing an example of a file to
be validated. Test cases are identified by additional elements in the SUT
namespace, http://www.powerware.com/nz/XMLSchemaUnitTest
. The case
element identifies test cases created by adding or removing elements. The attribute
element identifies test cases created by adding, removing or changing attributes.
Detailed descriptions of these elements are available:
case
attribute
ref
Examples from the W3C Schema
Primer:
Reinforced examples based on the W3C Schema Primer, but with an embedded Schematron:
Example of how test cases are generated from a test.xml file:
To invoke SUT, use java
(version 1.4 or later) to invoke nz.co.invensysenergy.proj.schemaUnitTest.SchemaUnitTest
with the jar files for SUT, JUnit and Xalan-J all in the classpath. The
DOS batch file sut.bat
is included in the download which
illustrates this.
The command line options for SUT are:
Option | Description |
-help | Displays the available command line options. |
-ut | Use the JUnit text user interface. The default is to use the JUnit Swing GUI. |
-v | Be verbose. This option is usually used with logging enabled, and causes SUT to log the XML that was under test for each test case that fails. |
-l | Log to console. This logs each test as it runs and also the reason for validation failing. It is important to verify that each test case that is expected to fail validation fails for the correct reason, so to ensure meaningful results logging should be enabled during test development. |
-lf logfile | Log to logfile. This option logs to a file instead of to the console. |
-p | Preserve temporary test case files if the test fails (default is to delete). This allows the viewing of the files that are validated as part of each test. |
-pa | Preserve all temporary test case files, not just the failing tests. |
-s schemafile | Specifies the schema file under test. If it is not specified, SUT attempts to locate the schema file in the directory where the tests are located, or in its parent directory by finding a file with an xsd extension. |
As of version 1.6, SUT must be run with the JDK/JRE 1.4. Running under earlier JDK/JRE will no longer work.
To build SUT, a Java 1.4 SDK and Apache Ant are used. Install the required
libraries into the Ant lib directory, unzip source.zip
, then invoke
the jar
target to build the SUT jar file. The test
target is the default which executes the tests under the examples
directory. Javadocs are built with the javadoc
target.
SUTV is an XML validator that will validate an XML file against a W3C schema
with an embedded Schematron schema. It is the same validator that is used in the
SUT unit tests. It is invoked in the same way as SUT, but the main class is nz.co.invensysenergy.proj.schemaUnitTest.ErrorDetector
.
The sutv.bat
DOS batch file provides an example of how to invoke
SUTV.
* XML Schema Unit Test * http://sut.sourceforge.net/ * * $Id: index.html,v 1.8 2005/01/26 01:42:08 gavink Exp $ * * Eaton Power Quality Ltd * Christchurch, New Zealand * http://www.powerware.com * Contact: Gavin Kingsley <gavin.kingsley@powerware.com> * Seb Unger <sebastian.unger@powerware.com> * * Copyright (c) 2003 - 2005 Eaton Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of Eaton Corporation nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL INVENSYS ENERGY SYSTEMS (NZ) LTD OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * http://www.opensource.org/licenses/bsd-license.html