|
@@ -3,6 +3,7 @@ package com.yomahub.liteflow.test.zookeeper;
|
|
|
import cn.hutool.core.io.resource.ResourceUtil;
|
|
|
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.I0Itec.zkclient.ZkClient;
|
|
|
import org.I0Itec.zkclient.exception.ZkMarshallingError;
|
|
@@ -34,7 +35,9 @@ import java.nio.charset.StandardCharsets;
|
|
|
@ComponentScan({"com.yomahub.liteflow.test.zookeeper.cmp"})
|
|
|
public class ZkClusterWithXmlELSpringbootTest extends BaseTest {
|
|
|
|
|
|
- private static final String ZK_NODE_PATH = "/lite-flow/flow";
|
|
|
+ private static final String ZK_CHAIN_PATH = "/liteflow/chain";
|
|
|
+
|
|
|
+ private static final String ZK_SCRIPT_PATH = "/liteflow/script";
|
|
|
|
|
|
private static TestingCluster zkCluster;
|
|
|
|
|
@@ -50,7 +53,6 @@ public class ZkClusterWithXmlELSpringbootTest extends BaseTest {
|
|
|
zkCluster.start();
|
|
|
String connectStr = zkCluster.getConnectString();
|
|
|
|
|
|
- String data = ResourceUtil.readUtf8Str("zookeeper/flow.xml");
|
|
|
ZkClient zkClient = new ZkClient(connectStr);
|
|
|
zkClient.setZkSerializer(new ZkSerializer() {
|
|
|
@Override
|
|
@@ -63,14 +65,22 @@ public class ZkClusterWithXmlELSpringbootTest extends BaseTest {
|
|
|
return new String(bytes, StandardCharsets.UTF_8);
|
|
|
}
|
|
|
});
|
|
|
- zkClient.createPersistent(ZK_NODE_PATH, true);
|
|
|
- zkClient.writeData(ZK_NODE_PATH, data);
|
|
|
+
|
|
|
+ String chain1Path = ZK_CHAIN_PATH+"/chain1";
|
|
|
+ zkClient.createPersistent(chain1Path, true);
|
|
|
+ zkClient.writeData(chain1Path, "THEN(a, b, c, s1);");
|
|
|
+
|
|
|
+ String script1Path = ZK_SCRIPT_PATH+"/s1:script:脚本s1";
|
|
|
+ zkClient.createPersistent(script1Path, true);
|
|
|
+ zkClient.writeData(script1Path, "defaultContext.setData(\"test\",\"hello\");");
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void testZkNodeWithXml() {
|
|
|
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
|
|
|
+ DefaultContext context = response.getFirstContextBean();
|
|
|
Assert.assertTrue(response.isSuccess());
|
|
|
+ Assert.assertEquals("hello", context.getData("test"));
|
|
|
}
|
|
|
|
|
|
@AfterClass
|