Update httpClient test
This commit is contained in:
parent
d042d236f1
commit
13f7e2a692
|
@ -15,9 +15,7 @@ import org.apache.http.HttpHeaders;
|
|||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.params.BasicHttpParams;
|
||||
import org.apache.http.params.HttpParams;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -33,10 +31,7 @@ public class HttpClientUnshortenLiveTest {
|
|||
|
||||
@Before
|
||||
public final void before() {
|
||||
final HttpParams httpParameters = new BasicHttpParams();
|
||||
httpParameters.setParameter("http.protocol.handle-redirects", false);
|
||||
|
||||
client = new DefaultHttpClient(httpParameters);
|
||||
client = HttpClientBuilder.create().disableRedirectHandling().build();
|
||||
}
|
||||
|
||||
// tests
|
||||
|
|
|
@ -8,12 +8,12 @@ import java.io.InputStream;
|
|||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.protocol.HttpClientContext;
|
||||
import org.apache.http.impl.client.BasicCookieStore;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.cookie.BasicClientCookie;
|
||||
import org.apache.http.protocol.BasicHttpContext;
|
||||
|
@ -70,12 +70,12 @@ public class HttpClientCookieLiveTest {
|
|||
cookie.setDomain(".github.com");
|
||||
cookie.setPath("/");
|
||||
cookieStore.addCookie(cookie);
|
||||
final DefaultHttpClient client = new DefaultHttpClient();
|
||||
client.setCookieStore(cookieStore);
|
||||
final HttpClient client = HttpClientBuilder.create()
|
||||
.setDefaultCookieStore(cookieStore).build();
|
||||
|
||||
final HttpGet request = new HttpGet("http://www.github.com");
|
||||
|
||||
response = client.execute(request);
|
||||
response = (CloseableHttpResponse) client.execute(request);
|
||||
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue