Browse Source

测试用例优化代码

bryan31 3 years ago
parent
commit
28e22f32d7
20 changed files with 133 additions and 26 deletions
  1. 1 1
      liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringbootTest.java
  2. 1 1
      liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlSpringbootTest.java
  3. 1 1
      liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/LFParserJsonSpringbootTest.java
  4. 1 1
      liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/LFParserXmlSpringbootTest.java
  5. 1 1
      liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/LFParserYmlSpringbootTest.java
  6. 3 13
      liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliverySpringbootTest.java
  7. 48 0
      liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/reload/ReloadSpringbootTest.java
  8. 20 0
      liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/reload/cmp/ACmp.java
  9. 21 0
      liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/reload/cmp/BCmp.java
  10. 21 0
      liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/reload/cmp/CCmp.java
  11. 1 1
      liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotSpringbootTest.java
  12. 1 1
      liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithJsonSpringbootTest.java
  13. 1 1
      liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlSpringbootTest.java
  14. 1 1
      liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithYmlSpringbootTest.java
  15. 1 0
      liteflow-testcase-springboot/src/test/resources/reload/application.properties
  16. 6 0
      liteflow-testcase-springboot/src/test/resources/reload/flow.xml
  17. 1 1
      liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringTest.java
  18. 1 1
      liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserJsonSpringTest.java
  19. 1 1
      liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserXmlSpringTest.java
  20. 1 1
      liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserYmlSpringTest.java

+ 1 - 1
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringbootTest.java

@@ -32,7 +32,7 @@ public class CustomParserJsonSpringbootTest extends BaseTest {
 
     //测试springboot场景的自定义json parser
     @Test
-    public void testSpringboot() {
+    public void testJsonCustomParser() {
         LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "args");
         Assert.assertTrue(response.isSuccess());
     }

+ 1 - 1
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlSpringbootTest.java

@@ -33,7 +33,7 @@ public class CustomParserXmlSpringbootTest extends BaseTest {
 
     //测试springboot场景的自定义json parser
     @Test
-    public void testSpringboot() {
+    public void testXmlCustomParser() {
         LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "args");
         Assert.assertTrue(response.isSuccess());
     }

+ 1 - 1
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/LFParserJsonSpringbootTest.java

@@ -32,7 +32,7 @@ public class LFParserJsonSpringbootTest extends BaseTest {
 
     //测试spring场景的json parser
     @Test
-    public void testSpringboot() {
+    public void testJsonParser() {
         LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain2", "arg");
         Assert.assertTrue(response.isSuccess());
     }

+ 1 - 1
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/LFParserXmlSpringbootTest.java

@@ -32,7 +32,7 @@ public class LFParserXmlSpringbootTest extends BaseTest {
 
     //测试无springboot场景的xml parser
     @Test
-    public void testSpringboot() {
+    public void testXmlParser() {
         LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
         Assert.assertTrue(response.isSuccess());
     }

+ 1 - 1
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/LFParserYmlSpringbootTest.java

@@ -32,7 +32,7 @@ public class LFParserYmlSpringbootTest extends BaseTest {
 
     //测试无springboot场景的yml parser
     @Test
-    public void testSpringboot() {
+    public void testYmlParser() {
         LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain2", "arg");
         Assert.assertTrue(response.isSuccess());
     }

+ 3 - 13
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/PirvateDeliverySpringbootTest.java → liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliverySpringbootTest.java

@@ -1,11 +1,8 @@
 package com.yomahub.liteflow.test.privateDelivery;
 
-import cn.hutool.core.util.ReflectUtil;
 import com.yomahub.liteflow.core.FlowExecutor;
-import com.yomahub.liteflow.entity.data.DataBus;
 import com.yomahub.liteflow.entity.data.DefaultSlot;
 import com.yomahub.liteflow.entity.data.LiteflowResponse;
-import com.yomahub.liteflow.entity.data.Slot;
 import com.yomahub.liteflow.test.BaseTest;
 import org.junit.Assert;
 import org.junit.Test;
@@ -17,14 +14,7 @@ import org.springframework.test.context.TestPropertySource;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import javax.annotation.Resource;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
 import java.util.Set;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
 
 /**
  * springboot环境下隐私投递的测试
@@ -33,16 +23,16 @@ import java.util.concurrent.Future;
  */
 @RunWith(SpringRunner.class)
 @TestPropertySource(value = "classpath:/privateDelivery/application.properties")
-@SpringBootTest(classes = PirvateDeliverySpringbootTest.class)
+@SpringBootTest(classes = PrivateDeliverySpringbootTest.class)
 @EnableAutoConfiguration
 @ComponentScan({"com.yomahub.liteflow.test.privateDelivery.cmp"})
-public class PirvateDeliverySpringbootTest extends BaseTest {
+public class PrivateDeliverySpringbootTest extends BaseTest {
 
     @Resource
     private FlowExecutor flowExecutor;
 
     @Test
-    public void testSpringboot() throws Exception{
+    public void testPrivateDelivery() throws Exception{
         LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
         Set<Integer> set = response.getSlot().getData("testSet");
         Assert.assertTrue(response.isSuccess());

+ 48 - 0
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/reload/ReloadSpringbootTest.java

@@ -0,0 +1,48 @@
+package com.yomahub.liteflow.test.reload;
+
+import cn.hutool.core.util.ReflectUtil;
+import com.yomahub.liteflow.core.FlowExecutor;
+import com.yomahub.liteflow.entity.data.DataBus;
+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;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+/**
+ * springboot环境下slot扩容测试
+ * @author Bryan.Zhang
+ * @since 2.5.0
+ */
+@RunWith(SpringRunner.class)
+@TestPropertySource(value = "classpath:/reload/application.properties")
+@SpringBootTest(classes = ReloadSpringbootTest.class)
+@EnableAutoConfiguration
+@ComponentScan({"com.yomahub.liteflow.test.reload.cmp"})
+public class ReloadSpringbootTest extends BaseTest {
+
+    @Resource
+    private FlowExecutor flowExecutor;
+
+    @Test
+    public void testReload() throws Exception{
+        flowExecutor.reloadRule();
+        LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
+        Assert.assertTrue(response.isSuccess());
+    }
+}

+ 20 - 0
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/reload/cmp/ACmp.java

@@ -0,0 +1,20 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.reload.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import org.springframework.stereotype.Component;
+
+@Component("a")
+public class ACmp extends NodeComponent {
+
+	@Override
+	public void process() {
+		System.out.println("ACmp executed!");
+	}
+}

+ 21 - 0
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/reload/cmp/BCmp.java

@@ -0,0 +1,21 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.reload.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import org.springframework.stereotype.Component;
+
+@Component("b")
+public class BCmp extends NodeComponent {
+
+	@Override
+	public void process() {
+		System.out.println("BCmp executed!");
+	}
+
+}

+ 21 - 0
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/reload/cmp/CCmp.java

@@ -0,0 +1,21 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.reload.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import org.springframework.stereotype.Component;
+
+@Component("c")
+public class CCmp extends NodeComponent {
+
+	@Override
+	public void process() {
+		System.out.println("CCmp executed!");
+	}
+
+}

+ 1 - 1
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotSpringbootTest.java

@@ -38,7 +38,7 @@ public class ResizeSlotSpringbootTest extends BaseTest {
     private FlowExecutor flowExecutor;
 
     @Test
-    public void testSpringboot() throws Exception{
+    public void testResize() throws Exception{
         ExecutorService pool = Executors.newCachedThreadPool();
 
         List<Future<LiteflowResponse<DefaultSlot>>> futureList = new ArrayList<>();

+ 1 - 1
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithJsonSpringbootTest.java

@@ -70,7 +70,7 @@ public class ZkNodeWithJsonSpringbootTest extends BaseTest {
     }
     
     @Test
-    public void test() {
+    public void testZkNodeWithJson() {
         LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
         Assert.assertTrue(response.isSuccess());
     }

+ 1 - 1
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlSpringbootTest.java

@@ -70,7 +70,7 @@ public class ZkNodeWithXmlSpringbootTest extends BaseTest {
     }
     
     @Test
-    public void test() {
+    public void testZkNodeWithXml() {
         LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
         Assert.assertTrue(response.isSuccess());
     }

+ 1 - 1
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithYmlSpringbootTest.java

@@ -76,7 +76,7 @@ public class ZkNodeWithYmlSpringbootTest extends BaseTest {
     }
     
     @Test
-    public void test() {
+    public void testZkNodeWithYml() {
         LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
         Assert.assertTrue(response.isSuccess());
     }

+ 1 - 0
liteflow-testcase-springboot/src/test/resources/reload/application.properties

@@ -0,0 +1 @@
+liteflow.rule-source=reload/flow.xml

+ 6 - 0
liteflow-testcase-springboot/src/test/resources/reload/flow.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<flow>
+    <chain name="chain1">
+        <then value="a,b,c"/>
+    </chain>
+</flow>

+ 1 - 1
liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringTest.java

@@ -26,7 +26,7 @@ public class CustomParserJsonSpringTest extends BaseTest {
 
     //测试spring场景的自定义json parser
     @Test
-    public void testSpringCustomParser() {
+    public void testJsonCustomParser() {
         LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "args");
         Assert.assertTrue(response.isSuccess());
     }

+ 1 - 1
liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserJsonSpringTest.java

@@ -26,7 +26,7 @@ public class LFParserJsonSpringTest extends BaseTest {
 
     //测试spring场景的xml parser
     @Test
-    public void testSpring() {
+    public void testJsonParser() {
         LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
         Assert.assertTrue(response.isSuccess());
     }

+ 1 - 1
liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserXmlSpringTest.java

@@ -26,7 +26,7 @@ public class LFParserXmlSpringTest extends BaseTest {
 
     //测试spring场景的xml parser
     @Test
-    public void testSpring() {
+    public void testXmlParser() {
         LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
         Assert.assertTrue(response.isSuccess());
     }

+ 1 - 1
liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserYmlSpringTest.java

@@ -26,7 +26,7 @@ public class LFParserYmlSpringTest extends BaseTest {
 
     //测试spring场景的xml parser
     @Test
-    public void testSpring() {
+    public void testYmlParser() {
         LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
         Assert.assertTrue(response.isSuccess());
     }