[#2271] jOOQ integration tests fail when not run in CET / CEST
This commit is contained in:
parent
9fb08f7d39
commit
9cba0ba771
@ -783,6 +783,26 @@ public abstract class BaseTest<
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
protected final String zeroDate() {
|
||||
return new Date(0).toString();
|
||||
}
|
||||
|
||||
protected final String zeroDatePlusOneDay() {
|
||||
return new Date(1000L * 60L * 60L * 24L).toString();
|
||||
}
|
||||
|
||||
protected final String zeroDatePlusTwoDays() {
|
||||
return new Date(1000L * 60L * 60L * 48L).toString();
|
||||
}
|
||||
|
||||
protected final String zeroTime() {
|
||||
return new Time(0).toString();
|
||||
}
|
||||
|
||||
protected final String zeroTimestamp() {
|
||||
return new Timestamp(0).toString();
|
||||
}
|
||||
|
||||
protected final void assertCountAuthors(int count) {
|
||||
assertEquals(count, (int) create().selectCount().from(TAuthor()).fetchOne(0, Integer.class));
|
||||
}
|
||||
|
||||
@ -104,14 +104,11 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
|
||||
public void testInsertUpdateDelete() throws Exception {
|
||||
jOOQAbstractTest.reset = false;
|
||||
|
||||
long timeIn = 0;
|
||||
long timeOut = -3600000;
|
||||
|
||||
InsertQuery<A> i = create().insertQuery(TAuthor());
|
||||
i.addValue(TAuthor_ID(), 100);
|
||||
i.addValue(TAuthor_FIRST_NAME(), "Hermann");
|
||||
i.addValue(TAuthor_LAST_NAME(), "Hesse");
|
||||
i.addValue(TAuthor_DATE_OF_BIRTH(), new Date(timeIn));
|
||||
i.addValue(TAuthor_DATE_OF_BIRTH(), Date.valueOf(zeroDate()));
|
||||
i.addValue(TAuthor_YEAR_OF_BIRTH(), 2010);
|
||||
|
||||
// Check insertion of UDTs and Enums if applicable
|
||||
@ -128,7 +125,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
|
||||
// [#1009] Somewhere on the way to the database and back, the CET time
|
||||
// zone is added, that's why there is a one-hour shift (except for SQLite)
|
||||
if (getDialect() != SQLITE)
|
||||
assertEquals(new Date(timeOut), author.getValue(TAuthor_DATE_OF_BIRTH()));
|
||||
assertEquals(Date.valueOf(zeroDate()), author.getValue(TAuthor_DATE_OF_BIRTH()));
|
||||
|
||||
Map<Field<?>, String> map = new HashMap<Field<?>, String>();
|
||||
map.put(TAuthor_FIRST_NAME(), "Hermie");
|
||||
|
||||
@ -1338,23 +1338,19 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
|
||||
|
||||
@Test
|
||||
public void testDateTime() throws Exception {
|
||||
|
||||
// [#1009] SQL DATE doesn't have a time zone. SQL TIMESTAMP does
|
||||
long tsShift = -3600000;
|
||||
|
||||
Record record =
|
||||
create().select(
|
||||
val(new Date(0)).as("d"),
|
||||
val(new Time(0)).as("t"),
|
||||
val(new Timestamp(0)).as("ts")
|
||||
val(Date.valueOf(zeroDate())).as("d"),
|
||||
val(Time.valueOf("00:00:00")).as("t"),
|
||||
val(Timestamp.valueOf(zeroTimestamp())).as("ts")
|
||||
).fetchOne();
|
||||
|
||||
// ... (except for SQLite)
|
||||
if (getDialect() != SQLITE)
|
||||
assertEquals(new Date(tsShift), record.getValue("d"));
|
||||
assertEquals(Date.valueOf(zeroDate()), record.getValue("d"));
|
||||
|
||||
assertEquals(new Time(0), record.getValue("t"));
|
||||
assertEquals(new Timestamp(0), record.getValue("ts"));
|
||||
assertEquals(Time.valueOf("00:00:00"), record.getValue("t"));
|
||||
assertEquals(Timestamp.valueOf(zeroTimestamp()), record.getValue("ts"));
|
||||
|
||||
// Interval tests
|
||||
// --------------
|
||||
|
||||
@ -298,9 +298,6 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
|
||||
// enforced. But the inserted values should at least be converted to the
|
||||
// right types
|
||||
|
||||
long timeIn = 0;
|
||||
long timeOut = -3600000;
|
||||
|
||||
// Explicit field list
|
||||
assertEquals(1,
|
||||
create().insertInto(TAuthor(),
|
||||
@ -311,7 +308,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
|
||||
.values(
|
||||
"5",
|
||||
"Smith",
|
||||
timeIn,
|
||||
0L,
|
||||
new BigDecimal("1980"))
|
||||
.execute());
|
||||
|
||||
@ -323,7 +320,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
|
||||
// [#1009] Somewhere on the way to the database and back, the CET time
|
||||
// zone is added, that's why there is a one-hour shift (except for SQLite)
|
||||
if (getDialect() != SQLITE)
|
||||
assertEquals(new Date(timeOut), author1.getValue(TAuthor_DATE_OF_BIRTH()));
|
||||
assertEquals(zeroDate(), author1.getValue(TAuthor_DATE_OF_BIRTH()));
|
||||
assertEquals(1980, (int) author1.getValue(TAuthor_YEAR_OF_BIRTH()));
|
||||
|
||||
// Implicit field list
|
||||
|
||||
@ -598,9 +598,9 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
|
||||
assertEquals("1", n[0].toString());
|
||||
assertEquals("2", n[1].toString());
|
||||
assertEquals("3", n[2].toString());
|
||||
assertEquals("1970-01-01", d[0].toString());
|
||||
assertEquals("1970-01-02", d[1].toString());
|
||||
assertEquals("1970-01-03", d[2].toString());
|
||||
assertEquals(zeroDate(), d[0].toString());
|
||||
assertEquals(zeroDatePlusOneDay(), d[1].toString());
|
||||
assertEquals(zeroDatePlusTwoDays(), d[2].toString());
|
||||
|
||||
|
||||
|
||||
@ -635,9 +635,9 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
|
||||
assertEquals("3", n[0].toString());
|
||||
assertEquals("2", n[1].toString());
|
||||
assertEquals("1", n[2].toString());
|
||||
assertEquals("1970-01-03", d[0].toString());
|
||||
assertEquals("1970-01-02", d[1].toString());
|
||||
assertEquals("1970-01-01", d[2].toString());
|
||||
assertEquals(zeroDatePlusTwoDays(), d[0].toString());
|
||||
assertEquals(zeroDatePlusOneDay(), d[1].toString());
|
||||
assertEquals(zeroDate(), d[2].toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user