feature #I7I3LL 修改测试用例

This commit is contained in:
Dale Lee
2023-07-12 15:18:01 +08:00
parent 99413e6c3e
commit 93e5693db6
10 changed files with 170 additions and 10 deletions

View File

@@ -17,6 +17,8 @@ import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.concurrent.TimeoutException;
import static com.yomahub.liteflow.test.maxWaitSeconds.cmp.CmpConfig.CONTENT_KEY;
/**
@@ -49,7 +51,7 @@ public class MaxWaitSecondsELDeclMultiSpringbootTest extends BaseTest {
// 测试 When 的超时情况
@Test
public void testWhen1() {
assertTimeout("when1");
assertWhenTimeout("when1");
}
// 测试 WHEN 的非超时情况
@@ -135,7 +137,7 @@ public class MaxWaitSecondsELDeclMultiSpringbootTest 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));
@@ -147,7 +149,25 @@ public class MaxWaitSecondsELDeclMultiSpringbootTest 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());

View File

@@ -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>

View File

@@ -22,6 +22,8 @@ import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.concurrent.TimeoutException;
import static com.yomahub.liteflow.test.maxWaitSeconds.cmp.DCmp.CONTENT_KEY;
/**
@@ -54,7 +56,7 @@ public class MaxWaitSecondsELDeclSpringbootTest extends BaseTest {
// 测试 When 的超时情况
@Test
public void testWhen1() {
assertTimeout("when1");
assertWhenTimeout("when1");
}
// 测试 WHEN 的非超时情况
@@ -140,7 +142,7 @@ public class MaxWaitSecondsELDeclSpringbootTest 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));
@@ -170,7 +172,25 @@ public class MaxWaitSecondsELDeclSpringbootTest 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());

View File

@@ -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>

View File

@@ -17,6 +17,8 @@ import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import java.util.concurrent.TimeoutException;
import static com.yomahub.liteflow.test.maxWaitSeconds.cmp.DCmp.CONTENT_KEY;
/**
@@ -51,7 +53,7 @@ public class MaxWaitSecondsTest extends BaseTest {
// 测试 When 的超时情况
@Test
public void testWhen1() {
assertTimeout("when1");
assertWhenTimeout("when1");
}
// 测试 WHEN 的非超时情况
@@ -137,7 +139,7 @@ public class MaxWaitSecondsTest 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));
@@ -168,7 +170,25 @@ public class MaxWaitSecondsTest 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());

View File

@@ -105,4 +105,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>

View File

@@ -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());

View File

@@ -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>

View File

@@ -19,6 +19,8 @@ import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.concurrent.TimeoutException;
import static com.yomahub.liteflow.test.maxWaitSeconds.cmp.DCmp.CONTENT_KEY;
/**
@@ -48,7 +50,7 @@ public class MaxWaitSecondsELSpringTest extends BaseTest {
// 测试 When 的超时情况
@Test
public void testWhen1() {
assertTimeout("when1");
assertWhenTimeout("when1");
}
// 测试 WHEN 的非超时情况
@@ -134,7 +136,7 @@ public class MaxWaitSecondsELSpringTest 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 MaxWaitSecondsELSpringTest 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());

View File

@@ -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>