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