Skip to content

Commit 4b5f59e

Browse files
Matt Whisenhnuntmattwhisenhunt
authored andcommitted
Bump version of Apache httpclient.
1 parent 5125c72 commit 4b5f59e

File tree

5 files changed

+20
-17
lines changed

5 files changed

+20
-17
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ notifications:
88
jdk:
99
- oraclejdk8
1010
- openjdk7
11-
- openjdk6

google-http-client/src/main/java/com/google/api/client/http/apache/ApacheHttpTransport.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,6 @@ public ApacheHttpTransport() {
123123
*/
124124
public ApacheHttpTransport(HttpClient httpClient) {
125125
this.httpClient = httpClient;
126-
HttpParams params = httpClient.getParams();
127-
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
128-
params.setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);
129126
}
130127

131128
/**
@@ -164,6 +161,8 @@ static HttpParams newDefaultHttpParams() {
164161
HttpConnectionParams.setSocketBufferSize(params, 8192);
165162
ConnManagerParams.setMaxTotalConnections(params, 200);
166163
ConnManagerParams.setMaxConnectionsPerRoute(params, new ConnPerRouteBean(20));
164+
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
165+
params.setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);
167166
return params;
168167
}
169168

@@ -278,7 +277,7 @@ public static final class Builder {
278277
* </p>
279278
*
280279
* <pre>
281-
setProxy(new HttpHost("127.0.0.1", 8080))
280+
setProxy(new HttpHost("127.0.0.1", 8080))
282281
* </pre>
283282
*/
284283
public Builder setProxy(HttpHost proxy) {
@@ -314,7 +313,7 @@ public Builder setProxySelector(ProxySelector proxySelector) {
314313
* </p>
315314
*
316315
* <pre>
317-
trustCertificatesFromJavaKeyStore(new FileInputStream("certs.jks"), "password");
316+
trustCertificatesFromJavaKeyStore(new FileInputStream("certs.jks"), "password");
318317
* </pre>
319318
*
320319
* @param keyStoreStream input stream to the key store (closed at the end of this method in a
@@ -338,7 +337,7 @@ public Builder trustCertificatesFromJavaKeyStore(InputStream keyStoreStream, Str
338337
* </p>
339338
*
340339
* <pre>
341-
trustCertificatesFromStream(new FileInputStream("certs.pem"));
340+
trustCertificatesFromStream(new FileInputStream("certs.pem"));
342341
* </pre>
343342
*
344343
* @param certificateStream certificate stream

google-http-client/src/main/java/com/google/api/client/testing/http/apache/MockHttpClient.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,14 @@
5050
* @since 1.14
5151
* @author Yaniv Inbar
5252
*/
53-
@Beta
53+
@Deprecated
5454
public class MockHttpClient extends DefaultHttpClient {
5555

5656
/** HTTP response code to use. */
5757
int responseCode;
5858

5959
@Override
60+
@Deprecated
6061
protected RequestDirector createClientRequestDirector(HttpRequestExecutor requestExec,
6162
ClientConnectionManager conman, ConnectionReuseStrategy reustrat,
6263
ConnectionKeepAliveStrategy kastrat, HttpRoutePlanner rouplan, HttpProcessor httpProcessor,
@@ -73,11 +74,13 @@ public HttpResponse execute(HttpHost target, HttpRequest request, HttpContext co
7374
}
7475

7576
/** Returns the HTTP response code to use. */
77+
@Deprecated
7678
public final int getResponseCode() {
7779
return responseCode;
7880
}
7981

8082
/** Sets the HTTP response code to use. */
83+
@Deprecated
8184
public MockHttpClient setResponseCode(int responseCode) {
8285
Preconditions.checkArgument(responseCode >= 0);
8386
this.responseCode = responseCode;

google-http-client/src/test/java/com/google/api/client/http/apache/ApacheHttpTransportTest.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414

1515
package com.google.api.client.http.apache;
1616

17-
import com.google.api.client.testing.http.apache.MockHttpClient;
1817
import com.google.api.client.util.ByteArrayStreamingContent;
1918
import com.google.api.client.util.StringUtils;
2019

2120
import junit.framework.TestCase;
2221
import org.apache.http.HttpVersion;
2322
import org.apache.http.client.HttpClient;
23+
import org.apache.http.client.methods.HttpUriRequest;
2424
import org.apache.http.client.params.ClientPNames;
2525
import org.apache.http.impl.client.DefaultHttpClient;
2626
import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
@@ -29,6 +29,10 @@
2929
import org.apache.http.params.HttpParams;
3030
import org.apache.http.params.HttpProtocolParams;
3131

32+
import static org.mockito.Matchers.any;
33+
import static org.mockito.Mockito.mock;
34+
import static org.mockito.Mockito.when;
35+
3236
/**
3337
* Tests {@link ApacheHttpTransport}.
3438
*
@@ -43,17 +47,16 @@ public void testApacheHttpTransport() {
4347
checkHttpClient(httpClient);
4448
}
4549

46-
public void testApacheHttpTransportWithParam() {
47-
ApacheHttpTransport transport = new ApacheHttpTransport(new DefaultHttpClient());
48-
checkHttpClient(transport.getHttpClient());
49-
}
50-
5150
public void testNewDefaultHttpClient() {
5251
checkDefaultHttpClient(ApacheHttpTransport.newDefaultHttpClient());
5352
}
5453

5554
public void testRequestsWithContent() throws Exception {
56-
ApacheHttpTransport transport = new ApacheHttpTransport(new MockHttpClient());
55+
HttpClient mockClient = mock(HttpClient.class);
56+
org.apache.http.HttpResponse mockResponse = mock(org.apache.http.HttpResponse.class);
57+
when(mockClient.execute(any(HttpUriRequest.class))).thenReturn(mockResponse);
58+
59+
ApacheHttpTransport transport = new ApacheHttpTransport(mockClient);
5760

5861
// Test GET.
5962
subtestUnsupportedRequestsWithContent(

pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,7 @@
617617
<project.guava.version>17.0</project.guava.version>
618618
<project.xpp3.version>1.1.4c</project.xpp3.version>
619619
<project.commons-logging.version>1.1.1</project.commons-logging.version>
620-
<project.httpclient.version>4.0.1</project.httpclient.version>
621-
<project.httpcore.version>4.0.1</project.httpcore.version>
620+
<project.httpclient.version>4.5.3</project.httpclient.version>
622621
<project.jdo2-api.version>2.3-eb</project.jdo2-api.version>
623622
</properties>
624623
</project>

0 commit comments

Comments
 (0)