Ver código fonte

feature #I5AYM5 组件事件回调特性支持

everywhere.z 3 anos atrás
pai
commit
cf4c233533
32 arquivos alterados com 914 adições e 1 exclusões
  1. 9 1
      liteflow-core/src/main/java/com/yomahub/liteflow/enums/LiteFlowMethodEnum.java
  2. 61 0
      liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/EventSpringbootTest.java
  3. 35 0
      liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java
  4. 33 0
      liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java
  5. 33 0
      liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java
  6. 32 0
      liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java
  7. 33 0
      liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java
  8. 1 0
      liteflow-testcase-declare-component/src/test/resources/event/application.properties
  9. 14 0
      liteflow-testcase-declare-component/src/test/resources/event/flow.xml
  10. 51 0
      liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/EventTest.java
  11. 29 0
      liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java
  12. 27 0
      liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java
  13. 27 0
      liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java
  14. 26 0
      liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java
  15. 27 0
      liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java
  16. 22 0
      liteflow-testcase-nospring/src/test/resources/event/flow.xml
  17. 61 0
      liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/EventSpringbootTest.java
  18. 31 0
      liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java
  19. 29 0
      liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java
  20. 29 0
      liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java
  21. 28 0
      liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java
  22. 29 0
      liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java
  23. 1 0
      liteflow-testcase-springboot/src/test/resources/event/application.properties
  24. 14 0
      liteflow-testcase-springboot/src/test/resources/event/flow.xml
  25. 49 0
      liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/EventSpringTest.java
  26. 31 0
      liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java
  27. 29 0
      liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java
  28. 29 0
      liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java
  29. 28 0
      liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java
  30. 29 0
      liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java
  31. 23 0
      liteflow-testcase-springnative/src/test/resources/event/application.xml
  32. 14 0
      liteflow-testcase-springnative/src/test/resources/event/flow.xml

+ 9 - 1
liteflow-core/src/main/java/com/yomahub/liteflow/enums/LiteFlowMethodEnum.java

@@ -8,7 +8,15 @@ public enum LiteFlowMethodEnum {
     IS_END("isEnd"),
     IS_CONTINUE_ON_ERROR("isContinueOnError"),
 
-    GET_NODE_EXECUTOR_CLASS("getNodeExecutorClass");
+    GET_NODE_EXECUTOR_CLASS("getNodeExecutorClass"),
+
+    ON_SUCCESS("onSuccess"),
+
+    ON_ERROR("onError"),
+
+    BEFORE_PROCESS("beforeProcess"),
+
+    AFTER_PROCESS("afterProcess");
 
     private String methodName;
 

+ 61 - 0
liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/EventSpringbootTest.java

@@ -0,0 +1,61 @@
+package com.yomahub.liteflow.test.event;
+
+import com.yomahub.liteflow.core.FlowExecutor;
+import com.yomahub.liteflow.flow.LiteflowResponse;
+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.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.annotation.Resource;
+
+/**
+ * springboot环境最普通的例子测试
+ * @author Bryan.Zhang
+ * @since 2.6.4
+ */
+@RunWith(SpringRunner.class)
+@TestPropertySource(value = "classpath:/event/application.properties")
+@SpringBootTest(classes = EventSpringbootTest.class)
+@EnableAutoConfiguration
+@ComponentScan({"com.yomahub.liteflow.test.event.cmp"})
+public class EventSpringbootTest extends BaseTest {
+
+    @Resource
+    private FlowExecutor flowExecutor;
+
+    //测试组件成功事件
+    @Test
+    public void testEvent1() throws Exception{
+        LiteflowResponse<DefaultContext> response = flowExecutor.execute2Resp("chain1", "arg");
+        Assert.assertTrue(response.isSuccess());
+        Assert.assertEquals("abc", response.getContextBean().getData("test"));
+    }
+
+    //测试组件失败事件
+    @Test
+    public void testEvent2() throws Exception{
+        LiteflowResponse<DefaultContext> response = flowExecutor.execute2Resp("chain2", "arg");
+        Assert.assertFalse(response.isSuccess());
+        Assert.assertEquals(NullPointerException.class, response.getCause().getClass());
+        Assert.assertEquals("ab", response.getContextBean().getData("test"));
+        Assert.assertEquals("error:d", response.getContextBean().getData("error"));
+    }
+
+    //测试组件失败事件本身抛出异常
+    @Test
+    public void testEvent3() throws Exception{
+        LiteflowResponse<DefaultContext> response = flowExecutor.execute2Resp("chain3", "arg");
+        Assert.assertFalse(response.isSuccess());
+        Assert.assertEquals(NullPointerException.class, response.getCause().getClass());
+        Assert.assertEquals("a", response.getContextBean().getData("test"));
+        Assert.assertEquals("error:e", response.getContextBean().getData("error"));
+    }
+
+}

+ 35 - 0
liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java

@@ -0,0 +1,35 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.event.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
+import com.yomahub.liteflow.annotation.LiteflowMethod;
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
+import com.yomahub.liteflow.slot.DefaultContext;
+import org.springframework.stereotype.Component;
+
+@Component("a")
+@LiteflowCmpDefine
+public class ACmp{
+
+	@LiteflowMethod(LiteFlowMethodEnum.PROCESS)
+	public void process(NodeComponent bindCmp) {
+		DefaultContext context = bindCmp.getContextBean();
+		context.setData("test","");
+		System.out.println("ACmp executed!");
+	}
+
+	@LiteflowMethod(LiteFlowMethodEnum.ON_SUCCESS)
+	public void onSuccess(NodeComponent bindCmp) throws Exception {
+		DefaultContext context = bindCmp.getContextBean();
+		String str = context.getData("test");
+		str += bindCmp.getNodeId();
+		context.setData("test", str);
+	}
+}

+ 33 - 0
liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java

@@ -0,0 +1,33 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.event.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
+import com.yomahub.liteflow.annotation.LiteflowMethod;
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
+import com.yomahub.liteflow.slot.DefaultContext;
+import org.springframework.stereotype.Component;
+
+@Component("b")
+@LiteflowCmpDefine
+public class BCmp{
+
+	@LiteflowMethod(LiteFlowMethodEnum.PROCESS)
+	public void process(NodeComponent bindCmp) {
+		System.out.println("BCmp executed!");
+	}
+
+	@LiteflowMethod(LiteFlowMethodEnum.ON_SUCCESS)
+	public void onSuccess(NodeComponent bindCmp) throws Exception {
+		DefaultContext context = bindCmp.getContextBean();
+		String str = context.getData("test");
+		str += bindCmp.getNodeId();
+		context.setData("test", str);
+	}
+}

+ 33 - 0
liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java

@@ -0,0 +1,33 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.event.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
+import com.yomahub.liteflow.annotation.LiteflowMethod;
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
+import com.yomahub.liteflow.slot.DefaultContext;
+import org.springframework.stereotype.Component;
+
+@Component("c")
+@LiteflowCmpDefine
+public class CCmp{
+
+	@LiteflowMethod(LiteFlowMethodEnum.PROCESS)
+	public void process(NodeComponent bindCmp) {
+		System.out.println("CCmp executed!");
+	}
+
+	@LiteflowMethod(LiteFlowMethodEnum.ON_SUCCESS)
+	public void onSuccess(NodeComponent bindCmp) throws Exception {
+		DefaultContext context = bindCmp.getContextBean();
+		String str = context.getData("test");
+		str += bindCmp.getNodeId();
+		context.setData("test", str);
+	}
+}

+ 32 - 0
liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java

@@ -0,0 +1,32 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.event.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
+import com.yomahub.liteflow.annotation.LiteflowMethod;
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
+import com.yomahub.liteflow.slot.DefaultContext;
+import org.springframework.stereotype.Component;
+
+@Component("d")
+@LiteflowCmpDefine
+public class DCmp{
+
+	@LiteflowMethod(LiteFlowMethodEnum.PROCESS)
+	public void process(NodeComponent bindCmp) throws Exception{
+		System.out.println("CCmp executed!");
+		throw new NullPointerException();
+	}
+
+	@LiteflowMethod(LiteFlowMethodEnum.ON_ERROR)
+	public void onError(NodeComponent bindCmp) throws Exception {
+		DefaultContext context = bindCmp.getContextBean();
+		context.setData("error","error:"+bindCmp.getNodeId());
+	}
+}

+ 33 - 0
liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java

@@ -0,0 +1,33 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.event.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
+import com.yomahub.liteflow.annotation.LiteflowMethod;
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
+import com.yomahub.liteflow.slot.DefaultContext;
+import org.springframework.stereotype.Component;
+
+@Component("e")
+@LiteflowCmpDefine
+public class ECmp{
+
+	@LiteflowMethod(LiteFlowMethodEnum.PROCESS)
+	public void process(NodeComponent bindCmp) throws Exception{
+		System.out.println("CCmp executed!");
+		throw new NullPointerException();
+	}
+
+	@LiteflowMethod(LiteFlowMethodEnum.ON_ERROR)
+	public void onError(NodeComponent bindCmp) throws Exception {
+		DefaultContext context = bindCmp.getContextBean();
+		context.setData("error","error:"+bindCmp.getNodeId());
+		throw new IllegalAccessException("错误事件回调本身抛出异常");
+	}
+}

+ 1 - 0
liteflow-testcase-declare-component/src/test/resources/event/application.properties

@@ -0,0 +1 @@
+liteflow.rule-source=event/flow.xml

+ 14 - 0
liteflow-testcase-declare-component/src/test/resources/event/flow.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<flow>
+    <chain name="chain1">
+        <then value="a,b,c"/>
+    </chain>
+
+    <chain name="chain2">
+        <then value="a,b,d"/>
+    </chain>
+
+    <chain name="chain3">
+        <then value="a,e,b"/>
+    </chain>
+</flow>

+ 51 - 0
liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/EventTest.java

@@ -0,0 +1,51 @@
+package com.yomahub.liteflow.test.event;
+
+import com.yomahub.liteflow.core.FlowExecutor;
+import com.yomahub.liteflow.core.FlowExecutorHolder;
+import com.yomahub.liteflow.flow.LiteflowResponse;
+import com.yomahub.liteflow.property.LiteflowConfig;
+import com.yomahub.liteflow.slot.DefaultContext;
+import com.yomahub.liteflow.test.BaseTest;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class EventTest extends BaseTest{
+
+    private static FlowExecutor flowExecutor;
+
+    @BeforeClass
+    public static void init(){
+        LiteflowConfig config = new LiteflowConfig();
+        config.setRuleSource("event/flow.xml");
+        flowExecutor = FlowExecutorHolder.loadInstance(config);
+    }
+
+    //测试组件成功事件
+    @Test
+    public void testEvent1() throws Exception{
+        LiteflowResponse<DefaultContext> response = flowExecutor.execute2Resp("chain1", "arg");
+        Assert.assertTrue(response.isSuccess());
+        Assert.assertEquals("abc", response.getContextBean().getData("test"));
+    }
+
+    //测试组件失败事件
+    @Test
+    public void testEvent2() throws Exception{
+        LiteflowResponse<DefaultContext> response = flowExecutor.execute2Resp("chain2", "arg");
+        Assert.assertFalse(response.isSuccess());
+        Assert.assertEquals(NullPointerException.class, response.getCause().getClass());
+        Assert.assertEquals("ab", response.getContextBean().getData("test"));
+        Assert.assertEquals("error:d", response.getContextBean().getData("error"));
+    }
+
+    //测试组件失败事件本身抛出异常
+    @Test
+    public void testEvent3() throws Exception{
+        LiteflowResponse<DefaultContext> response = flowExecutor.execute2Resp("chain3", "arg");
+        Assert.assertFalse(response.isSuccess());
+        Assert.assertEquals(NullPointerException.class, response.getCause().getClass());
+        Assert.assertEquals("a", response.getContextBean().getData("test"));
+        Assert.assertEquals("error:e", response.getContextBean().getData("error"));
+    }
+}

+ 29 - 0
liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java

@@ -0,0 +1,29 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.event.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.slot.DefaultContext;
+
+public class ACmp extends NodeComponent {
+
+	@Override
+	public void process() {
+		DefaultContext context = this.getContextBean();
+		context.setData("test","");
+		System.out.println("ACmp executed!");
+	}
+
+	@Override
+	public void onSuccess() throws Exception {
+		DefaultContext context = this.getContextBean();
+		String str = context.getData("test");
+		str += this.getNodeId();
+		context.setData("test", str);
+	}
+}

+ 27 - 0
liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java

@@ -0,0 +1,27 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.event.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.slot.DefaultContext;
+
+public class BCmp extends NodeComponent {
+
+	@Override
+	public void process() {
+		System.out.println("BCmp executed!");
+	}
+
+	@Override
+	public void onSuccess() throws Exception {
+		DefaultContext context = this.getContextBean();
+		String str = context.getData("test");
+		str += this.getNodeId();
+		context.setData("test", str);
+	}
+}

+ 27 - 0
liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java

@@ -0,0 +1,27 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.event.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.slot.DefaultContext;
+
+public class CCmp extends NodeComponent {
+
+	@Override
+	public void process() {
+		System.out.println("CCmp executed!");
+	}
+
+	@Override
+	public void onSuccess() throws Exception {
+		DefaultContext context = this.getContextBean();
+		String str = context.getData("test");
+		str += this.getNodeId();
+		context.setData("test", str);
+	}
+}

+ 26 - 0
liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java

@@ -0,0 +1,26 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.event.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.slot.DefaultContext;
+
+public class DCmp extends NodeComponent {
+
+	@Override
+	public void process() throws Exception{
+		System.out.println("CCmp executed!");
+		throw new NullPointerException();
+	}
+
+	@Override
+	public void onError() throws Exception {
+		DefaultContext context = this.getContextBean();
+		context.setData("error","error:"+this.getNodeId());
+	}
+}

+ 27 - 0
liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java

@@ -0,0 +1,27 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.event.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.slot.DefaultContext;
+
+public class ECmp extends NodeComponent {
+
+	@Override
+	public void process() throws Exception{
+		System.out.println("CCmp executed!");
+		throw new NullPointerException();
+	}
+
+	@Override
+	public void onError() throws Exception {
+		DefaultContext context = this.getContextBean();
+		context.setData("error","error:"+this.getNodeId());
+		throw new IllegalAccessException("错误事件回调本身抛出异常");
+	}
+}

+ 22 - 0
liteflow-testcase-nospring/src/test/resources/event/flow.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<flow>
+    <nodes>
+        <node id="a" class="com.yomahub.liteflow.test.event.cmp.ACmp"/>
+        <node id="b" class="com.yomahub.liteflow.test.event.cmp.BCmp"/>
+        <node id="c" class="com.yomahub.liteflow.test.event.cmp.CCmp"/>
+        <node id="d" class="com.yomahub.liteflow.test.event.cmp.DCmp"/>
+        <node id="e" class="com.yomahub.liteflow.test.event.cmp.ECmp"/>
+    </nodes>
+
+    <chain name="chain1">
+        <then value="a,b,c"/>
+    </chain>
+
+    <chain name="chain2">
+        <then value="a,b,d"/>
+    </chain>
+
+    <chain name="chain3">
+        <then value="a,e,b"/>
+    </chain>
+</flow>

+ 61 - 0
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/EventSpringbootTest.java

@@ -0,0 +1,61 @@
+package com.yomahub.liteflow.test.event;
+
+import com.yomahub.liteflow.core.FlowExecutor;
+import com.yomahub.liteflow.flow.LiteflowResponse;
+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.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.annotation.Resource;
+
+/**
+ * springboot环境事件回调测试
+ * @author Bryan.Zhang
+ * @since 2.7.1
+ */
+@RunWith(SpringRunner.class)
+@TestPropertySource(value = "classpath:/event/application.properties")
+@SpringBootTest(classes = EventSpringbootTest.class)
+@EnableAutoConfiguration
+@ComponentScan({"com.yomahub.liteflow.test.event.cmp"})
+public class EventSpringbootTest extends BaseTest {
+
+    @Resource
+    private FlowExecutor flowExecutor;
+
+    //测试组件成功事件
+    @Test
+    public void testEvent1() throws Exception{
+        LiteflowResponse<DefaultContext> response = flowExecutor.execute2Resp("chain1", "arg");
+        Assert.assertTrue(response.isSuccess());
+        Assert.assertEquals("abc", response.getContextBean().getData("test"));
+    }
+
+    //测试组件失败事件
+    @Test
+    public void testEvent2() throws Exception{
+        LiteflowResponse<DefaultContext> response = flowExecutor.execute2Resp("chain2", "arg");
+        Assert.assertFalse(response.isSuccess());
+        Assert.assertEquals(NullPointerException.class, response.getCause().getClass());
+        Assert.assertEquals("ab", response.getContextBean().getData("test"));
+        Assert.assertEquals("error:d", response.getContextBean().getData("error"));
+    }
+
+    //测试组件失败事件本身抛出异常
+    @Test
+    public void testEvent3() throws Exception{
+        LiteflowResponse<DefaultContext> response = flowExecutor.execute2Resp("chain3", "arg");
+        Assert.assertFalse(response.isSuccess());
+        Assert.assertEquals(NullPointerException.class, response.getCause().getClass());
+        Assert.assertEquals("a", response.getContextBean().getData("test"));
+        Assert.assertEquals("error:e", response.getContextBean().getData("error"));
+    }
+
+}

+ 31 - 0
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java

@@ -0,0 +1,31 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.event.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.slot.DefaultContext;
+import org.springframework.stereotype.Component;
+
+@Component("a")
+public class ACmp extends NodeComponent {
+
+	@Override
+	public void process() {
+		DefaultContext context = this.getContextBean();
+		context.setData("test","");
+		System.out.println("ACmp executed!");
+	}
+
+	@Override
+	public void onSuccess() throws Exception {
+		DefaultContext context = this.getContextBean();
+		String str = context.getData("test");
+		str += this.getNodeId();
+		context.setData("test", str);
+	}
+}

+ 29 - 0
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java

@@ -0,0 +1,29 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.event.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.slot.DefaultContext;
+import org.springframework.stereotype.Component;
+
+@Component("b")
+public class BCmp extends NodeComponent {
+
+	@Override
+	public void process() {
+		System.out.println("BCmp executed!");
+	}
+
+	@Override
+	public void onSuccess() throws Exception {
+		DefaultContext context = this.getContextBean();
+		String str = context.getData("test");
+		str += this.getNodeId();
+		context.setData("test", str);
+	}
+}

+ 29 - 0
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java

@@ -0,0 +1,29 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.event.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.slot.DefaultContext;
+import org.springframework.stereotype.Component;
+
+@Component("c")
+public class CCmp extends NodeComponent {
+
+	@Override
+	public void process() {
+		System.out.println("CCmp executed!");
+	}
+
+	@Override
+	public void onSuccess() throws Exception {
+		DefaultContext context = this.getContextBean();
+		String str = context.getData("test");
+		str += this.getNodeId();
+		context.setData("test", str);
+	}
+}

+ 28 - 0
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java

@@ -0,0 +1,28 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.event.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.slot.DefaultContext;
+import org.springframework.stereotype.Component;
+
+@Component("d")
+public class DCmp extends NodeComponent {
+
+	@Override
+	public void process() throws Exception{
+		System.out.println("CCmp executed!");
+		throw new NullPointerException();
+	}
+
+	@Override
+	public void onError() throws Exception {
+		DefaultContext context = this.getContextBean();
+		context.setData("error","error:"+this.getNodeId());
+	}
+}

+ 29 - 0
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java

@@ -0,0 +1,29 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.event.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.slot.DefaultContext;
+import org.springframework.stereotype.Component;
+
+@Component("e")
+public class ECmp extends NodeComponent {
+
+	@Override
+	public void process() throws Exception{
+		System.out.println("CCmp executed!");
+		throw new NullPointerException();
+	}
+
+	@Override
+	public void onError() throws Exception {
+		DefaultContext context = this.getContextBean();
+		context.setData("error","error:"+this.getNodeId());
+		throw new IllegalAccessException("错误事件回调本身抛出异常");
+	}
+}

+ 1 - 0
liteflow-testcase-springboot/src/test/resources/event/application.properties

@@ -0,0 +1 @@
+liteflow.rule-source=event/flow.xml

+ 14 - 0
liteflow-testcase-springboot/src/test/resources/event/flow.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<flow>
+    <chain name="chain1">
+        <then value="a,b,c"/>
+    </chain>
+
+    <chain name="chain2">
+        <then value="a,b,d"/>
+    </chain>
+
+    <chain name="chain3">
+        <then value="a,e,b"/>
+    </chain>
+</flow>

+ 49 - 0
liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/EventSpringTest.java

@@ -0,0 +1,49 @@
+package com.yomahub.liteflow.test.event;
+
+import com.yomahub.liteflow.core.FlowExecutor;
+import com.yomahub.liteflow.flow.LiteflowResponse;
+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.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.annotation.Resource;
+
+@RunWith(SpringRunner.class)
+@ContextConfiguration("classpath:/event/application.xml")
+public class EventSpringTest extends BaseTest {
+
+    @Resource
+    private FlowExecutor flowExecutor;
+
+    //测试组件成功事件
+    @Test
+    public void testEvent1() throws Exception{
+        LiteflowResponse<DefaultContext> response = flowExecutor.execute2Resp("chain1", "arg");
+        Assert.assertTrue(response.isSuccess());
+        Assert.assertEquals("abc", response.getContextBean().getData("test"));
+    }
+
+    //测试组件失败事件
+    @Test
+    public void testEvent2() throws Exception{
+        LiteflowResponse<DefaultContext> response = flowExecutor.execute2Resp("chain2", "arg");
+        Assert.assertFalse(response.isSuccess());
+        Assert.assertEquals(NullPointerException.class, response.getCause().getClass());
+        Assert.assertEquals("ab", response.getContextBean().getData("test"));
+        Assert.assertEquals("error:d", response.getContextBean().getData("error"));
+    }
+
+    //测试组件失败事件本身抛出异常
+    @Test
+    public void testEvent3() throws Exception{
+        LiteflowResponse<DefaultContext> response = flowExecutor.execute2Resp("chain3", "arg");
+        Assert.assertFalse(response.isSuccess());
+        Assert.assertEquals(NullPointerException.class, response.getCause().getClass());
+        Assert.assertEquals("a", response.getContextBean().getData("test"));
+        Assert.assertEquals("error:e", response.getContextBean().getData("error"));
+    }
+}

+ 31 - 0
liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java

@@ -0,0 +1,31 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.event.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.slot.DefaultContext;
+import org.springframework.stereotype.Component;
+
+@Component("a")
+public class ACmp extends NodeComponent {
+
+	@Override
+	public void process() {
+		DefaultContext context = this.getContextBean();
+		context.setData("test","");
+		System.out.println("ACmp executed!");
+	}
+
+	@Override
+	public void onSuccess() throws Exception {
+		DefaultContext context = this.getContextBean();
+		String str = context.getData("test");
+		str += this.getNodeId();
+		context.setData("test", str);
+	}
+}

+ 29 - 0
liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java

@@ -0,0 +1,29 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.event.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.slot.DefaultContext;
+import org.springframework.stereotype.Component;
+
+@Component("b")
+public class BCmp extends NodeComponent {
+
+	@Override
+	public void process() {
+		System.out.println("BCmp executed!");
+	}
+
+	@Override
+	public void onSuccess() throws Exception {
+		DefaultContext context = this.getContextBean();
+		String str = context.getData("test");
+		str += this.getNodeId();
+		context.setData("test", str);
+	}
+}

+ 29 - 0
liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java

@@ -0,0 +1,29 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.event.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.slot.DefaultContext;
+import org.springframework.stereotype.Component;
+
+@Component("c")
+public class CCmp extends NodeComponent {
+
+	@Override
+	public void process() {
+		System.out.println("CCmp executed!");
+	}
+
+	@Override
+	public void onSuccess() throws Exception {
+		DefaultContext context = this.getContextBean();
+		String str = context.getData("test");
+		str += this.getNodeId();
+		context.setData("test", str);
+	}
+}

+ 28 - 0
liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java

@@ -0,0 +1,28 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.event.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.slot.DefaultContext;
+import org.springframework.stereotype.Component;
+
+@Component("d")
+public class DCmp extends NodeComponent {
+
+	@Override
+	public void process() throws Exception{
+		System.out.println("CCmp executed!");
+		throw new NullPointerException();
+	}
+
+	@Override
+	public void onError() throws Exception {
+		DefaultContext context = this.getContextBean();
+		context.setData("error","error:"+this.getNodeId());
+	}
+}

+ 29 - 0
liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java

@@ -0,0 +1,29 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.event.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.slot.DefaultContext;
+import org.springframework.stereotype.Component;
+
+@Component("e")
+public class ECmp extends NodeComponent {
+
+	@Override
+	public void process() throws Exception{
+		System.out.println("CCmp executed!");
+		throw new NullPointerException();
+	}
+
+	@Override
+	public void onError() throws Exception {
+		DefaultContext context = this.getContextBean();
+		context.setData("error","error:"+this.getNodeId());
+		throw new IllegalAccessException("错误事件回调本身抛出异常");
+	}
+}

+ 23 - 0
liteflow-testcase-springnative/src/test/resources/event/application.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns="http://www.springframework.org/schema/beans"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+       http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
+       http://www.springframework.org/schema/context
+       http://www.springframework.org/schema/context/spring-context-4.0.xsd">
+
+    <context:component-scan base-package="com.yomahub.liteflow.test.event.cmp" />
+
+    <bean id="springAware" class="com.yomahub.liteflow.spi.spring.SpringAware"/>
+
+    <bean class="com.yomahub.liteflow.spring.ComponentScanner"/>
+
+    <bean id="liteflowConfig" class="com.yomahub.liteflow.property.LiteflowConfig">
+        <property name="ruleSource" value="event/flow.xml"/>
+    </bean>
+
+    <bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor">
+        <constructor-arg name="liteflowConfig" ref="liteflowConfig"/>
+    </bean>
+</beans>

+ 14 - 0
liteflow-testcase-springnative/src/test/resources/event/flow.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<flow>
+    <chain name="chain1">
+        <then value="a,b,c"/>
+    </chain>
+
+    <chain name="chain2">
+        <then value="a,b,d"/>
+    </chain>
+
+    <chain name="chain3">
+        <then value="a,e,b"/>
+    </chain>
+</flow>