|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.apache.derbyTesting.junit.BaseTestCase
org.apache.derbyTesting.junit.BaseJDBCTestCase
org.apache.derbyTesting.functionTests.tests.lang.TimestampArithTest
public class TimestampArithTest
Test the JDBC TIMESTAMPADD and TIMESTAMPDIFF escape functions. Things to test: + Test each interval type with timestamp, date, and time inputs. + Test diff with all 9 combinations of datetime input types (timestamp - timestamp, timestamp - date, etc). + Test PreparedStatements with parameters, '?', in each argument, and Statements. (Statements are prepared internally so we do not also have to test PrepardStatements without parameters). + Test with null inputs. + Test with input string that is convertible to timestamp. + Test with invalid interval type. + Test with invalid arguments in the date time arguments. + Test TIMESTAMPADD with an invalid type in the count argument. + Test overflow cases.
| Nested Class Summary | |
|---|---|
private class |
TimestampArithTest.OneAddTest
|
private class |
TimestampArithTest.OneDiffTest
|
private class |
TimestampArithTest.OneStringAddTest
|
private class |
TimestampArithTest.OneStringDiffTest
|
private class |
TimestampArithTest.OneTest
Abstract class that factors out all the common code for the timestamps tests. |
| Field Summary | |
|---|---|
private TimestampArithTest.OneAddTest[] |
addBetweenDateAndTsTests
date + timestamp |
private TimestampArithTest.OneStringAddTest[] |
addBetweenStringTests
|
private TimestampArithTest.OneAddTest[] |
addBetweenTsTests
timestamp + timestamp |
private static int |
DAY_INTERVAL
|
private TimestampArithTest.OneDiffTest[] |
diffBetweenDateAndTsTests
date - timestamp |
private TimestampArithTest.OneStringDiffTest[] |
diffBetweenStringTests
|
private TimestampArithTest.OneDiffTest[] |
diffBetweenTsAndDateTests
timestamp - date |
private TimestampArithTest.OneDiffTest[] |
diffBetweenTsTests
timestamp - timestamp |
private static int |
FRAC_SECOND_INTERVAL
|
private static int |
HOUR_INTERVAL
|
private static java.lang.String[] |
intervalJdbcNames
|
private java.lang.String[][] |
invalid
|
private static int |
MINUTE_INTERVAL
|
private static int |
MONTH_INTERVAL
|
private static int |
ONE_BILLION
|
private TimestampArithTest.OneTest[] |
overflowTests
check overflow conditions |
private static int |
QUARTER_INTERVAL
|
private static int |
SECOND_INTERVAL
|
private static java.sql.Statement |
stmt
|
private static java.lang.String |
TODAY
|
private static java.lang.String |
TOMORROW
|
private static java.sql.PreparedStatement[] |
tsAddPS
|
private static java.sql.PreparedStatement[] |
tsDiffPS
|
private static java.lang.String |
WEEK_FROM_TODAY
|
private static int |
WEEK_INTERVAL
|
private static java.lang.String |
YEAR_FROM_TODAY
|
private static java.lang.String |
YEAR_FROM_TOMORROW
|
private static int |
YEAR_INTERVAL
|
private static java.lang.String |
YESTERDAY
|
| Fields inherited from class org.apache.derbyTesting.junit.BaseTestCase |
|---|
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE |
| Constructor Summary | |
|---|---|
TimestampArithTest(java.lang.String name)
Basic constructor. |
|
| Method Summary | |
|---|---|
private static java.lang.String |
composeSqlStr(java.lang.String fn,
int interval,
java.lang.String parm1,
java.lang.String parm2)
|
private static java.lang.String |
dateTimeToLiteral(java.lang.Object ts)
|
private static java.sql.Date |
dt(java.lang.String s)
|
private static void |
expectException(java.sql.PreparedStatement ps,
java.lang.Object obj1,
java.lang.Object obj2,
java.lang.String expectedSQLState,
java.lang.String label)
|
private static void |
expectNullResult(java.sql.PreparedStatement ps,
java.lang.String label)
|
protected void |
initializeConnection(java.sql.Connection conn)
Allow a sub-class to initialize a connection to provide consistent connection state for its tests. |
private static java.lang.String |
isoFormatDate(java.util.Calendar cal)
|
private static void |
setDateTime(java.sql.PreparedStatement ps,
int parameterIdx,
java.util.Date dateTime)
|
static junit.framework.Test |
suite()
|
void |
testAddBetweenDateAndTimestamps()
|
void |
testAddBetweenString()
|
void |
testAddBetweenTimestamp()
|
void |
testDiffBetweenDateAndTimestamp()
|
void |
testDiffBetweenString()
|
void |
testDiffBetweenTimestamp()
|
void |
testDiffBetweenTimestampAndDate()
|
void |
testInvalidArgTypes()
|
void |
testInvalidLengths()
|
void |
testNullInputs()
Tests null inputs, each position, each type. |
void |
testOverflow()
|
private static java.sql.Timestamp |
ts(java.lang.String s)
|
| Methods inherited from class org.apache.derbyTesting.junit.BaseTestCase |
|---|
alarm, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertSecurityManager, assertThrowableEquals, execJavaCmd, fail, getFailureFolder, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeSystemProperty, runBare, setSystemProperty, traceit |
| Methods inherited from class junit.framework.TestCase |
|---|
countTestCases, createResult, getName, run, run, runTest, setName, setUp, 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 |
|---|
private final TimestampArithTest.OneDiffTest[] diffBetweenTsTests
private final TimestampArithTest.OneDiffTest[] diffBetweenTsAndDateTests
private final TimestampArithTest.OneDiffTest[] diffBetweenDateAndTsTests
private final TimestampArithTest.OneAddTest[] addBetweenTsTests
private final TimestampArithTest.OneAddTest[] addBetweenDateAndTsTests
private final TimestampArithTest.OneStringDiffTest[] diffBetweenStringTests
private final TimestampArithTest.OneStringAddTest[] addBetweenStringTests
private final TimestampArithTest.OneTest[] overflowTests
private final java.lang.String[][] invalid
private static final java.lang.String[] intervalJdbcNames
private static java.sql.Statement stmt
private static java.sql.PreparedStatement[] tsAddPS
private static java.sql.PreparedStatement[] tsDiffPS
private static final int FRAC_SECOND_INTERVAL
private static final int SECOND_INTERVAL
private static final int MINUTE_INTERVAL
private static final int HOUR_INTERVAL
private static final int DAY_INTERVAL
private static final int WEEK_INTERVAL
private static final int MONTH_INTERVAL
private static final int QUARTER_INTERVAL
private static final int YEAR_INTERVAL
private static final int ONE_BILLION
private static java.lang.String TODAY
private static java.lang.String TOMORROW
private static java.lang.String YEAR_FROM_TOMORROW
private static java.lang.String YEAR_FROM_TODAY
private static java.lang.String YESTERDAY
private static java.lang.String WEEK_FROM_TODAY
| Constructor Detail |
|---|
public TimestampArithTest(java.lang.String name)
| Method Detail |
|---|
protected void initializeConnection(java.sql.Connection conn)
throws java.sql.SQLException
BaseJDBCTestCase
initializeConnection in class BaseJDBCTestCaseconn - Connection to be intialized
java.sql.SQLException - Error setting the initial state.public static junit.framework.Test suite()
public void testDiffBetweenTimestamp()
throws java.sql.SQLException
java.sql.SQLException
public void testDiffBetweenTimestampAndDate()
throws java.sql.SQLException
java.sql.SQLException
public void testDiffBetweenDateAndTimestamp()
throws java.sql.SQLException
java.sql.SQLException
public void testAddBetweenTimestamp()
throws java.sql.SQLException
java.sql.SQLException
public void testAddBetweenDateAndTimestamps()
throws java.sql.SQLException
java.sql.SQLException
public void testDiffBetweenString()
throws java.sql.SQLException
java.sql.SQLException
public void testAddBetweenString()
throws java.sql.SQLException
java.sql.SQLException
public void testOverflow()
throws java.sql.SQLException
java.sql.SQLException
public void testNullInputs()
throws java.sql.SQLException
java.sql.SQLException
public void testInvalidLengths()
throws java.sql.SQLException
java.sql.SQLException
public void testInvalidArgTypes()
throws java.sql.SQLException
java.sql.SQLException
private static void expectException(java.sql.PreparedStatement ps,
java.lang.Object obj1,
java.lang.Object obj2,
java.lang.String expectedSQLState,
java.lang.String label)
private static void expectNullResult(java.sql.PreparedStatement ps,
java.lang.String label)
private static java.lang.String isoFormatDate(java.util.Calendar cal)
private static java.lang.String dateTimeToLiteral(java.lang.Object ts)
private static java.lang.String composeSqlStr(java.lang.String fn,
int interval,
java.lang.String parm1,
java.lang.String parm2)
private static void setDateTime(java.sql.PreparedStatement ps,
int parameterIdx,
java.util.Date dateTime)
throws java.sql.SQLException
java.sql.SQLExceptionprivate static java.sql.Timestamp ts(java.lang.String s)
private static java.sql.Date dt(java.lang.String s)
|
Built on Sat 2009-11-28 18:44:18-0800, from revision 885187 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||