org.apache.derbyTesting.functionTests.tests.jdbc4
Class VerifySignatures

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.derbyTesting.junit.BaseTestCase
              extended by org.apache.derbyTesting.functionTests.tests.jdbc4.VerifySignatures
All Implemented Interfaces:
junit.framework.Test

public class VerifySignatures
extends BaseTestCase

JUnit test which checks that all methods specified by the interfaces in JDBC 4.0 are implemented. The test requires JVM 1.6 to run. Even though this class uses JDBC it extends BaseTestCase as it handles getting connections itself and thus does not need the utility methods or connecion handlng provided by BaseJDBCTestCase.


Nested Class Summary
private static class VerifySignatures.ClassInfo
          Data structure holding a Derby implementation class and the JDBC interface it is supposed to implement.
 
Field Summary
private static java.lang.Class[] JDBC_INTERFACES
          All the java.sql and javax.sql interfaces specified by JDBC 4.0.
 
Fields inherited from class org.apache.derbyTesting.junit.BaseTestCase
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
 
Constructor Summary
VerifySignatures(java.lang.String name)
          Creates a new instance.
 
Method Summary
private static void addClass(java.util.Set<VerifySignatures.ClassInfo> classes, java.lang.Class implementation, java.lang.Class iface)
          Adds a ClassInfo object to a set.
private static void checkImplementationMethod(java.lang.Class derbyImplementation, java.lang.reflect.Method ifaceMethod)
          checks that a class implements a specific method.
private static void collectClassesFromCallableStatement(java.sql.Connection conn, java.util.Set<VerifySignatures.ClassInfo> classes)
          Perform JDBC operations on a CallableStatement.
private static void collectClassesFromConnection(java.sql.Connection conn, java.util.Set<VerifySignatures.ClassInfo> classes)
          Perform JDBC operations on a Connection.
private static void collectClassesFromConnectionPoolDataSource(java.util.Set<VerifySignatures.ClassInfo> classes)
          Obtain a connection from a ConnectionPoolDataSource object and perform JDBC operations on it.
private static void collectClassesFromDataSource(java.util.Set<VerifySignatures.ClassInfo> classes)
          Obtain a connection from a DataSource object and perform JDBC operations on it.
private static void collectClassesFromPreparedStatement(java.sql.Connection conn, java.util.Set<VerifySignatures.ClassInfo> classes)
          Perform JDBC operations on a PreparedStatement.
private static void collectClassesFromStatement(java.sql.Connection conn, java.util.Set<VerifySignatures.ClassInfo> classes)
          Perform JDBC operations on a Statement.
private static void collectClassesFromXADataSource(java.util.Set<VerifySignatures.ClassInfo> classes)
          Obtain a connection from an XADataSource object and perform JDBC operations on it.
private static java.lang.Class findCompatibleClass(java.lang.Class exception, java.lang.Class[] declared)
          Search an array of classes for a class that is identical to or a super-class of the specified exception class.
private static java.util.Set<java.lang.Class> getAllInterfaces(java.lang.Class iface)
          Get the set consisting of an interface and all its super-interfaces.
private static java.util.Set<java.lang.Class> getInterfacesToCheck()
          Returns the declared set of JDBC interfaces that Derby implements.
static junit.framework.Test suite()
          Build a suite of tests to be run.
 void testAllJDBCObjects()
           
 
Methods inherited from class org.apache.derbyTesting.junit.BaseTestCase
alarm, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertSecurityManager, assertThrowableEquals, execJavaCmd, fail, getFailureFolder, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeSystemProperty, runBare, setSystemProperty, traceit
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

JDBC_INTERFACES

private static final java.lang.Class[] JDBC_INTERFACES
All the java.sql and javax.sql interfaces specified by JDBC 4.0.

Constructor Detail

VerifySignatures

public VerifySignatures(java.lang.String name)
Creates a new instance.

Method Detail

suite

public static junit.framework.Test suite()
Build a suite of tests to be run.

Returns:
a test suite

testAllJDBCObjects

public void testAllJDBCObjects()
                        throws java.lang.NoSuchMethodException,
                               java.sql.SQLException
Throws:
java.lang.NoSuchMethodException
java.sql.SQLException

collectClassesFromDataSource

private static void collectClassesFromDataSource(java.util.Set<VerifySignatures.ClassInfo> classes)
                                          throws java.sql.SQLException
Obtain a connection from a DataSource object and perform JDBC operations on it. Collect the classes of all JDBC objects that are found.

Parameters:
classes - set into which classes are collected
Throws:
java.sql.SQLException - if a database error occurs

collectClassesFromConnectionPoolDataSource

private static void collectClassesFromConnectionPoolDataSource(java.util.Set<VerifySignatures.ClassInfo> classes)
                                                        throws java.sql.SQLException
Obtain a connection from a ConnectionPoolDataSource object and perform JDBC operations on it. Collect the classes of all JDBC objects that are found.

Parameters:
classes - set into which classes are collected
Throws:
java.sql.SQLException - if a database error occurs

collectClassesFromXADataSource

private static void collectClassesFromXADataSource(java.util.Set<VerifySignatures.ClassInfo> classes)
                                            throws java.sql.SQLException
Obtain a connection from an XADataSource object and perform JDBC operations on it. Collect the classes of all JDBC objects that are found.

Parameters:
classes - set into which classes are collected
Throws:
java.sql.SQLException - if a database error occurs

collectClassesFromConnection

private static void collectClassesFromConnection(java.sql.Connection conn,
                                                 java.util.Set<VerifySignatures.ClassInfo> classes)
                                          throws java.sql.SQLException
Perform JDBC operations on a Connection. Collect the classes of all JDBC objects that are found.

Parameters:
conn - connection to a database
classes - set into which classes are collected
Throws:
java.sql.SQLException - if a database error occurs

collectClassesFromStatement

private static void collectClassesFromStatement(java.sql.Connection conn,
                                                java.util.Set<VerifySignatures.ClassInfo> classes)
                                         throws java.sql.SQLException
Perform JDBC operations on a Statement. Collect the classes of all JDBC objects that are found.

Parameters:
conn - connection to a database
classes - set into which classes are collected
Throws:
java.sql.SQLException - if a database error occurs

collectClassesFromPreparedStatement

private static void collectClassesFromPreparedStatement(java.sql.Connection conn,
                                                        java.util.Set<VerifySignatures.ClassInfo> classes)
                                                 throws java.sql.SQLException
Perform JDBC operations on a PreparedStatement. Collect the classes of all JDBC objects that are found.

Parameters:
conn - connection to a database
classes - set into which classes are collected
Throws:
java.sql.SQLException - if a database error occurs

collectClassesFromCallableStatement

private static void collectClassesFromCallableStatement(java.sql.Connection conn,
                                                        java.util.Set<VerifySignatures.ClassInfo> classes)
                                                 throws java.sql.SQLException
Perform JDBC operations on a CallableStatement. Collect the classes of all JDBC objects that are found.

Parameters:
conn - connection to a database
classes - set into which classes are collected
Throws:
java.sql.SQLException - if a database error occurs

addClass

private static void addClass(java.util.Set<VerifySignatures.ClassInfo> classes,
                             java.lang.Class implementation,
                             java.lang.Class iface)
Adds a ClassInfo object to a set.

Parameters:
classes - set to which the class should be added
implementation - Derby implementation class
iface - JDBC interface supposed to be implemented

getAllInterfaces

private static java.util.Set<java.lang.Class> getAllInterfaces(java.lang.Class iface)
Get the set consisting of an interface and all its super-interfaces.

Parameters:
iface - an interface
Returns:
the set consisting of iface and all its super-interfaces

checkImplementationMethod

private static void checkImplementationMethod(java.lang.Class derbyImplementation,
                                              java.lang.reflect.Method ifaceMethod)
                                       throws java.lang.NoSuchMethodException
checks that a class implements a specific method.

Parameters:
derbyImplementation - The Derby implementation class which is tested
ifaceMethod - The method that should be implemented.
Throws:
java.lang.NoSuchMethodException

findCompatibleClass

private static java.lang.Class findCompatibleClass(java.lang.Class exception,
                                                   java.lang.Class[] declared)
Search an array of classes for a class that is identical to or a super-class of the specified exception class.

Parameters:
exception - an exception class
declared - an array of exception classes declared to be thrown by a method
Returns:
a class that is compatible with the specified exception class, or null if no compatible class is found

getInterfacesToCheck

private static java.util.Set<java.lang.Class> getInterfacesToCheck()
Returns the declared set of JDBC interfaces that Derby implements.


Built on Sat 2009-11-28 18:44:18-0800, from revision 885187

Apache Derby V10.6 Internals - Copyright © 2004,2008 The Apache Software Foundation. All Rights Reserved.