测试用例统一归并在主要2个工程test目录下,删除多余的测试用例

This commit is contained in:
bryan31
2021-04-08 12:10:32 +08:00
parent cc10ec1f46
commit fde796526f
30 changed files with 0 additions and 911 deletions

View File

@@ -1,16 +0,0 @@
package com.yomahub.flowtest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class FlowtestApplicationTests {
@Test
public void contextLoads() {
}
}

View File

@@ -1,130 +0,0 @@
package com.yomahub.flowtest.concurrent;
import org.junit.Assert;
import java.util.AbstractMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
/**
* 流程的顺序执行、并发执行的CASE构造器
* @author justin.xu
*/
public class ConcurrentCase {
public static final Map<String, AbstractMap.SimpleEntry<List<Routers>, List<Routers>>> CASES = new ConcurrentHashMap<>();
/**
* 初始化一个测试用例的预期
* @param request
* @param expected
*/
public static void caseInit(String request, List<Routers> expected) {
CASES.put(request, new AbstractMap.SimpleEntry<List<Routers>, List<Routers>>(expected, new CopyOnWriteArrayList<>()));
}
/**
* 添加这个测试用例的实际
* @param request
* @param actual
*/
public static void caseAdd(String request, Routers actual) {
CASES.computeIfPresent(request, (k, v) -> {
v.getValue().add(actual);
return v;
});
}
/**
* 测试当前的Expected与Actual是否相同
*
* @param request
*/
public static void caseAssert(String request) {
AbstractMap.SimpleEntry<List<Routers>, List<Routers>> ca = CASES.get(request);
Assert.assertNotNull(ca);
Assert.assertEquals(ca.getKey(), ca.getValue());
if (ca.getValue().size() > 0) {
Integer expectedIndex = null;
for (Routers actual : ca.getValue()) {
if (expectedIndex == null) {
expectedIndex = actual.getIndex();
} else {
Assert.assertEquals(expectedIndex.intValue(), actual.getIndex());
}
}
}
}
/**
* 测试当前的Expected与Actual是否相同
*
* @param request
*/
public static void caseAssertRandom(String request) {
AbstractMap.SimpleEntry<List<Routers>, List<Routers>> ca = CASES.get(request);
Assert.assertNotNull(ca);
Assert.assertEquals(ca.getKey().size(), ca.getValue().size());
if (ca.getValue().size() > 0) {
Integer expectedIndex = null;
for (Routers actual : ca.getValue()) {
boolean find = false;
for(Routers routers : ca.getKey()) {
if (routers.getValue().equals(actual.getValue())) {
find = true;
}
}
Assert.assertTrue(find);
if (expectedIndex == null) {
expectedIndex = actual.getIndex();
} else {
Assert.assertEquals(expectedIndex.intValue(), actual.getIndex());
}
}
}
}
public static class Routers {
int index;
String value;
public Routers(String value) {
this.index = -1;
this.value = value;
}
public Routers(int index, String value) {
this.index = index;
this.value = value;
}
public int getIndex() {
return index;
}
public String getValue() {
return value;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Routers routers = (Routers) o;
return value.equals(routers.value);
}
@Override
public int hashCode() {
return Objects.hash(value);
}
}
}

View File

@@ -1,20 +0,0 @@
package com.yomahub.flowtest.concurrent;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
/**
* 启动类
* @author justin.xu
*/
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})
public class SpringBootApp {
/**
* @param args
*/
public static void main(String[] args) {
SpringApplication.run(SpringBootApp.class, args);
}
}

View File

@@ -1,49 +0,0 @@
package com.yomahub.flowtest.concurrent;
import com.yomahub.liteflow.core.FlowExecutor;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import static com.yomahub.flowtest.concurrent.ConcurrentCase.caseAssertRandom;
import static com.yomahub.flowtest.concurrent.ConcurrentCase.caseInit;
/**
* 测试流程的顺序执行、并发执行等
* @author justin.xu
*/
@ActiveProfiles("test")
@RunWith(SpringRunner.class)
@SpringBootTest
public class TestGroupIdFlow {
@Resource
private FlowExecutor flowExecutor;
private String init(List<String> steps) {
String requestId = UUID.randomUUID().toString();
caseInit(requestId, steps.stream().map(ConcurrentCase.Routers::new).collect(Collectors.toList()));
return requestId;
}
@Test
public void whenConditionGroupTest() throws Exception {
//由于errorResume即使p5执行失败抛出异常, p7 p8也将会执行
String requestId = init(Arrays.asList("s1", "s2", "s3", "s4", "s5", "s6", "p3", "p4", "p6", "p7", "p8"));
flowExecutor.execute("test-groupId", requestId);
caseAssertRandom(requestId);
}
}

View File

@@ -1,85 +0,0 @@
package com.yomahub.flowtest.concurrent;
import com.yomahub.liteflow.entity.flow.Chain;
import com.yomahub.liteflow.entity.flow.Condition;
import com.yomahub.liteflow.entity.flow.ThenCondition;
import com.yomahub.liteflow.entity.flow.WhenCondition;
import com.yomahub.liteflow.flow.FlowBus;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* 测试流程的解析
* @author justin.xu
*/
@ActiveProfiles("test")
@RunWith(SpringRunner.class)
@SpringBootTest
public class TestParseFlow {
private Check caseErrorResume = new Check("test-errorResume", Arrays.asList(
new AbstractMap.SimpleEntry<Class<? extends Condition>, Boolean>(ThenCondition.class, null),
new AbstractMap.SimpleEntry<Class<? extends Condition>, Boolean>(WhenCondition.class, true),
new AbstractMap.SimpleEntry<Class<? extends Condition>, Boolean>(WhenCondition.class, true),
new AbstractMap.SimpleEntry<Class<? extends Condition>, Boolean>(WhenCondition.class, true)
));
private Check caseErrorBreak = new Check("test-errorBreak", Arrays.asList(
new AbstractMap.SimpleEntry<Class<? extends Condition>, Boolean>(ThenCondition.class, null),
new AbstractMap.SimpleEntry<Class<? extends Condition>, Boolean>(WhenCondition.class, true),
new AbstractMap.SimpleEntry<Class<? extends Condition>, Boolean>(WhenCondition.class, false),
new AbstractMap.SimpleEntry<Class<? extends Condition>, Boolean>(WhenCondition.class, true)
));
@Test
public void parseWhen() throws Exception {
assertTrue(caseErrorResume, FlowBus.getChain(caseErrorResume.getChainCode()));
assertTrue(caseErrorBreak, FlowBus.getChain(caseErrorBreak.getChainCode()));
}
private void assertTrue(Check check, Chain chain) {
Assert.assertNotNull(chain);
Assert.assertTrue(null != chain.getConditionList() && !chain.getConditionList().isEmpty());
for (int i = 0; i < chain.getConditionList().size(); i ++) {
AbstractMap.SimpleEntry<Class<? extends Condition>, Boolean> expected = check.getClazzWithFlags().get(i);
Condition actual = chain.getConditionList().get(i);
Assert.assertEquals(expected.getKey(), actual.getClass());
if (actual.getClass().equals(WhenCondition.class)) {
Assert.assertEquals(expected.getValue(), ((WhenCondition) actual).isErrorResume());
}
}
}
public static class Check {
private String chainCode;
private List<AbstractMap.SimpleEntry<Class<? extends Condition>, Boolean>> clazzWithFlags;
public Check(String chainCode, List<AbstractMap.SimpleEntry<Class<? extends Condition>, Boolean>> clazzWithFlags) {
this.chainCode = chainCode;
this.clazzWithFlags = clazzWithFlags;
}
public String getChainCode() {
return chainCode;
}
public List<AbstractMap.SimpleEntry<Class<? extends Condition>, Boolean>> getClazzWithFlags() {
return clazzWithFlags;
}
}
}

View File

@@ -1,90 +0,0 @@
package com.yomahub.flowtest.concurrent;
import com.yomahub.liteflow.core.FlowExecutor;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import static com.yomahub.flowtest.concurrent.ConcurrentCase.caseAssertRandom;
import static com.yomahub.flowtest.concurrent.ConcurrentCase.caseInit;
/**
* 测试流程的顺序执行、并发执行等
* @author justin.xu
*/
@ActiveProfiles("test")
@RunWith(SpringRunner.class)
@SpringBootTest
public class TestRunFlow {
@Resource
private FlowExecutor flowExecutor;
private String init(List<String> steps) {
String requestId = UUID.randomUUID().toString();
caseInit(requestId, steps.stream().map(ConcurrentCase.Routers::new).collect(Collectors.toList()));
return requestId;
}
@Test
public void mixedRunByErrorResumeTest() throws Exception {
//由于errorResume即使p5执行失败抛出异常, p7 p8也将会执行
String requestId = init(Arrays.asList("s1", "s2", "s3", "s4", "s5", "s6", "p3", "p4", "p6", "p7", "p8"));
flowExecutor.execute("test-errorResume", requestId);
caseAssertRandom(requestId);
}
@Test
public void mixedRunByErrorBreakTest() throws Exception {
//由于errorBreakp5执行失败抛出异常, p7 p8将不会执行
String requestId = init(Arrays.asList("s1", "s2", "s3", "s4", "s5", "s6", "p3", "p4", "p6"));
flowExecutor.execute("test-errorBreak", requestId);
caseAssertRandom(requestId);
}
@Test
public void parallelTest() throws InterruptedException {
//测试2个线程并发时所执行的序列是正常的线程安全的slotIndex在每个执行序列chain中都是不变的
String requestId1 = init(Arrays.asList("c1", "c2", "c3", "c4", "c5"));
String requestId2 = init(Arrays.asList("c6", "c7", "c8", "c9", "c10"));
List<Thread> ts = Arrays.asList(
newExecutor("async-concurrent1", requestId1),
newExecutor("async-concurrent2", requestId2)
);
ts.forEach(Thread::start);
for (Thread t : ts) {
t.join();
}
caseAssertRandom(requestId1);
caseAssertRandom(requestId2);
}
private Thread newExecutor(String chain, String requestId) {
return new Thread(() -> {
try {
flowExecutor.execute(chain, requestId);
} catch (Exception e) {
e.printStackTrace();
}
});
}
}

View File

@@ -1,22 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.c;
import com.yomahub.flowtest.concurrent.ConcurrentCase;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("c10")
public class C10Component extends NodeComponent {
private static final String name = "c10";
@Override
public void process() throws Exception {
Thread.sleep(1_000);
ConcurrentCase.caseAdd((String) getSlot().getRequestData(), new ConcurrentCase.Routers(getSlotIndex(), name));
System.out.println(String.format("[%s] component executed, index[%d].", name, getSlotIndex()));
}
}

View File

@@ -1,22 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.c;
import com.yomahub.flowtest.concurrent.ConcurrentCase;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("c1")
public class C1Component extends NodeComponent {
private static final String name = "c1";
@Override
public void process() throws Exception {
Thread.sleep(1_000);
ConcurrentCase.caseAdd((String) getSlot().getRequestData(), new ConcurrentCase.Routers(getSlotIndex(), name));
System.out.println(String.format("[%s] component executed, index[%d].", name, getSlotIndex()));
}
}

View File

@@ -1,22 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.c;
import com.yomahub.flowtest.concurrent.ConcurrentCase;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("c2")
public class C2Component extends NodeComponent {
private static final String name = "c2";
@Override
public void process() throws Exception {
Thread.sleep(1_000);
ConcurrentCase.caseAdd((String) getSlot().getRequestData(), new ConcurrentCase.Routers(getSlotIndex(), name));
System.out.println(String.format("[%s] component executed, index[%d].", name, getSlotIndex()));
}
}

View File

@@ -1,22 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.c;
import com.yomahub.flowtest.concurrent.ConcurrentCase;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("c3")
public class C3Component extends NodeComponent {
private static final String name = "c3";
@Override
public void process() throws Exception {
Thread.sleep(1_000);
ConcurrentCase.caseAdd((String) getSlot().getRequestData(), new ConcurrentCase.Routers(getSlotIndex(), name));
System.out.println(String.format("[%s] component executed, index[%d].", name, getSlotIndex()));
}
}

View File

@@ -1,22 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.c;
import com.yomahub.flowtest.concurrent.ConcurrentCase;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("c4")
public class C4Component extends NodeComponent {
private static final String name = "c4";
@Override
public void process() throws Exception {
Thread.sleep(1_000);
ConcurrentCase.caseAdd((String) getSlot().getRequestData(), new ConcurrentCase.Routers(getSlotIndex(), name));
System.out.println(String.format("[%s] component executed, index[%d].", name, getSlotIndex()));
}
}

View File

@@ -1,22 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.c;
import com.yomahub.flowtest.concurrent.ConcurrentCase;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("c5")
public class C5Component extends NodeComponent {
private static final String name = "c5";
@Override
public void process() throws Exception {
Thread.sleep(1_000);
ConcurrentCase.caseAdd((String) getSlot().getRequestData(), new ConcurrentCase.Routers(getSlotIndex(), name));
System.out.println(String.format("[%s] component executed, index[%d].", name, getSlotIndex()));
}
}

View File

@@ -1,22 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.c;
import com.yomahub.flowtest.concurrent.ConcurrentCase;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("c6")
public class C6Component extends NodeComponent {
private static final String name = "c6";
@Override
public void process() throws Exception {
Thread.sleep(1_000);
ConcurrentCase.caseAdd((String) getSlot().getRequestData(), new ConcurrentCase.Routers(getSlotIndex(), name));
System.out.println(String.format("[%s] component executed, index[%d].", name, getSlotIndex()));
}
}

View File

@@ -1,22 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.c;
import com.yomahub.flowtest.concurrent.ConcurrentCase;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("c7")
public class C7Component extends NodeComponent {
private static final String name = "c7";
@Override
public void process() throws Exception {
Thread.sleep(1_000);
ConcurrentCase.caseAdd((String) getSlot().getRequestData(), new ConcurrentCase.Routers(getSlotIndex(), name));
System.out.println(String.format("[%s] component executed, index[%d].", name, getSlotIndex()));
}
}

View File

@@ -1,22 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.c;
import com.yomahub.flowtest.concurrent.ConcurrentCase;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("c8")
public class C8Component extends NodeComponent {
private static final String name = "c8";
@Override
public void process() throws Exception {
Thread.sleep(1_000);
ConcurrentCase.caseAdd((String) getSlot().getRequestData(), new ConcurrentCase.Routers(getSlotIndex(), name));
System.out.println(String.format("[%s] component executed, index[%d].", name, getSlotIndex()));
}
}

View File

@@ -1,22 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.c;
import com.yomahub.flowtest.concurrent.ConcurrentCase;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("c9")
public class C9Component extends NodeComponent {
private static final String name = "c9";
@Override
public void process() throws Exception {
Thread.sleep(1_000);
ConcurrentCase.caseAdd((String) getSlot().getRequestData(), new ConcurrentCase.Routers(getSlotIndex(), name));
System.out.println(String.format("[%s] component executed, index[%d].", name, getSlotIndex()));
}
}

View File

@@ -1,21 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.p;
import com.yomahub.flowtest.concurrent.ConcurrentCase;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("p3")
public class P3Component extends NodeComponent {
private static final String name = "p3";
@Override
public void process() throws Exception {
ConcurrentCase.caseAdd((String) getSlot().getRequestData(), new ConcurrentCase.Routers(getSlotIndex(), name));
System.out.println(String.format("[%s] component executed, index[%d].", name, getSlotIndex()));
}
}

View File

@@ -1,21 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.p;
import com.yomahub.flowtest.concurrent.ConcurrentCase;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("p4")
public class P4Component extends NodeComponent {
private static final String name = "p4";
@Override
public void process() throws Exception {
ConcurrentCase.caseAdd((String) getSlot().getRequestData(), new ConcurrentCase.Routers(getSlotIndex(), name));
System.out.println(String.format("[%s] component executed, index[%d].", name, getSlotIndex()));
}
}

View File

@@ -1,19 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.p;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("p5")
public class P5Component extends NodeComponent {
private static final String name = "p5";
@Override
public void process() throws Exception {
throw new RuntimeException(String.format("test mock error [%s]", name));
}
}

View File

@@ -1,21 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.p;
import com.yomahub.flowtest.concurrent.ConcurrentCase;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("p6")
public class P6Component extends NodeComponent {
private static final String name = "p6";
@Override
public void process() throws Exception {
ConcurrentCase.caseAdd((String) getSlot().getRequestData(), new ConcurrentCase.Routers(getSlotIndex(), name));
System.out.println(String.format("[%s] component executed, index[%d].", name, getSlotIndex()));
}
}

View File

@@ -1,21 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.p;
import com.yomahub.flowtest.concurrent.ConcurrentCase;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("p7")
public class P7Component extends NodeComponent {
private static final String name = "p7";
@Override
public void process() throws Exception {
ConcurrentCase.caseAdd((String) getSlot().getRequestData(), new ConcurrentCase.Routers(getSlotIndex(), name));
System.out.println(String.format("[%s] component executed, index[%d].", name, getSlotIndex()));
}
}

View File

@@ -1,21 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.p;
import com.yomahub.flowtest.concurrent.ConcurrentCase;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("p8")
public class P8Component extends NodeComponent {
private static final String name = "p8";
@Override
public void process() throws Exception {
ConcurrentCase.caseAdd((String) getSlot().getRequestData(), new ConcurrentCase.Routers(getSlotIndex(), name));
System.out.println(String.format("[%s] component executed, index[%d].", name, getSlotIndex()));
}
}

View File

@@ -1,21 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.s;
import com.yomahub.flowtest.concurrent.ConcurrentCase;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("s1")
public class S1Component extends NodeComponent {
private static final String name = "s1";
@Override
public void process() throws Exception {
ConcurrentCase.caseAdd((String) getSlot().getRequestData(), new ConcurrentCase.Routers(getSlotIndex(), name));
System.out.println(String.format("[%s] component executed, index[%d].", name, getSlotIndex()));
}
}

View File

@@ -1,21 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.s;
import com.yomahub.flowtest.concurrent.ConcurrentCase;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("s2")
public class S2Component extends NodeComponent {
private static final String name = "s2";
@Override
public void process() throws Exception {
ConcurrentCase.caseAdd((String) getSlot().getRequestData(), new ConcurrentCase.Routers(getSlotIndex(), name));
System.out.println(String.format("[%s] component executed, index[%d].", name, getSlotIndex()));
}
}

View File

@@ -1,21 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.s;
import com.yomahub.flowtest.concurrent.ConcurrentCase;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("s3")
public class S3Component extends NodeComponent {
private static final String name = "s3";
@Override
public void process() throws Exception {
ConcurrentCase.caseAdd((String) getSlot().getRequestData(), new ConcurrentCase.Routers(getSlotIndex(), name));
System.out.println(String.format("[%s] component executed, index[%d].", name, getSlotIndex()));
}
}

View File

@@ -1,21 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.s;
import com.yomahub.flowtest.concurrent.ConcurrentCase;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("s4")
public class S4Component extends NodeComponent {
private static final String name = "s4";
@Override
public void process() throws Exception {
ConcurrentCase.caseAdd((String) getSlot().getRequestData(), new ConcurrentCase.Routers(getSlotIndex(), name));
System.out.println(String.format("[%s] component executed, index[%d].", name, getSlotIndex()));
}
}

View File

@@ -1,21 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.s;
import com.yomahub.flowtest.concurrent.ConcurrentCase;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("s5")
public class S5Component extends NodeComponent {
private static final String name = "s5";
@Override
public void process() throws Exception {
ConcurrentCase.caseAdd((String) getSlot().getRequestData(), new ConcurrentCase.Routers(getSlotIndex(), name));
System.out.println(String.format("[%s] component executed, index[%d].", name, getSlotIndex()));
}
}

View File

@@ -1,21 +0,0 @@
package com.yomahub.flowtest.concurrent.mock.component.s;
import com.yomahub.flowtest.concurrent.ConcurrentCase;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
/**
* 测试mock component
* @author justin.xu
*/
@Component("s6")
public class S6Component extends NodeComponent {
private static final String name = "s6";
@Override
public void process() throws Exception {
ConcurrentCase.caseAdd((String) getSlot().getRequestData(), new ConcurrentCase.Routers(getSlotIndex(), name));
System.out.println(String.format("[%s] component executed, index[%d].", name, getSlotIndex()));
}
}

View File

@@ -1,18 +0,0 @@
logging:
level:
root: debug
io:
lettuce: info
pattern:
console: "%d{yyyy-MM-dd} %d{hhh:mm:ss},%red(%d{SSS}) %green(%-5level) [%thread] %cyan(%logger{36}) : %msg%n"
server:
port: 8086
liteflow:
rule-source: "config/flow-test.xml"
threadPool:
parallel:
worker: 3
queue: 512

View File

@@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<!-- 测试XML解析 when节点中async是否正常 -->
<!-- 测试when节点中errorResume是值各种设置后是否按照正确逻辑调用 -->
<chain name="test-errorResume">
<then value="s1, s2"/> <!-- then表示串行 -->
<when errorResume = "true" value="s3, s4, s5, s6"/> <!-- errorResume = false 表示失败将继续 -->
<when errorResume = "true" value="p3, p4, p5, p6"/> <!-- errorResume = true 表示失败将继续 -->
<when value = "p7, p8"/> <!-- 假设P5抛出Exception时errorResume未设置 则p7 p8必会执行 -->
</chain>
<chain name="test-errorBreak">
<then value="s1, s2"/> <!-- then表示串行 -->
<when errorResume = "true" value="s3, s4, s5, s6"/> <!-- errorResume = false 表示失败将继续 -->
<when errorResume = "false" value="p3, p4, p5, p6"/> <!-- errorResume = true 表示失败将退出 -->
<when value = "p7, p8"/> <!-- 假设P5抛出Exception时则p7 p8必不会执行-->
</chain>
<!-- 模拟线程池中可用线程只有2个线程时当并发的when都大于2时线程来回处理切换中threadLocal中的slotIndex是否正确 -->
<chain name="async-concurrent1">
<when value="c1, c2, c3, c4, c5"/> <!-- async = true 表示并行 -->
</chain>
<chain name="async-concurrent2">
<when value="c6, c7, c8, c9, c10"/> <!-- async = true 表示并行 -->
</chain>
<chain name="test-groupId">
<then value="s1, s2"/> <!-- then表示串行 -->
<when errorResume = "true" value="s3, s4, s5, s6" groupId="g1"/> <!-- 相同groupId errorResume = true -->
<when errorResume = "false" value="p3, p4, p5, p6" groupId="g1"/> <!-- 相同groupId 合并compentent -->
</chain>
</flow>