@Test @TestForIssue(jiraKey="HHH-9498") public void testIsolationPropertyCouldBeEmpty() { C3P0ConnectionProvider provider = new C3P0ConnectionProvider(); try { Properties configuration = new Properties(); configuration.setProperty( Environment.ISOLATION, "" ); provider.configure( configuration ); } finally { provider.stop(); } } }
private void setOverwriteProperty( String hibernateStyleKey, String c3p0StyleKey, Map hibp, Properties c3p, Integer value) { if ( value != null ) { final String peeledC3p0Key = c3p0StyleKey.substring( 5 ); c3p.put( peeledC3p0Key, String.valueOf( value ).trim() ); if ( hibp.containsKey( c3p0StyleKey ) ) { warnPropertyConflict( hibernateStyleKey, c3p0StyleKey ); } final String longC3p0StyleKey = "hibernate." + c3p0StyleKey; if ( hibp.containsKey( longC3p0StyleKey ) ) { warnPropertyConflict( hibernateStyleKey, longC3p0StyleKey ); } } }
@Override public void closeConnection(Connection conn) throws SQLException { Connection originalConnection = connectionSpyMap.get( conn ); super.closeConnection( originalConnection != null ? originalConnection : conn ); }
@Override protected ConnectionProvider getConnectionProviderUnderTest() { C3P0ConnectionProvider provider = new C3P0ConnectionProvider(); provider.injectServices( (ServiceRegistryImplementor) ssr ); return provider; } }
final String newKey = key.substring( 15 ); if ( props.containsKey( newKey ) ) { warnPropertyConflict( key, newKey ); setOverwriteProperty( Environment.C3P0_MIN_SIZE, C3P0_STYLE_MIN_POOL_SIZE, props, c3props, minPoolSize ); setOverwriteProperty( Environment.C3P0_MAX_SIZE, C3P0_STYLE_MAX_POOL_SIZE, props, c3props, maxPoolSize ); setOverwriteProperty( Environment.C3P0_TIMEOUT, C3P0_STYLE_MAX_IDLE_TIME, props, c3props, maxIdleTime ); setOverwriteProperty( Environment.C3P0_MAX_STATEMENTS, C3P0_STYLE_MAX_STATEMENTS, props, c3props, maxStatements ); setOverwriteProperty( Environment.C3P0_ACQUIRE_INCREMENT, C3P0_STYLE_ACQUIRE_INCREMENT, props, c3props, acquireIncrement ); setOverwriteProperty( Environment.C3P0_IDLE_TEST_PERIOD, C3P0_STYLE_IDLE_CONNECTION_TEST_PERIOD, setOverwriteProperty( "", C3P0_STYLE_INITIAL_POOL_SIZE, props, c3props, minPoolSize );
/** * Close the provider. * * @deprecated Use {@link #stop} instead */ @SuppressWarnings("UnusedDeclaration") @Deprecated public void close() { stop(); }
@Override public void configure(Map props) { super.configure( props ); DataSource ds = unwrap( DataSource.class ); DataSource dataSource = spy( ds ); try { Mockito.doAnswer( invocation -> { Connection connection = (Connection) invocation.callRealMethod(); Connection connectionSpy = spy( connection ); connectionSpyMap.put( connectionSpy, connection ); return connectionSpy; } ).when( dataSource ).getConnection(); } catch (SQLException e) { throw new IllegalStateException( e ); } ReflectionUtil.setField( C3P0ConnectionProvider.class.cast( this ), "ds", dataSource ); }
final String newKey = key.substring( 15 ); if ( props.containsKey( newKey ) ) { warnPropertyConflict( key, newKey ); setOverwriteProperty( Environment.C3P0_MIN_SIZE, C3P0_STYLE_MIN_POOL_SIZE, props, c3props, minPoolSize ); setOverwriteProperty( Environment.C3P0_MAX_SIZE, C3P0_STYLE_MAX_POOL_SIZE, props, c3props, maxPoolSize ); setOverwriteProperty( Environment.C3P0_TIMEOUT, C3P0_STYLE_MAX_IDLE_TIME, props, c3props, maxIdleTime ); setOverwriteProperty( Environment.C3P0_MAX_STATEMENTS, C3P0_STYLE_MAX_STATEMENTS, props, c3props, maxStatements ); setOverwriteProperty( Environment.C3P0_ACQUIRE_INCREMENT, C3P0_STYLE_ACQUIRE_INCREMENT, props, c3props, acquireIncrement ); setOverwriteProperty( Environment.C3P0_IDLE_TEST_PERIOD, C3P0_STYLE_IDLE_CONNECTION_TEST_PERIOD, setOverwriteProperty( "", C3P0_STYLE_INITIAL_POOL_SIZE, props, c3props, minPoolSize );
/** * Close the provider. * * @deprecated Use {@link #stop} instead */ @SuppressWarnings("UnusedDeclaration") @Deprecated public void close() { stop(); }
private void setOverwriteProperty( String hibernateStyleKey, String c3p0StyleKey, Map hibp, Properties c3p, Integer value) { if ( value != null ) { final String peeledC3p0Key = c3p0StyleKey.substring( 5 ); c3p.put( peeledC3p0Key, String.valueOf( value ).trim() ); if ( hibp.containsKey( c3p0StyleKey ) ) { warnPropertyConflict( hibernateStyleKey, c3p0StyleKey ); } final String longC3p0StyleKey = "hibernate." + c3p0StyleKey; if ( hibp.containsKey( longC3p0StyleKey ) ) { warnPropertyConflict( hibernateStyleKey, longC3p0StyleKey ); } } }