org.jmx4odp.junitDiagnosticWorkers
Class JdbcClientTest

java.lang.Object
  extended by TestCase
      extended by org.jmx4odp.junitDiagnosticWorkers.JdbcClientTest
Direct Known Subclasses:
BasicJdbcTest, JdbcClientTestExample

public class JdbcClientTest
extends TestCase

Extend or implement this test class for tests of JDBC services

Author:
Lucas McGregor

Constructor Summary
JdbcClientTest()
          Creates a new instance of HttpClient
 
Method Summary
static void assertJdbcConnected(java.sql.Connection con)
          This will check the connection for metadata.
static void assertJdbcIsCurrent(java.sql.Connection con, java.lang.String sql, int toleranceMs)
          Uses the connection and sql to create a result set.
static void assertJdbcRecordCountIs(java.sql.Connection con, java.lang.String sql, int count)
          Uses the connection and sql to create a result set.
static void assertJdbcRecordCountIs(java.sql.ResultSet rs, int count)
          Checks to see if the number of rows returned from the ResultSet is equal to the count
static void assertJdbcRecordCountIsNoLessThan(java.sql.Connection con, java.lang.String sql, int count)
          Uses the connection and sql to create a result set.
static void assertJdbcRecordCountIsNoLessThan(java.sql.ResultSet rs, int count)
          Checks to see if the number of rows returned from the ResultSet is greater than or equal to the count
static void assertJdbcRecordCountIsNoMoreThan(java.sql.Connection con, java.lang.String sql, int count)
          Uses the connection and sql to create a result set.
static void assertJdbcRecordCountIsNoMoreThan(java.sql.ResultSet rs, int count)
          Checks to see if the number of rows returned from the ResultSet is less than or equal to the count
 java.sql.Connection getConnection(java.lang.String resourceBundle)
          The same as calling getConnectionHashtable(getConnectionParameters(resourceBundle))
 java.sql.Connection getConnection(java.lang.String driverName, java.lang.String url, java.lang.String username, java.lang.String password)
           
 java.sql.Connection getConnectionHashtable(java.util.HashMap connectionParamters)
          Uses a hashmap with the keyed strings of: driverName, url, username, and password to create a JDBC connection
 java.util.HashMap getConnectionParameters(java.lang.String resourceBundle)
          Get the connection paramters from a resourceBundle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbcClientTest

public JdbcClientTest()
Creates a new instance of HttpClient

Method Detail

getConnectionParameters

public java.util.HashMap getConnectionParameters(java.lang.String resourceBundle)
                                          throws java.lang.Exception
Get the connection paramters from a resourceBundle. It should have the following keys: driverName, url, username, and password.

Throws:
java.lang.Exception

getConnection

public java.sql.Connection getConnection(java.lang.String resourceBundle)
                                  throws java.lang.Exception
The same as calling getConnectionHashtable(getConnectionParameters(resourceBundle))

Throws:
java.lang.Exception

getConnectionHashtable

public java.sql.Connection getConnectionHashtable(java.util.HashMap connectionParamters)
                                           throws java.lang.Exception
Uses a hashmap with the keyed strings of: driverName, url, username, and password to create a JDBC connection

Throws:
java.lang.Exception

getConnection

public java.sql.Connection getConnection(java.lang.String driverName,
                                         java.lang.String url,
                                         java.lang.String username,
                                         java.lang.String password)
                                  throws java.lang.Exception
Throws:
java.lang.Exception

assertJdbcConnected

public static void assertJdbcConnected(java.sql.Connection con)
This will check the connection for metadata. If no exception is throws, then it will return true.


assertJdbcRecordCountIs

public static void assertJdbcRecordCountIs(java.sql.Connection con,
                                           java.lang.String sql,
                                           int count)
Uses the connection and sql to create a result set. Then calls assertJdbcRecordCountIs(ResultSet, int)


assertJdbcRecordCountIsNoLessThan

public static void assertJdbcRecordCountIsNoLessThan(java.sql.Connection con,
                                                     java.lang.String sql,
                                                     int count)
Uses the connection and sql to create a result set. Then calls assertJdbcRecordCountIsNoLessThan(ResultSet, int)


assertJdbcRecordCountIsNoMoreThan

public static void assertJdbcRecordCountIsNoMoreThan(java.sql.Connection con,
                                                     java.lang.String sql,
                                                     int count)
Uses the connection and sql to create a result set. Then calls assertJdbcRecordCountIsNoMoreThan(ResultSet, int)


assertJdbcRecordCountIs

public static void assertJdbcRecordCountIs(java.sql.ResultSet rs,
                                           int count)
Checks to see if the number of rows returned from the ResultSet is equal to the count


assertJdbcRecordCountIsNoMoreThan

public static void assertJdbcRecordCountIsNoMoreThan(java.sql.ResultSet rs,
                                                     int count)
Checks to see if the number of rows returned from the ResultSet is less than or equal to the count


assertJdbcRecordCountIsNoLessThan

public static void assertJdbcRecordCountIsNoLessThan(java.sql.ResultSet rs,
                                                     int count)
Checks to see if the number of rows returned from the ResultSet is greater than or equal to the count


assertJdbcIsCurrent

public static void assertJdbcIsCurrent(java.sql.Connection con,
                                       java.lang.String sql,
                                       int toleranceMs)
Uses the connection and sql to create a result set. If this throws an exeception, it will fail. Else, this will then call assertJdbcIsCurrent(ResultSet rs, int toleranceMs)