Re-enabled additional tests

This commit is contained in:
Andrea Boriero 2021-09-21 09:11:49 +02:00
parent e466c52002
commit 61d1891f55
2 changed files with 38 additions and 35 deletions

View File

@ -4,10 +4,10 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. * 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>. * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/ */
package org.hibernate.test.annotations.comment; package org.hibernate.orm.test.annotations.comment;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is; import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import java.util.Iterator; import java.util.Iterator;
import java.util.stream.StreamSupport; import java.util.stream.StreamSupport;
@ -26,13 +26,14 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.mapping.Column; import org.hibernate.mapping.Column;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.testing.orm.junit.BaseUnitTest;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* @author Yanming Zhou * @author Yanming Zhou
*/ */
public class CommentTest extends BaseUnitTestCase { @BaseUnitTest
public class CommentTest {
private static final String TABLE_NAME = "TestEntity"; private static final String TABLE_NAME = "TestEntity";
private static final String TABLE_COMMENT = "I am table"; private static final String TABLE_COMMENT = "I am table";

View File

@ -1,4 +1,4 @@
package org.hibernate.test.onetoone.cache; package org.hibernate.orm.test.onetoone.cache;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import javax.persistence.Cacheable; import javax.persistence.Cacheable;
@ -11,65 +11,67 @@ import javax.persistence.OneToOne;
import javax.persistence.Version; import javax.persistence.Version;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.orm.junit.DomainModel;
import org.junit.Test; 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 static org.junit.Assert.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
@TestForIssue( jiraKey = "HHH-14826") @TestForIssue( jiraKey = "HHH-14826")
public class OneToOneCacheEnableSelectingTest extends BaseCoreFunctionalTestCase { @DomainModel(
@Override annotatedClasses = {
protected Class<?>[] getAnnotatedClasses() { OneToOneCacheEnableSelectingTest.Product.class,
return new Class[] { OneToOneCacheEnableSelectingTest.ProductConfig.class
Product.class, }
ProductConfig.class )
}; @SessionFactory(generateStatistics = true)
} @ServiceRegistry(
settings = {
@Override @Setting( name = AvailableSettings.USE_SECOND_LEVEL_CACHE, value = "true"),
protected void configure(Configuration configuration) { @Setting( name = AvailableSettings.JPA_SHARED_CACHE_MODE, value = "ENABLE_SELECTIVE")
configuration.setProperty( AvailableSettings.USE_SECOND_LEVEL_CACHE, "true"); }
configuration.setProperty(AvailableSettings.JPA_SHARED_CACHE_MODE, "ENABLE_SELECTIVE"); )
configuration.setProperty(AvailableSettings.GENERATE_STATISTICS, "true"); public class OneToOneCacheEnableSelectingTest {
}
@Test @Test
public void testFieldShouldNotBeNull() { public void testFieldShouldNotBeNull(SessionFactoryScope scope) {
final AtomicLong pid = new AtomicLong(); final AtomicLong pid = new AtomicLong();
// create Product // create Product
inTransaction(s -> { scope.inTransaction(s -> {
Product product = new Product(); Product product = new Product();
s.persist(product); s.persist(product);
pid.set(product.getId()); pid.set(product.getId());
}); });
// create ProductConfig and associate with a Product // create ProductConfig and associate with a Product
inTransaction(s -> { scope.inTransaction(s -> {
Product product = s.find(Product.class, pid.get()); Product product = s.find(Product.class, pid.get());
ProductConfig config = new ProductConfig(); ProductConfig config = new ProductConfig();
config.setProduct(product); config.setProduct(product);
s.persist(config); s.persist(config);
}); });
assertTrue(sessionFactory().getCache().containsEntity(Product.class, pid.get())); assertTrue(scope.getSessionFactory().getCache().containsEntity(Product.class, pid.get()));
sessionFactory().getStatistics().clear(); scope.getSessionFactory().getStatistics().clear();
// now fetch the Product again // now fetch the Product again
inTransaction(s -> { scope.inTransaction(s -> {
Product product = s.find(Product.class, pid.get()); Product product = s.find(Product.class, pid.get());
// should have been from cache // should have been from cache
assertNotEquals (0, sessionFactory().getStatistics().getSecondLevelCacheHitCount()); assertNotEquals (0, scope.getSessionFactory().getStatistics().getSecondLevelCacheHitCount());
// this should not fail // this should not fail
assertNotNull("one-to-one field should not be null", product.getConfig()); assertNotNull( product.getConfig(), "one-to-one field should not be null");
}); });
} }