Skip to content

Commit d8f978f

Browse files
committed
fix test in JsonPathSelectorTest #289
1 parent 25821c3 commit d8f978f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

webmagic-core/src/test/java/us/codecraft/webmagic/selector/JsonPathSelectorTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package us.codecraft.webmagic.selector;
22

3+
import com.alibaba.fastjson.JSON;
4+
import com.alibaba.fastjson.JSONObject;
35
import org.junit.Test;
46

57
import java.util.List;
@@ -44,5 +46,10 @@ public void testJsonPath() {
4446
select = jsonPathSelector.select(text);
4547
assertThat(select).isEqualTo("Sayings of the Century");
4648
assertThat(list).contains("Sayings of the Century");
49+
jsonPathSelector = new JsonPathSelector("$.store.book[?(@.category == 'reference')]");
50+
select = jsonPathSelector.select(text);
51+
JSONObject object1= JSON.parseObject(select);
52+
JSONObject object2=JSON.parseObject("{\"author\":\"Nigel Rees\",\"title\":\"Sayings of the Century\",\"category\":\"reference\",\"price\":8.95}");
53+
assertThat(object1).isEqualTo(object2);
4754
}
4855
}

0 commit comments

Comments
 (0)