for 0.7.0.alpha
parent
e8abc28072
commit
3c1338193b
9
pom.xml
9
pom.xml
|
@ -6,7 +6,7 @@
|
|||
<version>7</version>
|
||||
</parent>
|
||||
<groupId>us.codecraft</groupId>
|
||||
<version>0.7.0-SNAPSHOT</version>
|
||||
<version>0.7.0.alpha-SNAPSHOT</version>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>pom</packaging>
|
||||
<properties>
|
||||
|
@ -108,7 +108,7 @@
|
|||
<dependency>
|
||||
<groupId>com.github.dreamhead</groupId>
|
||||
<artifactId>moco-core</artifactId>
|
||||
<version>0.9.1</version>
|
||||
<version>0.11.0</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
|
@ -164,8 +164,7 @@
|
|||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.18</version>
|
||||
<configuration>
|
||||
<forkMode>pertest</forkMode>
|
||||
<argLine>-Xms1024m -Xmx1024m -Xss1m </argLine>
|
||||
<forkCount>0</forkCount>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
@ -234,7 +233,7 @@
|
|||
<version>2.10.4</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<doctitle>WebMagic 0.7.0-SNAPSHOT</doctitle>
|
||||
<doctitle>WebMagic 0.7.0.alpha</doctitle>
|
||||
<locale>en_US</locale>
|
||||
</configuration>
|
||||
<executions>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<parent>
|
||||
<groupId>us.codecraft</groupId>
|
||||
<artifactId>webmagic-parent</artifactId>
|
||||
<version>0.7.0-SNAPSHOT</version>
|
||||
<version>0.7.0.alpha-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -63,20 +63,20 @@ public class HttpClientDownloaderTest {
|
|||
|
||||
@Test
|
||||
public void testGetHtmlCharset() throws Exception {
|
||||
HttpServer server = httpserver(13423);
|
||||
HttpServer server = httpServer(13423);
|
||||
server.get(by(uri("/header"))).response(header("Content-Type", "text/html; charset=gbk"));
|
||||
server.get(by(uri("/meta4"))).response(with(text("<html>\n" +
|
||||
" <head>\n" +
|
||||
" <meta charset='gbk'/>\n" +
|
||||
" </head>\n" +
|
||||
" <body></body>\n" +
|
||||
"</html>")),header("Content-Type",""));
|
||||
"</html>")),header("Content-Type","text/html; charset=gbk"));
|
||||
server.get(by(uri("/meta5"))).response(with(text("<html>\n" +
|
||||
" <head>\n" +
|
||||
" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=gbk\" />\n" +
|
||||
" </head>\n" +
|
||||
" <body></body>\n" +
|
||||
"</html>")),header("Content-Type",""));
|
||||
"</html>")),header("Content-Type","text/html"));
|
||||
Runner.running(server, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -114,7 +114,8 @@ public class HttpClientDownloaderTest {
|
|||
|
||||
@Test
|
||||
public void test_selectRequestMethod() throws Exception {
|
||||
HttpServer server = httpserver(13423);
|
||||
final int port = 13423;
|
||||
HttpServer server = httpServer(port);
|
||||
server.get(eq(query("q"), "webmagic")).response("get");
|
||||
server.post(eq(form("q"), "webmagic")).response("post");
|
||||
server.put(eq(form("q"), "webmagic")).response("put");
|
||||
|
@ -127,11 +128,11 @@ public class HttpClientDownloaderTest {
|
|||
@Override
|
||||
public void run() throws Exception {
|
||||
Request request = new Request();
|
||||
request.setUrl("http://127.0.0.1:13423/search?q=webmagic");
|
||||
request.setUrl("http://127.0.0.1:" + port + "/search?q=webmagic");
|
||||
request.setMethod(HttpConstant.Method.GET);
|
||||
Map<String,Object> params = new HashedMap();
|
||||
params.put("q","webmagic");
|
||||
HttpUriRequest httpUriRequest = httpUriRequestConverter.convert(request,site,null).getHttpUriRequest();
|
||||
HttpUriRequest httpUriRequest = httpUriRequestConverter.convert(request,site,null).getHttpUriRequest();
|
||||
assertThat(EntityUtils.toString(HttpClients.custom().build().execute(httpUriRequest).getEntity())).isEqualTo("get");
|
||||
request.setMethod(HttpConstant.Method.DELETE);
|
||||
httpUriRequest = httpUriRequestConverter.convert(request, site, null).getHttpUriRequest();
|
||||
|
@ -142,7 +143,7 @@ public class HttpClientDownloaderTest {
|
|||
request.setMethod(HttpConstant.Method.TRACE);
|
||||
httpUriRequest = httpUriRequestConverter.convert(request, site, null).getHttpUriRequest();
|
||||
assertThat(EntityUtils.toString(HttpClients.custom().build().execute(httpUriRequest).getEntity())).isEqualTo("trace");
|
||||
request.setUrl("http://127.0.0.1:13423/search");
|
||||
request.setUrl("http://127.0.0.1:" + port + "/search");
|
||||
request.setMethod(HttpConstant.Method.POST);
|
||||
request.setRequestBody(HttpRequestBody.form(params, "utf-8"));
|
||||
httpUriRequest = httpUriRequestConverter.convert(request, site, null).getHttpUriRequest();
|
||||
|
@ -156,7 +157,7 @@ public class HttpClientDownloaderTest {
|
|||
|
||||
@Test
|
||||
public void test_set_request_cookie() throws Exception {
|
||||
HttpServer server = httpserver(13423);
|
||||
HttpServer server = httpServer(13423);
|
||||
server.get(eq(cookie("cookie"), "cookie-webmagic")).response("ok");
|
||||
Runner.running(server, new Runnable() {
|
||||
@Override
|
||||
|
@ -173,7 +174,7 @@ public class HttpClientDownloaderTest {
|
|||
|
||||
@Test
|
||||
public void test_set_request_header() throws Exception {
|
||||
HttpServer server = httpserver(13423);
|
||||
HttpServer server = httpServer(13423);
|
||||
server.get(eq(header("header"), "header-webmagic")).response("ok");
|
||||
Runner.running(server, new Runnable() {
|
||||
@Override
|
||||
|
@ -190,7 +191,7 @@ public class HttpClientDownloaderTest {
|
|||
|
||||
@Test
|
||||
public void test_set_site_cookie() throws Exception {
|
||||
HttpServer server = httpserver(13423);
|
||||
HttpServer server = httpServer(13423);
|
||||
server.get(eq(cookie("cookie"), "cookie-webmagic")).response("ok");
|
||||
Runner.running(server, new Runnable() {
|
||||
@Override
|
||||
|
@ -207,7 +208,7 @@ public class HttpClientDownloaderTest {
|
|||
|
||||
@Test
|
||||
public void test_download_when_task_is_null() throws Exception {
|
||||
HttpServer server = httpserver(13423);
|
||||
HttpServer server = httpServer(13423);
|
||||
server.response("foo");
|
||||
Runner.running(server, new Runnable() {
|
||||
@Override
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<parent>
|
||||
<groupId>us.codecraft</groupId>
|
||||
<artifactId>webmagic-parent</artifactId>
|
||||
<version>0.7.0-SNAPSHOT</version>
|
||||
<version>0.7.0.alpha-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<parent>
|
||||
<artifactId>webmagic-parent</artifactId>
|
||||
<groupId>us.codecraft</groupId>
|
||||
<version>0.7.0-SNAPSHOT</version>
|
||||
<version>0.7.0.alpha-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<parent>
|
||||
<artifactId>webmagic-parent</artifactId>
|
||||
<groupId>us.codecraft</groupId>
|
||||
<version>0.7.0-SNAPSHOT</version>
|
||||
<version>0.7.0.alpha-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<parent>
|
||||
<artifactId>webmagic-parent</artifactId>
|
||||
<groupId>us.codecraft</groupId>
|
||||
<version>0.7.0-SNAPSHOT</version>
|
||||
<version>0.7.0.alpha-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<parent>
|
||||
<artifactId>webmagic-parent</artifactId>
|
||||
<groupId>us.codecraft</groupId>
|
||||
<version>0.7.0-SNAPSHOT</version>
|
||||
<version>0.7.0.alpha-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
Loading…
Reference in New Issue