<html><head><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Appendix E. Hsqldb Test Utility</title><link href="guide.css" rel="stylesheet" type="text/css"><meta content="DocBook XSL Stylesheets V1.65.1" name="generator"><meta name="keywords" content="Hsqldb, Test, Utility"><meta name="keywords" content="Hsqldb, Hypersonic, Database, JDBC, Java"><link rel="home" href="index.html" title="Hsqldb User Guide"><link rel="up" href="index.html" title="Hsqldb User Guide"><link rel="previous" href="apd.html" title="Appendix D. Running Hsqldb with OpenOffice.org 1.1.x"><link rel="next" href="apf.html" title="Appendix F. Database Manager"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table summary="Navigation header" width="100%"><tr><th align="center" colspan="3">Appendix E. Hsqldb Test Utility</th></tr><tr><td align="left" width="20%"><a accesskey="p" href="apd.html"><img src="navicons/prev.gif" alt="Prev"></a> </td><th align="center" width="60%"> </th><td align="right" width="20%"> <a accesskey="n" href="apf.html"><img src="navicons/next.gif" alt="Next"></a></td></tr></table><hr></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="N12BDE"></a>Appendix E. Hsqldb Test Utility</h2></div><div><p class="pubdate">$Date: 2005/05/27 12:41:50 $</p></div></div><div></div></div><p>The <tt class="literal">org.hsqldb.test</tt> package contains a number of tests for various functions of the database engine. Among these, the <tt class="classname">TestSelf</tt> class performs the tests that are based on scripts. To run the tests, you should compile the <tt class="filename">hsqldbtest.jar</tt> target with Ant.</p><p>For <tt class="classname">TestSelf</tt>, a batch file is provided in the testrun/hsqldb directory, together with a set of TestSelf*.txt files. To start the application in Windows, change to the directory and type:</p><pre class="screen"> runtest TestSelf</pre><p>In Unix / Linux, type:</p><pre class="screen"> ./runTest.sh TestSelf</pre><p>The new version of <tt class="classname">TestSelf</tt> runs multiple SQL test files to test different SQL operations of the database. All files in the working directory with names matching TestSelf*.txt are processed in alphabetical order.</p><p>You can add your own scripts to test different series of SQL queries. The format of the TestSelf*.txt file is simple text, with some indentation and prefixes in the form of Java-style comments. The prefixes indicate what the expected result should be.</p><div class="itemizedlist"><ul type="disc"><li><p>Comment lines must start with -- and are ignored</p></li><li><p>Lines starting with spaces are the continuation of the previous line</p></li><li><p>SQL statements with no prefix are simply executed.</p></li><li><p> <span class="emphasis"><em>The remaining items in this list exemplify use of the available command line-prefixes.</em></span> </p></li><li><div class="informalexample"><p>The /*s*/ option stands for silent. It is used for executing quries regardless of results. Used for preparation of tests, not for actual tests.</p><pre class="programlisting"> /*s*/ Any SQL statement - errors are ignored</pre></div></li><li><div class="informalexample"><p>The /*c<rows>*/ option is for SELECT queries and asserts the number of rows in the result matches the given count.</p><pre class="programlisting"> /*c<rows>*/ SQL statement returning count of <rows></pre></div></li><li><div class="informalexample"><p>The /*u*/ option is for queries that return an update count, such as DELETE and UPDATE. It asserts the update count matches.</p><pre class="programlisting"> /*u<count>*/ SQL statement returning an update count equal to <count></pre></div></li><li><div class="informalexample"><p>The /*e*/ option asserts that the given query results in an erros. It is mainly used for testing the error detection capabilities of the engine. It can also be used with syntactically valid queries to assert a certain state in the database. For example a CREATE TABLE can be used to assert the table of the same name already exists.</p><pre class="programlisting"> /*e*/ SQL statement that should produce an error when executing</pre></div></li><li><div class="informalexample"><p>The /*r....*/ option asserts the SELECT query returns a single row containing the given set of field values.</p><pre class="programlisting"> /*r<string1>,<string2>*/ SQL statement returning a single row ResultSet equal to the specified value</pre></div></li><li><div class="informalexample"><p>The extended /*r...*/ option asserts the SELECT query returns the given rows containing the given set of field values.</p><pre class="programlisting"> /*r <string1>,<string2> <string1>,<string2> <string1>,<string2> */ SQL statement returning a multiple row ResultSet equal to the specified values</pre></div><p>(note that the result set lines are indented).</p></li><li><p>All the options are lowercase letters. During development, an uppercase can be used for a given test to exclude a test from the test run. The utility will just report the test blocks that have been excluded without running them. Once the code has been developed, the option can be turned into lowercase to perform the actual test. </p></li></ul></div><p>See the TestSelf*.txt files in the /testrun/hsqldb/ directory for actual examples.</p></div><div class="navfooter"><hr><table summary="Navigation footer" width="100%"><tr><td align="left" width="40%"><a accesskey="p" href="apd.html"><img src="navicons/prev.gif" alt="Prev"></a> </td><td align="center" width="20%"><a accesskey="u" href="index.html"><img src="navicons/up.gif" alt="Up"></a></td><td align="right" width="40%"> <a accesskey="n" href="apf.html"><img src="navicons/next.gif" alt="Next"></a></td></tr><tr><td valign="top" align="left" width="40%">Appendix D. Running Hsqldb with OpenOffice.org 1.1.x </td><td align="center" width="20%"><a accesskey="h" href="index.html"><img src="navicons/home.gif" alt="Home"></a></td><td valign="top" align="right" width="40%"> Appendix F. Database Manager</td></tr></table></div></body></html>