浏览代码

优化测试

zhouhao 6 年之前
父节点
当前提交
68ecacbbd5

+ 1 - 1
.travis.yml

@@ -3,7 +3,7 @@ sudo: false
 jdk:
   - oraclejdk8
 script:
-  - mvn test
+  - mvn -q test
 after_success:
   - bash <(curl -s https://codecov.io/bash)
 cache:

+ 8 - 6
hsweb-concurrent/hsweb-concurrent-async-job/src/test/java/org/hswebframework/web/async/TransactionSupportAsyncJobServiceTest.java

@@ -57,7 +57,7 @@ public class TransactionSupportAsyncJobServiceTest extends SimpleWebApplicationT
                 Thread.sleep(50);
                 throw new RuntimeException("1234");
             }, true);
-            for (int i = 0; i < 100; i++) {
+            for (int i = 0; i < 10; i++) {
                 jobContainer.submit(() -> sqlExecutor.insert("insert into test values('test')", null), true);
             }
 
@@ -72,15 +72,17 @@ public class TransactionSupportAsyncJobServiceTest extends SimpleWebApplicationT
     public void testSimple() throws Exception {
         try {
             BatchAsyncJobContainer jobContainer = asyncJobService.batch();
+
+            for (int i = 0; i < 10; i++) {
+                jobContainer.submit(() -> sqlExecutor.insert("insert into test values('test')", null), false);
+            }
+
             jobContainer.submit(() -> {
-                Thread.sleep(10);
+                Thread.sleep(100);
                 jobContainer.cancel();
                 throw new RuntimeException();
             }, false);
-            for (int i = 0; i < 100; i++) {
-                jobContainer.submit(() -> sqlExecutor.insert("insert into test values('test')", null), false);
-            }
-
+            
             System.out.println(jobContainer.getResult().size());
 
         } catch (Exception ignore) {

+ 0 - 2
hsweb-concurrent/hsweb-concurrent-counter/hsweb-concurrent-counter-api/src/main/java/org/hswebframework/web/concurrent/counter/CounterManager.java

@@ -18,8 +18,6 @@
 package org.hswebframework.web.concurrent.counter;
 
 /**
- * TODO 完成注释
- *
  * @author zhouhao
  */
 public interface CounterManager {

+ 0 - 25
hsweb-concurrent/hsweb-concurrent-counter/hsweb-concurrent-counter-api/src/test/java/org/hswebframework/web/concurrent/counter/SimpleCounterTest.java

@@ -1,25 +0,0 @@
-package org.hswebframework.web.concurrent.counter;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * TODO 完成注释
- *
- * @author zhouhao
- */
-public class SimpleCounterTest {
-
-    private CounterManager counterManager = new SimpleCounterManager();
-
-    @Test
-    public void testSimple() throws InterruptedException {
-        for (int i = 0; i < 100; i++) {
-            new Thread(() -> counterManager.getCounter("test").increment()).start();
-        }
-
-        Thread.sleep(500);
-        Assert.assertEquals(counterManager.getCounter("test").get(), 100);
-    }
-
-}

+ 0 - 34
hsweb-concurrent/hsweb-concurrent-counter/hsweb-concurrent-counter-redis/src/test/java/org/hswebframework/web/counter/redis/RedissonCounterTest.java

@@ -1,34 +0,0 @@
-package org.hswebframework.web.counter.redis;
-
-import org.hswebframework.web.concurrent.counter.CounterManager;
-import org.junit.Assert;
-import org.redisson.Redisson;
-import org.redisson.config.Config;
-
-/**
- * TODO 完成注释
- *
- * @author zhouhao
- */
-public class RedissonCounterTest {
-
-    public static void main(String[] args) throws InterruptedException {
-        Config config = new Config();
-//        config.setUseLinuxNativeEpoll(true);
-        config.useSingleServer().setAddress("redis://127.0.0.1:6379");
-        Redisson redisson = (Redisson) Redisson.create(config);
-
-        CounterManager counterManager = new RedissonCounterManager(redisson);
-        //重置
-        counterManager.getCounter("test").set(0);
-
-        for (int i = 0; i < 100; i++) {
-            new Thread(() -> counterManager.getCounter("test").increment()).start();
-        }
-
-        Thread.sleep(500);
-        Assert.assertEquals(counterManager.getCounter("test").get(), 100);
-        redisson.shutdown();
-
-    }
-}