[I5BR5M]chain 重复的问题

This commit is contained in:
tangkc
2022-06-13 14:40:33 +08:00
parent dcb2e4e587
commit b1e1cfce5e
8 changed files with 106 additions and 23 deletions

View File

@@ -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.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,26 @@ import javax.annotation.Resource;
@SpringBootTest(classes = Exception1SpringBootTest.class)
@EnableAutoConfiguration
public class Exception1SpringBootTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
/**
* 验证 chain 节点重复的异常
*/
@Test(expected = FlowExecutorNotInitException.class)
public void testChainDuplicateException() {
try {
LiteflowConfig config = LiteflowConfigGetter.get();
config.setRuleSource("exception/flow-exception.xml");
flowExecutor.init();
} catch (Exception ex) {
// 这里需要 catch 是因为,异常是往上抛的,最后被包装成了 FlowExecutorNotInitException
Assert.assertTrue(ex.getMessage().contains("[chain name duplicate]"));
throw ex;
}
}
@Test(expected = ConfigErrorException.class)
public void testConfigErrorException() {
flowExecutor.setLiteflowConfig(null);

View File

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

View File

@@ -2,14 +2,10 @@ package com.yomahub.liteflow.test.exception;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.core.FlowExecutorHolder;
import com.yomahub.liteflow.exception.ChainNotFoundException;
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.BeforeClass;
@@ -33,6 +29,22 @@ public class Exception1Test extends BaseTest {
flowExecutor = FlowExecutorHolder.loadInstance(config);
}
/**
* 验证 chain 节点重复的异常
*/
@Test(expected = FlowExecutorNotInitException.class)
public void testChainDuplicateException() {
try {
LiteflowConfig config = LiteflowConfigGetter.get();
config.setRuleSource("exception/flow-exception.xml");
flowExecutor.init();
} catch (Exception ex) {
// 这里需要 catch 是因为,异常是往上抛的,最后被包装成了 FlowExecutorNotInitException
Assert.assertTrue(ex.getMessage().contains("[chain name duplicate]"));
throw ex;
}
}
@Test(expected = ConfigErrorException.class)
public void testConfigErrorException() {
flowExecutor.setLiteflowConfig(null);

View File

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

View File

@@ -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.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;
@@ -38,6 +29,22 @@ public class Exception1SpringBootTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
/**
* 验证 chain 节点重复的异常
*/
@Test(expected = FlowExecutorNotInitException.class)
public void testChainDuplicateException() {
try {
LiteflowConfig config = LiteflowConfigGetter.get();
config.setRuleSource("exception/flow-exception.xml");
flowExecutor.init();
} catch (Exception ex) {
// 这里需要 catch 是因为,异常是往上抛的,最后被包装成了 FlowExecutorNotInitException
Assert.assertTrue(ex.getMessage().contains("[chain name duplicate]"));
throw ex;
}
}
@Test(expected = ConfigErrorException.class)
public void testConfigErrorException() {
flowExecutor.setLiteflowConfig(null);

View File

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

View File

@@ -6,6 +6,7 @@ import com.yomahub.liteflow.exception.FlowExecutorNotInitException;
import com.yomahub.liteflow.property.LiteflowConfig;
import com.yomahub.liteflow.property.LiteflowConfigGetter;
import com.yomahub.liteflow.test.BaseTest;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
@@ -26,6 +27,22 @@ public class Exception1SpringTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
/**
* 验证 chain 节点重复的异常
*/
@Test(expected = FlowExecutorNotInitException.class)
public void testChainDuplicateException() {
try {
LiteflowConfig config = LiteflowConfigGetter.get();
config.setRuleSource("exception/flow-exception.xml");
flowExecutor.init();
} catch (Exception ex) {
// 这里需要 catch 是因为,异常是往上抛的,最后被包装成了 FlowExecutorNotInitException
Assert.assertTrue(ex.getMessage().contains("[chain name duplicate]"));
throw ex;
}
}
@Test(expected = ConfigErrorException.class)
public void testConfigErrorException() {
flowExecutor.setLiteflowConfig(null);

View File

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