net.sourceforge.jtds.test
Class ResultSetTest

java.lang.Object
  |
  +--junit.framework.Assert
        |
        +--junit.framework.TestCase
              |
              +--net.sourceforge.jtds.test.TestBase
                    |
                    +--net.sourceforge.jtds.test.DatabaseTestCase
                          |
                          +--net.sourceforge.jtds.test.ResultSetTest
All Implemented Interfaces:
junit.framework.Test

public class ResultSetTest
extends DatabaseTestCase

Version:
1.0

Fields inherited from class net.sourceforge.jtds.test.DatabaseTestCase
typemap
 
Fields inherited from class net.sourceforge.jtds.test.TestBase
con, CONNECTION_PROPERTIES, props
 
Fields inherited from class junit.framework.TestCase
fName
 
Constructor Summary
ResultSetTest(java.lang.String name)
           
 
Method Summary
static void main(java.lang.String[] args)
           
 void testAbsoluteLargeValue()
          Test that calling absolute() with very large positive values positions the cursor after the last row and with very large negative values positions the cursor before the first row.
 void testAbsoluteMinusOne()
          Test that absolute(-1) works the same as last().
 void testCancelResultSet()
          Test for bug [1246270] Closing a statement after canceling it throws an exception.
 void testCursorFallback()
          Test that the cursor fallback logic correctly discriminates between "real" sql errors and cursor open failures.
 void testCursorFetch()
          Test the behavior of sp_cursorfetch with fetch sizes greater than 1.
 void testCursorMaxRows()
          Test that Statement.setMaxRows() works on cursor ResultSets.
 void testCursorPrevious()
          Test that ResultSet.previous() works correctly on cursor ResultSets.
 void testCursorWarning()
          Test for bug [1022445] Cursor downgrade warning not raised.
 void testDeleteRowMarksDeleted()
          Test that deleted rows are not removed but rather marked as deleted.
 void testDistinctBug()
          Test bug with Sybase where readonly scrollable result set based on a SELECT DISTINCT returns duplicate rows.
 void testDynamicCursors()
          Test if dynamic cursors (ResultSet.TYPE_SCROLL_SENSITIVE+1) see others' updates.
 void testEmptyInsertRow()
          Test that insertRow() works with no values set.
 void testGetByName()
          Test whether retrieval by name returns the first occurence (that's what the spec requires).
 void testGetObject1()
          Test BIT data type.
 void testGetObject2()
          Test TINYINT data type.
 void testGetObject3()
          Test SMALLINT data type.
 void testGetObject4()
          Test INT data type.
 void testGetObject5()
          Test BIGINT data type.
 void testInsertRowVisible()
          Test that inserted rows are visible in a scroll sensitive ResultSet and that they show up at the end.
 void testMoreThan255Columns()
          Test if COL_INFO packets are processed correctly for ResultSets with over 255 columns.
 void testOutOfMemory()
          Test the behavior of the ResultSet/Statement/Connection when the JVM runs out of memory (hopefully) in the middle of a packet.
 void testPessimisticConcurrency()
          Test pessimistic concurrency for SQL Server (for Sybase optimistic concurrency will always be used).
 void testRelative()
          Test for bug [1182066] regression bug resultset: relative() not working as expected.
 void testRelativeLargeValue()
          Test that calling absolute() with very large positive values positions the cursor after the last row and with very large negative values positions the cursor before the first row.
 void testResultSetColumnName1()
          Test for bug [1009233] ResultSet getColumnName, getColumnLabel return wrong values
 void testResultSetMetaData()
          Test for fixed bugs in ResultSetMetaData: isNullable() always returns columnNoNulls.
 void testResultSetScroll1()
          Test for bug [961594] ResultSet.
 void testResultSetScroll2()
          Test for bug [945462] getResultSet() return null if you use scrollable/updatable.
 void testResultSetScroll3()
          Test for bug [1028881] statement.execute() causes wrong ResultSet type.
 void testResultSetUpdate1()
          Test for bug [1008208] 0.9-rc1 updateNull doesn't work.
 void testRowstat()
          Test for bug [1329765] Pseudo column ROWSTAT is back with SQL 2005 (September CTP).
 void testSetObjectScale()
          Test for bug [1075977] setObject() causes SQLException.
 void testUnicodeStream()
          Test that read() works ok on the stream returned by ResultSet.getUnicodeStream() (i.e.
 void testUpdateableClientCursor()
          Test for bug [1197603] Cursor downgrade error in CachedResultSet -- updateable result sets were incorrectly downgraded to read only forward only ones when client side cursors were used.
 void testUpdateRowDuplicatesRow()
          Test that updated rows are marked as deleted and the new values inserted at the end of the ResultSet if the primary key is updated.
 void testUpdateRowNoChanges()
          Test for bug [1170777] resultSet.updateRow() fails if no row has been changed.
 void testUpdateRowPosition()
          Test that after updateRow() the cursor is positioned correctly.
 void testUpdateRowUpdatesRow()
          Test that updated rows are modified in place if the primary key is not updated.
 void testZeroFetchSize()
          Test for bug [1232733] setFetchSize(0) causes exception.
 
Methods inherited from class net.sourceforge.jtds.test.DatabaseTestCase
compareBytes, dropFunction, dropProcedure, dropProcedure, dropTable, getLongString, getLongString, getType, getTypemap
 
Methods inherited from class net.sourceforge.jtds.test.TestBase
compareInputStreams, compareReaders, connect, disconnect, dump, dumpRow, getConnection, getConnection, loadProperties, makeObjects, makeTestTables, setUp, tearDown
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, 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, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Constructor Detail

ResultSetTest

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

testGetObject1

public void testGetObject1()
                    throws java.lang.Exception
Test BIT data type.

testGetObject2

public void testGetObject2()
                    throws java.lang.Exception
Test TINYINT data type.

testGetObject3

public void testGetObject3()
                    throws java.lang.Exception
Test SMALLINT data type.

testGetObject4

public void testGetObject4()
                    throws java.lang.Exception
Test INT data type.

testGetObject5

public void testGetObject5()
                    throws java.lang.Exception
Test BIGINT data type.

testResultSetScroll1

public void testResultSetScroll1()
                          throws java.lang.Exception
Test for bug [961594] ResultSet.

testResultSetScroll2

public void testResultSetScroll2()
                          throws java.lang.Exception
Test for bug [945462] getResultSet() return null if you use scrollable/updatable.

testResultSetScroll3

public void testResultSetScroll3()
                          throws java.lang.Exception
Test for bug [1028881] statement.execute() causes wrong ResultSet type.

testResultSetUpdate1

public void testResultSetUpdate1()
                          throws java.lang.Exception
Test for bug [1008208] 0.9-rc1 updateNull doesn't work.

testResultSetColumnName1

public void testResultSetColumnName1()
                              throws java.lang.Exception
Test for bug [1009233] ResultSet getColumnName, getColumnLabel return wrong values

testResultSetMetaData

public void testResultSetMetaData()
                           throws java.lang.Exception
Test for fixed bugs in ResultSetMetaData:
  1. isNullable() always returns columnNoNulls.
  2. isSigned returns true in error for TINYINT columns.
  3. Type names for numeric / decimal have (prec,scale) appended in error.
  4. Type names for auto increment columns do not have "identity" appended.
NB: This test assumes getColumnName has been fixed to work as per the suggestion in bug report [1009233].
Throws:
java.lang.Exception -  

testCursorWarning

public void testCursorWarning()
                       throws java.lang.Exception
Test for bug [1022445] Cursor downgrade warning not raised.

testCursorFallback

public void testCursorFallback()
                        throws java.lang.Exception
Test that the cursor fallback logic correctly discriminates between "real" sql errors and cursor open failures.

This illustrates the logic added to fix:

  1. [1323363] Deadlock Exception not reported (SQL Server)
  2. [1283472] Unable to cancel statement with cursor resultset

testCancelResultSet

public void testCancelResultSet()
                         throws java.lang.Exception
Test for bug [1246270] Closing a statement after canceling it throws an exception.

testGetByName

public void testGetByName()
                   throws java.lang.Exception
Test whether retrieval by name returns the first occurence (that's what the spec requires).

testMoreThan255Columns

public void testMoreThan255Columns()
                            throws java.lang.Exception
Test if COL_INFO packets are processed correctly for ResultSets with over 255 columns.

testEmptyInsertRow

public void testEmptyInsertRow()
                        throws java.lang.Exception
Test that insertRow() works with no values set.

testInsertRowVisible

public void testInsertRowVisible()
                          throws java.lang.Exception
Test that inserted rows are visible in a scroll sensitive ResultSet and that they show up at the end.

testUpdateRowDuplicatesRow

public void testUpdateRowDuplicatesRow()
                                throws java.lang.Exception
Test that updated rows are marked as deleted and the new values inserted at the end of the ResultSet if the primary key is updated.

testUpdateRowUpdatesRow

public void testUpdateRowUpdatesRow()
                             throws java.lang.Exception
Test that updated rows are modified in place if the primary key is not updated.

testDeleteRowMarksDeleted

public void testDeleteRowMarksDeleted()
                               throws java.lang.Exception
Test that deleted rows are not removed but rather marked as deleted.

testUpdateRowNoChanges

public void testUpdateRowNoChanges()
                            throws java.lang.Exception
Test for bug [1170777] resultSet.updateRow() fails if no row has been changed.

testCursorFetch

public void testCursorFetch()
                     throws java.lang.Exception
Test the behavior of sp_cursorfetch with fetch sizes greater than 1.

Assertions tested:


testAbsoluteMinusOne

public void testAbsoluteMinusOne()
                          throws java.lang.Exception
Test that absolute(-1) works the same as last().

testAbsoluteLargeValue

public void testAbsoluteLargeValue()
                            throws java.sql.SQLException
Test that calling absolute() with very large positive values positions the cursor after the last row and with very large negative values positions the cursor before the first row.

testRelativeLargeValue

public void testRelativeLargeValue()
                            throws java.sql.SQLException
Test that calling absolute() with very large positive values positions the cursor after the last row and with very large negative values positions the cursor before the first row.

testUnicodeStream

public void testUnicodeStream()
                       throws java.lang.Exception
Test that read() works ok on the stream returned by ResultSet.getUnicodeStream() (i.e. it doesn't always fill the buffer, regardless of whether there's available data or not).

testCursorMaxRows

public void testCursorMaxRows()
                       throws java.lang.Exception
Test that Statement.setMaxRows() works on cursor ResultSets.

testSetObjectScale

public void testSetObjectScale()
                        throws java.lang.Exception
Test for bug [1075977] setObject() causes SQLException.

Conversion of float values to String adds grouping to the value, which cannot then be parsed.


testCursorPrevious

public void testCursorPrevious()
                        throws java.lang.Exception
Test that ResultSet.previous() works correctly on cursor ResultSets.

testOutOfMemory

public void testOutOfMemory()
                     throws java.sql.SQLException
Test the behavior of the ResultSet/Statement/Connection when the JVM runs out of memory (hopefully) in the middle of a packet.

Previously jTDS was not able to close a ResultSet/Statement/Connection after an OutOfMemoryError because the input stream pointer usually remained inside a packet and further attempts to dump the rest of the response failed because of "protocol confusions".


testRelative

public void testRelative()
                  throws java.lang.Exception
Test for bug [1182066] regression bug resultset: relative() not working as expected.

testUpdateRowPosition

public void testUpdateRowPosition()
                           throws java.lang.Exception
Test that after updateRow() the cursor is positioned correctly.

testUpdateableClientCursor

public void testUpdateableClientCursor()
                                throws java.lang.Exception
Test for bug [1197603] Cursor downgrade error in CachedResultSet -- updateable result sets were incorrectly downgraded to read only forward only ones when client side cursors were used.

testDistinctBug

public void testDistinctBug()
                     throws java.lang.Exception
Test bug with Sybase where readonly scrollable result set based on a SELECT DISTINCT returns duplicate rows.

testPessimisticConcurrency

public void testPessimisticConcurrency()
                                throws java.lang.Exception
Test pessimistic concurrency for SQL Server (for Sybase optimistic concurrency will always be used).

testDynamicCursors

public void testDynamicCursors()
                        throws java.lang.Exception
Test if dynamic cursors (ResultSet.TYPE_SCROLL_SENSITIVE+1) see others' updates. SQL Server only.

testZeroFetchSize

public void testZeroFetchSize()
                       throws java.lang.Exception
Test for bug [1232733] setFetchSize(0) causes exception.

testRowstat

public void testRowstat()
                 throws java.lang.Exception
Test for bug [1329765] Pseudo column ROWSTAT is back with SQL 2005 (September CTP).

main

public static void main(java.lang.String[] args)


Generated on August 22 2007