@Test public void testConnectionProvider() throws Exception { HikariConnectionProvider provider = new HikariConnectionProvider(); Properties props = new Properties(); props.load(getClass().getResourceAsStream("/hibernate.properties")); provider.configure(props); Connection connection = provider.getConnection(); provider.closeConnection(connection); Assert.assertNotNull(provider.unwrap(HikariConnectionProvider.class)); Assert.assertFalse(provider.supportsAggressiveRelease()); try { provider.unwrap(TestHibernate.class); Assert.fail("Expected exception"); } catch (UnknownUnwrapTypeException e) { } provider.stop(); }
@Override public <T> T unwrap(Class<T> unwrapType) { if (ConnectionProvider.class.equals(unwrapType) || CustomJDBCConnectionProvider.class.isAssignableFrom(unwrapType)) { return (T) this; } else { throw new UnknownUnwrapTypeException( unwrapType ); } }
@Override @SuppressWarnings( {"unchecked"}) public <T> T unwrap(Class<T> unwrapType) { if ( isUnwrappableAs( unwrapType ) ) { return (T) this; } else { throw new UnknownUnwrapTypeException( unwrapType ); } }
@Override @SuppressWarnings( {"unchecked"}) public <T> T unwrap(Class<T> unwrapType) { if ( ConnectionProvider.class.equals( unwrapType ) || DriverManagerConnectionProviderImpl.class.isAssignableFrom( unwrapType ) ) { return (T) this; } else { throw new UnknownUnwrapTypeException( unwrapType ); } }
@Override @SuppressWarnings( {"unchecked"}) public <T> T unwrap(Class<T> unwrapType) { if ( ConnectionProvider.class.equals( unwrapType ) || UserSuppliedConnectionProviderImpl.class.isAssignableFrom( unwrapType ) ) { return (T) this; } else { throw new UnknownUnwrapTypeException( unwrapType ); } }
@Override @SuppressWarnings( {"unchecked"}) public <T> T unwrap(Class<T> unwrapType) { if ( ConnectionProvider.class.equals( unwrapType ) || DatasourceConnectionProviderImpl.class.isAssignableFrom( unwrapType ) ) { return (T) this; } else if ( DataSource.class.isAssignableFrom( unwrapType ) ) { return (T) getDataSource(); } else { throw new UnknownUnwrapTypeException( unwrapType ); } }
@Override @SuppressWarnings("unchecked") public <T> T unwrap(Class<T> unwrapType) { if (ConnectionProvider.class.equals(unwrapType) || DBCPConnectionProvider.class.isAssignableFrom(unwrapType)) { return (T) this; } if (DataSource.class.isAssignableFrom(unwrapType)) { return (T) this.dataSource; } throw new UnknownUnwrapTypeException(unwrapType); }
@Override @SuppressWarnings("unchecked") public <T> T unwrap(Class<T> unwrapType) { if ( ConnectionProvider.class.equals( unwrapType ) || HikariConnectionProvider.class.isAssignableFrom( unwrapType ) ) { return (T) this; } else if ( DataSource.class.isAssignableFrom( unwrapType ) ) { return (T) this.hds; } else { throw new UnknownUnwrapTypeException( unwrapType ); } }
@Override @SuppressWarnings({ "unchecked" }) public <T> T unwrap(final Class<T> unwrapType) { if (ConnectionProvider.class.equals(unwrapType) || BeanLookupDatasourceConnectionProvider.class.isAssignableFrom(unwrapType)) { return (T) this; } else if (DataSource.class.isAssignableFrom(unwrapType)) { return (T) dataSource; } else { throw new UnknownUnwrapTypeException(unwrapType); } }
@SuppressWarnings("unchecked") @Override public <T> T unwrap(Class<T> unwrapType) { if (BoneCPConnectionProvider.class.equals(unwrapType) || BoneCPConnectionProvider.class.isAssignableFrom(unwrapType)) { return (T) this; } else { throw new UnknownUnwrapTypeException(unwrapType); } }
@Override @SuppressWarnings( {"unchecked"}) public <T> T unwrap(Class<T> unwrapType) { if (isUnwrappableAs(unwrapType)) return (T) this; else throw new UnknownUnwrapTypeException(unwrapType); }
@Override @SuppressWarnings( {"unchecked"}) public <T> T unwrap(Class<T> unwrapType) { if ( ConnectionProvider.class.equals( unwrapType ) || CloudSqlConnectionProvider.class.isAssignableFrom( unwrapType ) ) { return (T) this; } else { throw new UnknownUnwrapTypeException( unwrapType ); } }
@Override @SuppressWarnings({ "unchecked" }) public <T> T unwrap(Class<T> unwrapType) { if (ConnectionProvider.class.equals(unwrapType) || DatasourceConnectionProviderImpl.class.isAssignableFrom(unwrapType)) { return (T) this; } else if (DataSource.class.isAssignableFrom(unwrapType)) { return (T) this.dataSource; } else { throw new UnknownUnwrapTypeException(unwrapType); } }