Re-enabled additional tests

This commit is contained in:
Andrea Boriero 2021-10-12 13:22:33 +02:00 committed by Andrea Boriero
parent 9b48207ba0
commit 4543ab176b
3 changed files with 183 additions and 190 deletions

View File

@ -4,10 +4,25 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.joinedsubclassbatch;
package org.hibernate.orm.test.joinedsubclassbatch;
import java.io.Serializable;
import java.math.BigDecimal;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.cfg.Environment;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.persistence.Embedded;
@ -20,19 +35,8 @@ import jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType;
import jakarta.persistence.ManyToOne;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Assert;
import org.junit.Test;
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
/**
* Test batching of insert,update,delete on joined subclasses
@ -40,59 +44,57 @@ import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
* @author dcebotarenco
*/
@TestForIssue(jiraKey = "HHH-2558")
@RequiresDialectFeature(DialectChecks.SupportsIdentityColumns.class)
public class IdentityJoinedSubclassBatchingTest extends BaseCoreFunctionalTestCase {
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class[] {
Person.class,
Employee.class,
Customer.class
};
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsIdentityColumns.class)
@DomainModel(
annotatedClasses = {
IdentityJoinedSubclassBatchingTest.Person.class,
IdentityJoinedSubclassBatchingTest.Employee.class,
IdentityJoinedSubclassBatchingTest.Customer.class
}
)
@SessionFactory
@ServiceRegistry(
settings = @Setting(name = Environment.STATEMENT_BATCH_SIZE, value = "20")
)
public class IdentityJoinedSubclassBatchingTest {
@Override
public void configure(Configuration cfg) {
cfg.setProperty( Environment.STATEMENT_BATCH_SIZE, "20" );
@Test
public void doBatchInsertUpdateJoinedSubclassNrEqualWithBatch(SessionFactoryScope scope) {
doBatchInsertUpdateJoined( 20, 20, scope );
}
@Test
public void doBatchInsertUpdateJoinedSubclassNrEqualWithBatch() {
doBatchInsertUpdateJoined( 20, 20 );
public void doBatchInsertUpdateJoinedSubclassNrLessThenBatch(SessionFactoryScope scope) {
doBatchInsertUpdateJoined( 19, 20, scope );
}
@Test
public void doBatchInsertUpdateJoinedSubclassNrLessThenBatch() {
doBatchInsertUpdateJoined( 19, 20 );
public void doBatchInsertUpdateJoinedSubclassNrBiggerThenBatch(SessionFactoryScope scope) {
doBatchInsertUpdateJoined( 21, 20, scope );
}
@Test
public void doBatchInsertUpdateJoinedSubclassNrBiggerThenBatch() {
doBatchInsertUpdateJoined( 21, 20 );
public void testBatchInsertUpdateSizeEqJdbcBatchSize(SessionFactoryScope scope) {
int batchSize = scope.getSessionFactory().getSessionFactoryOptions().getJdbcBatchSize();
doBatchInsertUpdateJoined( 50, batchSize, scope );
}
@Test
public void testBatchInsertUpdateSizeEqJdbcBatchSize() {
int batchSize = sessionFactory().getSettings().getJdbcBatchSize();
doBatchInsertUpdateJoined( 50, batchSize );
public void testBatchInsertUpdateSizeLtJdbcBatchSize(SessionFactoryScope scope) {
int batchSize = scope.getSessionFactory().getSessionFactoryOptions().getJdbcBatchSize();
doBatchInsertUpdateJoined( 50, batchSize - 1, scope );
}
@Test
public void testBatchInsertUpdateSizeLtJdbcBatchSize() {
int batchSize = sessionFactory().getSettings().getJdbcBatchSize();
doBatchInsertUpdateJoined( 50, batchSize - 1 );
public void testBatchInsertUpdateSizeGtJdbcBatchSize(SessionFactoryScope scope) {
int batchSize = scope.getSessionFactory().getSessionFactoryOptions().getJdbcBatchSize();
doBatchInsertUpdateJoined( 50, batchSize + 1, scope );
}
@Test
public void testBatchInsertUpdateSizeGtJdbcBatchSize() {
int batchSize = sessionFactory().getSettings().getJdbcBatchSize();
doBatchInsertUpdateJoined( 50, batchSize + 1 );
}
public void doBatchInsertUpdateJoined(int nEntities, int nBeforeFlush, SessionFactoryScope scope) {
public void doBatchInsertUpdateJoined(int nEntities, int nBeforeFlush) {
doInHibernate( this::sessionFactory, s -> {
scope.inTransaction( s -> {
for ( int i = 0; i < nEntities; i++ ) {
Employee e = new Employee();
e.getId();
@ -110,8 +112,7 @@ public class IdentityJoinedSubclassBatchingTest extends BaseCoreFunctionalTestCa
}
} );
doInHibernate( this::sessionFactory, s -> {
int i = 0;
scope.inTransaction( s -> {
ScrollableResults sr = s.createQuery(
"select e from Employee e" )
.scroll( ScrollMode.FORWARD_ONLY );
@ -122,8 +123,7 @@ public class IdentityJoinedSubclassBatchingTest extends BaseCoreFunctionalTestCa
}
} );
doInHibernate( this::sessionFactory, s -> {
int i = 0;
scope.inTransaction( s -> {
ScrollableResults sr = s.createQuery(
"select e from Employee e" )
.scroll( ScrollMode.FORWARD_ONLY );
@ -136,10 +136,10 @@ public class IdentityJoinedSubclassBatchingTest extends BaseCoreFunctionalTestCa
}
@Test
public void testAssertSubclassInsertedSuccessfullyAfterCommit() {
public void testAssertSubclassInsertedSuccessfullyAfterCommit(SessionFactoryScope scope) {
final int nEntities = 10;
doInHibernate( this::sessionFactory, s -> {
scope.inTransaction( s -> {
for ( int i = 0; i < nEntities; i++ ) {
Employee e = new Employee();
e.setName( "Mark" );
@ -152,13 +152,12 @@ public class IdentityJoinedSubclassBatchingTest extends BaseCoreFunctionalTestCa
}
} );
doInHibernate( this::sessionFactory, s -> {
scope.inTransaction( s -> {
long numberOfInsertedEmployee = (long) s.createQuery( "select count(e) from Employee e" ).uniqueResult();
Assert.assertEquals( nEntities, numberOfInsertedEmployee );
assertEquals( nEntities, numberOfInsertedEmployee );
} );
doInHibernate( this::sessionFactory, s -> {
int i = 0;
scope.inTransaction( s -> {
ScrollableResults sr = s.createQuery(
"select e from Employee e" )
.scroll( ScrollMode.FORWARD_ONLY );
@ -172,9 +171,10 @@ public class IdentityJoinedSubclassBatchingTest extends BaseCoreFunctionalTestCa
}
@Test
public void testAssertSubclassInsertedSuccessfullyAfterFlush() {
public void testAssertSubclassInsertedSuccessfullyAfterFlush(SessionFactoryScope scope) {
scope.inTransaction( s -> {
doInHibernate( this::sessionFactory, s -> {
Employee e = new Employee();
e.setName( "Mark" );
e.setTitle( "internal sales" );
@ -186,12 +186,11 @@ public class IdentityJoinedSubclassBatchingTest extends BaseCoreFunctionalTestCa
s.flush();
long numberOfInsertedEmployee = (long) s.createQuery( "select count(e) from Employee e" ).uniqueResult();
Assert.assertEquals( 1L, numberOfInsertedEmployee );
assertEquals( 1L, numberOfInsertedEmployee );
} );
doInHibernate( this::sessionFactory, s -> {
int i = 0;
scope.inTransaction( s -> {
ScrollableResults sr = s.createQuery(
"select e from Employee e" )
.scroll( ScrollMode.FORWARD_ONLY );

View File

@ -4,10 +4,24 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.joinedsubclassbatch;
package org.hibernate.orm.test.joinedsubclassbatch;
import java.io.Serializable;
import java.math.BigDecimal;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.cfg.Environment;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.persistence.Embedded;
@ -19,76 +33,61 @@ import jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType;
import jakarta.persistence.ManyToOne;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
/**
* Test batching of insert,update,delete on joined subclasses
*
* @author dcebotarenco
*/
@TestForIssue(jiraKey = "HHH-2558")
public class JoinedSubclassBatchingTest extends BaseCoreFunctionalTestCase {
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class[] {
Person.class,
Employee.class,
Customer.class
};
@DomainModel(
annotatedClasses = {
JoinedSubclassBatchingTest.Person.class,
JoinedSubclassBatchingTest.Employee.class,
JoinedSubclassBatchingTest.Customer.class
}
)
@SessionFactory
@ServiceRegistry(
settings = @Setting(name = Environment.STATEMENT_BATCH_SIZE, value = "20")
)
public class JoinedSubclassBatchingTest {
@Override
public void configure(Configuration cfg) {
cfg.setProperty( Environment.STATEMENT_BATCH_SIZE, "20" );
@Test
public void doBatchInsertUpdateJoinedSubclassNrEqualWithBatch(SessionFactoryScope scope) {
doBatchInsertUpdateJoined( 20, 20, scope );
}
@Test
public void doBatchInsertUpdateJoinedSubclassNrEqualWithBatch() {
doBatchInsertUpdateJoined( 20, 20 );
public void doBatchInsertUpdateJoinedSubclassNrLessThenBatch(SessionFactoryScope scope) {
doBatchInsertUpdateJoined( 19, 20, scope );
}
@Test
public void doBatchInsertUpdateJoinedSubclassNrLessThenBatch() {
doBatchInsertUpdateJoined( 19, 20 );
public void doBatchInsertUpdateJoinedSubclassNrBiggerThenBatch(SessionFactoryScope scope) {
doBatchInsertUpdateJoined( 21, 20, scope );
}
@Test
public void doBatchInsertUpdateJoinedSubclassNrBiggerThenBatch() {
doBatchInsertUpdateJoined( 21, 20 );
public void testBatchInsertUpdateSizeEqJdbcBatchSize(SessionFactoryScope scope) {
int batchSize = scope.getSessionFactory().getSessionFactoryOptions().getJdbcBatchSize();
doBatchInsertUpdateJoined( 50, batchSize, scope );
}
@Test
public void testBatchInsertUpdateSizeEqJdbcBatchSize() {
int batchSize = sessionFactory().getSettings().getJdbcBatchSize();
doBatchInsertUpdateJoined( 50, batchSize );
public void testBatchInsertUpdateSizeLtJdbcBatchSize(SessionFactoryScope scope) {
int batchSize = scope.getSessionFactory().getSessionFactoryOptions().getJdbcBatchSize();
doBatchInsertUpdateJoined( 50, batchSize - 1, scope );
}
@Test
public void testBatchInsertUpdateSizeLtJdbcBatchSize() {
int batchSize = sessionFactory().getSettings().getJdbcBatchSize();
doBatchInsertUpdateJoined( 50, batchSize - 1 );
public void testBatchInsertUpdateSizeGtJdbcBatchSize(SessionFactoryScope scope) {
int batchSize = scope.getSessionFactory().getSessionFactoryOptions().getJdbcBatchSize();
doBatchInsertUpdateJoined( 50, batchSize + 1, scope );
}
@Test
public void testBatchInsertUpdateSizeGtJdbcBatchSize() {
int batchSize = sessionFactory().getSettings().getJdbcBatchSize();
doBatchInsertUpdateJoined( 50, batchSize + 1 );
}
public void doBatchInsertUpdateJoined(int nEntities, int nBeforeFlush, SessionFactoryScope scope) {
public void doBatchInsertUpdateJoined(int nEntities, int nBeforeFlush) {
doInHibernate( this::sessionFactory, s -> {
scope.inTransaction( s -> {
for ( int i = 0; i < nEntities; i++ ) {
Employee e = new Employee();
e.getId();
@ -106,8 +105,7 @@ public class JoinedSubclassBatchingTest extends BaseCoreFunctionalTestCase {
}
} );
doInHibernate( this::sessionFactory, s -> {
int i = 0;
scope.inTransaction( s -> {
ScrollableResults sr = s.createQuery(
"select e from Employee e" )
.scroll( ScrollMode.FORWARD_ONLY );
@ -118,8 +116,7 @@ public class JoinedSubclassBatchingTest extends BaseCoreFunctionalTestCase {
}
} );
doInHibernate( this::sessionFactory, s -> {
int i = 0;
scope.inTransaction( s -> {
ScrollableResults sr = s.createQuery(
"select e from Employee e" )
.scroll( ScrollMode.FORWARD_ONLY );

View File

@ -4,10 +4,25 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.joinedsubclassbatch;
package org.hibernate.orm.test.joinedsubclassbatch;
import java.io.Serializable;
import java.math.BigDecimal;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.cfg.Environment;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.persistence.Embedded;
@ -20,19 +35,7 @@ import jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType;
import jakarta.persistence.ManyToOne;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Assert;
import org.junit.Test;
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test batching of insert,update,delete on joined subclasses using SEQUENCE
@ -40,59 +43,56 @@ import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
* @author Vlad Mihalcea
*/
@TestForIssue(jiraKey = "HHH-12968\n")
@RequiresDialectFeature(DialectChecks.SupportsSequences.class)
public class SequenceJoinedSubclassBatchingTest extends BaseCoreFunctionalTestCase {
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class[] {
Person.class,
Employee.class,
Customer.class
};
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsSequences.class)
@DomainModel(
annotatedClasses = {
SequenceJoinedSubclassBatchingTest.Person.class,
SequenceJoinedSubclassBatchingTest.Employee.class,
SequenceJoinedSubclassBatchingTest.Customer.class
}
)
@SessionFactory
@ServiceRegistry(
settings = @Setting(name = Environment.STATEMENT_BATCH_SIZE, value = "20")
)
public class SequenceJoinedSubclassBatchingTest {
@Override
public void configure(Configuration cfg) {
cfg.setProperty( Environment.STATEMENT_BATCH_SIZE, "20" );
@Test
public void doBatchInsertUpdateJoinedSubclassNrEqualWithBatch(SessionFactoryScope scope) {
doBatchInsertUpdateJoined( 20, 20, scope );
}
@Test
public void doBatchInsertUpdateJoinedSubclassNrEqualWithBatch() {
doBatchInsertUpdateJoined( 20, 20 );
public void doBatchInsertUpdateJoinedSubclassNrLessThenBatch(SessionFactoryScope scope) {
doBatchInsertUpdateJoined( 19, 20, scope );
}
@Test
public void doBatchInsertUpdateJoinedSubclassNrLessThenBatch() {
doBatchInsertUpdateJoined( 19, 20 );
public void doBatchInsertUpdateJoinedSubclassNrBiggerThenBatch(SessionFactoryScope scope) {
doBatchInsertUpdateJoined( 21, 20, scope );
}
@Test
public void doBatchInsertUpdateJoinedSubclassNrBiggerThenBatch() {
doBatchInsertUpdateJoined( 21, 20 );
public void testBatchInsertUpdateSizeEqJdbcBatchSize(SessionFactoryScope scope) {
int batchSize = scope.getSessionFactory().getSessionFactoryOptions().getJdbcBatchSize();
doBatchInsertUpdateJoined( 50, batchSize, scope );
}
@Test
public void testBatchInsertUpdateSizeEqJdbcBatchSize() {
int batchSize = sessionFactory().getSettings().getJdbcBatchSize();
doBatchInsertUpdateJoined( 50, batchSize );
public void testBatchInsertUpdateSizeLtJdbcBatchSize(SessionFactoryScope scope) {
int batchSize = scope.getSessionFactory().getSessionFactoryOptions().getJdbcBatchSize();
doBatchInsertUpdateJoined( 50, batchSize - 1, scope );
}
@Test
public void testBatchInsertUpdateSizeLtJdbcBatchSize() {
int batchSize = sessionFactory().getSettings().getJdbcBatchSize();
doBatchInsertUpdateJoined( 50, batchSize - 1 );
public void testBatchInsertUpdateSizeGtJdbcBatchSize(SessionFactoryScope scope) {
int batchSize = scope.getSessionFactory().getSessionFactoryOptions().getJdbcBatchSize();
doBatchInsertUpdateJoined( 50, batchSize + 1, scope );
}
@Test
public void testBatchInsertUpdateSizeGtJdbcBatchSize() {
int batchSize = sessionFactory().getSettings().getJdbcBatchSize();
doBatchInsertUpdateJoined( 50, batchSize + 1 );
}
public void doBatchInsertUpdateJoined(int nEntities, int nBeforeFlush, SessionFactoryScope scope) {
public void doBatchInsertUpdateJoined(int nEntities, int nBeforeFlush) {
doInHibernate( this::sessionFactory, s -> {
scope.inTransaction( s -> {
for ( int i = 0; i < nEntities; i++ ) {
Employee e = new Employee();
e.getId();
@ -110,8 +110,7 @@ public class SequenceJoinedSubclassBatchingTest extends BaseCoreFunctionalTestCa
}
} );
doInHibernate( this::sessionFactory, s -> {
int i = 0;
scope.inTransaction( s -> {
ScrollableResults sr = s.createQuery(
"select e from Employee e" )
.scroll( ScrollMode.FORWARD_ONLY );
@ -122,8 +121,7 @@ public class SequenceJoinedSubclassBatchingTest extends BaseCoreFunctionalTestCa
}
} );
doInHibernate( this::sessionFactory, s -> {
int i = 0;
scope.inTransaction( s -> {
ScrollableResults sr = s.createQuery(
"select e from Employee e" )
.scroll( ScrollMode.FORWARD_ONLY );
@ -136,9 +134,9 @@ public class SequenceJoinedSubclassBatchingTest extends BaseCoreFunctionalTestCa
}
@Test
public void testAssertSubclassInsertedSuccessfullyAfterFlush() {
public void testAssertSubclassInsertedSuccessfullyAfterFlush(SessionFactoryScope scope) {
doInHibernate( this::sessionFactory, s -> {
scope.inTransaction( s -> {
Employee e = new Employee();
e.setName( "Mark" );
e.setTitle( "internal sales" );
@ -150,12 +148,11 @@ public class SequenceJoinedSubclassBatchingTest extends BaseCoreFunctionalTestCa
s.flush();
long numberOfInsertedEmployee = (long) s.createQuery( "select count(e) from Employee e" ).uniqueResult();
Assert.assertEquals( 1L, numberOfInsertedEmployee );
assertEquals( 1L, numberOfInsertedEmployee );
} );
doInHibernate( this::sessionFactory, s -> {
int i = 0;
scope.inTransaction( s -> {
ScrollableResults sr = s.createQuery(
"select e from Employee e" )
.scroll( ScrollMode.FORWARD_ONLY );