diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/exception/Exception1SpringBootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/exception/Exception1SpringBootTest.java
index 338fbe424..bd1e2fa90 100644
--- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/exception/Exception1SpringBootTest.java
+++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/exception/Exception1SpringBootTest.java
@@ -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);
diff --git a/liteflow-testcase-declare-component/src/test/resources/exception/flow-exception.xml b/liteflow-testcase-declare-component/src/test/resources/exception/flow-exception.xml
new file mode 100644
index 000000000..662226def
--- /dev/null
+++ b/liteflow-testcase-declare-component/src/test/resources/exception/flow-exception.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/exception/Exception1Test.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/exception/Exception1Test.java
index c988a9b5a..b062dd7fb 100644
--- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/exception/Exception1Test.java
+++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/exception/Exception1Test.java
@@ -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);
diff --git a/liteflow-testcase-nospring/src/test/resources/exception/flow-exception.xml b/liteflow-testcase-nospring/src/test/resources/exception/flow-exception.xml
new file mode 100644
index 000000000..662226def
--- /dev/null
+++ b/liteflow-testcase-nospring/src/test/resources/exception/flow-exception.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception1SpringBootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception1SpringBootTest.java
index 5a79866e4..65b7b7edc 100644
--- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception1SpringBootTest.java
+++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception1SpringBootTest.java
@@ -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);
diff --git a/liteflow-testcase-springboot/src/test/resources/exception/flow-exception.xml b/liteflow-testcase-springboot/src/test/resources/exception/flow-exception.xml
new file mode 100644
index 000000000..662226def
--- /dev/null
+++ b/liteflow-testcase-springboot/src/test/resources/exception/flow-exception.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/exception/Exception1SpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/exception/Exception1SpringTest.java
index 3bccb2781..fbb9d3c9e 100644
--- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/exception/Exception1SpringTest.java
+++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/exception/Exception1SpringTest.java
@@ -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);
diff --git a/liteflow-testcase-springnative/src/test/resources/exception/flow-exception.xml b/liteflow-testcase-springnative/src/test/resources/exception/flow-exception.xml
new file mode 100644
index 000000000..662226def
--- /dev/null
+++ b/liteflow-testcase-springnative/src/test/resources/exception/flow-exception.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file