improve hibernate support

This commit is contained in:
wenshao
2012-12-23 16:40:42 +08:00
parent 82488c8ae1
commit 70352665a6
2 changed files with 41 additions and 0 deletions
@@ -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) {
@@ -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());
}
}