alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

HSQLDB example source code file (testutility.xml)

This example HSQLDB source code file (testutility.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - HSQLDB tags/keywords

all, date, it, it, select, select, sql, sql, testself, the, the, to, used, utility

The HSQLDB testutility.xml source code

<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: testutility.xml,v 1.11 2004/12/24 23:40:59 fredt Exp $ -->
<appendix>
  <title>Hsqldb Test Utility

  <appendixinfo>
    <edition>$Revision: 1.11 $

    <pubdate>$Date: 2004/12/24 23:40:59 $

    <keywordset>
      <keyword>Hsqldb

      <keyword>Test

      <keyword>Utility
    </keywordset>
  </appendixinfo>

  <para>The org.hsqldb.test package contains a number of
  tests for various functions of the database engine. Among these, the
  <classname>TestSelf class performs the tests that are based on
  scripts. To run the tests, you should compile the
  <filename>hsqldbtest.jar target with Ant.

  <para>For TestSelf, 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:</para>

  <screen>
    runtest TestSelf</screen>

  <para>In Unix / Linux, type:

  <screen>
    ./runTest.sh TestSelf</screen>

  <para>The new version of TestSelf 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.</para>

  <para>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.</para>

  <itemizedlist>
    <listitem>
      <para>Comment lines must start with -- and are ignored
    </listitem>

    <listitem>
      <para>Lines starting with spaces are the continuation of the previous
      line</para>
    </listitem>

    <listitem>
      <para>SQL statements with no prefix are simply executed.
    </listitem>

    <listitem>
      <para>
        <emphasis>The remaining items in this list exemplify use of the
        available command line-prefixes.</emphasis>
      </para>
    </listitem>

    <listitem>
      <informalexample>
        <simpara>The /*s*/ option stands for silent. It is used for executing
        quries regardless of results. Used for preparation of tests, not for
        actual tests.</simpara>

        <programlisting>
/*s*/ Any SQL statement - errors are ignored</programlisting>
      </informalexample>
    </listitem>

    <listitem>
      <informalexample>
        <simpara>The /*c<rows>*/ option is for SELECT queries and
        asserts the number of rows in the result matches the given
        count.</simpara>

        <programlisting>
/*c<rows>*/ SQL statement returning count of <rows></programlisting>
      </informalexample>
    </listitem>

    <listitem>
      <informalexample>
        <simpara>The /*u*/ option is for queries that return an update count,
        such as DELETE and UPDATE. It asserts the update count
        matches.</simpara>

        <programlisting>
/*u<count>*/ SQL statement returning an update count equal to <count></programlisting>
      </informalexample>
    </listitem>

    <listitem>
      <informalexample>
        <simpara>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.</simpara>

        <programlisting>
/*e*/ SQL statement that should produce an error when executing</programlisting>
      </informalexample>
    </listitem>

    <listitem>
      <informalexample>
        <simpara>The /*r....*/ option asserts the SELECT query returns a
        single row containing the given set of field values.</simpara>

        <programlisting>
/*r<string1>,<string2>*/ SQL statement returning a single row ResultSet equal to the specified value</programlisting>
      </informalexample>
    </listitem>

    <listitem>
      <informalexample>
        <simpara>The extended /*r...*/ option asserts the SELECT query returns
        the given rows containing the given set of field values.</simpara>

        <programlisting>
/*r
    <string1>,<string2>
    <string1>,<string2>
    <string1>,<string2>
*/ SQL statement returning a multiple row ResultSet equal to the specified values</programlisting>
      </informalexample>

      <simpara>(note that the result set lines are indented).
    </listitem>

    <listitem>
      <para>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. </para>
    </listitem>
  </itemizedlist>

  <para>See the TestSelf*.txt files in the /testrun/hsqldb/ directory for
  actual examples.</para>
</appendix>

Other HSQLDB examples (source code examples)

Here is a short list of links related to this HSQLDB testutility.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.