Fix broken tests on Jenkins
This commit is contained in:
parent
62e499538c
commit
a00a30f488
|
@ -99,16 +99,16 @@ public class JdbcTimeCustomTimeZoneTest
|
|||
calendarArgumentCaptor.getValue().getTimeZone()
|
||||
);
|
||||
}
|
||||
catch (SQLException e) {
|
||||
catch ( SQLException e ) {
|
||||
fail( e.getMessage() );
|
||||
}
|
||||
|
||||
connectionProvider.clear();
|
||||
doInHibernate( this::sessionFactory, s -> {
|
||||
s.doWork( connection -> {
|
||||
try (Statement st = connection.createStatement()) {
|
||||
try (ResultSet rs = st.executeQuery(
|
||||
"select createdOn from Person" )) {
|
||||
try ( Statement st = connection.createStatement() ) {
|
||||
try ( ResultSet rs = st.executeQuery(
|
||||
"select createdOn from Person" ) ) {
|
||||
while ( rs.next() ) {
|
||||
Time time = rs.getTime( 1 );
|
||||
Time offsetTime = Time.valueOf( OffsetTime.ofInstant(
|
||||
|
|
|
@ -73,7 +73,7 @@ public class JdbcTimeDefaultTimeZoneTest
|
|||
try {
|
||||
verify( ps, times( 1 ) ).setTime( anyInt(), any( Time.class ) );
|
||||
}
|
||||
catch (SQLException e) {
|
||||
catch ( SQLException e ) {
|
||||
fail( e.getMessage() );
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,9 @@ public class JdbcTimestampCustomSessionLevelTimeZoneTest
|
|||
public void testTimeZone() {
|
||||
|
||||
connectionProvider.clear();
|
||||
doInHibernateSessionBuilder( () -> {return sessionFactory().withOptions().jdbcTimeZone( TIME_ZONE);}, s -> {
|
||||
doInHibernateSessionBuilder( () -> {
|
||||
return sessionFactory().withOptions().jdbcTimeZone( TIME_ZONE );
|
||||
}, s -> {
|
||||
Person person = new Person();
|
||||
person.id = 1L;
|
||||
s.persist( person );
|
||||
|
@ -92,16 +94,18 @@ public class JdbcTimestampCustomSessionLevelTimeZoneTest
|
|||
calendarArgumentCaptor.getValue().getTimeZone()
|
||||
);
|
||||
}
|
||||
catch (SQLException e) {
|
||||
catch ( SQLException e ) {
|
||||
fail( e.getMessage() );
|
||||
}
|
||||
|
||||
connectionProvider.clear();
|
||||
doInHibernateSessionBuilder( () -> {return sessionFactory().withOptions().jdbcTimeZone( TIME_ZONE);}, s -> {
|
||||
doInHibernateSessionBuilder( () -> {
|
||||
return sessionFactory().withOptions().jdbcTimeZone( TIME_ZONE );
|
||||
}, s -> {
|
||||
s.doWork( connection -> {
|
||||
try (Statement st = connection.createStatement()) {
|
||||
try (ResultSet rs = st.executeQuery(
|
||||
"select createdOn from Person" )) {
|
||||
try ( Statement st = connection.createStatement() ) {
|
||||
try ( ResultSet rs = st.executeQuery(
|
||||
"select createdOn from Person" ) ) {
|
||||
while ( rs.next() ) {
|
||||
Timestamp timestamp = rs.getTimestamp( 1 );
|
||||
int offsetDiff = TimeZone.getDefault()
|
||||
|
|
|
@ -96,16 +96,16 @@ public class JdbcTimestampCustomTimeZoneTest
|
|||
calendarArgumentCaptor.getValue().getTimeZone()
|
||||
);
|
||||
}
|
||||
catch (SQLException e) {
|
||||
catch ( SQLException e ) {
|
||||
fail( e.getMessage() );
|
||||
}
|
||||
|
||||
connectionProvider.clear();
|
||||
doInHibernate( this::sessionFactory, s -> {
|
||||
s.doWork( connection -> {
|
||||
try (Statement st = connection.createStatement()) {
|
||||
try (ResultSet rs = st.executeQuery(
|
||||
"select createdOn from Person" )) {
|
||||
try ( Statement st = connection.createStatement() ) {
|
||||
try ( ResultSet rs = st.executeQuery(
|
||||
"select createdOn from Person" ) ) {
|
||||
while ( rs.next() ) {
|
||||
Timestamp timestamp = rs.getTimestamp( 1 );
|
||||
int offsetDiff = TimeZone.getDefault()
|
||||
|
|
|
@ -76,7 +76,7 @@ public class JdbcTimestampDefaultTimeZoneTest
|
|||
any( Timestamp.class )
|
||||
);
|
||||
}
|
||||
catch (SQLException e) {
|
||||
catch ( SQLException e ) {
|
||||
fail( e.getMessage() );
|
||||
}
|
||||
|
||||
|
|
|
@ -10,16 +10,20 @@ import java.util.Map;
|
|||
import java.util.TimeZone;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.dialect.PostgreSQL82Dialect;
|
||||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.test.util.jdbc.TimeZoneConnectionProvider;
|
||||
|
||||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@RequiresDialect(value = PostgreSQL82Dialect.class)
|
||||
public class JdbcTimestampUTCTimeZoneTest
|
||||
extends JdbcTimestampWithoutUTCTimeZoneTest {
|
||||
|
||||
private TimeZoneConnectionProvider connectionProvider = new TimeZoneConnectionProvider( "America/Los_Angeles" );
|
||||
private TimeZoneConnectionProvider connectionProvider = new TimeZoneConnectionProvider(
|
||||
"America/Los_Angeles" );
|
||||
|
||||
private static final TimeZone TIME_ZONE = TimeZone.getTimeZone( "UTC" );
|
||||
|
||||
|
|
|
@ -9,16 +9,20 @@ package org.hibernate.test.timestamp;
|
|||
import java.util.Map;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.dialect.PostgreSQL82Dialect;
|
||||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.test.util.jdbc.TimeZoneConnectionProvider;
|
||||
|
||||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@RequiresDialect(value = PostgreSQL82Dialect.class)
|
||||
public class JdbcTimestampWithDefaultUTCTimeZoneTest
|
||||
extends JdbcTimestampWithoutUTCTimeZoneTest {
|
||||
|
||||
private TimeZoneConnectionProvider connectionProvider = new TimeZoneConnectionProvider( "UTC" );
|
||||
private TimeZoneConnectionProvider connectionProvider = new TimeZoneConnectionProvider(
|
||||
"UTC" );
|
||||
|
||||
@Override
|
||||
protected void addSettings(Map settings) {
|
||||
|
|
|
@ -29,11 +29,12 @@ import static org.junit.Assert.assertEquals;
|
|||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@RequiresDialect( value = PostgreSQL82Dialect.class)
|
||||
@RequiresDialect(value = PostgreSQL82Dialect.class)
|
||||
public class JdbcTimestampWithoutUTCTimeZoneTest
|
||||
extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
private TimeZoneConnectionProvider connectionProvider = new TimeZoneConnectionProvider( "America/Los_Angeles" );
|
||||
private TimeZoneConnectionProvider connectionProvider = new TimeZoneConnectionProvider(
|
||||
"America/Los_Angeles" );
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
|
@ -65,21 +66,21 @@ public class JdbcTimestampWithoutUTCTimeZoneTest
|
|||
.atZone( ZoneId.of( "UTC" ) )
|
||||
.toInstant()
|
||||
.toEpochMilli();
|
||||
assertEquals(946684800000L, y2kMillis);
|
||||
assertEquals( 946684800000L, y2kMillis );
|
||||
|
||||
person.createdOn = new Timestamp(y2kMillis);
|
||||
person.createdOn = new Timestamp( y2kMillis );
|
||||
session.persist( person );
|
||||
|
||||
} );
|
||||
doInHibernate( this::sessionFactory, s -> {
|
||||
s.doWork( connection -> {
|
||||
try (Statement st = connection.createStatement()) {
|
||||
try (ResultSet rs = st.executeQuery(
|
||||
try ( Statement st = connection.createStatement() ) {
|
||||
try ( ResultSet rs = st.executeQuery(
|
||||
"SELECT to_char(createdon, 'YYYY-MM-DD HH24:MI:SS.US') " +
|
||||
"FROM person" )) {
|
||||
"FROM person" ) ) {
|
||||
while ( rs.next() ) {
|
||||
String timestamp = rs.getString( 1 );
|
||||
assertEquals(expectedTimestampValue(), timestamp);
|
||||
assertEquals( expectedTimestampValue(), timestamp );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue