This commit is contained in:
Looly
2020-04-11 13:08:46 +08:00
parent 73fd3b849f
commit bc486cdac4
207 changed files with 1329 additions and 1355 deletions

View File

@@ -22,7 +22,7 @@ import java.util.List;
*/
public class CRUDTest {
private static Db db = Db.use("test");
private static final Db db = Db.use("test");
@Test
public void findIsNullTest() throws SQLException {

View File

@@ -1,16 +1,15 @@
package cn.hutool.db;
import java.sql.SQLException;
import java.util.List;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Console;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.db.handler.EntityListHandler;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import java.sql.SQLException;
import java.util.List;
/**
* SqlRunner线程安全测试
@@ -31,17 +30,14 @@ public class ConcurentTest {
@Test
public void findTest() {
for(int i = 0; i < 10000; i++) {
ThreadUtil.execute(new Runnable() {
@Override
public void run() {
List<Entity> find;
try {
find = db.find(CollectionUtil.newArrayList("name AS name2"), Entity.create("user"), new EntityListHandler());
} catch (SQLException e) {
throw new DbRuntimeException(e);
}
Console.log(find);
ThreadUtil.execute(() -> {
List<Entity> find;
try {
find = db.find(CollectionUtil.newArrayList("name AS name2"), Entity.create("user"), new EntityListHandler());
} catch (SQLException e) {
throw new DbRuntimeException(e);
}
Console.log(find);
});
}

View File

@@ -1,11 +1,9 @@
package cn.hutool.db;
import java.sql.SQLException;
import org.junit.Ignore;
import org.junit.Test;
import cn.hutool.core.lang.func.VoidFunc1;
import java.sql.SQLException;
/**
* 事务性数据库操作单元测试
@@ -30,11 +28,6 @@ public class SessionTest {
@Test
@Ignore
public void txTest() throws SQLException {
Session.create("test").tx(new VoidFunc1<Session>() {
@Override
public void call(Session session) throws SQLException {
session.update(Entity.create().set("age", 78), Entity.create("user").set("name", "unitTestUser"));
}
});
Session.create("test").tx(session -> session.update(Entity.create().set("age", 78), Entity.create("user").set("name", "unitTestUser")));
}
}