mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-15 04:22:09 +08:00
补充测试用例
This commit is contained in:
@@ -24,7 +24,6 @@ import javax.annotation.Resource;
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = BuilderSpringbootTest.class)
|
||||
@EnableAutoConfiguration
|
||||
@ComponentScan({"com.yomahub.liteflow.test.builder.cmp"})
|
||||
public class BuilderSpringbootTest extends BaseTest {
|
||||
|
||||
@Resource
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* springboot环境下异步线程超时日志打印测试
|
||||
* springboot环境下自定义声明节点的测试
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.6.4
|
||||
*/
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.yomahub.liteflow.test.customThreadPool;
|
||||
|
||||
import com.yomahub.liteflow.thread.ExecutorBuilder;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class CustomThreadExecutor implements ExecutorBuilder {
|
||||
@Override
|
||||
public ExecutorService buildExecutor() {
|
||||
return Executors.newCachedThreadPool();
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.yomahub.liteflow.test.customThreadPool;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.entity.data.DefaultSlot;
|
||||
import com.yomahub.liteflow.entity.data.LiteflowResponse;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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:/customThreadPool/application.properties")
|
||||
@SpringBootTest(classes = CustomThreadPoolSpringbootTest.class)
|
||||
@EnableAutoConfiguration
|
||||
@ComponentScan({"com.yomahub.liteflow.test.customThreadPool.cmp"})
|
||||
public class CustomThreadPoolSpringbootTest extends BaseTest {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
@Test
|
||||
public void testCustomThreadPool() throws Exception{
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertFalse(response.getSlot().getData("threadName").toString().startsWith("lf-when-thead"));
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.customThreadPool.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("a")
|
||||
public class ACmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("ACmp executed!");
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.customThreadPool.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("b")
|
||||
public class BCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
this.getSlot().setData("threadName", Thread.currentThread().getName());
|
||||
System.out.println("BCmp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.customThreadPool.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("c")
|
||||
public class CCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("CCmp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.yomahub.liteflow.test.enable;
|
||||
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import com.yomahub.liteflow.spi.holder.ContextAwareHolder;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
@@ -27,13 +29,9 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
@ComponentScan({"com.yomahub.liteflow.test.enable.cmp"})
|
||||
public class LiteflowEnableSpringbootTest extends BaseTest {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
|
||||
|
||||
@Test
|
||||
public void testEnable() {
|
||||
LiteflowConfig config = context.getBean(LiteflowConfig.class);
|
||||
LiteflowConfig config = LiteflowConfigGetter.get();
|
||||
Boolean enable = config.getEnable();
|
||||
if (enable) {
|
||||
System.out.println("成功启动,并且打印");
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.yomahub.liteflow.test.exception;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.entity.data.DefaultSlot;
|
||||
import com.yomahub.liteflow.entity.data.LiteflowResponse;
|
||||
import com.yomahub.liteflow.entity.data.Slot;
|
||||
import com.yomahub.liteflow.exception.ChainNotFoundException;
|
||||
import com.yomahub.liteflow.exception.ConfigErrorException;
|
||||
import com.yomahub.liteflow.exception.FlowExecutorNotInitException;
|
||||
@@ -32,10 +31,10 @@ import javax.annotation.Resource;
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@TestPropertySource(value = "classpath:/exception/application.properties")
|
||||
@SpringBootTest(classes = FlowExecutorSpringBootTest.class)
|
||||
@SpringBootTest(classes = ExceptionSpringBootTest.class)
|
||||
@EnableAutoConfiguration
|
||||
@ComponentScan({"com.yomahub.liteflow.test.exception.cmp1"})
|
||||
public class FlowExecutorSpringBootTest extends BaseTest {
|
||||
@ComponentScan({"com.yomahub.liteflow.test.exception.cmp"})
|
||||
public class ExceptionSpringBootTest extends BaseTest {
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
@@ -65,7 +64,7 @@ public class FlowExecutorSpringBootTest extends BaseTest {
|
||||
public void testComponentCustomException() throws Exception {
|
||||
flowExecutor.execute("chain1", "exception");
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = FlowSystemException.class)
|
||||
public void testNoConditionInChainException() throws Exception {
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "test");
|
||||
@@ -81,11 +80,4 @@ public class FlowExecutorSpringBootTest extends BaseTest {
|
||||
Assert.assertNotNull(response.getCause());
|
||||
Assert.assertNotNull(response.getSlot());
|
||||
}
|
||||
|
||||
// @Test(expected = WhenExecuteException.class)
|
||||
// public void testWhenExecuteTimeoutException() throws Exception {
|
||||
// LiteflowResponse response = flowExecutor.execute("chain3", "when");
|
||||
// Assert.assertFalse(response.isSuccess());
|
||||
// ReflectionUtils.rethrowException(response.getCause());
|
||||
// }
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.exception.cmp1;
|
||||
package com.yomahub.liteflow.test.exception.cmp;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
@@ -5,7 +5,7 @@
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.exception.cmp1;
|
||||
package com.yomahub.liteflow.test.exception.cmp;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
@@ -5,7 +5,7 @@
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.exception.cmp1;
|
||||
package com.yomahub.liteflow.test.exception.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.slf4j.Logger;
|
||||
@@ -5,7 +5,7 @@
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.exception.cmp1;
|
||||
package com.yomahub.liteflow.test.exception.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.slf4j.Logger;
|
||||
@@ -1,2 +0,0 @@
|
||||
liteflow.rule-source=customThreadPool/flow.xml
|
||||
liteflow.thread-executor-class=com.yomahub.liteflow.test.customThreadPool.CustomThreadExecutor
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
<when value="a,b,c"/>
|
||||
</chain>
|
||||
</flow>
|
||||
Reference in New Issue
Block a user