Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kengao2018
fastjson
提交
6e956d2c
fastjson
项目概览
kengao2018
/
fastjson
与 Fork 源项目一致
从无法访问的项目Fork
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
fastjson
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
6e956d2c
编写于
7月 10, 2021
作者:
温
温绍锦
提交者:
GitHub
7月 10, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3530 from MengdiGao/fix-JSONPath_reverse_test
Fix flaky test JSONPath_reverse_test
上级
433398d5
133cca0e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
12 addition
and
3 deletion
+12
-3
src/test/java/com/alibaba/json/bvt/path/JSONPath_reverse_test.java
...java/com/alibaba/json/bvt/path/JSONPath_reverse_test.java
+12
-3
未找到文件。
src/test/java/com/alibaba/json/bvt/path/JSONPath_reverse_test.java
浏览文件 @
6e956d2c
...
...
@@ -3,6 +3,7 @@ package com.alibaba.json.bvt.path;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONPath
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
junit.framework.TestCase
;
public
class
JSONPath_reverse_test
extends
TestCase
...
...
@@ -12,7 +13,13 @@ public class JSONPath_reverse_test extends TestCase
assertEquals
(
"[1001,\"ljw\"]"
,
JSONPath
.
reserveToArray
(
object
,
"id"
,
"name"
).
toString
());
assertEquals
(
"[\"ljw\",1001]"
,
JSONPath
.
reserveToArray
(
object
,
"name"
,
"id"
).
toString
());
assertEquals
(
"[\"ljw\",[\"ljw\",1001,50]]"
,
JSONPath
.
reserveToArray
(
object
,
"name"
,
"*"
).
toString
());
String
text
=
JSON
.
toJSONString
(
JSONPath
.
reserveToArray
(
object
,
"name"
,
"*"
),
SerializerFeature
.
MapSortField
);
assertTrue
(
text
.
equals
(
"[\"ljw\",[\"ljw\",1001,50]]"
)
||
text
.
equals
(
"[\"ljw\",[\"ljw\",50,1001]]"
)
||
text
.
equals
(
"[\"ljw\",[50,1001,\"ljw\"]]"
)
||
text
.
equals
(
"[\"ljw\",[1001,50,\"ljw\"]]"
)
||
text
.
equals
(
"[\"ljw\",[1001,\"ljw\",50]]"
)
||
text
.
equals
(
"[\"ljw\",[50,\"ljw\",1001]]"
));
}
public
void
test_reserve2
()
throws
Exception
{
...
...
@@ -26,8 +33,10 @@ public class JSONPath_reverse_test extends TestCase
public
void
test_reserve3
()
throws
Exception
{
JSONObject
object
=
JSON
.
parseObject
(
"{\"player\":{\"id\":1001,\"name\":\"ljw\",\"age\":50}}"
);
assertEquals
(
"{\"player\":{\"name\":\"ljw\",\"id\":1001}}"
,
JSONPath
.
reserveToObject
(
object
,
"player.id"
,
"player.name"
).
toString
());
assertEquals
(
"{\"player\":{\"name\":\"ljw\",\"id\":1001}}"
,
JSONPath
.
reserveToObject
(
object
,
"player.name"
,
"player.id"
,
"ab.c"
).
toString
());
String
text
=
JSON
.
toJSONString
(
JSONPath
.
reserveToObject
(
object
,
"player.id"
,
"player.name"
),
SerializerFeature
.
MapSortField
);
assertEquals
(
"{\"player\":{\"id\":1001,\"name\":\"ljw\"}}"
,
text
);
text
=
JSON
.
toJSONString
(
JSONPath
.
reserveToObject
(
object
,
"player.name"
,
"player.id"
,
"ab.c"
),
SerializerFeature
.
MapSortField
);
assertEquals
(
"{\"player\":{\"id\":1001,\"name\":\"ljw\"}}"
,
text
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录