SAfeTest (jTDS API)
Keywords: net.sourceforge.jtds.test.SAfeTest class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sourceforge.jtds.test
Class SAfeTest

    java.lang.Object
      junit.framework.Assert
          junit.framework.TestCase
              net.sourceforge.jtds.test.TestBase
                  net.sourceforge.jtds.test.DatabaseTestCase
                      net.sourceforge.jtds.test.SAfeTest

All Implemented Interfaces:
  junit.framework.Test

public class SAfeTest
extends DatabaseTestCase

Since:
  0.4
Version:
  $Id: SAfeTest.java,v 1.62.2.1 2009/08/04 10:33:54 ickzon Exp $
Author:
  Alin Sinpalean

Field Summary
`(package private) int` | `done`
`(package private) boolean` | `failed`
`(package private) int` | `started`

Fields inherited from class net.sourceforge.jtds.test.DatabaseTestCase
``

Fields inherited from class net.sourceforge.jtds.test.TestBase
`con, props`

Fields inherited from class junit.framework.TestCase
``

Constructor Summary
`SAfeTest(java.lang.String name)`

Method Summary
`private static void` | `insertBigDecimal(java.sql.PreparedStatement stmt, double val, boolean scaleFlag)` Helper method for `testBigDecimal0007`.
`static void` | `main(java.lang.String[] args)`
`void` | `testBatchUpdates0015()` Test batch updates for both plain and prepared statements.
`void` | `testBigDecimal0007()` Test `BigDecimal`s created from double values (i.e with very large scales).
`void` | `testBigDecimal1()` Test for bug [939206] TdsException: can't sent this BigDecimal
`void` | `testBitFields0005()` Check that values returned from bit fields are correct (not just 0) (bug #841670).
`void` | `testBytesToString()` Test that getString() on a varbinary column returns a hex string.
`void` | `testCallableStatement0006()` Test that `CallableStatement`s with return values work correctly.
`void` | `testCallableStatementVarchar0010()` Test VARCHAR output parameters returned by CallableStatements.
`void` | `testCancel0001()` Test cancelling.
`void` | `testCancel0002()` Test cancelling.
`void` | `testCancel0003()` Test for bug [1120442] Statement hangs in socket read after Statement.cancel().
`void` | `testCursorResultSetConcurrency0003()` Test `CursorResultSet` concurrency.
`void` | `testCursorResultSetEmpty0004()` Check that meta data information is fetched even for empty cursor-based result sets (bug #613199).
`void` | `testDataTruncException()` Test `DataTruncation` exception.
`void` | `testDatetimeRounding1()` Test for bug [983561] getDatetimeValue truncates fractional milliseconds
`void` | `testDeleteRow0009()` Test `ResultSet.deleteRow()` on updateable result sets.
`void` | `testExecuteUpdateSelect()` Tests that `executeUpdate("SELECT ...")`
`void` | `testFloat1()` Test for bug [963799] float values change when written to the database
`void` | `testFnEscape()` Test for bug related with [1368058] Calling StoredProcedure with functions ({fn} escape can't handle special characters, e.g. underscore).
`void` | `testFnEscapeNesting()` Test for bug #1116046 {fn } escape can't handle nested functions.
`void` | `testGetMultiScrollRs()` Test return of multiple scrollable result sets from one execute.
`void` | `testInsertRow0012()` Test `ResultSet.insertRow()` on updateable result sets.
`void` | `testLongToVarchar0008()` Test writing `long` values to VARCHAR fields.
`void` | `testMaxFieldSize()` Test `Statement.setMaxFieldSize()`.
`void` | `testNullLengthStrings0001()` Test whether NULL values, 0-length strings and single space strings are treated right.
`void` | `testNullOutputParameters()` Test that `null` output parameters are handled correctly.
`void` | `testOldDates0016()` Test that dates prior to 06/15/1940 0:00:00 are stored and retrieved correctly.
`void` | `testOutOfOrderClose0013()` Test how an "out-of-order" close behaves (e.g close the `Connection` first, then the `Statement` anf finally the `ResultSet`).
`void` | `testPlainResultSetPosition0004()` Check that the `isBeforeFirst`, `isAfterLast`, `isFirst` and `isLast` methods work for forward-only, read-only result sets (bug [1039876] MS SQL JtdsResultSet.isAfterLast() always returns false).
`void` | `testPreparedAndCallableCursors0014()` Test cursor-based `ResultSet`s obtained from `PreparedStatement`s and `CallableStatement`s.
`void` | `testQueryTimeout()` Test for bug [1222199] Delayed exception thrown in statement close.
`void` | `testSocketConcurrency1()`
`void` | `testSocketConcurrency2()`
`void` | `testSocketConcurrency3()`
`void` | `testSocketConcurrency4()` Test running SELECT queries on one `Statement` at the same time as `cancel()` is called on a concurrent `Statement`.
`void` | `testTableParsing()` Test that the SQL parser doesn't try to parse the table name unless necessary (or that it is able to parse function calls if it does).
`void` | `testThreadInterrupt()` Test for bug [1596743] executeQuery absorbs thread interrupt status
`void` | `testUnterminatedCommentParsing()` Test for bug [1187927] Driver Hangs on Statement.execute().
`void` | `testUpdateRow0011()` Test `ResultSet.updateRow()` on updateable result sets.

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, dump, dumpRow, getConnection, getConnection, 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`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### started

    volatile int started

### done

    volatile int done

### failed

    volatile boolean failed

Constructor Detail

### SAfeTest

    public SAfeTest(java.lang.String name)

Method Detail

### main

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

### testNullLengthStrings0001

    public void testNullLengthStrings0001()
                                   throws java.lang.Exception

  Test whether NULL values, 0-length strings and single space strings are treated right.

  Throws:
    `java.lang.Exception`

### testCancel0001

    public void testCancel0001()
                        throws java.lang.Exception

  Test cancelling. Create 2 connections, lock some records on one of them and try to read them using the other one. Cancel the statement from the second connection, then try executing a simple query on it to make sure it's in a correct state.

  Throws:
    `java.lang.Exception`

### testCancel0002

    public void testCancel0002()
                        throws java.lang.Exception

  Test cancelling. Create 2 connections, lock some records on one of them and try to read them using the other one with a timeout set. When the second connection times out try executing a simple query on it to make sure it's in a correct state.

  Throws:
    `java.lang.Exception`

### testCancel0003

    public void testCancel0003()
                        throws java.lang.Exception

  Test for bug [1120442] Statement hangs in socket read after Statement.cancel().

  In 1.0.1 and earlier versions network packets consisting of a single TDS_DONE packet with the CANCEL flag set were ignored and a new read() was attempted, essentially causing a deadlock.

  Because it relies on a particular succession of events this test will not always work as expected, i.e. the cancel might be executed too early or too late, but it won't fail in this situation.

  Throws:
    `java.lang.Exception`

### testQueryTimeout

    public void testQueryTimeout()
                          throws java.lang.Exception

  Test for bug [1222199] Delayed exception thrown in statement close.

  Throws:
    `java.lang.Exception`

### testCursorResultSetConcurrency0003

    public void testCursorResultSetConcurrency0003()
                                            throws java.lang.Exception

  Test `CursorResultSet` concurrency. Create a number of threads that execute concurrent queries using scrollable result sets. All requests should be run on the same connection (`Tds` instance).

  Throws:
    `java.lang.Exception`

### testCursorResultSetEmpty0004

    public void testCursorResultSetEmpty0004()
                                      throws java.lang.Exception

  Check that meta data information is fetched even for empty cursor-based result sets (bug #613199).

  Throws:
    `java.lang.Exception`

### testPlainResultSetPosition0004

    public void testPlainResultSetPosition0004()
                                        throws java.lang.Exception

  Check that the `isBeforeFirst`, `isAfterLast`, `isFirst` and `isLast` methods work for forward-only, read-only result sets (bug [1039876] MS SQL JtdsResultSet.isAfterLast() always returns false).

  Throws:
    `java.lang.Exception` - if an error condition occurs

### testBitFields0005

    public void testBitFields0005()
                           throws java.lang.Exception

  Check that values returned from bit fields are correct (not just 0) (bug #841670).

  Throws:
    `java.lang.Exception`

### testCallableStatement0006

    public void testCallableStatement0006()
                                   throws java.lang.Exception

  Test that `CallableStatement`s with return values work correctly.

  Throws:
    `java.lang.Exception`

### insertBigDecimal

    private static void insertBigDecimal(java.sql.PreparedStatement stmt,
                                         double val,
                                         boolean scaleFlag)
                                  throws java.lang.Exception

  Helper method for `testBigDecimal0007`. Inserts a BigDecimal value obtained from a double value.

  Parameters:
    `stmt` - `PreparedStatement` instance
    `val` - the `double` value to insert
    `scaleFlag` - if `true` scale the value to 4, otherwise leave it as it is
  Throws:
    `java.lang.Exception`

### testBigDecimal0007

    public void testBigDecimal0007()
                            throws java.lang.Exception

  Test `BigDecimal`s created from double values (i.e with very large scales).

  Throws:
    `java.lang.Exception`

### testLongToVarchar0008

    public void testLongToVarchar0008()
                               throws java.lang.Exception

  Test writing `long` values to VARCHAR fields. There was a regression introduced in release 0.6 that caused `long` fields to be sent with non-zero scale and appear with decimals when written into VARCHAR fields.

  Throws:
    `java.lang.Exception`

### testDeleteRow0009

    public void testDeleteRow0009()
                           throws java.lang.Exception

  Test `ResultSet.deleteRow()` on updateable result sets.

  Throws:
    `java.lang.Exception`

### testCallableStatementVarchar0010

    public void testCallableStatementVarchar0010()
                                          throws java.lang.Exception

  Test VARCHAR output parameters returned by CallableStatements.

  An issue existed, caused by the fact that the parameter was sent to SQL Server as a short VARCHAR (not XORed with 0x80) limiting its length to 255 characters. See bug [815348] for more details.

  Throws:
    `java.lang.Exception`

### testUpdateRow0011

    public void testUpdateRow0011()
                           throws java.lang.Exception

  Test `ResultSet.updateRow()` on updateable result sets.

  Throws:
    `java.lang.Exception`

### testInsertRow0012

    public void testInsertRow0012()
                           throws java.lang.Exception

  Test `ResultSet.insertRow()` on updateable result sets.

  Throws:
    `java.lang.Exception`

### testOutOfOrderClose0013

    public void testOutOfOrderClose0013()
                                 throws java.lang.Exception

  Test how an "out-of-order" close behaves (e.g close the `Connection` first, then the `Statement` anf finally the `ResultSet`).

  Throws:
    `java.lang.Exception`

### testPreparedAndCallableCursors0014

    public void testPreparedAndCallableCursors0014()
                                            throws java.lang.Exception

  Test cursor-based `ResultSet`s obtained from `PreparedStatement`s and `CallableStatement`s.

  Throws:
    `java.lang.Exception`

### testBatchUpdates0015

    public void testBatchUpdates0015()
                              throws java.lang.Exception

  Test batch updates for both plain and prepared statements.

  Throws:
    `java.lang.Exception`

### testOldDates0016

    public void testOldDates0016()
                          throws java.lang.Exception

  Test that dates prior to 06/15/1940 0:00:00 are stored and retrieved correctly.

  Throws:
    `java.lang.Exception`

### testBigDecimal1

    public void testBigDecimal1()
                         throws java.lang.Exception

  Test for bug [939206] TdsException: can't sent this BigDecimal

  Throws:
    `java.lang.Exception`

### testFloat1

    public void testFloat1()
                    throws java.lang.Exception

  Test for bug [963799] float values change when written to the database

  Throws:
    `java.lang.Exception`

### testDatetimeRounding1

    public void testDatetimeRounding1()
                               throws java.lang.Exception

  Test for bug [983561] getDatetimeValue truncates fractional milliseconds

  Throws:
    `java.lang.Exception`

### testSocketConcurrency1

    public void testSocketConcurrency1()

### testSocketConcurrency2

    public void testSocketConcurrency2()

### testSocketConcurrency3

    public void testSocketConcurrency3()

### testSocketConcurrency4

    public void testSocketConcurrency4()
                                throws java.lang.Exception

  Test running SELECT queries on one `Statement` at the same time as `cancel()` is called on a concurrent `Statement`.

  Throws:
    `java.lang.Exception`

### testNullOutputParameters

    public void testNullOutputParameters()
                                  throws java.sql.SQLException

  Test that `null` output parameters are handled correctly.

  It seems that if a non-nullable type is sent as input value and the output value is NULL, SQL Server (not Sybase) gets confused and returns the same type but a single 0 byte as value instead of the equivalent nullable type (e.g. instead of returning an `INTN` with length 0, which means it's null, it returns an `INT4` followed by a single 0 byte). The output parameter packet length is also incorrect, which indicates that SQL Server is confused.

  Currently jTDS always sends RPC parameters as nullable types, but this test is necessary to ensure that it will always remain so.

  Throws:
    `java.sql.SQLException`

### testTableParsing

    public void testTableParsing()
                          throws java.sql.SQLException

  Test that the SQL parser doesn't try to parse the table name unless necessary (or that it is able to parse function calls if it does).

  Throws:
    `java.sql.SQLException`

### testFnEscape

    public void testFnEscape()
                      throws java.lang.Exception

  Test for bug related with [1368058] Calling StoredProcedure with functions ({fn} escape can't handle special characters, e.g. underscore).

  Throws:
    `java.lang.Exception`

### testFnEscapeNesting

    public void testFnEscapeNesting()
                             throws java.lang.Exception

  Test for bug #1116046 {fn } escape can't handle nested functions.

  Throws:
    `java.lang.Exception`

### testDataTruncException

    public void testDataTruncException()
                                throws java.lang.Exception

  Test `DataTruncation` exception.

  Throws:
    `java.lang.Exception`

### testMaxFieldSize

    public void testMaxFieldSize()
                          throws java.lang.Exception

  Test `Statement.setMaxFieldSize()`.

  Throws:
    `java.lang.Exception`

### testGetMultiScrollRs

    public void testGetMultiScrollRs()
                              throws java.lang.Exception

  Test return of multiple scrollable result sets from one execute.

  Throws:
    `java.lang.Exception`

### testUnterminatedCommentParsing

    public void testUnterminatedCommentParsing()
                                        throws java.lang.Exception

  Test for bug [1187927] Driver Hangs on Statement.execute().

  Versions 1.0.3 and prior entered an infinite loop when parsing an unterminated multi-line comment.

  Throws:
    `java.lang.Exception`

### testBytesToString

    public void testBytesToString()
                           throws java.lang.Exception

  Test that getString() on a varbinary column returns a hex string.

  Throws:
    `java.lang.Exception`

### testExecuteUpdateSelect

    public void testExecuteUpdateSelect()
                                 throws java.lang.Exception

  Tests that `executeUpdate("SELECT ...")` fails.

  Throws:
    `java.lang.Exception`

### testThreadInterrupt

    public void testThreadInterrupt()
                             throws java.lang.Exception

  Test for bug [1596743] executeQuery absorbs thread interrupt status

  Throws:
    `java.lang.Exception`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Generated on December 30 2009