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

some fix for tests #130

parent b75e64a6
...@@ -49,7 +49,7 @@ public class Site { ...@@ -49,7 +49,7 @@ public class Site {
private HttpHost httpProxy; private HttpHost httpProxy;
private ProxyPool httpProxyPool=new ProxyPool(); private ProxyPool httpProxyPool;
private boolean useGzip = true; private boolean useGzip = true;
...@@ -453,6 +453,11 @@ public class Site { ...@@ -453,6 +453,11 @@ public class Site {
return this; return this;
} }
public Site enableHttpProxyPool() {
this.httpProxyPool=new ProxyPool();
return this;
}
public ProxyPool getHttpProxyPool() { public ProxyPool getHttpProxyPool() {
return httpProxyPool; return httpProxyPool;
} }
......
...@@ -141,8 +141,8 @@ public class HttpClientDownloader extends AbstractDownloader { ...@@ -141,8 +141,8 @@ public class HttpClientDownloader extends AbstractDownloader {
.setSocketTimeout(site.getTimeOut()) .setSocketTimeout(site.getTimeOut())
.setConnectTimeout(site.getTimeOut()) .setConnectTimeout(site.getTimeOut())
.setCookieSpec(CookieSpecs.BEST_MATCH); .setCookieSpec(CookieSpecs.BEST_MATCH);
if (site.getHttpProxyPool().isEnable()) { if (site.getHttpProxyPool() != null && site.getHttpProxyPool().isEnable()) {
HttpHost host = site.getHttpProxyFromPool(); HttpHost host = site.getHttpProxyFromPool();
requestConfigBuilder.setProxy(host); requestConfigBuilder.setProxy(host);
request.putExtra(Request.PROXY, host); request.putExtra(Request.PROXY, host);
} }
......
package us.codecraft.webmagic.proxy; package us.codecraft.webmagic.proxy;
import static org.assertj.core.api.Assertions.assertThat; import org.apache.http.HttpHost;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.http.HttpHost; import static org.assertj.core.api.Assertions.assertThat;
import org.junit.BeforeClass;
import org.junit.Test;
import us.codecraft.webmagic.Request;
/** /**
* @author yxssfxwzy@sina.com May 30, 2014 * @author yxssfxwzy@sina.com May 30, 2014
...@@ -30,11 +28,6 @@ public class ProxyTest { ...@@ -30,11 +28,6 @@ public class ProxyTest {
} }
} }
@Test
public void testAddProxy() {
}
@Test @Test
public void testProxy() { public void testProxy() {
ProxyPool proxyPool = new ProxyPool(httpProxyList); ProxyPool proxyPool = new ProxyPool(httpProxyList);
......
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