mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve hibernate support
This commit is contained in:
@@ -32,6 +32,10 @@ public class DruidConnectionProvider implements ConnectionProvider, Configurable
|
||||
|
||||
private DruidDataSource dataSource;
|
||||
|
||||
public DruidConnectionProvider(){
|
||||
dataSource = new DruidDataSource();
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public boolean isUnwrappableAs(Class unwrapType) {
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.alibaba.druid.bvt.support.hibernate;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.support.hibernate.DruidConnectionProvider;
|
||||
|
||||
|
||||
public class DruidConnectionProviderTest extends TestCase {
|
||||
private DruidConnectionProvider provider;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
provider = new DruidConnectionProvider();
|
||||
|
||||
Map properties = new HashMap<String, Object>();
|
||||
properties.put("url", "jdbc:mock:xxx");
|
||||
|
||||
provider.configure(properties);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
provider.stop();
|
||||
}
|
||||
|
||||
public void test_hibernate() throws Exception {
|
||||
Connection conn = provider.getConnection();
|
||||
Assert.assertFalse(conn.isClosed());
|
||||
|
||||
provider.closeConnection(conn);
|
||||
Assert.assertTrue(conn.isClosed());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user