Created
January 10, 2018 15:38
-
-
Save sebersole/5ceea382f57e4a9a46f6f8da1fb57ee5 to your computer and use it in GitHub Desktop.
Test illustrating setting connection-release-mode does in fact work
This file contains hidden or 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
| package org.hibernate.test.connections; | |
| import java.util.Map; | |
| import org.hibernate.ConnectionReleaseMode; | |
| import org.hibernate.cfg.AvailableSettings; | |
| import org.hibernate.testing.jta.TestingJtaBootstrap; | |
| import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; | |
| import org.junit.Test; | |
| import static org.hamcrest.CoreMatchers.is; | |
| import static org.hamcrest.MatcherAssert.assertThat; | |
| /** | |
| * @author Steve Ebersole | |
| */ | |
| public class ConnectionReleaseModeSettingTest extends BaseNonConfigCoreFunctionalTestCase { | |
| @Override | |
| @SuppressWarnings({"deprecation", "unchecked"}) | |
| protected void addSettings(Map settings) { | |
| super.addSettings( settings ); | |
| TestingJtaBootstrap.prepare( settings ); | |
| settings.put( AvailableSettings.RELEASE_CONNECTIONS, ConnectionReleaseMode.AFTER_STATEMENT.name() ); | |
| } | |
| @Test | |
| public void testIt() { | |
| assertThat( | |
| sessionFactory().getSessionFactoryOptions().getPhysicalConnectionHandlingMode().getReleaseMode(), | |
| is( ConnectionReleaseMode.AFTER_STATEMENT ) | |
| ); | |
| inSession( | |
| session -> { | |
| assertThat( | |
| session.getJdbcSessionContext().getPhysicalConnectionHandlingMode().getReleaseMode(), | |
| is( ConnectionReleaseMode.AFTER_STATEMENT ) | |
| ); | |
| assertThat( | |
| session.getJdbcCoordinator().getLogicalConnection().getConnectionHandlingMode().getReleaseMode(), | |
| is( ConnectionReleaseMode.AFTER_STATEMENT ) | |
| ); | |
| } | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment