public class CallableTest extends BaseJDBCTestCase
This test converts the old derbynet/callable.java test to JUnit. It exercises the CallableStatement interface with various combinations of IN, OUT and INOUT registered parameters, SQL functions and procedures, and different data types.
Modifier and Type | Field and Description |
---|---|
private static java.lang.String[] |
ROUTINES
Routines that should be created before the tests are run and
dropped when the tests have finished.
|
private static java.lang.String[][] |
TABLES
Tables that should be created before the tests are run and
dropped when the tests have finished.
|
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
CallableTest(java.lang.String name)
Creates a new
CallableTest instance. |
Modifier and Type | Method and Description |
---|---|
void |
assertDecimalSameValue(java.lang.String message,
java.lang.String expected_s,
java.math.BigDecimal actual)
Wrapper for BigDecimal compareTo.
|
private void |
assertSameDate(java.util.Date expected,
java.util.Calendar cal1,
java.util.Date actual,
java.util.Calendar cal2)
Assert that two
java.util.Date values have the same
representation of their date components (year, month and day) in their
respective time zones. |
private void |
assertSameTime(java.util.Date expected,
java.util.Calendar cal1,
java.util.Date actual,
java.util.Calendar cal2)
Assert that two
java.util.Date values have the same
representation of their time components (hour, minute, second) in their
respective time zones. |
private static junit.framework.Test |
baseSuite(java.lang.String name) |
static void |
batchUpdateProc(int id,
int id_newval)
External code for the BATCH_UPDATE_PROC SQL procedure, which updates
data in a table for a given id.
|
static void |
bigDecimalInAndOutProc(java.math.BigDecimal bd1,
java.math.BigDecimal[] bdr1,
java.math.BigDecimal bd2,
java.math.BigDecimal[] bdr2,
java.math.BigDecimal[] bdr3,
java.math.BigDecimal[] bdr4,
java.math.BigDecimal[] bdr5,
java.math.BigDecimal[] bdr6,
java.math.BigDecimal[] bdr7)
External code for the BIGDECIMAL_IN_AND_OUT_PROC SQL procedure, which
tests INT and OUT parameters with the BigDecimal data type.
|
static void |
manyTypesInAndOutProc(java.sql.Date dt,
java.sql.Time t,
java.sql.Timestamp ts,
byte[] ba,
java.sql.Date[] dtr,
java.sql.Time[] tr,
java.sql.Timestamp[] tsr,
byte[][] bar)
External code for the NON_NUMERIC_TYPES_IN_AND_OUT_PROC SQL procedure,
which tests IN / OUT parameters with many non-numeric types.
|
static void |
manyTypesInAndOutProc(short s,
int i,
long l,
float f,
double d,
java.math.BigDecimal bd,
short[] sr,
int[] ir,
long[] lr,
float[] fr,
double[] dr,
java.math.BigDecimal[] bdr)
External code for the NUMERIC_TYPES_IN_AND_OUT_PROC SQL procedure,
which tests IN and OUT parameters with many numeric types.
|
static void |
manyTypesInoutProc(short s1,
short[] s2,
int p1,
int[] p2,
long l1,
long[] l2,
float f1,
float[] f2,
double d1,
double[] d2,
java.sql.Time t1,
java.sql.Time[] t2)
External code for the MANY_TYPES_INOUT_PROC SQL procedure, which tests
INOUT parameters with many types.
|
static int |
noInOneOutFunc()
External code for the NO_IN_ONE_OUT_FUNC SQL function, which takes no
parameters and returns the value 55.
|
void |
norun_testSystemOutPrintlnProc()
Calls a SQL procedure that outputs a message with System.out.println.
|
static void |
numericBoundariesProc(java.math.BigDecimal[] param1,
java.math.BigDecimal[] param2,
java.math.BigDecimal[] param3)
External code for the NUMERIC_BOUNDARIES_PROC SQL procedure, which
fetches max, min, and null values from a table with numeric columns.
|
static int |
oneInOneOutFunc(int p1)
External code for the ONE_IN_ONE_OUT_FUNC SQL function, which squares
the value of the input arg, then adds the input arg to that result.
|
void |
setUp()
Sets up the connection for a test case and clears all tables
used in the test cases.
|
static junit.framework.Test |
suite() |
static void |
systemOutPrintlnProc()
External code for the SYSTEM_OUT_PRINTLN_PROC SQL procedure, which
outputs a message to System out.
|
void |
testIsolationLevelChangeAfterFunctionCall() |
void |
testManyTypesInoutProc()
Calls a SQL procedure that takes INOUT parameters of various types.
|
void |
testNoInOneOutFunc()
Calls a SQL function that takes no input parameter and returns one
output.
|
void |
testNonNumericTypesInAndOutProc()
Calls a SQL procedure that takes non-numeric IN and OUT parameters.
|
void |
testOneInOneOutFunc()
Calls a SQL function with one input parameter and one output.
|
void |
testTimeAndDateWithCalendar()
Test that the getters and setters for Date, Time and Timestamp work as
expected when given a Calendar argument.
|
private void |
testTimeAndDateWithCalendar(java.util.Calendar cal1,
java.util.Calendar cal2)
Private helper for
testTimeAndDateWithCalendar() . |
void |
testTwoInOneOutProc()
Calls a SQL procedure with two input parameters and one output.
|
static void |
twoInOneOutProc(int p1,
int p2,
int[] p3)
External code for the TWO_IN_ONE_OUT_PROC SQL procedure, which sets the
value of the third arg to the sum of the first two.
|
static void |
updateLongVarbinaryProc(byte[] in_param)
External code for the UPDATE_LONGVARBINARY_PROC SQL procedure, which
sets the value of the Long varbinary column in the LONGVARBINARY_TABLE
table given the input parameter.
|
private void |
vetTimestamp(java.sql.Timestamp original,
java.util.Calendar cal1,
java.sql.Timestamp returned,
java.util.Calendar cal2)
Check that a
Timestamp value is as expected when it has been
passed to a stored procedure and read back again from that procedure,
using different calendars for the setTimestamp() and
getTimestamp() calls. |
void |
xtestBatchUpdate()
Batches up calls to a SQL procedure that updates a value in a table.
|
void |
xtestBatchUpdateError()
Batches up many calls to a SQL procedure that updates a value in a table.
|
void |
xtestBigDecimalInAndOutProc()
Calls a SQL procedure with BigDecimal IN and OUT parameters.
|
void |
xtestNumericBoundariesProc()
Calls a SQL procedure that populates OUT parameters with minimum,
maximum, and null values fetched from a table with numeric columns.
|
void |
xtestNumericTypesInAndOutProc()
Calls a SQL procedure that takes numeric IN and OUT parameters.
|
void |
xtestUpdateLongBinaryProc()
Calls a SQL procedure that updates a long varbinary column.
|
assertCallError, assertCheckTable, assertCompileError, assertEquals, assertEquals, assertEquals, assertEquivalentDataType, assertErrorCode, assertGetIntError, assertNextError, assertPreparedStatementError, assertSQLExceptionEquals, assertSQLState, assertSQLState, assertStatementError, assertStatementError, assertStatementError, assertStatementError, assertStatementErrorUnordered, assertTableRowCount, assertUpdateCount, assertUpdateCount, assertWarning, checkAllConsistency, checkEstimatedRowCount, closeStatement, commit, createStatement, createStatement, createStatement, dropTable, dropTable, dropView, dropView, emptyStatementCache, getClientTransactionID, getConnection, getDatabaseProperty, getLastSQLException, initializeConnection, openConnection, openDefaultConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runBare, runBareOverridable, runScript, runScript, runSQLCommands, setAutoCommit, tearDown, usingDB2Client, usingDerbyNetClient, usingEmbedded
alarm, assertDirectoryDeleted, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertLaunchedJUnitTestMethod, assertLaunchedJUnitTestMethod, assertSecurityManager, assertThrowableEquals, currentDirectory, execJavaCmd, execJavaCmd, fail, getClassVersionMajor, getEmmaJar, getFailureFolder, getFilesWith, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, hasInterruptibleIO, isCVM, isIBMJVM, isJ9Platform, isJava5, isJava7, isJava8, isPhoneME, isPlatform, isSunJVM, isWindowsPlatform, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeFiles, removeSystemProperty, runsWithEmma, runsWithJaCoCo, setSystemProperty, sleep, sleepAtLeastOneTick, traceit
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, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runTest, setName, toString
private static final java.lang.String[] ROUTINES
private static final java.lang.String[][] TABLES
public CallableTest(java.lang.String name)
CallableTest
instance.name
- name of the testpublic static junit.framework.Test suite()
private static junit.framework.Test baseSuite(java.lang.String name)
public void setUp() throws java.sql.SQLException
setUp
in class junit.framework.TestCase
java.sql.SQLException
public void testTwoInOneOutProc() throws java.sql.SQLException
java.sql.SQLException
public void testOneInOneOutFunc() throws java.sql.SQLException
java.sql.SQLException
public void testNoInOneOutFunc() throws java.sql.SQLException
java.sql.SQLException
public void testIsolationLevelChangeAfterFunctionCall() throws java.sql.SQLException
java.sql.SQLException
public void norun_testSystemOutPrintlnProc() throws java.sql.SQLException
java.sql.SQLException
public void xtestNumericTypesInAndOutProc() throws java.sql.SQLException
java.sql.SQLException
public void testNonNumericTypesInAndOutProc() throws java.sql.SQLException
java.sql.SQLException
public void testTimeAndDateWithCalendar() throws java.sql.SQLException
java.sql.SQLException
private void testTimeAndDateWithCalendar(java.util.Calendar cal1, java.util.Calendar cal2) throws java.sql.SQLException
testTimeAndDateWithCalendar()
. This method
calls a procedure that takes Date, Time and Timestamp arguments and
returns the exact same values. Call the setters with one calendar and
the getters with another calendar, and verify that the expected
conversion between time zones has happened.cal1
- the calendar to use for the setter methodscal2
- the calendar to use for the getter methodsjava.sql.SQLException
private void assertSameDate(java.util.Date expected, java.util.Calendar cal1, java.util.Date actual, java.util.Calendar cal2)
java.util.Date
values have the same
representation of their date components (year, month and day) in their
respective time zones.expected
- the expected datecal1
- a calendar representing the time zone of the expected dateactual
- the actual datecal2
- a calendar representing the time zone of the actual dateprivate void assertSameTime(java.util.Date expected, java.util.Calendar cal1, java.util.Date actual, java.util.Calendar cal2)
java.util.Date
values have the same
representation of their time components (hour, minute, second) in their
respective time zones.expected
- the expected timecal1
- a calendar representing the time zone of the expected timeactual
- the actual timecal2
- a calendar representing the time zone of the actual timeprivate void vetTimestamp(java.sql.Timestamp original, java.util.Calendar cal1, java.sql.Timestamp returned, java.util.Calendar cal2)
Timestamp
value is as expected when it has been
passed to a stored procedure and read back again from that procedure,
using different calendars for the setTimestamp()
and
getTimestamp()
calls.original
- the original timestamp that was passed to the procedurecal1
- the calendar object passed to setTimestamp()
before
calling the procedurereturned
- the timestamp returned from the procedurecal2
- the calendar object passed to getTimestamp()
when
reading the value returned by the procedurepublic void testManyTypesInoutProc() throws java.sql.SQLException
java.sql.SQLException
public void xtestUpdateLongBinaryProc() throws java.sql.SQLException
java.sql.SQLException
public void xtestBatchUpdate() throws java.sql.SQLException
java.sql.SQLException
public void xtestBatchUpdateError() throws java.sql.SQLException
java.sql.SQLException
public void xtestNumericBoundariesProc() throws java.sql.SQLException
java.sql.SQLException
public void xtestBigDecimalInAndOutProc() throws java.sql.SQLException
java.sql.SQLException
public void assertDecimalSameValue(java.lang.String message, java.lang.String expected_s, java.math.BigDecimal actual)
public static int oneInOneOutFunc(int p1)
p1
- integer input argument to be used in calculationpublic static void twoInOneOutProc(int p1, int p2, int[] p3)
p1
- integer input parameter to be used in calculationp2
- integer input parameter to be used in calculationp3
- integer output parameter that stores result of the calculationpublic static int noInOneOutFunc()
public static void systemOutPrintlnProc()
public static void updateLongVarbinaryProc(byte[] in_param) throws java.sql.SQLException
in_param
- input parameter to be used for database updatejava.sql.SQLException
- if a database error occurspublic static void numericBoundariesProc(java.math.BigDecimal[] param1, java.math.BigDecimal[] param2, java.math.BigDecimal[] param3) throws java.sql.SQLException
param1
- output parameter that returns maxcol valueparam2
- output parameter that returns mincol valueparam3
- output parameter that returns nulcol valuejava.sql.SQLException
- if a database error occurspublic static void bigDecimalInAndOutProc(java.math.BigDecimal bd1, java.math.BigDecimal[] bdr1, java.math.BigDecimal bd2, java.math.BigDecimal[] bdr2, java.math.BigDecimal[] bdr3, java.math.BigDecimal[] bdr4, java.math.BigDecimal[] bdr5, java.math.BigDecimal[] bdr6, java.math.BigDecimal[] bdr7)
bd1
- input parameterbdr1
- output parameter set to bd1 * bd2bd2
- input parameterbdr2
- output parameter set to bd1 + bd2bdr3
- output parameter set to a fixed valuebdr4
- output parameter set to a fixed valuebdr5
- output parameter set to a fixed valuebdr6
- output parameter set to a fixed valuebdr7
- output parameter set to a fixed valuepublic static void manyTypesInAndOutProc(short s, int i, long l, float f, double d, java.math.BigDecimal bd, short[] sr, int[] ir, long[] lr, float[] fr, double[] dr, java.math.BigDecimal[] bdr)
s
- short input parameteri
- int input parameterl
- long input parameterf
- float input parameterd
- double input parameterbd
- BigDecimal input parametersr
- short output parameterir
- int output parameterlr
- long output parameterfr
- float output parameterdr
- double output parameterbdr
- BigDecimal output parameterpublic static void manyTypesInAndOutProc(java.sql.Date dt, java.sql.Time t, java.sql.Timestamp ts, byte[] ba, java.sql.Date[] dtr, java.sql.Time[] tr, java.sql.Timestamp[] tsr, byte[][] bar)
dt
- date input parametert
- time input parameterts
- timestamp input parameterba
- byte input parameterdtr
- date output parametertr
- time output parametertsr
- timestamp output parameterbar
- byte output parameterpublic static void manyTypesInoutProc(short s1, short[] s2, int p1, int[] p2, long l1, long[] l2, float f1, float[] f2, double d1, double[] d2, java.sql.Time t1, java.sql.Time[] t2)
s1
- short input parameters2
- short output parameterp1
- int input parameterp2
- int output parameterl1
- long input parameterl2
- long output parameterf1
- float input parameterf2
- float output parameterd1
- double input parameterd2
- double output parametert1
- time input parametert2
- time output parameterpublic static void batchUpdateProc(int id, int id_newval) throws java.sql.SQLException
id
- Id to be updatedid_newval
- New value to which the id should be updatedjava.sql.SQLException
- if a database error occursApache Derby V10.10 Internals - Copyright © 2004,2014 The Apache Software Foundation. All Rights Reserved.