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

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

public class SURQueryMixTest
extends SURBaseTest

Tests for Scrollable Updatable ResultSet (SUR). This TestCase tests scrolling (navigation), updates (using updateXXX() and updateRow() or positioned updates), deletion of records (using deleteRow() or positioned deletes) of ResultSets.


Field Summary
private  boolean checkRowDeleted
           
private  boolean checkRowUpdated
           
private  java.lang.String cursorName
           
private  boolean positioned
           
private static java.lang.String[] projectConditions
           
private  java.lang.String query
           
private static java.lang.String[] selectConditions
           
 
Fields inherited from class org.apache.derbyTesting.functionTests.tests.jdbcapi.SURBaseTest
CURSOR_NOT_POSITIONED_ON_INSERT_ROW, CURSOR_NOT_UPDATABLE_SQL_STATE, CURSOR_OPERATION_CONFLICT, FOR_UPDATE_NOT_PERMITTED_SQL_STATE, INVALID_CURSOR_STATE_NO_CURRENT_ROW, LOCK_TIMEOUT_EXPRESSION_SQL_STATE, LOCK_TIMEOUT_SQL_STATE, QUERY_NOT_QUALIFIED_FOR_UPDATABLE_RESULTSET, recordCount, RESULTSET_NOT_UPDATABLE_SQL_STATE
 
Fields inherited from class org.apache.derbyTesting.junit.BaseTestCase
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
 
Constructor Summary
SURQueryMixTest(java.lang.String model, java.lang.String query, java.lang.String cursorName, boolean positioned)
          Constructor
 
Method Summary
private static junit.framework.Test baseSuite(java.lang.String name)
          The suite contains all testcases in this class running on different data models
private  java.util.List createRandomSample(java.util.Map rows, int k)
          Create a random sample of rows
private  java.util.Map createRowMap(java.sql.ResultSet rs)
          Creates a Map of the values in the ResultSet.
private static junit.framework.TestSuite createTestCases(java.lang.String modelName)
           
private  void deleteRandomSampleOfNRecords(java.sql.ResultSet rs, java.util.Map rows, java.util.Set deletedRows, int k)
          Delete a random sample of n records in the resultset
private  java.lang.String getRowString(java.sql.ResultSet rs)
          Get a concatenation of the values of the current Row in the ResultSet
 void runTest()
          Test SUR properties of the query
static junit.framework.Test suite()
          Run in client and embedded.
private  void testNavigation(java.sql.ResultSet rs, java.util.Map rows, java.util.Set updatedRows, java.util.Set deletedRows)
          Tests navigation in ResultSet.
private  void updatePositioned(java.sql.ResultSet rs, java.sql.ResultSetMetaData meta)
          Updates the current row in the ResultSet using updateRow()
private  void updateRandomSampleOfNRecords(java.sql.ResultSet rs, java.util.Map rows, java.util.Set updatedRows, int k)
          Update a random sample of n records in the resultset
private  void updateRow(java.sql.ResultSet rs, java.sql.ResultSetMetaData meta)
          Updates the current row in the ResultSet using updateRow()
 
Methods inherited from class org.apache.derbyTesting.functionTests.tests.jdbcapi.SURBaseTest
assertFailOnUpdate, assertWarning, initializeConnection, scrollBackward, scrollBackwardAndUpdate, scrollBackwardAndUpdatePositioned, scrollForward, scrollForwardAndUpdate, scrollForwardAndUpdatePositioned, updateTuple, updateTuplePositioned, verifyTuple
 
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, openConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runScript, runScript, runSQLCommands, setAutoCommit, tearDown, 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, 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

query

private final java.lang.String query

cursorName

private final java.lang.String cursorName

positioned

private final boolean positioned

checkRowUpdated

private boolean checkRowUpdated

checkRowDeleted

private boolean checkRowDeleted

selectConditions

private static final java.lang.String[] selectConditions

projectConditions

private static final java.lang.String[] projectConditions
Constructor Detail

SURQueryMixTest

public SURQueryMixTest(java.lang.String model,
                       java.lang.String query,
                       java.lang.String cursorName,
                       boolean positioned)
Constructor

Parameters:
model - name of data model for this TestCase
query - to use for producing the resultset
cursorName - name of cursor
positioned - flag to determine if the Test should use positioned updates/deletes instead of updateRow() and deleteRow()
Method Detail

runTest

public void runTest()
             throws java.sql.SQLException
Test SUR properties of the query

Overrides:
runTest in class junit.framework.TestCase
Throws:
java.sql.SQLException

createRowMap

private java.util.Map createRowMap(java.sql.ResultSet rs)
                            throws java.sql.SQLException
Creates a Map of the values in the ResultSet. The key object in the map, is the postion in the ResultSet (Integer 1..n), while the value is a concatenation of the strings for all columns in the row.

Throws:
java.sql.SQLException

createRandomSample

private java.util.List createRandomSample(java.util.Map rows,
                                          int k)
Create a random sample of rows

Parameters:
rows - Map to create sample from
k - number of rows in the sample
Returns:
a list containing k elements of rows

deleteRandomSampleOfNRecords

private void deleteRandomSampleOfNRecords(java.sql.ResultSet rs,
                                          java.util.Map rows,
                                          java.util.Set deletedRows,
                                          int k)
                                   throws java.sql.SQLException
Delete a random sample of n records in the resultset

Parameters:
rs - result set to be updated
rows - map of rows, will also be updated
deletedRows - set of rows being deleted (position in RS)
k - number of records to be deleted
Throws:
java.sql.SQLException

updateRandomSampleOfNRecords

private void updateRandomSampleOfNRecords(java.sql.ResultSet rs,
                                          java.util.Map rows,
                                          java.util.Set updatedRows,
                                          int k)
                                   throws java.sql.SQLException
Update a random sample of n records in the resultset

Parameters:
rs - result set to be updated
rows - map of rows, will also be updated
updatedRows - set of being updated (position in RS)
k - number of records to be updated
Throws:
java.sql.SQLException

updateRow

private void updateRow(java.sql.ResultSet rs,
                       java.sql.ResultSetMetaData meta)
                throws java.sql.SQLException
Updates the current row in the ResultSet using updateRow()

Parameters:
rs - ResultSet to be updated
meta - meta for the ResultSet
Throws:
java.sql.SQLException

updatePositioned

private void updatePositioned(java.sql.ResultSet rs,
                              java.sql.ResultSetMetaData meta)
                       throws java.sql.SQLException
Updates the current row in the ResultSet using updateRow()

Parameters:
rs - ResultSet to be updated
meta - meta for the ResultSet
Throws:
java.sql.SQLException

testNavigation

private void testNavigation(java.sql.ResultSet rs,
                            java.util.Map rows,
                            java.util.Set updatedRows,
                            java.util.Set deletedRows)
                     throws java.sql.SQLException
Tests navigation in ResultSet.

Parameters:
rs - ResultSet to test navigation of. Needs to be scrollable
rows - a sample of the rows which are in the ResultSet. Maps position to a concatenation of the string values
updatedRows - a integer set of which rows that have been updated. Used to test rowUpdated()
deletedRows - a integer set of which rows that have been deleted. Used to test rowDeleted()
Throws:
java.sql.SQLException

getRowString

private java.lang.String getRowString(java.sql.ResultSet rs)
                               throws java.sql.SQLException
Get a concatenation of the values of the current Row in the ResultSet

Throws:
java.sql.SQLException

createTestCases

private static junit.framework.TestSuite createTestCases(java.lang.String modelName)

suite

public static junit.framework.Test suite()
Run in client and embedded.


baseSuite

private static junit.framework.Test baseSuite(java.lang.String name)
The suite contains all testcases in this class running on different data models


Built on Sat 2009-11-28 18:44:18-0800, from revision 885187

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