public class TimeHandlingTest extends BaseJDBCTestCase
| Modifier and Type | Field and Description |
|---|---|
private java.util.Calendar |
cal
Calendar for testing returned values.
|
private static java.lang.String[] |
CURRENT_TIME_FUNCTIONS
All the functions or expressions that result in
a TIME value with the same value as CURRENT_TIME.
|
private static java.lang.String[] |
CURRENT_TIMESTAMP_FUNCTIONS
All the functions or expressions that result in
a TIMESTAMP value with the same value as CURRENT_TIMESTAMP.
|
private static long |
SLEEP_TIME
Time to sleep that will result in different TIME values.
|
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE| Constructor and Description |
|---|
TimeHandlingTest(java.lang.String name) |
| Modifier and Type | Method and Description |
|---|---|
private void |
assertTime1970(java.sql.Time t)
Javadoc for java.sql.Time states the components of
date for a java.sql.Time value must be set to January 1, 1970.
|
private void |
assertTimeEqual(java.util.Date tv1,
java.util.Date tv2)
Assert the SQL time portion of two SQL JDBC type
types are equal.
|
private java.lang.Object |
checkCurrentMultiple(int jdbcType,
long start,
long end,
java.sql.ResultSet rs,
int[] columns,
int expectedCount)
Check the validity of all CURRENT time values returned and
that they are identical.
|
private void |
checkCurrentQuery(int sqlType,
java.sql.Statement s,
java.lang.String sql,
int[] columns,
int expectedCount)
Execute a query that uses CURRENT expressions directly.
|
private java.sql.Time |
checkCurrentTimeMultiple(long start,
long end,
java.sql.ResultSet rs,
int[] columns,
int expectedCount)
Check a set of rows and columns with values set to CURRENT TIME
in a single statement are the same.
|
private java.sql.Timestamp |
checkCurrentTimestampMultiple(long start,
long end,
java.sql.ResultSet rs,
int[] columns,
int expectedCount)
Check a set of rows and columns with values set to CURRENT TIMESTAMP
in a single statement are the same.
|
private java.sql.Timestamp |
checkCurrentTimestampValue(long start,
long end,
java.sql.ResultSet rs,
int column)
Check the consistency of a ResultSet column that returns
CURRENT TIMESTAMP or a value set from CURRENT TIMESTAMP.
|
private java.sql.Time |
checkCurrentTimeValue(long start,
long end,
java.sql.ResultSet rs,
int column)
Check the consistency of a ResultSet column that returns
CURRENT TIME or a value set from CURRENT TIME.
|
private java.sql.Timestamp |
checkTimestampValue(java.sql.ResultSet rs,
int column)
Check the consistency of a ResultSet column that returns
a TIMESTAMP value.
|
private java.sql.Time |
checkTimeValue(java.sql.ResultSet rs,
int column)
Check the consistency of a ResultSet column that returns
a TIME value.
|
private void |
currentFunctionTests(int jdbcType,
java.lang.String[] functions)
Test all the current timedate functions passed in that
return the specified type.
|
private java.sql.Time |
getCodedTime(int id)
Return a time simply encoded from an integer identifier
and a set of fixed encoding keys, each a prime number.
|
private java.sql.Time |
getTime19700101(int hour,
int min,
int sec)
Create a Time object that has its date components
set to 1970/01/01 and its time to match the time
represented by h, m and s.
|
private java.sql.Time |
getTime19700101(long t,
java.util.Calendar cal)
Create a Time object that has its date components
set to 1970/01/01 and its time to match the time
represented by t and cal.
|
private java.sql.Time |
getTime19700101(java.lang.String s,
java.util.Calendar cal)
Create a Time object that has its date components
set to 1970/01/01 and its time to match the time
represented by t and cal.
|
private boolean |
isDateEqual(long d,
java.sql.Timestamp tsv)
Check if the date portion of a Timestamp value
is equal to the date portion of a time value
represented in milli-seconds since 1970.
|
protected void |
setUp()
Simple set up, just get a Calendar
and ensure the table T_ALL is empty.
|
static int |
sleep()
Method for SQL SLEEP function.
|
static junit.framework.Test |
suite()
Runs the tests in the default embedded configuration and then
the client server configuration.
|
void |
testCurrentTime()
Tests for CURRENT TIME and CURRENT_TIME.
|
void |
testCurrentTimestamp()
Tests for CURRENT TIMESTAMP functions.
|
void |
testInsertTime()
Test inserting and selecting of TIME values.
|
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, usingEmbeddedalarm, 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, traceitassertEquals, 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, toStringprivate static final java.lang.String[] CURRENT_TIME_FUNCTIONS
private static final java.lang.String[] CURRENT_TIMESTAMP_FUNCTIONS
private static final long SLEEP_TIME
private java.util.Calendar cal
public static junit.framework.Test suite()
public static int sleep()
throws java.lang.InterruptedException
java.lang.InterruptedExceptionprotected void setUp()
throws java.sql.SQLException
setUp in class junit.framework.TestCasejava.sql.SQLExceptionpublic void testInsertTime()
throws java.sql.SQLException
java.sql.SQLExceptionprivate java.sql.Time getCodedTime(int id)
id - public void testCurrentTime()
throws java.sql.SQLException,
java.lang.InterruptedException
java.sql.SQLExceptionjava.lang.InterruptedExceptionpublic void testCurrentTimestamp()
throws java.sql.SQLException,
java.lang.InterruptedException
java.sql.SQLExceptionjava.lang.InterruptedExceptionprivate void currentFunctionTests(int jdbcType,
java.lang.String[] functions)
throws java.sql.SQLException,
java.lang.InterruptedException
jdbcType - JDBC type, Types.TIME, DATE or TIMESTAMP.functions - List of functions or expressions that map to the
current time date value and return the specified type.java.sql.SQLExceptionjava.lang.InterruptedExceptionprivate void checkCurrentQuery(int sqlType,
java.sql.Statement s,
java.lang.String sql,
int[] columns,
int expectedCount)
throws java.sql.SQLException
sqlType - s - sql - columns - expectedCount - java.sql.SQLExceptionprivate java.lang.Object checkCurrentMultiple(int jdbcType,
long start,
long end,
java.sql.ResultSet rs,
int[] columns,
int expectedCount)
throws java.sql.SQLException
jdbcType - Types.TIME or TIMESTAMPstart - Start of window for valid value.end - End of window for valid value.rs - Result set positioned on row.columns - Columns holding current values.expectedCount - Total number of values exected to see
(row count times column count)java.sql.SQLExceptionprivate java.sql.Time checkCurrentTimeMultiple(long start,
long end,
java.sql.ResultSet rs,
int[] columns,
int expectedCount)
throws java.sql.SQLException
start - Start time for the statement that set the values.end - End time for the statement that set the values.rs - ResultSet positioned on the first row.columns - Set of columns holding the TIME valuesexpectedCount - Number of values we are execpted to check.java.sql.SQLExceptionprivate java.sql.Timestamp checkCurrentTimestampMultiple(long start,
long end,
java.sql.ResultSet rs,
int[] columns,
int expectedCount)
throws java.sql.SQLException
start - Start time for the statement that set the values.end - End time for the statement that set the values.rs - ResultSet positioned on the first row.columns - Set of columns holding the TIME valuesexpectedCount - Number of values we are execpted to check.java.sql.SQLExceptionprivate java.sql.Time checkTimeValue(java.sql.ResultSet rs,
int column)
throws java.sql.SQLException
rs - ResultSet holding the column, positioned on a rowcolumn - Column with the TIME value.java.sql.SQLExceptionprivate java.sql.Timestamp checkTimestampValue(java.sql.ResultSet rs,
int column)
throws java.sql.SQLException
rs - ResultSet holding the column, positioned on a rowcolumn - Column with the TIMESTAMP value.java.sql.SQLExceptionprivate java.sql.Time checkCurrentTimeValue(long start,
long end,
java.sql.ResultSet rs,
int column)
throws java.sql.SQLException
start - Time the statement settng the value was executedend - Time after first rs.next() or update statement was executedrs - ResultSet holding the column, positioned on a rowcolumn - Column with the timestamp.java.sql.SQLExceptionprivate java.sql.Timestamp checkCurrentTimestampValue(long start,
long end,
java.sql.ResultSet rs,
int column)
throws java.sql.SQLException
start - Time the statement settng the value was executedend - Time after first rs.next() or update statement was executedrs - ResultSet holding the column, positioned on a rowcolumn - Column with the timestamp.java.sql.SQLExceptionprivate java.sql.Time getTime19700101(int hour,
int min,
int sec)
private java.sql.Time getTime19700101(long t,
java.util.Calendar cal)
private java.sql.Time getTime19700101(java.lang.String s,
java.util.Calendar cal)
private void assertTime1970(java.sql.Time t)
t - private void assertTimeEqual(java.util.Date tv1,
java.util.Date tv2)
tv1 - the first time to comparetv2 - the second time to compareprivate boolean isDateEqual(long d,
java.sql.Timestamp tsv)
Apache Derby V10.10 Internals - Copyright © 2004,2014 The Apache Software Foundation. All Rights Reserved.