mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-15 04:22:09 +08:00
@@ -1,26 +1,17 @@
|
||||
package com.yomahub.liteflow.test.exception;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.exception.ChainNotFoundException;
|
||||
import com.yomahub.liteflow.exception.ChainDuplicateException;
|
||||
import com.yomahub.liteflow.exception.ConfigErrorException;
|
||||
import com.yomahub.liteflow.exception.FlowExecutorNotInitException;
|
||||
import com.yomahub.liteflow.exception.FlowSystemException;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import com.yomahub.liteflow.slot.DefaultContext;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@@ -34,10 +25,20 @@ import javax.annotation.Resource;
|
||||
@SpringBootTest(classes = Exception1SpringBootTest.class)
|
||||
@EnableAutoConfiguration
|
||||
public class Exception1SpringBootTest extends BaseTest {
|
||||
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
/**
|
||||
* 验证 chain 节点重复的异常
|
||||
*/
|
||||
@Test(expected = ChainDuplicateException.class)
|
||||
public void testChainDuplicateException() {
|
||||
LiteflowConfig config = LiteflowConfigGetter.get();
|
||||
config.setRuleSource("exception/flow-exception.xml");
|
||||
flowExecutor.init();
|
||||
}
|
||||
|
||||
@Test(expected = ConfigErrorException.class)
|
||||
public void testConfigErrorException() {
|
||||
flowExecutor.setLiteflowConfig(null);
|
||||
|
||||
@@ -26,7 +26,7 @@ public class SpringELSupportSpringbootTest extends BaseTest {
|
||||
//测试springEL的解析情况
|
||||
@Test
|
||||
public void testSpringELParser() {
|
||||
LiteflowResponse<DefaultContext> response = flowExecutor.execute2Resp("chain1", "arg");
|
||||
LiteflowResponse<DefaultContext> response = flowExecutor.execute2Resp("chain11", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
<then value="a,b,c"/>
|
||||
</chain>
|
||||
|
||||
<chain name="chain1">
|
||||
<then value="a,b,c"/>
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -10,13 +10,13 @@
|
||||
<node id="g" class="com.yomahub.liteflow.test.parser.cmp.GCmp"/>
|
||||
</nodes>
|
||||
|
||||
<chain name="chain1">
|
||||
<chain name="chain11">
|
||||
<then value="a,c"/>
|
||||
<when value="b,d,e(f|g)"/>
|
||||
<then value="chain2"/>
|
||||
</chain>
|
||||
|
||||
<chain name="chain2">
|
||||
<chain name="chain12">
|
||||
<then value="c,g,f"/>
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
|
||||
<chain name="chain1">
|
||||
<chain name="chain21">
|
||||
<then value="a,c"/>
|
||||
<when value="b,d,e(f|g)"/>
|
||||
<then value="chain2"/>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chain2">
|
||||
<chain name="chain32">
|
||||
<then value="c,g,f"/>
|
||||
</chain>
|
||||
</flow>
|
||||
Reference in New Issue
Block a user