|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.apache.derbyTesting.junit.BaseTestCase
org.apache.derbyTesting.junit.BaseJDBCTestCase
org.apache.derbyTesting.functionTests.tests.jdbcapi.AutoGenJDBC30Test
public class AutoGenJDBC30Test
Tests the JDBC 3.0 ability to establish a result set of auto-generated keys.
Converts the old jdbcapi/autoGeneratedJdbc30.java test to JUnit. The old harness test number is preserved in the comment for each fixture.
| Field Summary | |
|---|---|
private static java.lang.String[] |
ROUTINES
Routines that should be created before the tests are run. |
private static java.lang.String[][] |
TABLES
Tables that should be created before the tests are run. |
| Fields inherited from class org.apache.derbyTesting.junit.BaseTestCase |
|---|
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE |
| Constructor Summary | |
|---|---|
AutoGenJDBC30Test(java.lang.String name)
Creates a new AutoGenJDBC30Test instance. |
|
| Method Summary | |
|---|---|
static int |
addMe(int p1)
External code for the AddMe SQL function, which is called by the testInsertAutoGenExecuteSQLfunc fixture. |
private static junit.framework.Test |
baseSuite(java.lang.String name)
Tests are only run if JDBC 3.0 available, and database objects get created only once for the suite run. |
int |
getKeyValue(java.sql.ResultSet r)
Gets the key value from the result set. |
static java.lang.String |
MyMethodWithNoInsert()
External code for the MMWNI() SQL function, which is called by the testInsertNoAutoGenExecuteSQLfunc fixture. |
void |
runInsertFourWaysKeyIsNull(java.lang.String sql)
Runs the same SQL INSERT statement four ways: Statement.execute, Statement.executeUpdate, PreparedStatement.execute, and PreparedStatement.executeUpdate, and expects the resulting key value to be NULL. |
void |
setUp()
Sets up the connection for a test case, clears all tables and resets all auto-generated keys used by the test fixtures. |
static junit.framework.Test |
suite()
Implements suite() to run in embedded and client configurations. |
void |
testColumnIndexes()
Test that use of columnIndexes to indicate which keys should be made available works as expected. |
void |
testColumnNames()
Test that use of columnNames to indicate which keys should be made available works as expected. |
void |
testDelete()
Requests generated keys for an DELETE statement. |
void |
testDeleteAutoGenNoGenKeysJDBC20syntax()
Deletes rows from a table with an auto-generated column in the JDBC 2.0 way (with no generated key feature), then fetches key. |
void |
testGetKeyAfterCommit()
Does a one-row insert into a table with a generated column, commits, then requests generated keys for an insert into a table without a generated column. |
void |
testGetKeyAfterRollback()
Does a one-row insert into a table with a generated column, next does a rollback, then requests generated keys for an insert into a table without a generated column. |
void |
testGetKeyAfterSavepointRollback()
Inserts one row into a table with an auto-generated column while inside a savepoint unit, does a rollback, then gets keys after an insert into a table without an auto-generated column. |
void |
testGetKeyMetadataAfterInsert()
Inserts one row into a table with an auto-generated column, then examines the metadata for the generatedKeys ResultSet. |
void |
testInsertAutoGenExecuteSQLfunc()
Inserts a row into a table with a SQL function in the VALUES clause; the table has an auto-generated column. |
void |
testInsertJDBC20syntax()
Inserts one row into a table with an auto-generated column, but in the JDBC 2.0 way (with no generated key feature). |
void |
testInsertManyRowsAfterOneRowKey()
Requests generated keys for a multi-row insert statement after a one-row insert into a table with an auto-generated key. |
void |
testInsertManyRowsNoPriorKey()
Requests generated keys for a multi-row insert statement. |
void |
testInsertNoAutoGen()
Requests generated keys after doing an insert into a table that doesn't have a generated column (and there hasn't been a one row insert into a table with auto-generated keys yet). |
void |
testInsertNoAutoGenExecuteSQLfunc()
Inserts a row into a table with a SQL function in the VALUES clause; the table does not have an auto-generated column. |
void |
testInsertNoGenColAfterOneRowKey()
After a one-row insert into a table with an auto-generated key, next inserts into a table that does not have an auto-generated key, then requests generated keys. |
void |
testInsertNoGenKeys()
Inserts one row into a table with an auto-generated column, but with NO_GENERATED_KEYS. |
void |
testInsertOneRowKey()
Requests generated keys after doing a one-row insert into a table that has an auto-generated column. |
void |
testInsertSubqueryNoWhereClause()
Requests generated keys after doing a one-row insert into a table that has a generated column, but the insert is via a subquery with no where clause. |
void |
testInsertSubqueryWhere1is2()
Requests generated keys after doing a one-row insert into a table that has a generated column, but the insert is via a subquery with a "where 1=2" clause. |
void |
testInsertSubqueryWhereClause()
Requests generated keys after doing a one-row insert into a table that has a generated column, but the insert is via a subquery with a "where c21=23" clause. |
void |
testNoSql()
Requests generated keys for a new statement that hasn't executed any SQL yet. |
void |
testResultSetGarbageCollection()
Verifies fix for an old issue in which the ResultSet returned by getGenerateKeys was incorrectly tied to the activation of the PreparedStatement; so, when the ResultSet was garbage collected, the activation was closed, resulting in an "Activation closed, operation execute not permitted" exception on subsequent executes (warning: this fixture takes a noticeable time to run). |
void |
testSelect()
Requests generated keys for a Select statement (non-insert). |
void |
testUpdate()
Requests generated keys for an UPDATE statement. |
void |
testUpdateAutoGenNoGenKeys()
Updates a row in a table with an auto-generated column and NO_GENERATED_KEYS, then fetches key. |
private void |
testUserGivenColumns(int[] colIndexes,
java.lang.String[] colNames,
int expectedVal)
Verify that if user specifies *valid* column indexes or column names to indicate which keys should be made available, Derby will return the correct results. |
void |
testUserGivenColumnsEmpty()
Verify that if user specifies an empty array for columNames or columnIndexes, it is the same as NO_GENERATED_KEYS |
private void |
testUserGivenColumnsError(int[] colIndexes,
java.lang.String[] colNames)
Verify that if user specifies *INvalid* column indexes or column names to indicate which keys should be made available, Derby will throw an appropriate error. |
void |
testUserGivenColumnsNull()
Verify that if a user specifies a *NULL* column index or column name array to indicate which keys should be made available, Derby will effectively disable autogenerated keys (i.e. same as if user passed NO_GENERATED_KEYS). |
void |
verifyNullKey(java.lang.String description,
java.sql.ResultSet r)
Verifies that the generated key in a result set is null. |
| 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, 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 |
|---|
private static final java.lang.String[] ROUTINES
private static final java.lang.String[][] TABLES
| Constructor Detail |
|---|
public AutoGenJDBC30Test(java.lang.String name)
name - name of the test| Method Detail |
|---|
public static junit.framework.Test suite()
private static junit.framework.Test baseSuite(java.lang.String name)
name - name of the test
public void setUp()
throws java.sql.SQLException
setUp in class junit.framework.TestCasejava.sql.SQLException
public void testNoSql()
throws java.sql.SQLException
java.sql.SQLException
public void testSelect()
throws java.sql.SQLException
java.sql.SQLException
public void testInsertManyRowsNoPriorKey()
throws java.sql.SQLException
java.sql.SQLException
public void testInsertManyRowsAfterOneRowKey()
throws java.sql.SQLException
java.sql.SQLException
public void testInsertNoAutoGen()
throws java.sql.SQLException
java.sql.SQLException
public void testInsertSubqueryNoWhereClause()
throws java.sql.SQLException
java.sql.SQLException
public void testInsertSubqueryWhere1is2()
throws java.sql.SQLException
java.sql.SQLException
public void testInsertSubqueryWhereClause()
throws java.sql.SQLException
java.sql.SQLException
public void testInsertOneRowKey()
throws java.sql.SQLException
java.sql.SQLException
public void testInsertNoGenColAfterOneRowKey()
throws java.sql.SQLException
java.sql.SQLException
public void testUpdate()
throws java.sql.SQLException
java.sql.SQLException
public void testDelete()
throws java.sql.SQLException
java.sql.SQLException
public void testGetKeyAfterCommit()
throws java.sql.SQLException
java.sql.SQLException
public void testGetKeyAfterRollback()
throws java.sql.SQLException
java.sql.SQLException
public void testGetKeyAfterSavepointRollback()
throws java.sql.SQLException
java.sql.SQLException
public void testGetKeyMetadataAfterInsert()
throws java.sql.SQLException
java.sql.SQLException
public void testInsertNoGenKeys()
throws java.sql.SQLException
java.sql.SQLException
public void testInsertJDBC20syntax()
throws java.sql.SQLException
java.sql.SQLException
public void testUpdateAutoGenNoGenKeys()
throws java.sql.SQLException
java.sql.SQLException
public void testDeleteAutoGenNoGenKeysJDBC20syntax()
throws java.sql.SQLException
java.sql.SQLException
public void testInsertNoAutoGenExecuteSQLfunc()
throws java.sql.SQLException
java.sql.SQLException
public void testInsertAutoGenExecuteSQLfunc()
throws java.sql.SQLException
java.sql.SQLException
public void testResultSetGarbageCollection()
throws java.sql.SQLException
java.sql.SQLException
public void testColumnIndexes()
throws java.sql.SQLException
java.sql.SQLException
public void testColumnNames()
throws java.sql.SQLException
java.sql.SQLException
public void testUserGivenColumnsEmpty()
throws java.sql.SQLException
java.sql.SQLException
public void testUserGivenColumnsNull()
throws java.sql.SQLException
java.sql.SQLException
private void testUserGivenColumns(int[] colIndexes,
java.lang.String[] colNames,
int expectedVal)
throws java.sql.SQLException
colIndexes - Array of column indexes indicating which keys
should be made available. Must be null if colNames is non-null.colNames - Array of column names indicating which keys should
be made available. Must be null if colIndexes is non-null.expectedVal - First expected autogenerated key; will be
incremented for each successful INSERT statement.
java.sql.SQLException
private void testUserGivenColumnsError(int[] colIndexes,
java.lang.String[] colNames)
throws java.sql.SQLException
colIndexes - Array of column indexes indicating which keys
should be made available. Must be null if colNames is non-null.colNames - Array of column names indicating which keys should
be made available. Must be null if colIndexes is non-null.
java.sql.SQLException
public void runInsertFourWaysKeyIsNull(java.lang.String sql)
throws java.sql.SQLException
sql - The SQL statement to be executed
java.sql.SQLException - if a database error occurs
public void verifyNullKey(java.lang.String description,
java.sql.ResultSet r)
throws java.sql.SQLException
description - Text to be output for the assertionr - ResultSet
java.sql.SQLException - if a database error occurs
public int getKeyValue(java.sql.ResultSet r)
throws java.sql.SQLException
r - ResultSet
java.sql.SQLException - if a database error occurs
public static java.lang.String MyMethodWithNoInsert()
throws java.sql.SQLException
java.sql.SQLException - if a database error occurs
public static int addMe(int p1)
throws java.sql.SQLException
p1 - integer input argument to be used in calculation
java.sql.SQLException - if a database error occurs
|
Built on Wed 2009-11-25 18:43:31-0800, from revision 884373 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||