Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-13677 make org.hibernate.flushMode config take effect
- Loading branch information
1 parent
a693446
commit 9d2ac54
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
hibernate-core/src/test/java/org/hibernate/internal/FlushModeConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
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(); | ||
} | ||
|
||
} |