This commit is contained in:
Looly
2019-10-29 19:53:17 +08:00
parent f9ee2af71c
commit e754ec3e86
45 changed files with 172 additions and 179 deletions

View File

@@ -37,7 +37,7 @@ public class ConcurentTest {
ThreadUtil.execute(new Runnable() {
@Override
public void run() {
List<Entity> find = null;
List<Entity> find;
try {
find = db.find(CollectionUtil.newArrayList("name AS name2"), Entity.create("user"), new EntityListHandler());
} catch (SQLException e) {

View File

@@ -33,23 +33,19 @@ public class MySQLTest {
* 事务测试<br>
* 更新三条信息低2条后抛出异常正常情况下三条都应该不变
*
* @throws SQLException
* @throws SQLException SQL异常
*/
@Test(expected=SQLException.class)
@Ignore
public void txTest() throws SQLException {
Db.use("mysql").tx(new VoidFunc1<Db>() {
@Override
public void call(Db db) throws Exception {
int update = db.update(Entity.create("user").set("text", "描述100"), Entity.create().set("id", 100));
db.update(Entity.create("user").set("text", "描述101"), Entity.create().set("id", 101));
if(1 == update) {
// 手动指定异常,然后测试回滚触发
throw new RuntimeException("Error");
}
db.update(Entity.create("user").set("text", "描述102"), Entity.create().set("id", 102));
Db.use("mysql").tx(db -> {
int update = db.update(Entity.create("user").set("text", "描述100"), Entity.create().set("id", 100));
db.update(Entity.create("user").set("text", "描述101"), Entity.create().set("id", 101));
if(1 == update) {
// 手动指定异常,然后测试回滚触发
throw new RuntimeException("Error");
}
db.update(Entity.create("user").set("text", "描述102"), Entity.create().set("id", 102));
});
}

View File

@@ -1,14 +1,11 @@
package cn.hutool.db;
import java.sql.SQLException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import java.sql.SQLException;
public class UpdateTest {
@@ -22,7 +19,7 @@ public class UpdateTest {
/**
* 对更新做单元测试
*
* @throws SQLException
* @throws SQLException SQL异常
*/
@Test
@Ignore