diff --git a/core/src/test/java/com/taobao/arthas/core/shell/cli/impl/CliTokenImplTest.java b/core/src/test/java/com/taobao/arthas/core/shell/cli/impl/CliTokenImplTest.java new file mode 100644 index 000000000..608fdc11e --- /dev/null +++ b/core/src/test/java/com/taobao/arthas/core/shell/cli/impl/CliTokenImplTest.java @@ -0,0 +1,103 @@ +package com.taobao.arthas.core.shell.cli.impl; + +import com.taobao.arthas.core.shell.cli.CliToken; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Iterator; +import java.util.List; + +public class CliTokenImplTest { + + /** + * supported: + *
+ * case1:
+ * thread| grep xxx
+ * [thread|, grep, xxx] -> [thread, |, grep, xxx]
+ * case:2
+ * thread | grep xxx
+ * [thread, |, grep, xxx] -> [thread, |, grep, xxx]
+ * case3:
+ * thread |grep xxx
+ * [thread, |grep] -> [thread, |, grep, xxx]
+ */
+ @Test
+ public void testSupportedPipeCharWithoutRegex() {
+ String[] expectedTextTokenValue = new String[]{"thread", "|", "grep", "xxx"};
+ List
+ * case1:
+ * trace -E classA|classB methodA|methodB| grep classA
+ * [trace, -E, classA|classB, methodA|methodB|, grep, classA] -> [trace, -E, classA|classB, methodA|methodB, |, grep, classA]
+ * case2:
+ * trace -E classA|classB methodA|methodB | grep classA
+ * [trace, -E, classA|classB, methodA|methodB, |, grep, classA] -> [trace, -E, classA|classB, methodA|methodB, |, grep, classA]
+ * case3:
+ * trace -E classA|classB methodA|methodB |grep classA
+ * [trace, -E, classA|classB, methodA|methodB, |grep, classA] -> [trace, -E, classA|classB, methodA|methodB, |, grep, classA]
+ */
+ @Test
+ public void testSupportedPipeCharWithRegex() {
+ String[] expectedTextTokenValue = new String[]{"trace", "-E", "classA|classB", "methodA|methodB", "|", "grep", "classA"};
+ List
+ * case1:
+ * thread|grep xxx
+ * [thread|grep, xxx] -> [thread|grep, xxx]
+ * case2:
+ * trace -E classA|classB methodA|methodB|grep classA
+ * [trace, -E, classA|classB, methodA|methodB|grep, classA] -> [trace, -E, classA|classB, methodA|methodB|grep, classA]
+ */
+ @Test
+ public void testUnSupportedPipeChar() {
+ String[] expectedTextTokenValue = new String[]{"thread|grep", "xxx"};
+ List