public class ClosedObjectTest extends BaseJDBCTestCase
ResultSet
,
Statement
, PreparedStatement
,
CallableStatement
and Connection
objects
throw the appropriate exceptions when the objects are closed.Modifier and Type | Class and Description |
---|---|
private static class |
ClosedObjectTest.CallableStatementObjectDecorator
Decorator class for testing methods on a closed callable statement.
|
private static class |
ClosedObjectTest.ConnectionObjectDecorator
Decorator class for testing methods on a closed connection.
|
private static class |
ClosedObjectTest.DataSourceDecorator
Decorator class used for obtaining connections through a
DataSource . |
private static class |
ClosedObjectTest.ObjectDecorator
Abstract decorator class with functionality for obtaining a
closed object.
|
private static class |
ClosedObjectTest.PoolDataSourceDecorator
Decorator class used for obtaining connections through a
ConnectionPoolDataSource . |
private static class |
ClosedObjectTest.PreparedStatementObjectDecorator
Decorator class for testing methods on a closed prepared statement.
|
private static class |
ClosedObjectTest.ResultSetObjectDecorator
Decorator class for testing methods on a closed result set.
|
private static class |
ClosedObjectTest.StatementObjectDecorator
Decorator class for testing methods on a closed statement.
|
private static class |
ClosedObjectTest.XADataSourceDecorator
Decorator class used for obtaining connections through an
XADataSource . |
Modifier and Type | Field and Description |
---|---|
private ClosedObjectTest.ObjectDecorator |
decorator_
Test decorator which provides a closed object to invoke a
method on.
|
private java.lang.reflect.Method |
method_
The method to test.
|
private java.lang.String |
name_
Name of the test.
|
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
ClosedObjectTest(java.lang.reflect.Method method,
ClosedObjectTest.ObjectDecorator decorator)
Creates a new
ClosedObjectTest instance. |
Modifier and Type | Method and Description |
---|---|
private static junit.framework.Test |
baseSuite(boolean network)
Creates the test suite and fills it with tests using
DataSource , ConnectionPoolDataSource
and XADataSource to obtain objects. |
private static void |
fillDataSourceSuite(BaseTestSuite suite,
ClosedObjectTest.DataSourceDecorator dsDecorator)
Fills a test suite which is contained in a
DataSourceDecorator with tests for
ResultSet , Statement ,
PreparedStatement , CallableStatement
and Connection . |
private static void |
fillObjectSuite(BaseTestSuite suite,
ClosedObjectTest.ObjectDecorator decorator,
java.lang.Class iface)
Fills a suite with tests for all the methods of an interface.
|
java.lang.String |
getName()
Gets the name of the test.
|
private static java.lang.Object[] |
getNullArguments(java.lang.Class[] params)
Takes an array of classes and returns an array of objects with
null values compatible with the classes.
|
private static java.lang.Object |
getNullValueForType(java.lang.Class type)
Returns a null value compatible with the class.
|
private boolean |
isImplemented()
Check if the JDBC interface method tested by this test case is
actually implemented by the Derby object being tested.
|
private static junit.framework.Test |
poolSuite(java.util.Map dsProps)
Creates a suite that tests objects produced by a
ConnectionPoolDataSource.
|
static junit.framework.Test |
suite()
Creates a suite with all tests in the class.
|
void |
testClosedObjects()
Runs a test case.
|
assertCallError, assertCheckTable, assertCommitError, assertCompileError, assertEquals, assertEquals, assertEquals, assertEquivalentDataType, assertErrorCode, assertGetIntError, assertNextError, assertPreparedStatementError, assertResults, assertResults, assertSQLExceptionEquals, assertSQLState, assertSQLState, assertStatementError, assertStatementError, assertStatementError, assertStatementError, assertStatementErrorUnordered, assertTableRowCount, assertUpdateCount, assertUpdateCount, assertWarning, chattyPrepare, chattyPrepareCall, checkAllConsistency, checkEstimatedRowCount, closeStatement, commit, createStatement, createStatement, createStatement, dropTable, dropTable, dropView, dropView, dumpRs, dumpRs, emptyStatementCache, executeQuery, expectCompilationError, expectCompilationError, expectExecutionError, getClientTransactionID, getConnection, getDatabaseProperty, getLastSQLException, goodStatement, goodUpdate, initializeConnection, openConnection, openDefaultConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runBare, runBareOverridable, runScript, runScript, runSQLCommands, setAutoCommit, tearDown, usingDB2Client, usingDerbyNetClient, usingEmbedded
alarm, assertDirectoryDeleted, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertLaunchedJUnitTestMethod, assertLaunchedJUnitTestMethod, assertSameNullness, assertSecurityManager, assertThrowableEquals, currentDirectory, execJavaCmd, execJavaCmd, execJavaCmd, fail, getClassVersionMajor, getEmmaJar, getFailureFolder, getFilesWith, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, hasInterruptibleIO, isCVM, isIBMJVM, isJ9Platform, isJava5, isJava7, isPhoneME, isPlatform, isSunJVM, isWindowsPlatform, newAssertionFailedError, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeFiles, removeSystemProperty, runsWithEmma, runsWithJaCoCo, setSystemErr, setSystemOut, setSystemProperty, sleep, sleepAtLeastOneTick, traceit, vmAtLeast
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, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, run, run, runTest, setName, setUp, toString
private final java.lang.reflect.Method method_
private final ClosedObjectTest.ObjectDecorator decorator_
private java.lang.String name_
public ClosedObjectTest(java.lang.reflect.Method method, ClosedObjectTest.ObjectDecorator decorator)
ClosedObjectTest
instance.method
- the method to testdecorator
- a decorator which provides a closed objectpublic java.lang.String getName()
getName
in class junit.framework.TestCase
public void testClosedObjects() throws java.lang.Throwable
java.lang.Throwable
- if an error occursprivate boolean isImplemented() throws java.lang.NoSuchMethodException
java.lang.NoSuchMethodException
public static junit.framework.Test suite()
private static junit.framework.Test baseSuite(boolean network)
DataSource
, ConnectionPoolDataSource
and XADataSource
to obtain objects.network
- whether or not to run tests with the network clientTest
valuejava.lang.Exception
- if an error occurs while building the test suiteprivate static junit.framework.Test poolSuite(java.util.Map dsProps)
dsProps
- properties to set on the data sourceprivate static void fillDataSourceSuite(BaseTestSuite suite, ClosedObjectTest.DataSourceDecorator dsDecorator)
DataSourceDecorator
with tests for
ResultSet
, Statement
,
PreparedStatement
, CallableStatement
and Connection
.suite
- the test suite to filldsDecorator
- the decorator for the test suiteprivate static void fillObjectSuite(BaseTestSuite suite, ClosedObjectTest.ObjectDecorator decorator, java.lang.Class iface)
suite
- the suite to filldecorator
- a decorator for the test (used for obtaining a
closed object to test the method on)iface
- the interface which contains the methods to testprivate static java.lang.Object[] getNullArguments(java.lang.Class[] params)
params
- a Class[]
valueObject[]
valueprivate static java.lang.Object getNullValueForType(java.lang.Class type)
Boolean.FALSE
for primitive booleans, 0 for
primitive integers and null
for non-primitive
types.type
- a Class
valueApache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.