Commit d8f978fd authored by yihua.huang's avatar yihua.huang

fix test in JsonPathSelectorTest #289

parent 25821c3c
package us.codecraft.webmagic.selector; package us.codecraft.webmagic.selector;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.junit.Test; import org.junit.Test;
import java.util.List; import java.util.List;
...@@ -44,5 +46,10 @@ public class JsonPathSelectorTest { ...@@ -44,5 +46,10 @@ public class JsonPathSelectorTest {
select = jsonPathSelector.select(text); select = jsonPathSelector.select(text);
assertThat(select).isEqualTo("Sayings of the Century"); assertThat(select).isEqualTo("Sayings of the Century");
assertThat(list).contains("Sayings of the Century"); assertThat(list).contains("Sayings of the Century");
jsonPathSelector = new JsonPathSelector("$.store.book[?(@.category == 'reference')]");
select = jsonPathSelector.select(text);
JSONObject object1= JSON.parseObject(select);
JSONObject object2=JSON.parseObject("{\"author\":\"Nigel Rees\",\"title\":\"Sayings of the Century\",\"category\":\"reference\",\"price\":8.95}");
assertThat(object1).isEqualTo(object2);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment