public class ConnectionHandlingJunit extends BaseJDBCTestCase
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
ConnectionHandlingJunit(java.lang.String name)
Creates a new instance of this test class
|
Modifier and Type | Method and Description |
---|---|
private void |
driverMgrConnectionInitiator(java.lang.String url,
boolean appendId) |
void |
driverMgrTestConnectionsToNonexistentDb()
This fixture tries a number of times to connect to a non-existent
database, in order to test Derby's ability to handle this situation
without running out of resources (for example Java heap space (memory)).
|
void |
driverMgrTestConnectionsToNonexistentDbInMemory() |
static java.io.Writer |
getLogDiscarder()
Returns a log writer that discards all the data written to it.
|
private void |
loadDriver(java.lang.String url)
Will check if the JDBC driver has been loaded and load it if that is not
the case.
|
static junit.framework.Test |
suite()
Creates a Test Suite to be run by a JUnit TestRunner.
|
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, getName, run, run, runTest, setName, setUp, toString
public ConnectionHandlingJunit(java.lang.String name)
name
- The name of this test instance; may determine which test
fixture to run.public static java.io.Writer getLogDiscarder()
public static junit.framework.Test suite()
public void driverMgrTestConnectionsToNonexistentDb() throws java.sql.SQLException
This fixture tries a number of times to connect to a non-existent database, in order to test Derby's ability to handle this situation without running out of resources (for example Java heap space (memory)). See DERBY-2480 for details.
This test fixture is currently not part of any large JUnit suite because 1) the default number of connection attempts is rather large, and takes some time to complete (depending on hardware), and 2) if the tested Derby version is still vulnerable to DERBY-2480 or similar issues the JVM will most likely run out of memory (depending on heap settings), causing subsequent tests to fail, hang or not run at all.
Note: The JVM may slow down significantly (even appear to hang) before an OOME is thrown. Depending on the avaliable resources, the error may or may not be reported in the logs (derby.log, server console).
This fixture requires java.sql.DriverManager. This is because simple and easy control of the connection handling and database creation is desired (see implementation comments). However, the test logic itself should also work with other connection mechanisms.
java.sql.SQLException
- if an unexpected exception occurs that is not
examined using assertions.public void driverMgrTestConnectionsToNonexistentDbInMemory() throws java.sql.SQLException
java.sql.SQLException
private void driverMgrConnectionInitiator(java.lang.String url, boolean appendId) throws java.sql.SQLException
java.sql.SQLException
private void loadDriver(java.lang.String url) throws java.sql.SQLException
url
- a valid connection URL for the desired JDBC driverjava.sql.SQLException
- if an unexpected exception is thrownApache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.