Commit 8d8194be authored by yihua.huang's avatar yihua.huang

Change HashMap to LinkedHashMap in ResultItems for same order of input and output #76

parent c72483a2
package us.codecraft.webmagic;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
/**
......@@ -14,7 +15,7 @@ import java.util.Map;
*/
public class ResultItems {
private Map<String, Object> fields = new HashMap<String, Object>();
private Map<String, Object> fields = new LinkedHashMap<String, Object>();
private Request request;
......
package us.codecraft.webmagic;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author code4crafter@gmail.com
*/
public class ResultItemsTest {
@Test
public void testOrderOfEntries() throws Exception {
ResultItems resultItems = new ResultItems();
resultItems.put("a", "a");
resultItems.put("b", "b");
resultItems.put("c", "c");
assertThat(resultItems.getAll().keySet()).containsExactly("a","b","c");
}
}
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