HHH-11712 - Minor changes to test case
This commit is contained in:
parent
8ebf3039ef
commit
1752da008e
|
@ -294,8 +294,8 @@ public class NegativeValueSequenceTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-11709" )
|
||||
public void testNegativeTwoDecrementAllocationSizePooledOptimizer() {
|
||||
@TestForIssue( jiraKey = "HHH-11712" )
|
||||
public void testNegativeTwoAllocationSizePositiveStartNoopOptimizer() {
|
||||
ServiceRegistryImplementor serviceRegistry = null;
|
||||
SessionFactoryImplementor sessionFactory = null;
|
||||
Session session = null;
|
||||
|
@ -303,21 +303,28 @@ public class NegativeValueSequenceTest {
|
|||
serviceRegistry = (ServiceRegistryImplementor) new StandardServiceRegistryBuilder()
|
||||
.applySetting( AvailableSettings.HBM2DDL_AUTO, "create-drop" )
|
||||
.build();
|
||||
|
||||
Triggerable triggerable = logInspection.watchForLogMessages( "HHH000116" );
|
||||
|
||||
Metadata metadata = new MetadataSources( serviceRegistry )
|
||||
.addAnnotatedClass( NegativeTwoDecrementSize.class )
|
||||
.addAnnotatedClass( NegativeTwoIncrementSizePositiveInitialValue.class )
|
||||
.buildMetadata();
|
||||
|
||||
// NegativeTwoIncrementSizePositiveInitialValue ID has allocationSize == -2, so warning should be triggered.
|
||||
assertEquals( true, triggerable.wasTriggered() );
|
||||
|
||||
sessionFactory = (SessionFactoryImplementor) metadata.buildSessionFactory();
|
||||
|
||||
assertOptimizer( sessionFactory, NegativeTwoDecrementSize.class, NoopOptimizer.class );
|
||||
assertOptimizer( sessionFactory, NegativeTwoIncrementSizePositiveInitialValue.class, NoopOptimizer.class );
|
||||
|
||||
session = sessionFactory.openSession();
|
||||
session.getTransaction().begin();
|
||||
|
||||
// initial value is 5; sequence should be decremented by 1
|
||||
// (since NoopOptimizer positive default allocationSize is 1)
|
||||
// (since negative NoopOptimizer negative default is -1)
|
||||
for ( Integer i = 5; i <= -5; i-- ) {
|
||||
NegativeTwoDecrementSize theEntity = new NegativeTwoDecrementSize();
|
||||
NegativeTwoIncrementSizePositiveInitialValue theEntity =
|
||||
new NegativeTwoIncrementSizePositiveInitialValue();
|
||||
session.persist( theEntity );
|
||||
assertEquals( i, theEntity.id );
|
||||
}
|
||||
|
@ -389,12 +396,12 @@ public class NegativeValueSequenceTest {
|
|||
public Integer id;
|
||||
}
|
||||
|
||||
@Entity( name = "NegativeTwoDecrementSize" )
|
||||
@Table( name = "NegativeTwoDecrementSize" )
|
||||
public static class NegativeTwoDecrementSize {
|
||||
@Entity( name = "NegativeTwoIncrSizePosStart" )
|
||||
@Table( name = "NegativeTwoIncrSizePosStart" )
|
||||
public static class NegativeTwoIncrementSizePositiveInitialValue {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ID_GENERATOR")
|
||||
@SequenceGenerator(name = "ID_GENERATOR", sequenceName = "POS_TWO_SEQ", initialValue= 5, allocationSize = -2)
|
||||
@SequenceGenerator(name = "ID_GENERATOR", sequenceName = "NEG_TWO_INCR_POS_START_SEQ", initialValue= 5, allocationSize = -2)
|
||||
public Integer id;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue