public class StatementEventsTest extends BaseJDBCTestCase
| Modifier and Type | Class and Description |
|---|---|
private static class |
StatementEventsTest.Suite
Test suite class which contains all test cases in
StatementEventsTest for a given configuration. |
| Modifier and Type | Field and Description |
|---|---|
private boolean |
callable
Type of statement to use.
|
private int |
closedCount
Number of times statementClosed events have been raised.
|
private java.sql.Statement |
closedStatement
The statement that caused the last statementClosed event.
|
private java.sql.Connection |
connection
The connection object to use in the test.
|
private int |
errorCount
Number of times statementError events have been raised.
|
private java.sql.Statement |
errorStatement
The statement that caused the last statementError event.
|
private javax.sql.PooledConnection |
pooledConnection
The pooled connection to use in the test (could also be an XA
connection).
|
private boolean |
xa
Type of data source to use.
|
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE| Constructor and Description |
|---|
StatementEventsTest(java.lang.String name)
Create a test with the given name.
|
| Modifier and Type | Method and Description |
|---|---|
private static junit.framework.Test |
baseSuite(java.lang.String name)
Return suite with all tests of the class for all combinations of
pooled/xa connection and prepared/callable statement.
|
java.lang.String |
getName()
Return the name of the test.
|
private java.sql.PreparedStatement |
prepare(java.lang.String sql)
Prepare a statement.
|
private void |
setCallable(boolean callable)
Set whether the test should use
CallableStatement or
PreparedStatement. |
void |
setUp()
Set up the connection to the database and register a statement event
listener.
|
private void |
setXA(boolean xa)
Set whether the test should use
XADataSource or
ConnectionPoolDataSource. |
static junit.framework.Test |
suite()
Create a test suite with all tests in the class.
|
protected void |
tearDown()
Free resources used in the test.
|
void |
testAddListenerFromListener()
Test that adding a listener from a listener works.
|
void |
testAddNullEvent()
Test that you don't get a NullPointerException when the listeners are
triggered and one of them is null.
|
void |
testCloseEvent()
Test that a close event is raised when a statement is closed.
|
void |
testCloseEventOnClosedConnection()
Test whether a close event is raised when a connection is
closed.
|
void |
testErrorEventOnClosedConnection()
Test that an error event is raised when
execute() fails
because the connection is closed. |
void |
testRemoveListenerFromListener()
Test that removing a listener from a listener works.
|
void |
testRemoveNullEvent()
Test that you can call
removeStatementEventListener() with a
null argument. |
assertCallError, assertCheckTable, assertCompileError, assertEquals, assertEquals, assertEquals, assertEquivalentDataType, assertErrorCode, assertGetIntError, assertNextError, assertPreparedStatementError, assertSQLExceptionEquals, assertSQLState, assertSQLState, assertStatementError, assertStatementError, assertStatementError, assertStatementError, assertStatementErrorUnordered, assertTableRowCount, assertUpdateCount, assertUpdateCount, assertWarning, checkAllConsistency, checkEstimatedRowCount, closeStatement, commit, createStatement, createStatement, createStatement, dropTable, dropTable, dropView, dropView, emptyStatementCache, getClientTransactionID, getConnection, getDatabaseProperty, getLastSQLException, initializeConnection, openConnection, openDefaultConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runBare, runBareOverridable, runScript, runScript, runSQLCommands, setAutoCommit, usingDB2Client, usingDerbyNetClient, usingEmbeddedalarm, assertDirectoryDeleted, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertLaunchedJUnitTestMethod, assertLaunchedJUnitTestMethod, assertSecurityManager, assertThrowableEquals, currentDirectory, execJavaCmd, execJavaCmd, fail, getClassVersionMajor, getEmmaJar, getFailureFolder, getFilesWith, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, hasInterruptibleIO, isCVM, isIBMJVM, isJ9Platform, isJava5, isJava7, isJava8, isPhoneME, isPlatform, isSunJVM, isWindowsPlatform, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeFiles, removeSystemProperty, runsWithEmma, runsWithJaCoCo, setSystemProperty, sleep, sleepAtLeastOneTick, traceitassertEquals, 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, toStringprivate boolean xa
true, use
XADataSource; otherwise, use
ConnectionPoolDataSource.private boolean callable
true, use
CallableStatement; otherwise, use
PreparedStatement.private java.sql.Statement closedStatement
private int closedCount
private java.sql.Statement errorStatement
private int errorCount
private javax.sql.PooledConnection pooledConnection
private java.sql.Connection connection
public StatementEventsTest(java.lang.String name)
name - name of the test.private void setXA(boolean xa)
XADataSource or
ConnectionPoolDataSource.xa - if true, use XAprivate void setCallable(boolean callable)
CallableStatement or
PreparedStatement.callable - if true, use callable statement; otherwise,
use prepared statementpublic java.lang.String getName()
getName in class junit.framework.TestCasepublic void setUp()
throws java.sql.SQLException
setUp in class junit.framework.TestCasejava.sql.SQLException - if a database error occursprotected void tearDown()
throws java.lang.Exception
tearDown in class BaseJDBCTestCasejava.lang.Exception - if an error occursprivate static junit.framework.Test baseSuite(java.lang.String name)
name - name of the test suitepublic static junit.framework.Test suite()
private java.sql.PreparedStatement prepare(java.lang.String sql)
throws java.sql.SQLException
sql - SQL textPreparedStatement or
CallableStatement objectjava.sql.SQLException - if a database error occurspublic void testCloseEvent()
throws java.sql.SQLException
java.sql.SQLException - if a database error occurspublic void testAddNullEvent()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testRemoveNullEvent()
throws java.sql.SQLException
removeStatementEventListener() with a
null argument.java.sql.SQLExceptionpublic void testCloseEventOnClosedConnection()
throws java.sql.SQLException
close() on its statements. Embedded should not raise a
close event since the connection does not call close() on
its statements.)java.sql.SQLException - if a database error occurspublic void testErrorEventOnClosedConnection()
throws java.sql.SQLException
execute() fails
because the connection is closed.java.sql.SQLException - if a database error occurspublic void testRemoveListenerFromListener()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void testAddListenerFromListener()
throws java.sql.SQLException
java.sql.SQLExceptionApache Derby V10.10 Internals - Copyright © 2004,2014 The Apache Software Foundation. All Rights Reserved.