Browse Source

优化测试

zhou-hao 6 years ago
parent
commit
5ff364a87e

+ 10 - 5
hsweb-system/hsweb-system-database-manager/hsweb-system-database-manager-starter/src/test/java/org/hswebframework/web/datasource/manager/simple/SimpleDatabaseManagerServiceTest.java

@@ -6,6 +6,7 @@ import org.hswebframework.web.database.manager.SqlExecuteRequest;
 import org.hswebframework.web.database.manager.SqlExecuteResult;
 import org.hswebframework.web.database.manager.SqlInfo;
 import org.hswebframework.web.tests.SimpleWebApplicationTests;
+import org.junit.Assert;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.ComponentScan;
@@ -42,9 +43,10 @@ public class SimpleDatabaseManagerServiceTest extends SimpleWebApplicationTests
 
         request.setSql(Arrays.asList(sqlInfo));
         List<SqlExecuteResult> results = databaseManagerService.execute(id, request);
-        System.out.println(JSON.toJSONString(results));
+//        System.out.println(JSON.toJSONString(results));
+        Assert.assertFalse(results.isEmpty());
         request.setSql(Arrays.asList(sqlInfo2));
-        int total = 1000;
+        int total = 10;
         CountDownLatch countDownLatch = new CountDownLatch(total);
 
         for (int i = 0; i < total; i++) {
@@ -65,13 +67,16 @@ public class SimpleDatabaseManagerServiceTest extends SimpleWebApplicationTests
 
         request.setSql(Arrays.asList(sqlInfo));
         results = databaseManagerService.execute(id, request);
-        System.out.println(JSON.toJSONString(results));
+        Assert.assertFalse(results.isEmpty());
 
-        System.out.println(sqlExecutor.list("select * from t_test"));
+//        System.out.println(JSON.toJSONString(results));
+
+       Assert.assertTrue(sqlExecutor.list("select * from t_test").isEmpty());
 
         databaseManagerService.rollback(id);
         Thread.sleep(2000);
-        System.out.println(sqlExecutor.list("select * from t_test").size());
+        Assert.assertTrue(sqlExecutor.list("select * from t_test").isEmpty());
+
 
     }
 }