From 09b7062cb8f40cb9750c786a6d0790776eafc64c Mon Sep 17 00:00:00 2001 From: Dale Lee <1658850308@qq.com> Date: Fri, 14 Jul 2023 11:06:08 +0800 Subject: [PATCH] =?UTF-8?q?feature=20#I7I3LL=20=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E6=9B=B4=E6=96=B0=E4=B8=BAJUnit5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...xWaitSecondsELDeclMultiSpringbootTest.java | 31 +++++++++---------- .../MaxWaitSecondsELDeclSpringbootTest.java | 29 +++++++++-------- .../maxWaitSeconds/MaxWaitSecondsTest.java | 27 ++++++++-------- .../MaxWaitSecondsSolonTest.java | 28 ++++++++--------- .../MaxWaitSecondsELSpringbootTest.java | 27 +++++++--------- .../MaxWaitSecondsELSpringTest.java | 30 +++++++++--------- 6 files changed, 82 insertions(+), 90 deletions(-) diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsELDeclMultiSpringbootTest.java index 44f9de204..cbcdf5f71 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsELDeclMultiSpringbootTest.java @@ -6,17 +6,16 @@ import com.yomahub.liteflow.exception.WhenTimeoutException; 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.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 org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; - import java.util.concurrent.TimeoutException; import static com.yomahub.liteflow.test.maxWaitSeconds.cmp.CmpConfig.CONTENT_KEY; @@ -27,11 +26,11 @@ import static com.yomahub.liteflow.test.maxWaitSeconds.cmp.CmpConfig.CONTENT_KEY * @author DaleLee * @since 2.11.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/maxWaitSeconds/application.properties") @SpringBootTest(classes = MaxWaitSecondsELDeclMultiSpringbootTest.class) @EnableAutoConfiguration -@ComponentScan({ "com.yomahub.liteflow.test.maxWaitSeconds.cmp" }) +@ComponentScan({"com.yomahub.liteflow.test.maxWaitSeconds.cmp"}) public class MaxWaitSecondsELDeclMultiSpringbootTest extends BaseTest { @Resource private FlowExecutor flowExecutor; @@ -136,17 +135,17 @@ public class MaxWaitSecondsELDeclMultiSpringbootTest extends BaseTest { @Test public void testFinally1() { LiteflowResponse response = flowExecutor.execute2Resp("finally", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(TimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(TimeoutException.class, response.getCause().getClass()); // FINALLY 执行时在默认数据上下文中放入了 CONTENT_KEY DefaultContext contextBean = response.getFirstContextBean(); - Assert.assertTrue(contextBean.hasData(CONTENT_KEY)); + Assertions.assertTrue(contextBean.hasData(CONTENT_KEY)); } // 测试 maxWaitSeconds 关键字不能作用于 Finally @Test public void testFinally2() { - Assert.assertFalse(LiteFlowChainELBuilder.validate("THEN(a, b, FINALLY(c).maxWaitSeconds(10))")); + Assertions.assertFalse(LiteFlowChainELBuilder.validate("THEN(a, b, FINALLY(c).maxWaitSeconds(10))")); } // 测试 chain 的超时情况 @@ -163,18 +162,18 @@ public class MaxWaitSecondsELDeclMultiSpringbootTest extends BaseTest { private void assertTimeout(String chainId) { LiteflowResponse response = flowExecutor.execute2Resp(chainId, "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(TimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(TimeoutException.class, response.getCause().getClass()); } private void assertWhenTimeout(String chainId) { LiteflowResponse response = flowExecutor.execute2Resp(chainId, "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); } private void assertNotTimeout(String chainId) { LiteflowResponse response = flowExecutor.execute2Resp(chainId, "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsELDeclSpringbootTest.java index 4c4883197..0fe2a68fe 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsELDeclSpringbootTest.java @@ -11,17 +11,16 @@ import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.maxWaitSeconds.cmp.ACmp; import com.yomahub.liteflow.test.maxWaitSeconds.cmp.BCmp; import com.yomahub.liteflow.test.maxWaitSeconds.cmp.CCmp; -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.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 org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; - import java.util.concurrent.TimeoutException; import static com.yomahub.liteflow.test.maxWaitSeconds.cmp.DCmp.CONTENT_KEY; @@ -32,7 +31,7 @@ import static com.yomahub.liteflow.test.maxWaitSeconds.cmp.DCmp.CONTENT_KEY; * @author DaleLee * @since 2.11.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @TestPropertySource(value = "classpath:/maxWaitSeconds/application.properties") @SpringBootTest(classes = MaxWaitSecondsELDeclSpringbootTest.class) @EnableAutoConfiguration @@ -141,11 +140,11 @@ public class MaxWaitSecondsELDeclSpringbootTest extends BaseTest { @Test public void testFinally1() { LiteflowResponse response = flowExecutor.execute2Resp("finally", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(TimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(TimeoutException.class, response.getCause().getClass()); // FINALLY 执行时在默认数据上下文中放入了 CONTENT_KEY DefaultContext contextBean = response.getFirstContextBean(); - Assert.assertTrue(contextBean.hasData(CONTENT_KEY)); + Assertions.assertTrue(contextBean.hasData(CONTENT_KEY)); } // 测试 maxWaitSeconds 关键字不能作用于 Finally @@ -169,7 +168,7 @@ public class MaxWaitSecondsELDeclSpringbootTest extends BaseTest { .setType(NodeTypeEnum.COMMON) .setClazz(CCmp.class) .build(); - Assert.assertFalse(LiteFlowChainELBuilder.validate("THEN(a, b, FINALLY(c).maxWaitSeconds(10))")); + Assertions.assertFalse(LiteFlowChainELBuilder.validate("THEN(a, b, FINALLY(c).maxWaitSeconds(10))")); } // 测试 chain 的超时情况 @@ -186,18 +185,18 @@ public class MaxWaitSecondsELDeclSpringbootTest extends BaseTest { private void assertTimeout(String chainId) { LiteflowResponse response = flowExecutor.execute2Resp(chainId, "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(TimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(TimeoutException.class, response.getCause().getClass()); } private void assertWhenTimeout(String chainId) { LiteflowResponse response = flowExecutor.execute2Resp(chainId, "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); } private void assertNotTimeout(String chainId) { LiteflowResponse response = flowExecutor.execute2Resp(chainId, "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsTest.java index be538913e..3bf51e5c0 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsTest.java @@ -13,9 +13,10 @@ import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.maxWaitSeconds.cmp.ACmp; import com.yomahub.liteflow.test.maxWaitSeconds.cmp.BCmp; import com.yomahub.liteflow.test.maxWaitSeconds.cmp.CCmp; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + import java.util.concurrent.TimeoutException; @@ -31,7 +32,7 @@ public class MaxWaitSecondsTest extends BaseTest { private static FlowExecutor flowExecutor; - @BeforeClass + @BeforeAll public static void init() { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("maxWaitSeconds/flow.el.xml"); @@ -138,11 +139,11 @@ public class MaxWaitSecondsTest extends BaseTest { @Test public void testFinally1() { LiteflowResponse response = flowExecutor.execute2Resp("finally", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(TimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(TimeoutException.class, response.getCause().getClass()); // FINALLY 执行时在默认数据上下文中放入了 CONTENT_KEY DefaultContext contextBean = response.getFirstContextBean(); - Assert.assertTrue(contextBean.hasData(CONTENT_KEY)); + Assertions.assertTrue(contextBean.hasData(CONTENT_KEY)); } @@ -167,7 +168,7 @@ public class MaxWaitSecondsTest extends BaseTest { .setType(NodeTypeEnum.COMMON) .setClazz(CCmp.class) .build(); - Assert.assertFalse(LiteFlowChainELBuilder.validate("THEN(a, b, FINALLY(c).maxWaitSeconds(10))")); + Assertions.assertFalse(LiteFlowChainELBuilder.validate("THEN(a, b, FINALLY(c).maxWaitSeconds(10))")); } // 测试 chain 的超时情况 @@ -184,19 +185,19 @@ public class MaxWaitSecondsTest extends BaseTest { private void assertTimeout(String chainId) { LiteflowResponse response = flowExecutor.execute2Resp(chainId, "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(TimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(TimeoutException.class, response.getCause().getClass()); } private void assertWhenTimeout(String chainId) { LiteflowResponse response = flowExecutor.execute2Resp(chainId, "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); } private void assertNotTimeout(String chainId) { LiteflowResponse response = flowExecutor.execute2Resp(chainId, "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsSolonTest.java b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsSolonTest.java index feeb2c805..981d6b215 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsSolonTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsSolonTest.java @@ -11,11 +11,11 @@ import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.maxWaitSeconds.cmp.ACmp; import com.yomahub.liteflow.test.maxWaitSeconds.cmp.BCmp; import com.yomahub.liteflow.test.maxWaitSeconds.cmp.CCmp; -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.noear.solon.annotation.Inject; -import org.noear.solon.test.SolonJUnit4ClassRunner; +import org.noear.solon.test.SolonJUnit5Extension; import org.noear.solon.test.annotation.TestPropertySource; import java.util.concurrent.TimeoutException; @@ -28,7 +28,7 @@ import static com.yomahub.liteflow.test.maxWaitSeconds.cmp.DCmp.CONTENT_KEY; * @author DaleLee * @since 2.11.0 */ -@RunWith(SolonJUnit4ClassRunner.class) +@ExtendWith(SolonJUnit5Extension.class) @TestPropertySource("classpath:/maxWaitSeconds/application.properties") public class MaxWaitSecondsSolonTest extends BaseTest { @@ -135,11 +135,11 @@ public class MaxWaitSecondsSolonTest extends BaseTest { @Test public void testFinally1() { LiteflowResponse response = flowExecutor.execute2Resp("finally", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(TimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(TimeoutException.class, response.getCause().getClass()); // FINALLY 执行时在默认数据上下文中放入了 CONTENT_KEY DefaultContext contextBean = response.getFirstContextBean(); - Assert.assertTrue(contextBean.hasData(CONTENT_KEY)); + Assertions.assertTrue(contextBean.hasData(CONTENT_KEY)); } @@ -164,7 +164,7 @@ public class MaxWaitSecondsSolonTest extends BaseTest { .setType(NodeTypeEnum.COMMON) .setClazz(CCmp.class) .build(); - Assert.assertFalse(LiteFlowChainELBuilder.validate("THEN(a, b, FINALLY(c).maxWaitSeconds(10))")); + Assertions.assertFalse(LiteFlowChainELBuilder.validate("THEN(a, b, FINALLY(c).maxWaitSeconds(10))")); } // 测试 chain 的超时情况 @@ -181,18 +181,18 @@ public class MaxWaitSecondsSolonTest extends BaseTest { private void assertTimeout(String chainId) { LiteflowResponse response = flowExecutor.execute2Resp(chainId, "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(TimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(TimeoutException.class, response.getCause().getClass()); } private void assertWhenTimeout(String chainId) { LiteflowResponse response = flowExecutor.execute2Resp(chainId, "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); } private void assertNotTimeout(String chainId) { LiteflowResponse response = flowExecutor.execute2Resp(chainId, "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsELSpringbootTest.java index 7e980d595..a71ce42e4 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsELSpringbootTest.java @@ -11,17 +11,14 @@ import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.validateRule.cmp.ACmp; import com.yomahub.liteflow.test.validateRule.cmp.BCmp; import com.yomahub.liteflow.test.validateRule.cmp.CCmp; -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.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; - import java.util.concurrent.TimeoutException; import static com.yomahub.liteflow.test.maxWaitSeconds.cmp.DCmp.CONTENT_KEY; @@ -32,7 +29,6 @@ import static com.yomahub.liteflow.test.maxWaitSeconds.cmp.DCmp.CONTENT_KEY; * @author DaleLee * @since 2.11.0 */ -@RunWith(SpringRunner.class) @TestPropertySource(value = "classpath:/maxWaitSeconds/application.properties") @SpringBootTest(classes = MaxWaitSecondsELSpringbootTest.class) @EnableAutoConfiguration @@ -143,12 +139,11 @@ public class MaxWaitSecondsELSpringbootTest extends BaseTest { @Test public void testFinally1() { LiteflowResponse response = flowExecutor.execute2Resp("finally", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(TimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(TimeoutException.class, response.getCause().getClass()); // FINALLY 执行时在默认数据上下文中放入了 CONTENT_KEY DefaultContext contextBean = response.getFirstContextBean(); - Assert.assertTrue(contextBean.hasData(CONTENT_KEY)); - + Assertions.assertTrue(contextBean.hasData(CONTENT_KEY)); } // 测试 maxWaitSeconds 关键字不能作用于 Finally @@ -172,7 +167,7 @@ public class MaxWaitSecondsELSpringbootTest extends BaseTest { .setType(NodeTypeEnum.COMMON) .setClazz(CCmp.class) .build(); - Assert.assertFalse(LiteFlowChainELBuilder.validate("THEN(a, b, FINALLY(c).maxWaitSeconds(10))")); + Assertions.assertFalse(LiteFlowChainELBuilder.validate("THEN(a, b, FINALLY(c).maxWaitSeconds(10))")); } // 测试 chain 的超时情况 @@ -189,18 +184,18 @@ public class MaxWaitSecondsELSpringbootTest extends BaseTest { private void assertTimeout(String chainId) { LiteflowResponse response = flowExecutor.execute2Resp(chainId, "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(TimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(TimeoutException.class, response.getCause().getClass()); } private void assertWhenTimeout(String chainId) { LiteflowResponse response = flowExecutor.execute2Resp(chainId, "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); } private void assertNotTimeout(String chainId) { LiteflowResponse response = flowExecutor.execute2Resp(chainId, "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsELSpringTest.java index 085644f98..f4aceb423 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/maxWaitSeconds/MaxWaitSecondsELSpringTest.java @@ -11,14 +11,13 @@ import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.maxWaitSeconds.cmp.ACmp; import com.yomahub.liteflow.test.maxWaitSeconds.cmp.BCmp; import com.yomahub.liteflow.test.maxWaitSeconds.cmp.CCmp; -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.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.annotation.Resource; - import java.util.concurrent.TimeoutException; import static com.yomahub.liteflow.test.maxWaitSeconds.cmp.DCmp.CONTENT_KEY; @@ -29,7 +28,7 @@ import static com.yomahub.liteflow.test.maxWaitSeconds.cmp.DCmp.CONTENT_KEY; * @author DaleLee * @since 2.11.0 */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration("classpath:/maxWaitSeconds/application.xml") public class MaxWaitSecondsELSpringTest extends BaseTest { @Resource @@ -135,12 +134,11 @@ public class MaxWaitSecondsELSpringTest extends BaseTest { @Test public void testFinally1() { LiteflowResponse response = flowExecutor.execute2Resp("finally", "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(TimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(TimeoutException.class, response.getCause().getClass()); // FINALLY 执行时在默认数据上下文中放入了 CONTENT_KEY DefaultContext contextBean = response.getFirstContextBean(); - Assert.assertTrue(contextBean.hasData(CONTENT_KEY)); - + Assertions.assertTrue(contextBean.hasData(CONTENT_KEY)); } // 测试 maxWaitSeconds 关键字不能作用于 Finally @@ -164,7 +162,7 @@ public class MaxWaitSecondsELSpringTest extends BaseTest { .setType(NodeTypeEnum.COMMON) .setClazz(CCmp.class) .build(); - Assert.assertFalse(LiteFlowChainELBuilder.validate("THEN(a, b, FINALLY(c).maxWaitSeconds(10))")); + Assertions.assertFalse(LiteFlowChainELBuilder.validate("THEN(a, b, FINALLY(c).maxWaitSeconds(10))")); } // 测试 chain 的超时情况 @@ -181,18 +179,18 @@ public class MaxWaitSecondsELSpringTest extends BaseTest { private void assertTimeout(String chainId) { LiteflowResponse response = flowExecutor.execute2Resp(chainId, "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(TimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(TimeoutException.class, response.getCause().getClass()); } private void assertWhenTimeout(String chainId) { LiteflowResponse response = flowExecutor.execute2Resp(chainId, "arg"); - Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); + Assertions.assertFalse(response.isSuccess()); + Assertions.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); } private void assertNotTimeout(String chainId) { LiteflowResponse response = flowExecutor.execute2Resp(chainId, "arg"); - Assert.assertTrue(response.isSuccess()); + Assertions.assertTrue(response.isSuccess()); } }