Quellcode durchsuchen

增加脚本平滑刷新的测试用例

bryan31 vor 3 Jahren
Ursprung
Commit
4387155d6e

+ 22 - 0
liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteflowJsonScriptFileGroovyTest.java

@@ -67,4 +67,26 @@ public class LiteflowJsonScriptFileGroovyTest extends BaseTest {
         Assert.assertTrue(responseNew.isSuccess());
         Assert.assertEquals("d==>s2[条件脚本_改]==>b==>s3[普通脚本_新增]", responseNew.getSlot().printStep());
     }
+
+    //测试脚本&规则平滑重载刷新
+    @Test
+    public void testScript4() throws Exception{
+        new Thread(() -> {
+            try{
+                Thread.sleep(1000L);
+                //更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取
+                String newContent = ResourceUtil.readUtf8Str("classpath: /json-script-file/flow_update.json");
+                //进行刷新
+                FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_JSON, newContent);
+            }catch (Exception e){
+                e.printStackTrace();
+            }
+        }).start();
+
+        for (int i = 0; i < 500; i++) {
+            LiteflowResponse<DefaultSlot> responseNew = flowExecutor.execute2Resp("chain2", "arg");
+            Assert.assertTrue(responseNew.isSuccess());
+            Thread.sleep(10L);
+        }
+    }
 }

+ 22 - 0
liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteflowXmlScriptFileGroovyTest.java

@@ -67,4 +67,26 @@ public class LiteflowXmlScriptFileGroovyTest extends BaseTest {
         Assert.assertTrue(responseNew.isSuccess());
         Assert.assertEquals("d==>s2[条件脚本_改]==>b==>s3[普通脚本_新增]", responseNew.getSlot().printStep());
     }
+
+    //测试脚本&规则平滑重载刷新
+    @Test
+    public void testScript4() throws Exception{
+        new Thread(() -> {
+            try{
+                Thread.sleep(1000L);
+                //更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取
+                String newContent = ResourceUtil.readUtf8Str("classpath: /xml-script-file/flow_update.xml");
+                //进行刷新
+                FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_XML, newContent);
+            }catch (Exception e){
+                e.printStackTrace();
+            }
+        }).start();
+
+        for (int i = 0; i < 500; i++) {
+            LiteflowResponse<DefaultSlot> responseNew = flowExecutor.execute2Resp("chain2", "arg");
+            Assert.assertTrue(responseNew.isSuccess());
+            Thread.sleep(10L);
+        }
+    }
 }

+ 22 - 0
liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowJsonScriptFileQLExpressTest.java

@@ -66,4 +66,26 @@ public class LiteflowJsonScriptFileQLExpressTest extends BaseTest {
         Assert.assertTrue(responseNew.isSuccess());
         Assert.assertEquals("d==>s2[条件脚本_改]==>a==>s3[普通脚本_新增]", responseNew.getSlot().printStep());
     }
+
+    //测试脚本&规则平滑重载刷新
+    @Test
+    public void testScript4() throws Exception{
+        new Thread(() -> {
+            try{
+                Thread.sleep(1000L);
+                //更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取
+                String newContent = ResourceUtil.readUtf8Str("classpath: /json-script-file/flow_update.json");
+                //进行刷新
+                FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_JSON, newContent);
+            }catch (Exception e){
+                e.printStackTrace();
+            }
+        }).start();
+
+        for (int i = 0; i < 500; i++) {
+            LiteflowResponse<DefaultSlot> responseNew = flowExecutor.execute2Resp("chain2", "arg");
+            Assert.assertTrue(responseNew.isSuccess());
+            Thread.sleep(10L);
+        }
+    }
 }

+ 22 - 0
liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowXmlScriptFileQLExpressTest.java

@@ -66,4 +66,26 @@ public class LiteflowXmlScriptFileQLExpressTest extends BaseTest {
         Assert.assertTrue(responseNew.isSuccess());
         Assert.assertEquals("d==>s2[条件脚本_改]==>a==>s3[普通脚本_新增]", responseNew.getSlot().printStep());
     }
+
+    //测试脚本&规则平滑重载刷新
+    @Test
+    public void testScript4() throws Exception{
+        new Thread(() -> {
+            try{
+                Thread.sleep(1000L);
+                //更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取
+                String newContent = ResourceUtil.readUtf8Str("classpath: /xml-script-file/flow_update.xml");
+                //进行刷新
+                FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_XML, newContent);
+            }catch (Exception e){
+                e.printStackTrace();
+            }
+        }).start();
+
+        for (int i = 0; i < 500; i++) {
+            LiteflowResponse<DefaultSlot> responseNew = flowExecutor.execute2Resp("chain2", "arg");
+            Assert.assertTrue(responseNew.isSuccess());
+            Thread.sleep(10L);
+        }
+    }
 }