net.sourceforge.sqlunit |
Classes for the SQLUnit core package. The SQLUnit package is designed as a set of individual XML handlers for the various elements of the SQLUnit test suite authoring XML. There is a one to one correspondence between the SQLUnit element and the SQLUnit handler class as illustrated in the table below:
XML Element |
SQLUnit Handler Class |
sqlunit
- connection
- setup
- test
- prepare
- sql or call
- result
- teardown
|
- net.sourceforge.sqlunit.ConnectionHandler
- net.sourceforge.sqlunit.SetupHandler
- net.sourceforge.sqlunit.SqlHandler
- net.sourceforge.sqlunit.IncludeHandler
- net.sourceforge.sqlunit.TestHandler
- net.sourceforge.sqlunit.PrepareHandler
- net.sourceforge.sqlunit.SqlHandler|CallHandler
- net.sourceforge.sqlunit.ResultHandler
- net.sourceforge.sqlunit.TeardownHandler
- net.sourceforge.sqlunit.SqlHandler
- net.sourceforge.sqlunit.IncludeHandler
|
Each handler class reads the JDOM element and extracts the information to pass back to the SQLUnit class. The SQLUnit class is designed as a JUnit test class. The JUnit class contains a single test method called testWrapper() which is responsible for reading the XML file and carrying out the operations specified in the setup element, followed by each test in sequence, followed by the operations in the teardown element. The ConnectionHandler class is called before all the other operations to get a JDBC connection to the database.
All handler classes implement the IHandler interface, which specifies a single process method which takes a JDOM Element org.jdom.Element and a java.sql.Connection object and returns a java.lang.Object. A given handler implementation may not need to return an Object, in which case it must return null. The HandlerFactory uses the handlers.properties Java properties file to instantiate the appropriate instance of a handler given the JDOM Element name.
Apart from the handlers, there are some auxilliary classes that provide utilities to the handlers. The SymbolTable class is a container of variables that are declared within an SQLUnit test script. The DatabaseResult object is a HashMap of fields and values returned from processing a SQL statement or stored procedure, or parsed out of a SQLUnit result element. The key for this HashMap is a DatabaseResultKey which is really a tuple of (resultsetId, rowId, colId) for each column returned by a SQL statement or stored procedure specified by the SQLUnit sql or call elements and parsed out of the SQLUnit result element. The SqlTypeUtils class is responsible for converting between database type to String and back, depending on the method called.
The SQLUnitException class is a common class that is shared by the SQLUnit package. The content of the SQLUnitException error messages is handled by specifying constant Strings in the IErrorCodes interface class.
|
Java Source File Name | Type | Comment |
Assertions.java | Class | Provides methods to assert various conditions for doing SQLUnit tests. |
ConnectionFactory.java | Class | A factory to generate Connection objects given the Connection properties. |
ConnectionRegistry.java | Class | A Singelton object which stores database Connection objects in a HashMap
and returns them to the application on demand. |
HandlerFactory.java | Class | The HandlerFactory object returns references to Handlers. |
IErrorCodes.java | Interface | This interface lists the generic error codes that are raised by SQLUnit. |
IHandler.java | Interface | The IHandler interface represents a SQLUnit tag handler. |
IMatcher.java | Interface | The IMatcher interface specifies the contract that all Matcher objects
must fulfil. |
IReporter.java | Interface | The reporter interface that all reporters must implement. |
IType.java | Interface | Interface to be implemented by all SQLUnit datatypes. |
MatchPattern.java | Class | MatchPattern fills a role in SQLUnit similar to Regular Expressions in
text pattern matching. |
ReporterFactory.java | Class | The ReporterFactory returns references to Reporters. |
SQLUnit.java | Class | The SQLUnit class is actually a JUnit test case and is the main program
which is called by the SQLUnit user. |
SQLUnitDriverManager.java | Class | The SQLUnitDriverManager is an incomplete implementation the
java.sql.DriverManager class. |
SQLUnitEntityResolver.java | Class | The SQLUnit Entity Resolver sets the DTD for the SQLUnit test file from
within the SQLUnit JAR file. |
SQLUnitException.java | Class | SQLUnitException is an application specific Exception class. |
SQLUnitResult.java | Class | SQLUnitResult is a simple container which contains the cumulative
results of a SQLUnit test run. |
SymbolTable.java | Class | Models a HashMap as a symbol table to store temporary variables and their
values that are needed for a SQLUnit test case. |
ThreadHandlerAdapter.java | Class | The ThreadHandlerAdapter class allows the running of a Handler class
within a Thread. |
ThreadIdentifier.java | Class | Assigns and returns an identifier for a thread. |
TypeFactory.java | Class | Factory for generating concrete implementations of IType. |
TypeMapper.java | Class | Reads in the type resource files and provides methods to look up type
class names using various keys. |