HiRISE

HiRISE.HiCat.Utilities
Class DBFeatureTest

java.lang.Object
  extended by HiRISE.HiCat.Utilities.DBFeatureTest

public class DBFeatureTest
extends Object

DBFeatureTest is a class for verifying various idiosyncratic behaviors of the MySQL database server and the JDBC. These are typically behaviors that are set by the various SQL mode variables that can be set during start up the server software, or as options set at the time that a JDBC connection is established to the database. Details of the tested behaviors that are described in the documentation of the methods that run each test case. The application creates it's own test database and test table which can be optionally deleted upon completion of the tests.

Version:
1.6
Author:
Rodney Heyd UA/HiRISE

Nested Class Summary
static class DBFeatureTest.DBTestData
          An enumerated set of test data to be used for testing MySQL database server behavior.
static class DBFeatureTest.ExitStatus
          Exit Status Values
 
Field Summary
static String DEFAULT_CONFIGURATION_FILE
          Default configuration file
static String ID
          Class ID
static String TestDatabaseName
          The name of the temporary database to use for testing.
static String TestTableName
          The name of the temporary table to use for testing.
 
Constructor Summary
DBFeatureTest()
          Class to perform the feature tests
DBFeatureTest(String configurationFile)
           
 
Method Summary
 boolean delete()
           
 void delete(boolean delete)
          Sets the delete on completion option.
 void insertGoodValues()
          This is a control test.
 void insertInvalidDate()
          Tests the server behavior when an invalid date is inserted.
 void insertInvalidDateTime()
          Tests the behavior of the database server when an invalid date-time value is inserted into a datetime field.
 void insertInvalidTime()
          Test the behavior of the server when attempting to store an invalid time into a time field.
 void insertLongVarchar()
          This method tests the behavior of the server when a string longer than the defined length of a varchar column type is inserted into the test table.
 void insertZeroDate()
          Tests the behavior of the server when a "zero" date is inserted into a date field eg.
 void insertZeroDateTime()
          Tests the server behavior when a "zero" date-time is inserted into a DATETIME field.
 void insertZeroTime()
          Tests the behavior of the server when a "zero" time is inserted into a time field.
static void main(String[] arguments)
           
 void testDatabase()
          Runs a battery of tests against a mysql database to determine the behavior of the server under certain situations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

public static final String ID
Class ID

See Also:
Constant Field Values

DEFAULT_CONFIGURATION_FILE

public static final String DEFAULT_CONFIGURATION_FILE
Default configuration file

See Also:
Constant Field Values

TestDatabaseName

public static final String TestDatabaseName
The name of the temporary database to use for testing. This database will be deleted upon completion of the tests.

See Also:
Constant Field Values

TestTableName

public static final String TestTableName
The name of the temporary table to use for testing.

See Also:
Constant Field Values
Constructor Detail

DBFeatureTest

public DBFeatureTest()
              throws Configuration_Exception,
                     Database_Exception
Class to perform the feature tests

Throws:
Configuration_Exception
Database_Exception

DBFeatureTest

public DBFeatureTest(String configurationFile)
              throws Configuration_Exception,
                     Database_Exception
Throws:
Configuration_Exception
Database_Exception
Method Detail

insertGoodValues

public void insertGoodValues()
                      throws Database_Exception
This is a control test. The values inserted into the test table by this method are all valid for the data types in the test table, and have appropriate lengths for the table definition. The inserted values are immediately retrieved via a select statement and are verified against the original input values.

Throws:
Database_Exception - if an error occurs while running the test.

insertLongVarchar

public void insertLongVarchar()
                       throws Database_Exception
This method tests the behavior of the server when a string longer than the defined length of a varchar column type is inserted into the test table. Depending on the SQL mode, the server may silently truncate the value or throw an exception.

Throws:
Database_Exception

insertZeroDate

public void insertZeroDate()
                    throws Database_Exception
Tests the behavior of the server when a "zero" date is inserted into a date field eg. (0000-00-00). Depending on the SQL mode, the server may or may not accept such values. A zero date such as this, is an illegal value for JDBC dates. The server can be configure to return a null value in this circumstance as a connection parameter.

Throws:
Database_Exception

insertZeroTime

public void insertZeroTime()
                    throws Database_Exception
Tests the behavior of the server when a "zero" time is inserted into a time field.

Throws:
Database_Exception

insertZeroDateTime

public void insertZeroDateTime()
                        throws Database_Exception
Tests the server behavior when a "zero" date-time is inserted into a DATETIME field. The behavior should be similar to that for a DATE field.

Throws:
Database_Exception
See Also:
#insertZeroDate()}

insertInvalidDate

public void insertInvalidDate()
                       throws Database_Exception
Tests the server behavior when an invalid date is inserted.

Throws:
Database_Exception

insertInvalidTime

public void insertInvalidTime()
                       throws Database_Exception
Test the behavior of the server when attempting to store an invalid time into a time field. This should result in an exception being thrown.

Throws:
Database_Exception

insertInvalidDateTime

public void insertInvalidDateTime()
                           throws Database_Exception
Tests the behavior of the database server when an invalid date-time value is inserted into a datetime field. This should normally result in an exception.

Throws:
Database_Exception

delete

public void delete(boolean delete)
Sets the delete on completion option. If set, the test table and database will be deleted upon completion of the tests.

Parameters:
delete - - a boolean value indicating if the test table and database should be deleted upon completion of the testing.
See Also:
delete()

delete

public boolean delete()
Returns:
the current value of the deletion option. If true, the test table and database will be deleted after completion of the tests. If false, the test table will be left in place.
See Also:
delete(boolean)

testDatabase

public void testDatabase()
                  throws Database_Exception
Runs a battery of tests against a mysql database to determine the behavior of the server under certain situations. A call to this method will result in the creation of a test database and table on the database server. With the various test subsequently run. The specific tests are described in the documentation of the various "insert" methods of this class. If the delete(boolean) flag has been set to true, then the test database and table will be deleted as soon as the tests have been completed.

Throws:
Database_Exception
See Also:
insertGoodValues(), insertLongVarchar(), insertZeroDate(), insertZeroTime(), insertZeroDateTime(), insertInvalidDate(), insertInvalidTime(), insertInvalidDateTime()

main

public static void main(String[] arguments)
Parameters:
args -

HiRISE

Copyright (C) Arizona Board of Regents on behalf of the Planetary Image Research Laboratory, Lunar and Planetary Laboratory at the University of Arizona