mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package cn.hutool.db;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.db.ds.DSFactory;
|
||||
import cn.hutool.db.ds.DataSourceWrapper;
|
||||
import cn.hutool.db.ds.DSUtil;
|
||||
import cn.hutool.db.ds.DSWrapper;
|
||||
import cn.hutool.db.ds.bee.BeeDSFactory;
|
||||
import cn.hutool.db.ds.c3p0.C3p0DSFactory;
|
||||
import cn.hutool.db.ds.dbcp.DbcpDSFactory;
|
||||
@@ -27,7 +27,7 @@ public class DsTest {
|
||||
|
||||
@Test
|
||||
public void defaultDsTest() {
|
||||
final DataSource ds = DSFactory.get("test");
|
||||
final DataSource ds = DSUtil.getDS("test");
|
||||
final Db db = Db.of(ds);
|
||||
final List<Entity> all = db.findAll("user");
|
||||
Assert.assertTrue(CollUtil.isNotEmpty(all));
|
||||
@@ -35,8 +35,8 @@ public class DsTest {
|
||||
|
||||
@Test
|
||||
public void hikariDsTest() {
|
||||
DSFactory.setCurrentDSFactory(new HikariDSFactory());
|
||||
final DataSource ds = DSFactory.get("test");
|
||||
DSUtil.setGlobalDSFactory(new HikariDSFactory());
|
||||
final DataSource ds = DSUtil.getDS("test");
|
||||
final Db db = Db.of(ds);
|
||||
final List<Entity> all = db.findAll("user");
|
||||
Assert.assertTrue(CollUtil.isNotEmpty(all));
|
||||
@@ -44,8 +44,8 @@ public class DsTest {
|
||||
|
||||
@Test
|
||||
public void druidDsTest() {
|
||||
DSFactory.setCurrentDSFactory(new DruidDSFactory());
|
||||
final DataSource ds = DSFactory.get("test");
|
||||
DSUtil.setGlobalDSFactory(new DruidDSFactory());
|
||||
final DataSource ds = DSUtil.getDS("test");
|
||||
|
||||
final Db db = Db.of(ds);
|
||||
final List<Entity> all = db.findAll("user");
|
||||
@@ -54,8 +54,8 @@ public class DsTest {
|
||||
|
||||
@Test
|
||||
public void tomcatDsTest() {
|
||||
DSFactory.setCurrentDSFactory(new TomcatDSFactory());
|
||||
final DataSource ds = DSFactory.get("test");
|
||||
DSUtil.setGlobalDSFactory(new TomcatDSFactory());
|
||||
final DataSource ds = DSUtil.getDS("test");
|
||||
final Db db = Db.of(ds);
|
||||
final List<Entity> all = db.findAll("user");
|
||||
Assert.assertTrue(CollUtil.isNotEmpty(all));
|
||||
@@ -63,8 +63,8 @@ public class DsTest {
|
||||
|
||||
@Test
|
||||
public void beeCPDsTest() {
|
||||
DSFactory.setCurrentDSFactory(new BeeDSFactory());
|
||||
final DataSource ds = DSFactory.get("test");
|
||||
DSUtil.setGlobalDSFactory(new BeeDSFactory());
|
||||
final DataSource ds = DSUtil.getDS("test");
|
||||
final Db db = Db.of(ds);
|
||||
final List<Entity> all = db.findAll("user");
|
||||
Assert.assertTrue(CollUtil.isNotEmpty(all));
|
||||
@@ -72,8 +72,8 @@ public class DsTest {
|
||||
|
||||
@Test
|
||||
public void dbcpDsTest() {
|
||||
DSFactory.setCurrentDSFactory(new DbcpDSFactory());
|
||||
final DataSource ds = DSFactory.get("test");
|
||||
DSUtil.setGlobalDSFactory(new DbcpDSFactory());
|
||||
final DataSource ds = DSUtil.getDS("test");
|
||||
final Db db = Db.of(ds);
|
||||
final List<Entity> all = db.findAll("user");
|
||||
Assert.assertTrue(CollUtil.isNotEmpty(all));
|
||||
@@ -81,8 +81,8 @@ public class DsTest {
|
||||
|
||||
@Test
|
||||
public void c3p0DsTest() {
|
||||
DSFactory.setCurrentDSFactory(new C3p0DSFactory());
|
||||
final DataSource ds = DSFactory.get("test");
|
||||
DSUtil.setGlobalDSFactory(new C3p0DSFactory());
|
||||
final DataSource ds = DSUtil.getDS("test");
|
||||
final Db db = Db.of(ds);
|
||||
final List<Entity> all = db.findAll("user");
|
||||
Assert.assertTrue(CollUtil.isNotEmpty(all));
|
||||
@@ -91,16 +91,16 @@ public class DsTest {
|
||||
@Test
|
||||
public void c3p0DsuserAndPassTest() {
|
||||
// https://gitee.com/dromara/hutool/issues/I4T7XZ
|
||||
DSFactory.setCurrentDSFactory(new C3p0DSFactory());
|
||||
final ComboPooledDataSource ds = (ComboPooledDataSource) ((DataSourceWrapper) DSFactory.get("mysql")).getRaw();
|
||||
DSUtil.setGlobalDSFactory(new C3p0DSFactory());
|
||||
final ComboPooledDataSource ds = (ComboPooledDataSource) ((DSWrapper) DSUtil.getDS("mysql")).getRaw();
|
||||
Assert.assertEquals("root", ds.getUser());
|
||||
Assert.assertEquals("123456", ds.getPassword());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hutoolPoolTest() {
|
||||
DSFactory.setCurrentDSFactory(new PooledDSFactory());
|
||||
final DataSource ds = DSFactory.get("test");
|
||||
DSUtil.setGlobalDSFactory(new PooledDSFactory());
|
||||
final DataSource ds = DSUtil.getDS("test");
|
||||
final Db db = Db.of(ds);
|
||||
final List<Entity> all = db.findAll("user");
|
||||
Assert.assertTrue(CollUtil.isNotEmpty(all));
|
||||
|
@@ -9,9 +9,9 @@ public class DataSourceWrapperTest {
|
||||
@Test
|
||||
public void cloneTest(){
|
||||
final SimpleDataSource simpleDataSource = new SimpleDataSource("jdbc:sqlite:test.db", "", "");
|
||||
final DataSourceWrapper wrapper = new DataSourceWrapper(simpleDataSource, "test.driver");
|
||||
final DSWrapper wrapper = new DSWrapper(simpleDataSource, "test.driver");
|
||||
|
||||
final DataSourceWrapper clone = wrapper.clone();
|
||||
final DSWrapper clone = wrapper.clone();
|
||||
Assert.assertEquals("test.driver", clone.getDriver());
|
||||
Assert.assertEquals(simpleDataSource, clone.getRaw());
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ package cn.hutool.db.meta;
|
||||
import cn.hutool.core.collection.SetUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.core.text.split.SplitUtil;
|
||||
import cn.hutool.db.ds.DSFactory;
|
||||
import cn.hutool.db.ds.DSUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.List;
|
||||
*
|
||||
*/
|
||||
public class MetaUtilTest {
|
||||
final DataSource ds = DSFactory.get("test");
|
||||
final DataSource ds = DSUtil.getDS("test");
|
||||
|
||||
@Test
|
||||
public void getTablesTest() {
|
||||
|
Reference in New Issue
Block a user