mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-23 23:18:12 +08:00
新增部分单元测试
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package com.yomahub.liteflow.test.config;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.entity.data.LiteflowResponse;
|
||||
import com.yomahub.liteflow.entity.data.Slot;
|
||||
import com.yomahub.liteflow.exception.ConfigErrorException;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
@@ -19,14 +22,22 @@ public class LiteflowConfigNoSpringTest extends BaseTest {
|
||||
executor.init();
|
||||
}
|
||||
|
||||
@Test(expected = ConfigErrorException.class)
|
||||
public void testConfigError() throws Exception {
|
||||
LiteflowConfig liteflowConfig = new LiteflowConfig();
|
||||
liteflowConfig.setRuleSource("json:127.0.0.1:2181:/");
|
||||
|
||||
@Test
|
||||
public void testConfig() throws Exception {
|
||||
FlowExecutor executor = new FlowExecutor();
|
||||
executor.setLiteflowConfig(liteflowConfig);
|
||||
LiteflowConfig config = new LiteflowConfig();
|
||||
config.setRuleSource("config/flow.json");
|
||||
executor.setLiteflowConfig(config);
|
||||
executor.init();
|
||||
LiteflowResponse<Slot> response = executor.execute("chain1", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals(15, config.getWhenMaxWaitSeconds().intValue());
|
||||
Assert.assertEquals(200, config.getQueueLimit().intValue());
|
||||
Assert.assertEquals(300000L, config.getDelay().longValue());
|
||||
Assert.assertEquals(300000L, config.getPeriod().longValue());
|
||||
Assert.assertFalse(config.getEnableLog());
|
||||
Assert.assertEquals(Runtime.getRuntime().availableProcessors() * 2, config.getWhenMaxWorkers().longValue());
|
||||
Assert.assertEquals(512, config.getWhenQueueLimit().longValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.config.cmp" />
|
||||
|
||||
<bean id="springAware" class="com.yomahub.liteflow.util.SpringAware"/>
|
||||
|
||||
<bean class="com.yomahub.liteflow.spring.ComponentScanner"/>
|
||||
|
||||
<bean id="liteflowConfig" class="com.yomahub.liteflow.property.LiteflowConfig">
|
||||
<property name="ruleSource" value="config/flow.json"/>
|
||||
</bean>
|
||||
|
||||
<bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor">
|
||||
<property name="liteflowConfig" ref="liteflowConfig"/>
|
||||
</bean>
|
||||
</beans>
|
||||
Reference in New Issue
Block a user