Browse Source

add time out

zhou-hao 7 years ago
parent
commit
1476fb5c71

+ 2 - 1
hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/test/java/org/hswebframework/web/schedule/test/DynamicScheduleTests.java

@@ -12,6 +12,7 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 
 
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicLong;
 
 
 /**
 /**
@@ -51,7 +52,7 @@ public class DynamicScheduleTests extends SimpleWebApplicationTests {
 
 
     @Test
     @Test
     public void testCreateJob() throws InterruptedException {
     public void testCreateJob() throws InterruptedException {
-        counter.await();
+        counter.await(100, TimeUnit.SECONDS);
         Assert.assertTrue(value.get()>0);
         Assert.assertTrue(value.get()>0);
     }
     }
 }
 }

+ 2 - 1
hsweb-system/hsweb-system-schedule/hsweb-system-schedule-starter/src/test/java/org/hswebframework/web/schedule/test/ScheduleTests.java

@@ -8,6 +8,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.scheduling.annotation.Scheduled;
 
 
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicInteger;
 
 
 /**
 /**
@@ -31,7 +32,7 @@ public class ScheduleTests extends SimpleWebApplicationTests {
 
 
     @Test
     @Test
     public void test() throws InterruptedException {
     public void test() throws InterruptedException {
-        countDownLatch.await();
+        countDownLatch.await(100, TimeUnit.SECONDS);
         Assert.assertTrue(counter.get() > 0);
         Assert.assertTrue(counter.get() > 0);
     }
     }
 }
 }