org.apache.derbyTesting.functionTests.tests.jdbcapi
Class DriverTest

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.junit.BaseJDBCTestCase
                  extended by org.apache.derbyTesting.functionTests.tests.jdbcapi.DriverTest
All Implemented Interfaces:
junit.framework.Test

public class DriverTest
extends BaseJDBCTestCase

This test tests java.sql.Driver methods. Right now it just tests acceptsURL and some attributes Not tested in this test: - Tests for getPropertyInfo - tests for connection attributes


Field Summary
(package private) static java.lang.String[] ADDITIONAL_DBS
          Set of additional databases for tests that require a one-off database.
private static java.lang.String DB_NAME_WITH_SPACES
           
 
Fields inherited from class org.apache.derbyTesting.junit.BaseTestCase
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
 
Constructor Summary
DriverTest(java.lang.String name)
           
 
Method Summary
private static void assertConnect(boolean expectUrlEqualsGetUrl, java.lang.String url, java.util.Properties info)
          Do java.sql.Driver.connect(String url, Properties info call)
private static void assertTraceFilesExist()
          Check that trace files exist
private static junit.framework.Test baseSuite(java.lang.String name)
           
private static void loadDriver()
          Load the appropriate driver for the current framework
private static void setBaseProps(junit.framework.TestSuite suite, junit.framework.Test test)
           
private static void shutdownDB(java.lang.String url, java.util.Properties info)
          use this method to shutdown databases in an effort to release any locks they may be holding
static junit.framework.Test suite()
           
 void tearDown()
          Tear down this fixture, sub-classes should call super.tearDown().
 void testAcceptsURL()
          Check that drivers accept the correct urls and reject those for other supported drivers.
 void testClientAttributes()
          Tests that client side attributes cann be specified in either url or as info argument to connect.
 void testClientURL()
          Tests client URLs to see connection is successful or the correct exception is thrown.
 void testDbNameWithSpaces()
          Tests URL with spaces in database name to check create and connect works.
 void testDriverCompliantVersion()
          Load the driver and check java.sql.Driver.jdbcCompliant() and driver.get*Version
 void testEmbeddedAttributes()
          Tests that embedded attributes can be specified in either url or info argument to connect DERBY-530.
 
Methods inherited from class org.apache.derbyTesting.junit.BaseJDBCTestCase
assertCallError, assertCheckTable, assertCompileError, assertEquals, assertEquals, assertEquals, assertEquivalentDataType, assertGetIntError, assertNextError, assertPreparedStatementError, assertSQLExceptionEquals, assertSQLState, assertSQLState, assertStatementError, assertStatementError, assertStatementError, assertStatementError, assertTableRowCount, assertUpdateCount, assertUpdateCount, checkAllConsistency, checkEstimatedRowCount, commit, createStatement, createStatement, createStatement, dropTable, dropTable, getConnection, getDatabaseProperty, getLastSQLException, initializeConnection, openConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runScript, runScript, runSQLCommands, setAutoCommit, usingDB2Client, usingDerbyNetClient, usingEmbedded
 
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, 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

DB_NAME_WITH_SPACES

private static java.lang.String DB_NAME_WITH_SPACES

ADDITIONAL_DBS

static final java.lang.String[] ADDITIONAL_DBS
Set of additional databases for tests that require a one-off database. The additional database decorator wraps all the tests and phases. They are only created if a test opens a connection against them. In hard upgrade the test must explictly upgrade the database. The databases are shutdown at the end of each phase.

Constructor Detail

DriverTest

public DriverTest(java.lang.String name)
Method Detail

suite

public static junit.framework.Test suite()

baseSuite

private static junit.framework.Test baseSuite(java.lang.String name)

setBaseProps

private static void setBaseProps(junit.framework.TestSuite suite,
                                 junit.framework.Test test)

tearDown

public void tearDown()
              throws java.lang.Exception
Description copied from class: BaseJDBCTestCase
Tear down this fixture, sub-classes should call super.tearDown(). This cleanups & closes the connection if it is open and any statement objects returned through the utility methods.

Overrides:
tearDown in class BaseJDBCTestCase
Throws:
java.lang.Exception

testDriverCompliantVersion

public void testDriverCompliantVersion()
                                throws java.lang.Exception
Load the driver and check java.sql.Driver.jdbcCompliant() and driver.get*Version

Throws:
java.lang.Exception

testAcceptsURL

public void testAcceptsURL()
                    throws java.sql.SQLException,
                           java.lang.Exception
Check that drivers accept the correct urls and reject those for other supported drivers.

Throws:
SQLException, - Exception
java.sql.SQLException
java.lang.Exception

testEmbeddedAttributes

public void testEmbeddedAttributes()
                            throws java.sql.SQLException
Tests that embedded attributes can be specified in either url or info argument to connect DERBY-530. Only valid for embedded driver and client.

Throws:
java.sql.SQLException

testClientAttributes

public void testClientAttributes()
                          throws java.sql.SQLException
Tests that client side attributes cann be specified in either url or as info argument to connect. DERBY-530.

Throws:
java.sql.SQLException

assertTraceFilesExist

private static void assertTraceFilesExist()
Check that trace files exist


testClientURL

public void testClientURL()
                   throws java.sql.SQLException
Tests client URLs to see connection is successful or the correct exception is thrown.

Throws:
java.sql.SQLException

testDbNameWithSpaces

public void testDbNameWithSpaces()
                          throws java.sql.SQLException
Tests URL with spaces in database name to check create and connect works. (DERBY-618). Make sure that the specified database gets created. We need to check this because even without the patch for DERBY-618, no exception gets thrown when we try to connect to a database name with spaces. Instead, client driver extracts the database name as the string before the first occurence of space separator. Hence the database which gets created is wrong. e.g, if we specified database name as "db name with spaces", the database that got created by client driver was "db", which was wrong. We can check this by checking the correct URL is returned by call to conn.getMetaData().getURL(). This is currently checked inside the testConnect method. We do not explicilty check the database directory creation since this check fails in remote server testing.

Throws:
java.sql.SQLException

assertConnect

private static void assertConnect(boolean expectUrlEqualsGetUrl,
                                  java.lang.String url,
                                  java.util.Properties info)
                           throws java.sql.SQLException
Do java.sql.Driver.connect(String url, Properties info call)

Parameters:
expectUrlEqualsGetUrl - boolean indicating embedded would expect the url passed in to equal metadata.getURL()
url - url to pass to Driver.connect()
info - properties to pass to Driver.Connect()
Throws:
java.sql.SQLException - on error.

shutdownDB

private static void shutdownDB(java.lang.String url,
                               java.util.Properties info)
                        throws java.sql.SQLException
use this method to shutdown databases in an effort to release any locks they may be holding

Throws:
java.sql.SQLException

loadDriver

private static void loadDriver()
Load the appropriate driver for the current framework


Built on Thu 2009-11-26 18:42:53-0800, from revision 884739

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