From 68beff42c5c563770c4b978bd8d47ca188e4b9ff Mon Sep 17 00:00:00 2001 From: "yihua.huang" Date: Sat, 18 Mar 2017 11:01:30 +0800 Subject: [PATCH] add test #493 --- .../downloader/HttpClientDownloaderTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/webmagic-core/src/test/java/us/codecraft/webmagic/downloader/HttpClientDownloaderTest.java b/webmagic-core/src/test/java/us/codecraft/webmagic/downloader/HttpClientDownloaderTest.java index 0e442a87..5440b338 100644 --- a/webmagic-core/src/test/java/us/codecraft/webmagic/downloader/HttpClientDownloaderTest.java +++ b/webmagic-core/src/test/java/us/codecraft/webmagic/downloader/HttpClientDownloaderTest.java @@ -145,4 +145,20 @@ public class HttpClientDownloaderTest { } }); } + + @Test + public void test_download_when_task_is_null() throws Exception { + HttpServer server = httpserver(12306); + server.response("foo"); + Runner.running(server, new Runnable() { + @Override + public void run() throws Exception { + final HttpClientDownloader httpClientDownloader = new HttpClientDownloader(); + Request request = new Request(); + request.setUrl("http://127.0.0.1:12306/"); + Page page = httpClientDownloader.download(request, null); + assertThat(page.getRawText()).isEqualTo("foo"); + } + }); + } }