| 1 |
/* |
| 2 |
* Copyright (C) 2013, 2014 Brett Wooldridge |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
* you may not use this file except in compliance with the License. |
| 6 |
* You may obtain a copy of the License at |
| 7 |
* |
| 8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
* |
| 10 |
* Unless required by applicable law or agreed to in writing, software |
| 11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
* See the License for the specific language governing permissions and |
| 14 |
* limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
package com.zaxxer.hikari.pool; |
| 18 |
|
| 19 |
import static org.junit.Assert.assertFalse; |
| 20 |
import static org.junit.Assert.assertNotNull; |
| 21 |
import static org.junit.Assert.fail; |
| 22 |
|
| 23 |
import java.sql.Connection; |
| 24 |
import java.util.Properties; |
| 25 |
|
| 26 |
import org.hibernate.service.UnknownUnwrapTypeException; |
| 27 |
import org.junit.Test; |
| 28 |
|
| 29 |
import com.zaxxer.hikari.hibernate.HikariConnectionProvider; |
| 30 |
|
| 31 |
public class TestHibernate |
| 32 |
{ |
| 33 |
@Test |
| 34 |
public void testConnectionProvider() throws Exception |
| 35 |
{ |
| 36 |
HikariConnectionProvider provider = new HikariConnectionProvider(); |
| 37 |
|
| 38 |
Properties props = new Properties(); |
| 39 |
props.load(getClass().getResourceAsStream("/hibernate.properties")); |
| 40 |
|
| 41 |
provider.configure(props); |
| 42 |
Connection connection = provider.getConnection(); |
| 43 |
provider.closeConnection(connection); |
| 44 |
|
| 45 |
assertNotNull(provider.unwrap(HikariConnectionProvider.class)); |
| 46 |
assertFalse(provider.supportsAggressiveRelease()); |
| 47 |
|
| 48 |
try { |
| 49 |
provider.unwrap(TestHibernate.class); |
| 50 |
fail("Expected exception"); |
| 51 |
} |
| 52 |
catch (UnknownUnwrapTypeException e) { |
| 53 |
} |
| 54 |
|
| 55 |
provider.stop(); |
| 56 |
} |
| 57 |
} |