提交 649e199f authored 作者: 黄夏豪's avatar 黄夏豪

fix(base): 修复了一个小BUG

上级 581b70b0
...@@ -77,8 +77,6 @@ public class LogQueueRuntime { ...@@ -77,8 +77,6 @@ public class LogQueueRuntime {
String messageToDb = JSONObject.toJSONString(logMsg); String messageToDb = JSONObject.toJSONString(logMsg);
ExecutionRecord executionRecord = addExecutionRecord(testExecuteLog, messageToDb); ExecutionRecord executionRecord = addExecutionRecord(testExecuteLog, messageToDb);
sendMessage(currentThreadId, testExecuteLog.getUniqueKey(), executionRecord.getId(), messageToDb); sendMessage(currentThreadId, testExecuteLog.getUniqueKey(), executionRecord.getId(), messageToDb);
} else {
throw new GlobalException("该线程中的TestCaseLog对象未初始化,请先调用put方法初始化对象");
} }
} }
......
...@@ -64,37 +64,44 @@ class CaseActuatorTest { ...@@ -64,37 +64,44 @@ class CaseActuatorTest {
@Test @Test
void jsonPathTest() throws ScriptException { void jsonPathTest() throws ScriptException {
String json = "{ \"store\": {\n" + String json = "{\n" +
" \"book\": [ \n" + " \"store\": {\n" +
" { \"category\": \"reference\",\n" + " \"book\": [\n" +
" \"author\": \"Nigel Rees\",\n" + " {\n" +
" \"title\": \"Sayings of the Century\",\n" + " \"category\": \"reference\",\n" +
" \"price\": 8.95\n" + " \"author\": \"Nigel Rees\",\n" +
" },\n" + " \"title\": \"Sayings of the Century\",\n" +
" { \"category\": \"fiction\",\n" + " \"price\": 8.95\n" +
" \"author\": \"Evelyn Waugh\",\n" + " },\n" +
" \"title\": \"Sword of Honour\",\n" + " {\n" +
" \"price\": 12.99\n" + " \"category\": \"fiction\",\n" +
" },\n" + " \"author\": \"Evelyn Waugh\",\n" +
" { \"category\": \"fiction\",\n" + " \"title\": \"Sword of Honour\",\n" +
" \"author\": \"Herman Melville\",\n" + " \"price\": 12.99\n" +
" \"title\": \"Moby Dick\",\n" + " },\n" +
" \"isbn\": \"0-553-21311-3\",\n" + " {\n" +
" \"price\": 8.99\n" + " \"category\": \"fiction\",\n" +
" },\n" + " \"author\": \"Herman Melville\",\n" +
" { \"category\": \"fiction\",\n" + " \"title\": \"Moby Dick\",\n" +
" \"author\": \"J. R. R. Tolkien\",\n" + " \"isbn\": \"0-553-21311-3\",\n" +
" \"title\": \"The Lord of the Rings\",\n" + " \"price\": 8.99\n" +
" \"isbn\": \"0-395-19395-8\",\n" + " },\n" +
" \"price\": 22.99\n" + " {\n" +
" }\n" + " \"category\": \"fiction\",\n" +
" ],\n" + " \"author\": \"J. R. R. Tolkien\",\n" +
" \"bicycle\": {\n" + " \"title\": \"The Lord of the Rings\",\n" +
" \"color\": \"red\",\n" + " \"isbn\": \"0-395-19395-8\",\n" +
" \"price\": 19.95\n" + " \"price\": 22.99\n" +
" }\n" + " }\n" +
" }\n" + " ],\n" +
"}"; " \"bicycle\": {\n" +
" \"color\": \"red\",\n" +
" \"price\": 19.95\n" +
" }\n" +
" },\n" +
" \"expensive\": 10\n" +
"}\n" +
" ";
ScriptEngine jsEngine = ScriptUtil.createJsEngine(); ScriptEngine jsEngine = ScriptUtil.createJsEngine();
jsEngine.eval("//a跟b进行比较,对象类型分为以下几种:基础类型、数组、普通对象\n" + jsEngine.eval("//a跟b进行比较,对象类型分为以下几种:基础类型、数组、普通对象\n" +
"function equal(a, b) {\n" + "function equal(a, b) {\n" +
...@@ -219,8 +226,7 @@ class CaseActuatorTest { ...@@ -219,8 +226,7 @@ class CaseActuatorTest {
"var a = new BaseEntity('{\"name\":1,\"age\":2}');\n" + "var a = new BaseEntity('{\"name\":1,\"age\":2}');\n" +
"var b = new BaseEntity('{\"name\":1,\"age\":3}');\n" + "var b = new BaseEntity('{\"name\":1,\"age\":3}');\n" +
"\n"); "\n");
Object read = JsonPath.parse(json).read("$.store.book[0].price"); Object read = JsonPath.parse(json).read("$.store.bicycle.color");
Object eval = jsEngine.eval(JSON.toJSONString(read) + ".length()");
System.out.println("1"); System.out.println("1");
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论