mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 20:22:07 +08:00
feature #I7I3LL 修改测试用例
This commit is contained in:
@@ -18,6 +18,8 @@ import org.noear.solon.annotation.Inject;
|
||||
import org.noear.solon.test.SolonJUnit4ClassRunner;
|
||||
import org.noear.solon.test.annotation.TestPropertySource;
|
||||
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import static com.yomahub.liteflow.test.maxWaitSeconds.cmp.DCmp.CONTENT_KEY;
|
||||
|
||||
/**
|
||||
@@ -48,7 +50,7 @@ public class MaxWaitSecondsSolonTest extends BaseTest {
|
||||
// 测试 When 的超时情况
|
||||
@Test
|
||||
public void testWhen1() {
|
||||
assertTimeout("when1");
|
||||
assertWhenTimeout("when1");
|
||||
}
|
||||
|
||||
// 测试 WHEN 的非超时情况
|
||||
@@ -134,7 +136,7 @@ public class MaxWaitSecondsSolonTest extends BaseTest {
|
||||
public void testFinally1() {
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("finally", "arg");
|
||||
Assert.assertFalse(response.isSuccess());
|
||||
Assert.assertEquals(WhenTimeoutException.class, response.getCause().getClass());
|
||||
Assert.assertEquals(TimeoutException.class, response.getCause().getClass());
|
||||
// FINALLY 执行时在默认数据上下文中放入了 CONTENT_KEY
|
||||
DefaultContext contextBean = response.getFirstContextBean();
|
||||
Assert.assertTrue(contextBean.hasData(CONTENT_KEY));
|
||||
@@ -165,7 +167,25 @@ public class MaxWaitSecondsSolonTest extends BaseTest {
|
||||
Assert.assertFalse(LiteFlowChainELBuilder.validate("THEN(a, b, FINALLY(c).maxWaitSeconds(10))"));
|
||||
}
|
||||
|
||||
// 测试 chain 的超时情况
|
||||
@Test
|
||||
public void testChain1() {
|
||||
assertTimeout("chain1");
|
||||
}
|
||||
|
||||
// 测试 chain 的非超时情况
|
||||
@Test
|
||||
public void testChain2() {
|
||||
assertNotTimeout("chain2");
|
||||
}
|
||||
|
||||
private void assertTimeout(String chainId) {
|
||||
LiteflowResponse response = flowExecutor.execute2Resp(chainId, "arg");
|
||||
Assert.assertFalse(response.isSuccess());
|
||||
Assert.assertEquals(TimeoutException.class, response.getCause().getClass());
|
||||
}
|
||||
|
||||
private void assertWhenTimeout(String chainId) {
|
||||
LiteflowResponse response = flowExecutor.execute2Resp(chainId, "arg");
|
||||
Assert.assertFalse(response.isSuccess());
|
||||
Assert.assertEquals(WhenTimeoutException.class, response.getCause().getClass());
|
||||
|
||||
@@ -95,4 +95,16 @@
|
||||
THEN(PRE(a), b, FINALLY(d)).maxWaitSeconds(2);
|
||||
</chain>
|
||||
|
||||
<!-- 测试 chain -->
|
||||
<chain name="testChain">
|
||||
THEN(b)
|
||||
</chain>
|
||||
<chain name="chain1">
|
||||
<!-- 超时 -->
|
||||
testChain.maxWaitSeconds(1);
|
||||
</chain>
|
||||
<chain name="chain2">
|
||||
<!-- 不超时 -->
|
||||
testChain.maxWaitSeconds(3);
|
||||
</chain>
|
||||
</flow>
|
||||
Reference in New Issue
Block a user