mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-15 04:22:09 +08:00
bug #I4LV63 在2.6.5版本中多线程tag取值中,xml没有问题,而json形式有问题
This commit is contained in:
@@ -15,8 +15,6 @@ import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* springboot环境下隐私投递的测试
|
||||
@@ -24,11 +22,11 @@ import java.util.function.Function;
|
||||
* @since 2.5.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@TestPropertySource(value = "classpath:/tag/application.properties")
|
||||
@SpringBootTest(classes = NodeTagSpringbootTest.class)
|
||||
@TestPropertySource(value = "classpath:/tag/application-json.properties")
|
||||
@SpringBootTest(classes = NodeTagSpringbootJsonTest.class)
|
||||
@EnableAutoConfiguration
|
||||
@ComponentScan({"com.yomahub.liteflow.test.tag.cmp"})
|
||||
public class NodeTagSpringbootTest extends BaseTest {
|
||||
public class NodeTagSpringbootJsonTest extends BaseTest {
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.yomahub.liteflow.test.tag;
|
||||
|
||||
import cn.hutool.core.collection.ConcurrentHashSet;
|
||||
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.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.5.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@TestPropertySource(value = "classpath:/tag/application-xml.properties")
|
||||
@SpringBootTest(classes = NodeTagSpringbootXmlTest.class)
|
||||
@EnableAutoConfiguration
|
||||
@ComponentScan({"com.yomahub.liteflow.test.tag.cmp"})
|
||||
public class NodeTagSpringbootXmlTest extends BaseTest {
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
@Test
|
||||
public void testTag1() throws Exception{
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("123",response.getSlot().getData("test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTag2() throws Exception{
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain2", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("a==>a==>a==>c==>e", response.getSlot().printStep());
|
||||
}
|
||||
|
||||
//测试多线程when情况下的tag取值是否正确
|
||||
//这里循环多次的原因是,因为when多线程,有时候因为凑巧,可能正确。所以多次情况下在2.6.4版本肯定出错
|
||||
@Test
|
||||
public void testTag3() throws Exception{
|
||||
for (int i = 0; i < 50; i++) {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain3", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
ConcurrentHashSet<String> testSet = response.getSlot().getData("test");
|
||||
Assert.assertEquals(3, testSet.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
liteflow.rule-source=tag/flow.json
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"flow": {
|
||||
"chain": [
|
||||
{
|
||||
"name": "chain1",
|
||||
"condition": [
|
||||
{"type": "then", "value": "a[1],a[2],a[3]"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "chain2",
|
||||
"condition": [
|
||||
{"type": "then", "value": "a[1],a[2],a[3],c[2](d[5]|e[6])"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "chain3",
|
||||
"condition": [
|
||||
{"type": "then", "value": "b1"},
|
||||
{"type": "when", "value": "b[1],b[2],b[3]"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user