Enable more tests

This commit is contained in:
Steve Ebersole 2021-06-15 15:11:59 -05:00
parent 3172d52deb
commit 4734897601
18 changed files with 280 additions and 299 deletions

View File

@ -263,26 +263,31 @@ task generateEnversStaticMetamodel(
destinationDir = new File( "${projectDir}/src/main/java" )
}
test {
systemProperty 'file.encoding', 'utf-8'
tasks.withType( Test.class ).each { test ->
test.systemProperty 'file.encoding', 'utf-8'
if ( gradle.ext.javaVersions.test.launcher.asInt() >= 9 ) {
// See org.hibernate.boot.model.naming.NamingHelperTest.DefaultCharset.set
jvmArgs( ['--add-opens', 'java.base/java.nio.charset=ALL-UNNAMED'] )
test.jvmArgs( ['--add-opens', 'java.base/java.nio.charset=ALL-UNNAMED'] )
// Weld needs this to generate proxies
jvmArgs( ['--add-opens', 'java.base/java.security=ALL-UNNAMED'] )
jvmArgs( ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] )
test.jvmArgs( ['--add-opens', 'java.base/java.security=ALL-UNNAMED'] )
test.jvmArgs( ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] )
}
beforeTest { descriptor ->
test.beforeTest { descriptor ->
//println "Starting test: " + descriptor
}
// Allow to exclude specific tests
if (project.hasProperty('excludeTests')) {
filter {
test.filter {
excludeTestsMatching project.property('excludeTests').toString()
}
}
// widen the overall 6.0 filter to include various package-protected tests
test.include 'org/hibernate/bytecode/internal/bytebuddy/**'
test.include 'org/hibernate/event/service/internal/**'
}

View File

@ -1,60 +0,0 @@
package org.hibernate.internal;
import org.hibernate.FlushMode;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.TestForIssue;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
import static org.junit.Assert.assertEquals;
/**
* @author Nathan Xu
*/
@TestForIssue( jiraKey = "HHH-13677" )
@RunWith( Parameterized.class )
public class FlushModeConfigTest {
@Parameters
public static FlushMode[] parameters() {
return FlushMode.values();
}
@Parameter
public FlushMode flushMode;
private StandardServiceRegistryImpl serviceRegistry;
@Before
public void setUp() {
serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder()
.applySetting( AvailableSettings.FLUSH_MODE, flushMode.name() )
.build();
}
@Test
public void testFlushModeSettingTakingEffect() {
try ( final SessionFactory sessionFactory = new MetadataSources(serviceRegistry).buildMetadata().buildSessionFactory() ) {
try ( final Session session = sessionFactory.openSession() ) {
assertEquals( flushMode, session.getHibernateFlushMode() );
}
}
}
@After
public void tearDown() {
serviceRegistry.destroy();
}
}

View File

@ -1,50 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* 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.internal;
import java.util.Map;
import javax.persistence.EntityManagerFactory;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Test that sensitive information is correctly masked.
*
* @author Bruno P. Kinoshita
*/
public class MaskSensitiveInformationTest extends BaseEntityManagerFunctionalTestCase {
private EntityManagerFactory entityManagerFactory;
private static final String EXPECTED_MASKED_VALUE = "****";
@Before
public void setUp() {
entityManagerFactory = entityManagerFactory();
}
@Override
protected void addConfigOptions(Map options) {
super.addConfigOptions( options );
}
@Test
public void testMaskOutSensitiveInformation() {
SessionFactoryImpl sessionFactory = entityManagerFactory.unwrap( SessionFactoryImpl.class );
Map<String, Object> properties = sessionFactory.getProperties();
assertEquals( EXPECTED_MASKED_VALUE, properties.get( AvailableSettings.USER ) );
assertEquals( EXPECTED_MASKED_VALUE, properties.get( AvailableSettings.PASS ) );
assertEquals( EXPECTED_MASKED_VALUE, properties.get( AvailableSettings.JPA_JDBC_USER ) );
assertEquals( EXPECTED_MASKED_VALUE, properties.get( AvailableSettings.JPA_JDBC_PASSWORD ) );
}
}

View File

@ -1,63 +0,0 @@
package org.hibernate.internal;
import java.util.stream.Stream;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.TypedQuery;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.TestForIssue;
import org.junit.Before;
import org.junit.Test;
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
/**
* @author Dragoş Haiduc
* @author Nathan Xu
*/
@TestForIssue( jiraKey = "HHH-14231" )
@RequiresDialectFeature( DialectChecks.SupportsExpectedLobUsagePattern.class )
public class ScrollableResultsObjectArrayCastingTest extends BaseEntityManagerFunctionalTestCase {
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] { Product.class };
}
@Before
public void SetUp() {
doInJPA( this::entityManagerFactory, entityManager -> {
Product product = new Product();
product.binaryValue = new byte[] { 1, 2, 3 };
entityManager.persist( product );
} );
}
@Test
public void testNoClassCastExceptionThrown() {
doInJPA( this::entityManagerFactory, entityManager -> {
TypedQuery<byte[]> typedQuery = entityManager.createQuery( "select p.binaryValue from Product p", byte[].class );
Stream<byte[]> stream = typedQuery.getResultStream();
stream.findFirst();
} );
}
@Entity(name = "Product")
public static class Product {
@Id @GeneratedValue
Integer id;
String name;
@Lob
byte[] binaryValue;
}
}

View File

@ -1,56 +0,0 @@
package org.hibernate.internal;
import org.hibernate.FlushMode;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.testing.TestForIssue;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
import static org.junit.Assert.assertEquals;
/**
* @author Michael Spahn
*/
@TestForIssue(jiraKey = "HHH-13974")
@RunWith(Parameterized.class)
public class SessionBuilderFlushModeTest {
private static SessionFactory sessionFactory;
@Parameters
public static FlushMode[] parameters() {
return FlushMode.values();
}
@Parameter
public FlushMode flushMode;
@BeforeClass
public static void setup() {
sessionFactory = new MetadataSources( new StandardServiceRegistryBuilder().build() ).buildMetadata().buildSessionFactory();
}
@AfterClass
public static void tearDown() {
if ( sessionFactory != null ) {
sessionFactory.close();
}
}
@Test
public void testFlushMode() {
try (final Session session = sessionFactory.withOptions().flushMode( flushMode ).openSession()) {
assertEquals( flushMode, session.getHibernateFlushMode() );
}
}
}

View File

@ -10,7 +10,7 @@ import org.hibernate.annotations.Columns;
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappings;
import org.hibernate.cfg.annotations.reflection.internal.JPAXMLOverriddenAnnotationReader;
import org.hibernate.cfg.annotations.reflection.internal.XMLContext;
import org.hibernate.internal.util.xml.XMLMappingHelper;
import org.hibernate.orm.test.internal.util.xml.XMLMappingHelper;
import org.hibernate.testing.boot.BootstrapContextImpl;
import org.hibernate.testing.junit4.BaseUnitTestCase;

View File

@ -8,11 +8,11 @@ package org.hibernate.orm.test.annotations.reflection;
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappings;
import org.hibernate.cfg.annotations.reflection.internal.XMLContext;
import org.hibernate.internal.util.xml.XMLMappingHelper;
import org.hibernate.orm.test.internal.util.xml.XMLMappingHelper;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.boot.BootstrapContextImpl;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* @author Emmanuel Bernard

View File

@ -13,7 +13,7 @@ import java.lang.reflect.AnnotatedElement;
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappings;
import org.hibernate.cfg.annotations.reflection.internal.JPAXMLOverriddenAnnotationReader;
import org.hibernate.cfg.annotations.reflection.internal.XMLContext;
import org.hibernate.internal.util.xml.XMLMappingHelper;
import org.hibernate.orm.test.internal.util.xml.XMLMappingHelper;
import org.hibernate.testing.boot.BootstrapContextImpl;
import org.hibernate.testing.junit4.BaseUnitTestCase;

View File

@ -1,11 +1,18 @@
package org.hibernate.dialect;
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* 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.orm.test.dialect;
import org.hibernate.dialect.pagination.Oracle12LimitHandler;
import org.hibernate.engine.spi.QueryParameters;
import org.hibernate.engine.spi.RowSelection;
import org.hibernate.testing.TestForIssue;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;

View File

@ -0,0 +1,45 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* 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.orm.test.internal.util;
import org.hibernate.FlushMode;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.orm.junit.BaseUnitTest;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Nathan Xu
*/
@TestForIssue( jiraKey = "HHH-13677" )
@BaseUnitTest
public class FlushModeConfigTest {
@ParameterizedTest
@EnumSource( FlushMode.class )
public void testFlushModeSettingTakingEffect(FlushMode flushMode) {
final StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
.applySetting( AvailableSettings.FLUSH_MODE, flushMode.name() )
.build();
try ( final SessionFactory sessionFactory = new MetadataSources(serviceRegistry).buildMetadata().buildSessionFactory() ) {
try ( final Session session = sessionFactory.openSession() ) {
assertThat( session.getHibernateFlushMode() ).isEqualTo( flushMode );
}
}
finally {
StandardServiceRegistryBuilder.destroy( serviceRegistry );
}
}
}

View File

@ -0,0 +1,38 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* 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.orm.test.internal.util;
import java.util.Map;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
import org.hibernate.testing.orm.junit.Jpa;
import org.hibernate.testing.orm.junit.NotImplementedYet;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Test that sensitive information is correctly masked.
*
* @author Bruno P. Kinoshita
*/
@Jpa
public class MaskSensitiveInformationTest {
private static final String EXPECTED_MASKED_VALUE = "****";
@Test
@NotImplementedYet( strict = false, reason = "Setting `" + AvailableSettings.PASS + "` does not propagate to `" + AvailableSettings.JPA_JDBC_PASSWORD + "`" )
public void testMaskOutSensitiveInformation(EntityManagerFactoryScope scope) {
Map<String, Object> properties = scope.getEntityManagerFactory().getProperties();
assertThat( properties.get( AvailableSettings.USER ) ).isEqualTo( EXPECTED_MASKED_VALUE );
assertThat( properties.get( AvailableSettings.PASS ) ).isEqualTo( EXPECTED_MASKED_VALUE );
assertThat( properties.get( AvailableSettings.JPA_JDBC_USER ) ).isEqualTo( EXPECTED_MASKED_VALUE );
assertThat( properties.get( AvailableSettings.JPA_JDBC_PASSWORD ) ).isEqualTo( EXPECTED_MASKED_VALUE );
}
}

View File

@ -0,0 +1,42 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* 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.orm.test.internal.util;
import org.hibernate.internal.util.MathHelper;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Vlad Mihalcea
*/
public class MathHelperTest {
@Test
public void ceilingPowerOfTwo() {
assertThat( MathHelper.ceilingPowerOfTwo( 1 ) ).isEqualTo( 1 );
assertThat( MathHelper.ceilingPowerOfTwo( 2 ) ).isEqualTo( 2 );
assertThat( MathHelper.ceilingPowerOfTwo( 3 ) ).isEqualTo( 4 );
assertThat( MathHelper.ceilingPowerOfTwo( 4 ) ).isEqualTo( 4 );
assertThat( MathHelper.ceilingPowerOfTwo( 5 ) ).isEqualTo( 8 );
assertThat( MathHelper.ceilingPowerOfTwo( 6 ) ).isEqualTo( 8 );
assertThat( MathHelper.ceilingPowerOfTwo( 7 ) ).isEqualTo( 8 );
assertThat( MathHelper.ceilingPowerOfTwo( 8 ) ).isEqualTo( 8 );
assertThat( MathHelper.ceilingPowerOfTwo( 9 ) ).isEqualTo( 16 );
assertThat( MathHelper.ceilingPowerOfTwo( 10 ) ).isEqualTo( 16 );
assertThat( MathHelper.ceilingPowerOfTwo( 11 ) ).isEqualTo( 16 );
assertThat( MathHelper.ceilingPowerOfTwo( 12 ) ).isEqualTo( 16 );
assertThat( MathHelper.ceilingPowerOfTwo( 13 ) ).isEqualTo( 16 );
assertThat( MathHelper.ceilingPowerOfTwo( 14 ) ).isEqualTo( 16 );
assertThat( MathHelper.ceilingPowerOfTwo( 15 ) ).isEqualTo( 16 );
assertThat( MathHelper.ceilingPowerOfTwo( 16 ) ).isEqualTo( 16 );
}
}

View File

@ -4,7 +4,7 @@
* 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.orm.test.internal.utils;
package org.hibernate.orm.test.internal.util;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@ -14,7 +14,7 @@ import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.orm.test.internal.utils.hib3rnat3.C0nst4nts३;
import org.hibernate.orm.test.internal.util.hib3rnat3.C0nst4nts३;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.testing.TestForIssue;
@ -24,8 +24,8 @@ import org.junit.Test;
import org.mockito.Mockito;
import static java.lang.Integer.valueOf;
import static org.hibernate.orm.test.internal.utils.ReflectHelperTest.Status.OFF;
import static org.hibernate.orm.test.internal.utils.ReflectHelperTest.Status.ON;
import static org.hibernate.orm.test.internal.util.ReflectHelperTest.Status.OFF;
import static org.hibernate.orm.test.internal.util.ReflectHelperTest.Status.ON;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@ -172,8 +172,8 @@ public class ReflectHelperTest {
public void test_getConstantValue_enumClass() {
when( sessionFactoryOptionsMock.isConventionalJavaConstants() ).thenReturn( true );
when( classLoaderServiceMock.classForName( "org.hibernate.orm.test.internal.utils.ReflectHelperTest$Status" ) ).thenReturn( (Class) Status.class );
Object value = ReflectHelper.getConstantValue( "org.hibernate.orm.test.internal.utils.ReflectHelperTest$Status", sessionFactoryImplementorMock);
when( classLoaderServiceMock.classForName( "org.hibernate.orm.test.internal.util.ReflectHelperTest$Status" ) ).thenReturn( (Class) Status.class );
Object value = ReflectHelper.getConstantValue( "org.hibernate.orm.test.internal.util.ReflectHelperTest$Status", sessionFactoryImplementorMock);
assertNull(value);
verify(classLoaderServiceMock, never()).classForName( eq("org.hibernate.internal.util") );
}
@ -182,20 +182,20 @@ public class ReflectHelperTest {
public void test_getConstantValue_nestedEnum() {
when( sessionFactoryOptionsMock.isConventionalJavaConstants() ).thenReturn( true );
when( classLoaderServiceMock.classForName( "org.hibernate.orm.test.internal.utils.ReflectHelperTest$Status" ) ).thenReturn( (Class) Status.class );
Object value = ReflectHelper.getConstantValue( "org.hibernate.orm.test.internal.utils.ReflectHelperTest$Status.ON", sessionFactoryImplementorMock);
when( classLoaderServiceMock.classForName( "org.hibernate.orm.test.internal.util.ReflectHelperTest$Status" ) ).thenReturn( (Class) Status.class );
Object value = ReflectHelper.getConstantValue( "org.hibernate.orm.test.internal.util.ReflectHelperTest$Status.ON", sessionFactoryImplementorMock);
assertEquals( ON, value );
verify(classLoaderServiceMock, times(1)).classForName( eq("org.hibernate.orm.test.internal.utils.ReflectHelperTest$Status") );
verify(classLoaderServiceMock, times(1)).classForName( eq("org.hibernate.orm.test.internal.util.ReflectHelperTest$Status") );
}
@Test
public void test_getConstantValue_constant_digits() {
when( sessionFactoryOptionsMock.isConventionalJavaConstants() ).thenReturn( true );
when( classLoaderServiceMock.classForName( "org.hibernate.orm.test.internal.utils.hib3rnat3.C0nst4nts३" ) ).thenReturn( (Class) C0nst4nts३.class );
Object value = ReflectHelper.getConstantValue( "org.hibernate.orm.test.internal.utils.hib3rnat3.C0nst4nts३.ABC_DEF", sessionFactoryImplementorMock);
when( classLoaderServiceMock.classForName( "org.hibernate.orm.test.internal.util.hib3rnat3.C0nst4nts३" ) ).thenReturn( (Class) C0nst4nts३.class );
Object value = ReflectHelper.getConstantValue( "org.hibernate.orm.test.internal.util.hib3rnat3.C0nst4nts३.ABC_DEF", sessionFactoryImplementorMock);
assertEquals( C0nst4nts३.ABC_DEF, value );
verify(classLoaderServiceMock, times(1)).classForName( eq("org.hibernate.orm.test.internal.utils.hib3rnat3.C0nst4nts३") );
verify(classLoaderServiceMock, times(1)).classForName( eq("org.hibernate.orm.test.internal.util.hib3rnat3.C0nst4nts३") );
}
@Test

View File

@ -0,0 +1,78 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* 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.orm.test.internal.util;
import java.util.stream.Stream;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.TypedQuery;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
import org.hibernate.testing.orm.junit.Jpa;
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* @author Dragoş Haiduc
* @author Nathan Xu
*/
@TestForIssue( jiraKey = "HHH-14231" )
@RequiresDialectFeature( feature = DialectFeatureChecks.SupportsExpectedLobUsagePattern.class )
@Jpa( annotatedClasses = ScrollableResultsObjectArrayCastingTest.Product.class )
public class ScrollableResultsObjectArrayCastingTest {
@BeforeEach
public void prepareTestData(EntityManagerFactoryScope scope) {
scope.inTransaction(
(entityManager) -> {
Product product = new Product();
product.binaryValue = new byte[] { 1, 2, 3 };
entityManager.persist( product );
}
);
}
@AfterEach
public void dropTestData(EntityManagerFactoryScope scope) {
scope.inTransaction(
(entityManager) -> entityManager.createQuery( "delete Product" ).executeUpdate()
);
}
@Test
public void testNoClassCastExceptionThrown(EntityManagerFactoryScope scope) {
scope.inTransaction(
(entityManager) -> {
TypedQuery<byte[]> typedQuery = entityManager.createQuery( "select p.binaryValue from Product p", byte[].class );
Stream<byte[]> stream = typedQuery.getResultStream();
//noinspection ResultOfMethodCallIgnored
stream.findFirst();
}
);
}
@SuppressWarnings("unused")
@Entity(name = "Product")
public static class Product {
@Id @GeneratedValue
Integer id;
String name;
@Lob
byte[] binaryValue;
}
}

View File

@ -0,0 +1,36 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* 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.orm.test.internal.util;
import org.hibernate.FlushMode;
import org.hibernate.Session;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Michael Spahn
*/
@TestForIssue(jiraKey = "HHH-13974")
@DomainModel
@SessionFactory
public class SessionBuilderFlushModeTest {
@ParameterizedTest
@EnumSource( FlushMode.class )
public void testFlushModeSettingTakingEffect(FlushMode flushMode, SessionFactoryScope scope) {
try ( final Session session = scope.getSessionFactory().withOptions().flushMode( flushMode ).openSession() ) {
assertThat( session.getHibernateFlushMode() ).isEqualTo( flushMode );
}
}
}

View File

@ -4,7 +4,7 @@
* 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.orm.test.internal.utils.hib3rnat3;
package org.hibernate.orm.test.internal.util.hib3rnat3;
/**
* @author Vlad Mihalcea

View File

@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* 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>.
* 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.internal.util.xml;
package org.hibernate.orm.test.internal.util.xml;
import java.io.IOException;
import java.io.InputStream;

View File

@ -1,41 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* 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.orm.test.internal.utils;
import org.hibernate.internal.util.MathHelper;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* @author Vlad Mihalcea
*/
public class MathHelperTest {
@Test
public void ceilingPowerOfTwo() {
Assert.assertEquals( 1, MathHelper.ceilingPowerOfTwo( 1 ) );
assertEquals( 2, MathHelper.ceilingPowerOfTwo( 2 ) );
assertEquals( 4, MathHelper.ceilingPowerOfTwo( 3 ) );
assertEquals( 4, MathHelper.ceilingPowerOfTwo( 4 ) );
assertEquals( 8, MathHelper.ceilingPowerOfTwo( 5 ) );
assertEquals( 8, MathHelper.ceilingPowerOfTwo( 6 ) );
assertEquals( 8, MathHelper.ceilingPowerOfTwo( 7 ) );
assertEquals( 8, MathHelper.ceilingPowerOfTwo( 8 ) );
assertEquals( 16, MathHelper.ceilingPowerOfTwo( 9 ) );
assertEquals( 16, MathHelper.ceilingPowerOfTwo( 10 ) );
assertEquals( 16, MathHelper.ceilingPowerOfTwo( 11 ) );
assertEquals( 16, MathHelper.ceilingPowerOfTwo( 12 ) );
assertEquals( 16, MathHelper.ceilingPowerOfTwo( 13 ) );
assertEquals( 16, MathHelper.ceilingPowerOfTwo( 16 ) );
assertEquals( 16, MathHelper.ceilingPowerOfTwo( 14 ) );
assertEquals( 16, MathHelper.ceilingPowerOfTwo( 15 ) );
}
}