org.apache.derbyTesting.functionTests.tests.jdbc4
Class CallableStatementTestSetup

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.extensions.TestDecorator
          extended by junit.extensions.TestSetup
              extended by org.apache.derbyTesting.junit.BaseTestSetup
                  extended by org.apache.derbyTesting.junit.BaseJDBCTestSetup
                      extended by org.apache.derbyTesting.functionTests.tests.jdbc4.CallableStatementTestSetup
All Implemented Interfaces:
junit.framework.Test

public class CallableStatementTestSetup
extends BaseJDBCTestSetup

Create the necessary tables, function and procedures for running the CallableStatement tests under JDK 1.6. Java methods used as functions and procedures are also implemented here, along with helper methods that returns CallableStatements for the various functions and procedures.


Field Summary
private static java.lang.String[] FUNCTION_DROPS
          List of functions to drop on tear-down.
private static java.lang.String[] PROCEDURE_DROPS
          List of procedures to drop on tear-down.
private static java.lang.String SOURCECLASS
           
static int SQL_NULL_ID
          Id for row with SQL NULL values.
static java.lang.String STRING_BYTES
          String converted to bytes in UTF-16BE representation.
static int STRING_BYTES_ID
          Id for row with byte representation of a string.
private static java.lang.String[] TABLE_DROPS
          List of tables to drop on tear-down
 
Fields inherited from class junit.extensions.TestDecorator
fTest
 
Constructor Summary
CallableStatementTestSetup(junit.framework.Test test)
          Create a new test setup for the CallableStatementTest.
 
Method Summary
static void getBinaryDirect(java.lang.String inputString, byte[][] outputByte)
          Procedure creating a byte representation of a string.
static java.sql.CallableStatement getBinaryDirectProcedure(java.sql.Connection con)
          Return statement for calling procedure that converts a string to a byte array (UTF-16BE charset).
static byte[] getBinaryFromDb(int id)
          Function fetching binary data from the database.
static java.sql.CallableStatement getBinaryFromDbFunction(java.sql.Connection con)
          Return statement for calling getBinaryFromDb function.
static java.sql.CallableStatement getIntToStringFunction(java.sql.Connection con)
          Return function converting an integer to a string.
static java.lang.String getVarcharFromDb(int id)
          Function fetching character data from the database.
static java.sql.CallableStatement getVarcharFromDbFunction(java.sql.Connection con)
          Return statement for calling getVarcharFromDb function.
protected  void setUp()
           
protected  void tearDown()
          Tear down this fixture, sub-classes should call super.tearDown().
 
Methods inherited from class org.apache.derbyTesting.junit.BaseJDBCTestSetup
getConnection, getTestConfiguration, println
 
Methods inherited from class org.apache.derbyTesting.junit.BaseTestSetup
run
 
Methods inherited from class junit.extensions.TestDecorator
basicRun, countTestCases, getTest, 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

SOURCECLASS

private static final java.lang.String SOURCECLASS
See Also:
Constant Field Values

TABLE_DROPS

private static final java.lang.String[] TABLE_DROPS
List of tables to drop on tear-down


FUNCTION_DROPS

private static final java.lang.String[] FUNCTION_DROPS
List of functions to drop on tear-down.


PROCEDURE_DROPS

private static final java.lang.String[] PROCEDURE_DROPS
List of procedures to drop on tear-down.


STRING_BYTES_ID

public static final int STRING_BYTES_ID
Id for row with byte representation of a string.

See Also:
Constant Field Values

STRING_BYTES

public static final java.lang.String STRING_BYTES
String converted to bytes in UTF-16BE representation. Note that the charset used matters, and for Derby it must be UTF-16BE.

See Also:
Constant Field Values

SQL_NULL_ID

public static final int SQL_NULL_ID
Id for row with SQL NULL values.

See Also:
Constant Field Values
Constructor Detail

CallableStatementTestSetup

public CallableStatementTestSetup(junit.framework.Test test)
Create a new test setup for the CallableStatementTest.

Parameters:
test - the test/suite to provide setup for.
Method Detail

setUp

protected void setUp()
              throws java.sql.SQLException
Overrides:
setUp in class junit.extensions.TestSetup
Throws:
java.sql.SQLException

tearDown

protected void tearDown()
                 throws java.lang.Exception
Description copied from class: BaseJDBCTestSetup
Tear down this fixture, sub-classes should call super.tearDown(). This cleanups & closes the connection if it is open.

Overrides:
tearDown in class BaseJDBCTestSetup
Throws:
java.lang.Exception

getIntToStringFunction

public static java.sql.CallableStatement getIntToStringFunction(java.sql.Connection con)
                                                         throws java.sql.SQLException
Return function converting an integer to a string. Parameter 1: output - String/VARCHAR Parameter 2: input - int/INT

Throws:
java.sql.SQLException

getBinaryDirectProcedure

public static java.sql.CallableStatement getBinaryDirectProcedure(java.sql.Connection con)
                                                           throws java.sql.SQLException
Return statement for calling procedure that converts a string to a byte array (UTF-16BE charset). Parameter 1: input - String/VARCHAR(40) Parameter 2: output - byte[]/VARCHAR(160) FOR BIT DATA

Throws:
java.sql.SQLException

getBinaryFromDbFunction

public static java.sql.CallableStatement getBinaryFromDbFunction(java.sql.Connection con)
                                                          throws java.sql.SQLException
Return statement for calling getBinaryFromDb function. Parameter 1: return/output - byte[]/VARCHAR FOR BINARY - data from db Parameter 2: input - int/INT - id for row to fetch

Parameters:
con - database connection.
Returns:
statement for executing getBinaryFromDb function.
Throws:
java.sql.SQLException

getVarcharFromDbFunction

public static java.sql.CallableStatement getVarcharFromDbFunction(java.sql.Connection con)
                                                           throws java.sql.SQLException
Return statement for calling getVarcharFromDb function. Parameter 1: return/output - String/VARCHAR - data from db Parameter 2: input - int/INT - id for row to fetch

Parameters:
con - database connection.
Returns:
statement for executing getVarcharFromDb function.
Throws:
java.sql.SQLException

getBinaryDirect

public static void getBinaryDirect(java.lang.String inputString,
                                   byte[][] outputByte)
Procedure creating a byte representation of a string.

Parameters:
inputString - a string.
outputByte - string returned as UTF-16BE byte representation.

getBinaryFromDb

public static byte[] getBinaryFromDb(int id)
                              throws java.lang.Exception
Function fetching binary data from the database.

Parameters:
id - id of row to fetch.
Returns:
a byte array.
Throws:
java.lang.Exception

getVarcharFromDb

public static java.lang.String getVarcharFromDb(int id)
                                         throws java.lang.Exception
Function fetching character data from the database.

Parameters:
id - id of row to fetch.
Returns:
a string.
Throws:
java.lang.Exception

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.