ConnectionTest (jTDS API)
Date: 2013-06-08

net.sourceforge.jtds.jdbc

## Class ConnectionTest

- java.lang.Object
- - TestCase
  - - net.sourceforge.jtds.jdbc.TestBase
    - - net.sourceforge.jtds.jdbc.DatabaseTestCase
      - - net.sourceforge.jtds.jdbc.UnitTestBase
        - - net.sourceforge.jtds.jdbc.ConnectionTest

-     public class ConnectionTest
      extends UnitTestBase

  Unit test for the `JtdsConnection` class.
  Author:
    David Kilzer, Alin Sinpalean, Holger Rehn

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ConnectionTest.testTimerStopHelper` Helper class for test for bug [2871274].
    `static class` | `ConnectionTest.TestUnpackProperties` Class used to test `net.sourceforge.jtds.jdbc.JtdsConnection.unpackProperties(Properties)` .

  - ### Field Summary

    - ### Fields inherited from class net.sourceforge.jtds.jdbc.TestBase

      `con, props`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ConnectionTest(java.lang.String name)` Constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `private void` | `assertSQLExceptionForBadWholeNumberProperty(java.lang.String key)` Assert that an SQLException is thrown when `JtdsConnection.unpackProperties(Properties)` is called with an invalid integer (or long) string set on a property.
    `private java.sql.Connection` | `getConnectionOverrideProperties(java.util.Properties override)` Creates a `Connection`, overriding the default properties with the ones provided.
    `static Test` | `suite()` Construct a test suite for this class.
    `void` | `testAutoCommit()` Test for bug [1296482] setAutoCommit() behaviour.
    `void` | `testBug673()` Regression test for bug #673, function expansion causes buffer overflow.
    `void` | `testBug701()`
    `void` | `testForceCharset1()` Test correct behavior of the `charset` property.
    `void` | `testForceCharset2()` Test correct behavior of the `charset` property.
    `void` | `testInvalidIntegerProperty()` Test that an `SQLException` is thrown when parsing invalid integer (and long) properties.
    `void` | `testSavepointRelease()` Test that temporary procedures created within transactions with savepoints which are released are still kept in the procedure cache.
    `void` | `testTimerStop()` Test for bug [2871274], TimerThread prevents classloader from being GCed.
    `void` | `testUnclosedSocket()` Test for bug [1755448], login failure leaves unclosed sockets.

    - ### Methods inherited from class net.sourceforge.jtds.jdbc.UnitTestBase

      `assertEquals, invokeConstructor, invokeGetInstanceField, invokeInstanceMethod, invokeSetInstanceField, invokeStaticMethod, ucFirst`

    - ### Methods inherited from class net.sourceforge.jtds.jdbc.DatabaseTestCase

      `compareBytes, getLongString, getLongString, getType, getTypemap`

    - ### Methods inherited from class net.sourceforge.jtds.jdbc.TestBase

      `compareInputStreams, compareReaders, connect, dropDatabase, dropFunction, dropProcedure, dropTable, dropTrigger, dropType, dropView, dump, dump, dumpAll, dumpKeys, dumpRow, dumpRow, getConnection, getConnection, makeObjects, makeTestTables, setUp, tearDown`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ConnectionTest

          public ConnectionTest(java.lang.String name)

      Constructor.

      Parameters:
        `name` - name of the test

  - ### Method Detail

    - #### suite

          public static Test suite()

      Construct a test suite for this class.

      The test suite includes the tests in this class, and adds tests from `DefaultPropertiesTestLibrary` after creating an anonymous `DefaultPropertiesTester` object.
      Returns:
        The test suite to run.

    - #### testInvalidIntegerProperty

          public void testInvalidIntegerProperty()

      Test that an `SQLException` is thrown when parsing invalid integer (and long) properties.

    - #### testBug701

          public void testBug701()
                          throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### testForceCharset1

          public void testForceCharset1()
                                 throws java.lang.Exception

      Test correct behavior of the `charset` property. Values should be stored and retrieved using the requested charset rather than the server's as long as Unicode is not used.
      Throws:
        `java.lang.Exception`

    - #### testForceCharset2

          public void testForceCharset2()
                                 throws java.lang.Exception

      Test correct behavior of the `charset` property. Stored procedure output parameters should be decoded using the specified charset rather than the server's as long as they are non-Unicode.
      Throws:
        `java.lang.Exception`

    - #### testAutoCommit

          public void testAutoCommit()
                              throws java.lang.Exception

      Test for bug [1296482] setAutoCommit() behaviour.

      The behaviour of setAutoCommit() on JtdsConnection is inconsistent with the Sun JDBC 3.0 Specification. JDBC 3.0 Specification, section 10.1.1:

      > "If the value of auto-commit is changed in the middle of a transaction, the current transaction is committed."

      Throws:
        `java.lang.Exception`

    - #### testBug673

          public void testBug673()
                          throws java.lang.Exception

      Regression test for bug #673, function expansion causes buffer overflow.
      Throws:
        `java.lang.Exception`

    - #### testSavepointRelease

          public void testSavepointRelease()
                                    throws java.sql.SQLException

      Test that temporary procedures created within transactions with savepoints which are released are still kept in the procedure cache.
      Throws:
        `java.sql.SQLException`

    - #### testUnclosedSocket

          public void testUnclosedSocket()

      Test for bug [1755448], login failure leaves unclosed sockets.

    - #### testTimerStop

          public void testTimerStop()
                             throws java.lang.Throwable

      Test for bug [2871274], TimerThread prevents classloader from being GCed.
      Throws:
        `java.lang.Throwable`

    - #### assertSQLExceptionForBadWholeNumberProperty

          private void assertSQLExceptionForBadWholeNumberProperty(java.lang.String key)

      Assert that an SQLException is thrown when `JtdsConnection.unpackProperties(Properties)` is called with an invalid integer (or long) string set on a property.

      Note that because Java 1.3 is still supported, the `RuntimeException` that is caught may not contain the original `Throwable` cause, only the original message.
      Parameters:
        `key` - The message key used to retrieve the property name.

    - #### getConnectionOverrideProperties

          private java.sql.Connection getConnectionOverrideProperties(java.util.Properties override)
                                                               throws java.lang.Exception

      Creates a `Connection`, overriding the default properties with the ones provided.
      Parameters:
        `override` - the overriding properties
      Returns:
        a `Connection` object
      Throws:
        `java.lang.Exception`

Generated on June 8 2013