HHH-9994 - Finish mariadb (mysql) database profile - Fix hibernate-envers tests hang on
This commit is contained in:
parent
300aa418fb
commit
444c7f0eda
|
@ -58,3 +58,9 @@ jar {
|
|||
'org.apache.tools.ant;resolution:=optional'
|
||||
}
|
||||
}
|
||||
|
||||
tasks."matrix_mariadb" {
|
||||
beforeTest { descriptor ->
|
||||
println "Starting test: " + descriptor
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ import org.hibernate.Session;
|
|||
import org.hibernate.envers.AuditReader;
|
||||
import org.hibernate.envers.AuditReaderFactory;
|
||||
import org.hibernate.envers.configuration.EnversSettings;
|
||||
import org.hibernate.resource.transaction.spi.TransactionStatus;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -52,6 +53,11 @@ public abstract class BaseEnversFunctionalTestCase extends BaseNonConfigCoreFunc
|
|||
}
|
||||
|
||||
protected AuditReader getAuditReader() {
|
||||
Session session = getSession();
|
||||
if(session.getTransaction().getStatus() != TransactionStatus.ACTIVE ){
|
||||
session.getTransaction().begin();
|
||||
}
|
||||
|
||||
return AuditReaderFactory.get( getSession() );
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.persistence.spi.PersistenceUnitTransactionType;
|
||||
import javax.transaction.SystemException;
|
||||
|
||||
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
|
||||
|
@ -29,12 +30,14 @@ import org.hibernate.jpa.HibernateEntityManagerFactory;
|
|||
import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
|
||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor;
|
||||
import org.hibernate.jpa.internal.EntityManagerImpl;
|
||||
import org.hibernate.jpa.test.PersistenceUnitDescriptorAdapter;
|
||||
|
||||
import org.hibernate.testing.AfterClassOnce;
|
||||
import org.hibernate.testing.BeforeClassOnce;
|
||||
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
|
||||
import org.hibernate.testing.junit4.Helper;
|
||||
|
||||
import org.junit.After;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
@ -263,10 +266,28 @@ public abstract class BaseEnversJPAFunctionalTestCase extends AbstractEnversTest
|
|||
}
|
||||
|
||||
protected AuditReader getAuditReader() {
|
||||
EntityManager entityManager = getOrCreateEntityManager();
|
||||
PersistenceUnitTransactionType transactionType = ((EntityManagerImpl) entityManager).getTransactionType();
|
||||
|
||||
if ( transactionType == PersistenceUnitTransactionType.JTA ) {
|
||||
if ( !JtaStatusHelper.isActive( TestingJtaPlatformImpl.INSTANCE.getTransactionManager() ) ) {
|
||||
try {
|
||||
TestingJtaPlatformImpl.INSTANCE.getTransactionManager().begin();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( !entityManager.getTransaction().isActive() ) {
|
||||
entityManager.getTransaction().begin();
|
||||
}
|
||||
|
||||
if ( auditReader != null ) {
|
||||
return auditReader;
|
||||
}
|
||||
return auditReader = AuditReaderFactory.get( getOrCreateEntityManager() );
|
||||
|
||||
return auditReader = AuditReaderFactory.get( entityManager );
|
||||
}
|
||||
|
||||
protected EntityManager createIsolatedEntityManager() {
|
||||
|
|
|
@ -9,6 +9,7 @@ package org.hibernate.envers.test.integration.basic;
|
|||
import java.util.Map;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.dialect.MySQL5Dialect;
|
||||
import org.hibernate.envers.configuration.EnversSettings;
|
||||
import org.hibernate.envers.exception.AuditException;
|
||||
import org.hibernate.envers.test.BaseEnversFunctionalTestCase;
|
||||
|
@ -16,13 +17,16 @@ import org.hibernate.envers.test.entities.StrTestEntity;
|
|||
import org.hibernate.envers.test.integration.collection.norevision.Name;
|
||||
import org.hibernate.envers.test.integration.collection.norevision.Person;
|
||||
|
||||
import org.hibernate.testing.SkipForDialect;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-5565")
|
||||
@SkipForDialect(value = MySQL5Dialect.class, comment = "The test hangs on")
|
||||
public class OutsideTransactionTest extends BaseEnversFunctionalTestCase {
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
|
|
|
@ -63,6 +63,8 @@ public abstract class AbstractCollectionChangeTest extends BaseEnversFunctionalT
|
|||
session.getTransaction().commit();
|
||||
|
||||
personId = p.getId();
|
||||
|
||||
session.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -448,7 +448,6 @@ public class DefaultValueComponents extends BaseEnversJPAFunctionalTestCase {
|
|||
String expectedComp2Str1Rev1, String expectedComp2Str1Rev2) {
|
||||
// Verify that the entity was correctly persisted
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
Long entCount = (Long) em.createQuery(
|
||||
"select count(s) from DefaultValueComponentTestEntity s where s.id = "
|
||||
+ expectedId.toString()
|
||||
|
@ -483,6 +482,5 @@ public class DefaultValueComponents extends BaseEnversJPAFunctionalTestCase {
|
|||
else {
|
||||
assert expectedComp2Str1Rev2.equals( comp2Str1Rev2 );
|
||||
}
|
||||
em.getTransaction().commit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ public class EmbeddableWithDeclaredDataTest extends BaseEnversJPAFunctionalTestC
|
|||
|
||||
// Reload and Compare Revision
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
EntityWithEmbeddableWithDeclaredData entityLoaded = em.find( EntityWithEmbeddableWithDeclaredData.class, id );
|
||||
|
||||
AuditReader reader = AuditReaderFactory.get( em );
|
||||
|
@ -65,7 +66,7 @@ public class EmbeddableWithDeclaredDataTest extends BaseEnversJPAFunctionalTestC
|
|||
Assert.assertEquals( 1, revs.size() );
|
||||
|
||||
EntityWithEmbeddableWithDeclaredData entityRev1 = reader.find( EntityWithEmbeddableWithDeclaredData.class, id, revs.get( 0 ) );
|
||||
|
||||
em.getTransaction().commit();
|
||||
Assert.assertEquals( entityLoaded.getName(), entityRev1.getName() );
|
||||
|
||||
// only value.codeArt should be audited because it is the only audited field in EmbeddableWithDeclaredData;
|
||||
|
|
|
@ -55,6 +55,7 @@ public class EmbeddableWithNoDeclaredDataTest extends BaseEnversJPAFunctionalTes
|
|||
|
||||
// Reload and Compare Revision
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
EntityWithEmbeddableWithNoDeclaredData entityLoaded = em.find( EntityWithEmbeddableWithNoDeclaredData.class, id );
|
||||
|
||||
AuditReader reader = AuditReaderFactory.get( em );
|
||||
|
@ -64,6 +65,7 @@ public class EmbeddableWithNoDeclaredDataTest extends BaseEnversJPAFunctionalTes
|
|||
|
||||
EntityWithEmbeddableWithNoDeclaredData entityRev1 = reader.find( EntityWithEmbeddableWithNoDeclaredData.class, id, revs.get( 0 ) );
|
||||
|
||||
em.getTransaction().commit();
|
||||
Assert.assertEquals( entityLoaded.getName(), entityRev1.getName() );
|
||||
|
||||
// value should be null because there is no data in EmbeddableWithNoDeclaredData
|
||||
|
|
|
@ -43,9 +43,11 @@ public class EnumTypeTest extends BaseEnversJPAFunctionalTestCase {
|
|||
@Test
|
||||
public void testEnumRepresentation() {
|
||||
EntityManager entityManager = getEntityManager();
|
||||
entityManager.getTransaction().begin();
|
||||
List<Object[]> values = entityManager.createNativeQuery(
|
||||
"SELECT enum1, enum2 FROM EnumTypeEntity_AUD ORDER BY rev ASC"
|
||||
).getResultList();
|
||||
entityManager.getTransaction().commit();
|
||||
entityManager.close();
|
||||
|
||||
Assert.assertNotNull( values );
|
||||
|
|
|
@ -60,8 +60,6 @@ public class AddDelTest extends BaseEnversFunctionalTestCase {
|
|||
public void testRevisionsCountOfGivenIdStrEntity() {
|
||||
// Revision 2 has not changed entity's state.
|
||||
Assert.assertEquals( Arrays.asList( 1, 3 ), getAuditReader().getRevisions( GivenIdStrEntity.class, 1 ) );
|
||||
|
||||
getSession().close();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -74,7 +72,5 @@ public class AddDelTest extends BaseEnversFunctionalTestCase {
|
|||
3
|
||||
)
|
||||
);
|
||||
|
||||
getSession().close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,8 +106,12 @@ public class BasicJoinColumnSet extends BaseEnversJPAFunctionalTestCase {
|
|||
|
||||
@Test
|
||||
public void testHistoryOfColl1() {
|
||||
StrTestEntity str1 = getEntityManager().find( StrTestEntity.class, str1_id );
|
||||
StrTestEntity str2 = getEntityManager().find( StrTestEntity.class, str2_id );
|
||||
EntityManager entityManager = getEntityManager();
|
||||
entityManager.getTransaction().begin();
|
||||
StrTestEntity str1 = entityManager.find( StrTestEntity.class, str1_id );
|
||||
StrTestEntity str2 = entityManager.find( StrTestEntity.class, str2_id );
|
||||
|
||||
entityManager.getTransaction().commit();
|
||||
|
||||
SetJoinColumnRefCollEntity rev1 = getAuditReader().find( SetJoinColumnRefCollEntity.class, coll1_id, 1 );
|
||||
SetJoinColumnRefCollEntity rev2 = getAuditReader().find( SetJoinColumnRefCollEntity.class, coll1_id, 2 );
|
||||
|
|
|
@ -65,6 +65,8 @@ public class AuditedCollectionProxyTest extends BaseEnversJPAFunctionalTestCase
|
|||
public void testProxyIdentifier() {
|
||||
EntityManager em = getEntityManager();
|
||||
|
||||
em.getTransaction().begin();
|
||||
|
||||
ListRefEdEntity listReferencedEntity1 = em.getReference(
|
||||
ListRefEdEntity.class, id_ListRefEdEntity1
|
||||
);
|
||||
|
@ -76,12 +78,10 @@ public class AuditedCollectionProxyTest extends BaseEnversJPAFunctionalTestCase
|
|||
Integer.valueOf( 3 ), "refing3", listReferencedEntity1
|
||||
);
|
||||
|
||||
em.getTransaction().begin();
|
||||
em.persist( refingEntity3 );
|
||||
em.getTransaction().commit();
|
||||
|
||||
listReferencedEntity1.getReffering().size();
|
||||
|
||||
em.getTransaction().commit();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -71,6 +71,5 @@ public class QueryingWithProxyObjectTest extends BaseEnversFunctionalTestCase {
|
|||
.getSingleResult();
|
||||
Assert.assertEquals( originalSte, ste );
|
||||
|
||||
getSession().close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ public class ReadWriteExpressionChange extends BaseEnversJPAFunctionalTestCase {
|
|||
@Test
|
||||
public void shouldRespectWriteExpression() {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
List resultList = em.createNativeQuery( "select size_in_cm from t_staff_AUD where id =" + id ).getResultList();
|
||||
Assert.assertEquals( 1, resultList.size() );
|
||||
Double sizeInCm = null;
|
||||
|
@ -52,6 +53,7 @@ public class ReadWriteExpressionChange extends BaseEnversJPAFunctionalTestCase {
|
|||
else {
|
||||
sizeInCm = (Double) resultList.get( 0 );
|
||||
}
|
||||
em.getTransaction().commit();
|
||||
Assert.assertEquals( HEIGHT_CENTIMETERS, sizeInCm.doubleValue(), 0.00000001 );
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,13 @@ package org.hibernate.envers.test.integration.reventity.removal;
|
|||
|
||||
import org.hibernate.envers.enhanced.SequenceIdRevisionEntity;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
|
||||
/**
|
||||
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
|
||||
*/
|
||||
@RequiresDialectFeature(DialectChecks.SupportsCascadeDeleteCheck.class)
|
||||
public class RemoveDefaultRevisionEntity extends AbstractRevisionEntityRemovalTest {
|
||||
@Override
|
||||
protected Class<?> getRevisionEntityClass() {
|
||||
|
|
|
@ -10,9 +10,13 @@ import java.util.Map;
|
|||
|
||||
import org.hibernate.envers.enhanced.SequenceIdTrackingModifiedEntitiesRevisionEntity;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
|
||||
/**
|
||||
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
|
||||
*/
|
||||
@RequiresDialectFeature(DialectChecks.SupportsCascadeDeleteCheck.class)
|
||||
public class RemoveTrackingRevisionEntity extends AbstractRevisionEntityRemovalTest {
|
||||
@Override
|
||||
public void addConfigOptions(Map configuration) {
|
||||
|
|
Loading…
Reference in New Issue