Re-enabled additional tests

This commit is contained in:
Andrea Boriero 2022-02-16 15:19:05 +01:00 committed by Andrea Boriero
parent 32ee43cfe7
commit 8ed1ed5159
2 changed files with 17 additions and 20 deletions

View File

@ -23,8 +23,6 @@ import org.hibernate.stat.Statistics;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.jdbc.SQLStatementInspector;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.FailureExpected;
import org.hibernate.testing.orm.junit.NotImplementedYet;
import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
@ -206,7 +204,6 @@ public class MultiLoadTest {
@Test
@TestForIssue(jiraKey = "HHH-12944")
@NotImplementedYet(strict = false, reason = "Caching/CacheMode supported not yet implemented")
public void testMultiLoadFrom2ndLevelCache(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear();
@ -261,7 +258,6 @@ public class MultiLoadTest {
@Test
@TestForIssue(jiraKey = "HHH-12944")
@NotImplementedYet(strict = false, reason = "Caching/CacheMode supported not yet implemented")
public void testUnorderedMultiLoadFrom2ndLevelCache(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear();
@ -450,25 +446,19 @@ public class MultiLoadTest {
}
@Test
@NotImplementedYet(strict = false, reason = "CacheMode not yet implemented")
public void testMultiLoadWithCacheModeIgnore(SessionFactoryScope scope) {
// do the multi-load, telling Hibernate to IGNORE the L2 cache -
// the end result should be that the cache is (still) empty afterwards
scope.inTransaction(
session -> {
session.getTransaction().begin();
List<SimpleEntity> list = session.byMultipleIds( SimpleEntity.class )
.with( CacheMode.IGNORE )
.multiLoad( ids( 56 ) );
session.getTransaction().commit();
session.close();
assertEquals( 56, list.size() );
for ( SimpleEntity entity : list ) {
assertFalse( scope.getSessionFactory().getCache().containsEntity( SimpleEntity.class, entity.getId() ) );
}
}
List<SimpleEntity> list = scope.fromTransaction(
session ->
session.byMultipleIds( SimpleEntity.class )
.with( CacheMode.IGNORE )
.multiLoad( ids( 56 ) )
);
assertEquals( 56, list.size() );
for ( SimpleEntity entity : list ) {
assertFalse( scope.getSessionFactory().getCache().containsEntity( SimpleEntity.class, entity.getId() ) );
}
}
@Test

View File

@ -16,7 +16,7 @@ import org.hibernate.boot.internal.MetadataBuilderImpl;
import org.hibernate.boot.model.TypeContributor;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.mapping.BasicValue;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
@ -32,6 +32,8 @@ import org.junit.jupiter.api.extension.TestExecutionExceptionHandler;
import org.junit.jupiter.api.extension.TestInstancePostProcessor;
import org.junit.platform.commons.support.AnnotationSupport;
import jakarta.persistence.SharedCacheMode;
/**
* hibernate-testing implementation of a few JUnit5 contracts to support SessionFactory-based testing,
* including argument injection (or see {@link DomainModelScopeAware})
@ -133,6 +135,11 @@ public class DomainModelExtension
contributor.contribute( metadataBuilder, serviceRegistry );
}
final SharedCacheMode sharedCacheMode = domainModelAnnotation.sharedCacheMode();
final AccessType accessType = domainModelAnnotation.accessType();
metadataBuilder.applySharedCacheMode( sharedCacheMode );
metadataBuilder.applyAccessType( accessType );
MetadataImplementor metadataImplementor = metadataBuilder.build();
applyCacheSettings(
metadataImplementor,