mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-17 00:24:57 +00:00
Improve reliability of ProposedGeneratedTests
This commit is contained in:
parent
46857f456a
commit
25d8fda12c
@ -11,6 +11,7 @@
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import org.hibernate.HibernateError;
|
||||
import org.hibernate.dialect.SybaseASEDialect;
|
||||
import org.hibernate.tuple.GenerationTiming;
|
||||
|
||||
@ -48,8 +49,8 @@ public void test(SessionFactoryScope scope) throws InterruptedException {
|
||||
|
||||
created.name = "first";
|
||||
|
||||
// Precision is in milliseconds, so sleep a bit to ensure the TS changes
|
||||
Thread.sleep( 10L );
|
||||
//We need to wait a little to make sure the timestamps produced are different
|
||||
waitALittle();
|
||||
|
||||
// then changing
|
||||
final GeneratedInstantEntity merged = scope.fromTransaction( (session) -> {
|
||||
@ -64,6 +65,9 @@ public void test(SessionFactoryScope scope) throws InterruptedException {
|
||||
|
||||
assertThat( merged ).isNotNull();
|
||||
|
||||
//We need to wait a little to make sure the timestamps produced are different
|
||||
waitALittle();
|
||||
|
||||
// lastly, make sure we can load it..
|
||||
final GeneratedInstantEntity loaded = scope.fromTransaction( (session) -> {
|
||||
return session.get( GeneratedInstantEntity.class, 1 );
|
||||
@ -98,4 +102,14 @@ public GeneratedInstantEntity(Integer id, String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
private static void waitALittle() {
|
||||
try {
|
||||
Thread.sleep( 10 );
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
throw new HibernateError( "Unexpected wakeup from test sleep" );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user