Commit 3c133819 authored by yihua.huang's avatar yihua.huang

for 0.7.0.alpha

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