diff --git a/liteflow-test/pom.xml b/liteflow-test/pom.xml
index 302b6745c..49fcc8cc7 100644
--- a/liteflow-test/pom.xml
+++ b/liteflow-test/pom.xml
@@ -9,9 +9,8 @@
com.thebeastshop
- flowtest
+ liteflow-test
1.0.0
- flowtest
Demo project for Spring Boot
diff --git a/liteflow/src/test/java/com/thebeastshop/liteflow/test/TestCustomParser.java b/liteflow/src/test/java/com/thebeastshop/liteflow/test/TestCustomParser.java
deleted file mode 100644
index 652a90666..000000000
--- a/liteflow/src/test/java/com/thebeastshop/liteflow/test/TestCustomParser.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.thebeastshop.liteflow.test;
-
-import com.thebeastshop.liteflow.parser.ClassXmlFlowParser;
-
-public class TestCustomParser extends ClassXmlFlowParser {
-
- @Override
- public String parseCustom() {
- System.out.println("进入自定义parser,这里只做进入作用,不返回具体xml");
- return null;
- }
-
-}
diff --git a/liteflow/src/test/java/com/thebeastshop/liteflow/test/TestMain.java b/liteflow/src/test/java/com/thebeastshop/liteflow/test/TestMain.java
index 0beca1906..98c0d0c8a 100644
--- a/liteflow/src/test/java/com/thebeastshop/liteflow/test/TestMain.java
+++ b/liteflow/src/test/java/com/thebeastshop/liteflow/test/TestMain.java
@@ -14,16 +14,17 @@ import java.util.Arrays;
import com.thebeastshop.liteflow.core.FlowExecutor;
import com.thebeastshop.liteflow.entity.data.Slot;
+/**
+ * 这是编程式引用liteflow
+ */
public class TestMain {
public static void main(String[] args) throws Exception {
final FlowExecutor executor = new FlowExecutor();
executor.setRulePath(Arrays.asList(new String[]{"config/flow.xml"}));
executor.init();
-
- for(int i=0;i<1;i++){
- Slot slot = executor.execute("chain1", "it's a request");
- System.out.println(slot);
- }
+
+ Slot slot = executor.execute("chain1", "it's a request");
+ System.out.println(slot);
}
-
+
}
diff --git a/liteflow/src/test/java/com/thebeastshop/liteflow/test/TestWithSpringMain.java b/liteflow/src/test/java/com/thebeastshop/liteflow/test/TestWithSpringMain.java
index 61897ce48..553cf4533 100644
--- a/liteflow/src/test/java/com/thebeastshop/liteflow/test/TestWithSpringMain.java
+++ b/liteflow/src/test/java/com/thebeastshop/liteflow/test/TestWithSpringMain.java
@@ -14,31 +14,25 @@ import com.thebeastshop.liteflow.core.FlowExecutor;
import com.thebeastshop.liteflow.entity.data.Slot;
-
+/**
+ * 此示例演示了如何在spring中用liteflow
+ * 如果是springboot请参考flowtest
+ */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:spring-test.xml" })
public class TestWithSpringMain {
-
+
@Resource(name="flowExecutor")
private FlowExecutor flowExecutor;
-
+
@Test
public void test1() throws Exception {
- ExecutorService executorService = Executors.newFixedThreadPool(10);
-
- for(int i=0;i<1;i++){
- executorService.submit(new Thread(){
- @Override
- public void run() {
- Slot slot = flowExecutor.execute("chain1", "it's a request");
- System.out.println(slot);
- }
- });
- }
+ Slot slot = flowExecutor.execute("chain1", "it's a request");
+ System.out.println(slot);
System.out.println("done!");
System.in.read();
}
-
+
@Test
public void test2() throws Exception {
try {
@@ -48,9 +42,9 @@ public class TestWithSpringMain {
}catch(Exception e) {
e.printStackTrace();
}
-
+
}
-
+
@Test
public void test3() throws Exception {
try {
@@ -61,6 +55,6 @@ public class TestWithSpringMain {
}catch(Exception e) {
e.printStackTrace();
}
-
+
}
}
diff --git a/liteflow/src/test/java/com/thebeastshop/liteflow/test/curator/CuratorTest.java b/liteflow/src/test/java/com/thebeastshop/liteflow/test/curator/CuratorTest.java
deleted file mode 100644
index 3d6989dcc..000000000
--- a/liteflow/src/test/java/com/thebeastshop/liteflow/test/curator/CuratorTest.java
+++ /dev/null
@@ -1,135 +0,0 @@
-package com.thebeastshop.liteflow.test.curator;
-
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.framework.CuratorFrameworkFactory;
-import org.apache.curator.framework.recipes.cache.NodeCache;
-import org.apache.curator.framework.recipes.cache.NodeCacheListener;
-import org.apache.curator.framework.recipes.cache.PathChildrenCache;
-import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
-import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener;
-import org.apache.curator.retry.RetryNTimes;
-
-public class CuratorTest {
-
- /** Zookeeper info */
- private static final String ZK_ADDRESS = "123.206.92.144:2181,123.206.92.144:2182,123.206.92.144:2183";
- private static final String ZK_PATH = "/zktest/a1/aa1";
-
- public static void main(String[] args) throws Exception {
- // 1.Connect to zk
- CuratorFramework client = CuratorFrameworkFactory.newClient(
- ZK_ADDRESS,
- new RetryNTimes(10, 5000)
- );
- client.start();
-
- checkNode(client);
-
-// childNodeListen(client);
-
-// removeNodeData(client);
-
-// createNode(client);
-
-// nodeListen(client);
-//
-// modifyNodeData(client);
-
- System.in.read();
-
-// getNodeData(client);
-//
-//
-
- }
-
- private static void checkNode(CuratorFramework client) throws Exception {
- System.out.println(client.checkExists().forPath("/test"));
- }
-
- private static void createNode(CuratorFramework client) throws Exception {
- String data1 = "nice to meet you";
- print("create", ZK_PATH, data1);
- client.create().
- creatingParentsIfNeeded().
- forPath(ZK_PATH, data1.getBytes());
- }
-
- private static void getNodeData(CuratorFramework client) throws Exception {
- print("ls", "/");
- print(client.getChildren().forPath("/"));
- print("get", ZK_PATH);
- print(client.getData().forPath(ZK_PATH));
- }
-
- private static void modifyNodeData(CuratorFramework client) throws Exception {
- String data2 = "world for u";
- print("set", ZK_PATH, data2);
- client.setData().forPath(ZK_PATH, data2.getBytes());
- print("get", ZK_PATH);
- print(client.getData().forPath(ZK_PATH));
- }
-
- private static void removeNodeData(CuratorFramework client) throws Exception {
- print("delete", "/zktest/dddd");
- client.delete().forPath("/zktest/dddd");
- print("ls", "/");
- print(client.getChildren().forPath("/"));
- }
-
- private static void nodeListen(CuratorFramework client) throws Exception {
- final NodeCache cache = new NodeCache(client,ZK_PATH);
- cache.start();
-
- cache.getListenable().addListener(new NodeCacheListener() {
-
- @Override
- public void nodeChanged() throws Exception {
- byte[] res = cache.getCurrentData().getData();
- System.out.println("data: " + new String(res));
- }
- });
- }
-
- private static void childNodeListen(CuratorFramework client) throws Exception {
- final PathChildrenCache cache = new PathChildrenCache(client,"/zktest",true);
- cache.start();
-
- cache.getListenable().addListener(new PathChildrenCacheListener() {
-
- @Override
- public void childEvent(CuratorFramework curator, PathChildrenCacheEvent event) throws Exception {
- switch (event.getType()) {
- case CHILD_ADDED:
- System.out.println("add:" + event.getData().getPath() + ":" + new String(event.getData().getData()));
- break;
- case CHILD_UPDATED:
- System.out.println("update:" + event.getData().getPath() + ":" + new String(event.getData().getData()));
- break;
- case CHILD_REMOVED:
- System.out.println("remove:" + event.getData().getPath() + ":" + new String(event.getData().getData()));
- break;
- default:
- break;
- }
- }
- });
- }
-
-
- private static void print(String... cmds) {
- StringBuilder text = new StringBuilder("$ ");
- for (String cmd : cmds) {
- text.append(cmd).append(" ");
- }
- System.out.println(text.toString());
- }
-
- private static void print(Object result) {
- System.out.println(
- result instanceof byte[]
- ? new String((byte[]) result)
- : result);
- }
-
-}
diff --git a/liteflow/src/test/java/com/thebeastshop/liteflow/test/curator/CuratorTest2.java b/liteflow/src/test/java/com/thebeastshop/liteflow/test/curator/CuratorTest2.java
deleted file mode 100644
index 232ecace1..000000000
--- a/liteflow/src/test/java/com/thebeastshop/liteflow/test/curator/CuratorTest2.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package com.thebeastshop.liteflow.test.curator;
-
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.framework.CuratorFrameworkFactory;
-import org.apache.curator.framework.recipes.cache.NodeCache;
-import org.apache.curator.framework.recipes.cache.NodeCacheListener;
-import org.apache.curator.framework.recipes.cache.PathChildrenCache;
-import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
-import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener;
-import org.apache.curator.retry.RetryNTimes;
-
-public class CuratorTest2 {
-
- /** Zookeeper info */
- private static final String ZK_ADDRESS = "114.55.174.189:2181";
- private static final String ZK_PATH = "/zktest/ffff";
-
- public static void main(String[] args) throws Exception {
- // 1.Connect to zk
- CuratorFramework client = CuratorFrameworkFactory.newClient(
- ZK_ADDRESS,
- new RetryNTimes(10, 5000)
- );
- client.start();
-
-// removeNodeData(client);
-
-// createNode(client);
-
-// nodeListen(client);
-//
- modifyNodeData(client);
-
- }
-
- private static void createNode(CuratorFramework client) throws Exception {
- String data1 = "hello";
- print("create", ZK_PATH, data1);
- client.create().
- creatingParentsIfNeeded().
- forPath(ZK_PATH, data1.getBytes());
- }
-
- private static void getNodeData(CuratorFramework client) throws Exception {
- print("ls", "/");
- print(client.getChildren().forPath("/"));
- print("get", ZK_PATH);
- print(client.getData().forPath(ZK_PATH));
- }
-
- private static void modifyNodeData(CuratorFramework client) throws Exception {
- String data2 = "world for u";
- print("set", ZK_PATH, data2);
- client.setData().forPath(ZK_PATH, data2.getBytes());
- print("get", ZK_PATH);
- print(client.getData().forPath(ZK_PATH));
- }
-
- private static void removeNodeData(CuratorFramework client) throws Exception {
- print("delete", "/zktest/dddd");
- client.delete().forPath("/zktest/dddd");
- print("ls", "/");
- print(client.getChildren().forPath("/"));
- }
-
- private static void nodeListen(CuratorFramework client) throws Exception {
- final NodeCache cache = new NodeCache(client,ZK_PATH);
- cache.start();
-
- cache.getListenable().addListener(new NodeCacheListener() {
-
- @Override
- public void nodeChanged() throws Exception {
- byte[] res = cache.getCurrentData().getData();
- System.out.println("data: " + new String(res));
- }
- });
- }
-
- private static void childNodeListen(CuratorFramework client) throws Exception {
- final PathChildrenCache cache = new PathChildrenCache(client,"/zktest",true);
- cache.start();
-
- cache.getListenable().addListener(new PathChildrenCacheListener() {
-
- @Override
- public void childEvent(CuratorFramework curator, PathChildrenCacheEvent event) throws Exception {
- switch (event.getType()) {
- case CHILD_ADDED:
- System.out.println("add:" + event.getData().getPath() + ":" + new String(event.getData().getData()));
- break;
- case CHILD_UPDATED:
- System.out.println("update:" + event.getData().getPath() + ":" + new String(event.getData().getData()));
- break;
- case CHILD_REMOVED:
- System.out.println("remove:" + event.getData().getPath() + ":" + new String(event.getData().getData()));
- break;
- default:
- break;
- }
- }
- });
- }
-
-
- private static void print(String... cmds) {
- StringBuilder text = new StringBuilder("$ ");
- for (String cmd : cmds) {
- text.append(cmd).append(" ");
- }
- System.out.println(text.toString());
- }
-
- private static void print(Object result) {
- System.out.println(
- result instanceof byte[]
- ? new String((byte[]) result)
- : result);
- }
-
-}
diff --git a/liteflow/src/test/java/com/thebeastshop/liteflow/test/regex/RegexTest.java b/liteflow/src/test/java/com/thebeastshop/liteflow/test/regex/RegexTest.java
deleted file mode 100644
index c1efeebd9..000000000
--- a/liteflow/src/test/java/com/thebeastshop/liteflow/test/regex/RegexTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.thebeastshop.liteflow.test.regex;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class RegexTest {
-
- public static void main(String[] args) {
- String str = "192.168.1.1:2181,192.168.1.2:2182,192.168.1.3:2183";
- List list = new ArrayList();
- Pattern p = Pattern.compile("[\\w\\d][\\w\\d\\.]+\\:(\\d)+(\\,[\\w\\d][\\w\\d\\.]+\\:(\\d)+)*");
- Matcher m = p.matcher(str);
- while(m.find()){
- list.add(m.group());
- }
- System.out.println(list.size());
- System.out.println(list);
-
- }
-
-}