mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-15 04:22:09 +08:00
enhancement #I7KR2F 测试用例全面更新为junit5
enhancement #I7J59V java17下进行完整的测试用例测试
This commit is contained in:
@@ -6,11 +6,11 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner;
|
||||
import com.yomahub.liteflow.spring.ComponentScanner;
|
||||
import com.yomahub.liteflow.thread.ExecutorHelper;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
|
||||
public class BaseTest {
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void cleanScanCache() {
|
||||
ComponentScanner.cleanCache();
|
||||
FlowBus.cleanCache();
|
||||
|
||||
@@ -4,9 +4,10 @@ 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.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
@@ -21,7 +22,7 @@ import javax.annotation.Resource;
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.9.5
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@TestPropertySource(value = "classpath:/common/application.properties")
|
||||
@SpringBootTest(classes = ScriptPythonCommonELTest.class)
|
||||
@EnableAutoConfiguration
|
||||
@@ -36,9 +37,9 @@ public class ScriptPythonCommonELTest extends BaseTest {
|
||||
public void testCommon1() {
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
|
||||
DefaultContext context = response.getFirstContextBean();
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals(Integer.valueOf(30), context.getData("s1"));
|
||||
Assert.assertEquals("杰克", context.getData("name"));
|
||||
Assertions.assertTrue(response.isSuccess());
|
||||
Assertions.assertEquals(Integer.valueOf(30), context.getData("s1"));
|
||||
Assertions.assertEquals("杰克", context.getData("name"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,9 +6,10 @@ import com.yomahub.liteflow.test.BaseTest;
|
||||
import com.yomahub.liteflow.test.script.python.contextbean.bean.CheckContext;
|
||||
import com.yomahub.liteflow.test.script.python.contextbean.bean.Order2Context;
|
||||
import com.yomahub.liteflow.test.script.python.contextbean.bean.OrderContext;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
@@ -17,7 +18,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@TestPropertySource(value = "classpath:/contextbean/application.properties")
|
||||
@SpringBootTest(classes = LiteFlowScriptContextbeanPythonTest.class)
|
||||
@EnableAutoConfiguration
|
||||
@@ -32,13 +33,13 @@ public class LiteFlowScriptContextbeanPythonTest extends BaseTest {
|
||||
public void testContextBean1() throws Exception {
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class,
|
||||
Order2Context.class);
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assertions.assertTrue(response.isSuccess());
|
||||
OrderContext orderContext = response.getContextBean(OrderContext.class);
|
||||
CheckContext checkContext = response.getContextBean(CheckContext.class);
|
||||
Order2Context order2Context = response.getContextBean(Order2Context.class);
|
||||
Assert.assertEquals(30, orderContext.getOrderType());
|
||||
Assert.assertEquals("d", checkContext.getSign());
|
||||
Assert.assertEquals("order2", order2Context.getOrderNo());
|
||||
Assertions.assertEquals(30, orderContext.getOrderType());
|
||||
Assertions.assertEquals("d", checkContext.getSign());
|
||||
Assertions.assertEquals("order2", order2Context.getOrderNo());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -51,7 +52,7 @@ public class LiteFlowScriptContextbeanPythonTest extends BaseTest {
|
||||
orderContext2.setOrderNo("order2");
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain2", null, orderContext, checkContext,
|
||||
orderContext2);
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assertions.assertTrue(response.isSuccess());
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user