Skip to content

Commit cd96869

Browse files
committed
fix npe
1 parent 6036be3 commit cd96869

File tree

2 files changed

+31
-38
lines changed

2 files changed

+31
-38
lines changed

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

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,23 @@
1414

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

17+
import static org.junit.Assert.assertNotNull;
18+
19+
import java.io.InputStream;
1720
import org.apache.hc.client5.http.classic.methods.HttpPost;
1821
import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
1922
import org.junit.Test;
20-
import java.io.InputStream;
21-
22-
import static org.junit.Assert.assertNotNull;
2323

2424
public class Apache5HttpResponseTest {
25-
@Test
26-
public void testNullContent() throws Exception {
27-
HttpUriRequestBase base = new HttpPost("http://www.google.com");
28-
MockClassicHttpResponse mockResponse = new MockClassicHttpResponse();
29-
mockResponse.setEntity(null);
30-
Apache5HttpResponse response =
31-
new Apache5HttpResponse(
32-
base,
33-
mockResponse);
25+
@Test
26+
public void testNullContent() throws Exception {
27+
HttpUriRequestBase base = new HttpPost("http://www.google.com");
28+
MockClassicHttpResponse mockResponse = new MockClassicHttpResponse();
29+
mockResponse.setEntity(null);
30+
Apache5HttpResponse response = new Apache5HttpResponse(base, mockResponse);
3431

35-
InputStream content =
36-
response.getContent();
32+
InputStream content = response.getContent();
3733

38-
assertNotNull(content);
39-
}
34+
assertNotNull(content);
35+
}
4036
}

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

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,26 @@
1919
import org.junit.Test;
2020

2121
public class Apache5ResponseContentTest {
22-
@Test
23-
public void testNullResponseContent_doesNotThrowExceptionOnClose() throws Exception {
24-
Apache5ResponseContent response =
25-
new Apache5ResponseContent(
26-
new InputStream() {
27-
@Override
28-
public int read() throws IOException {
29-
return 0;
30-
}
31-
},
32-
null);
22+
@Test
23+
public void testNullResponseContent_doesNotThrowExceptionOnClose() throws Exception {
24+
Apache5ResponseContent response =
25+
new Apache5ResponseContent(
26+
new InputStream() {
27+
@Override
28+
public int read() throws IOException {
29+
return 0;
30+
}
31+
},
32+
null);
3333

34-
response.close();
35-
}
34+
response.close();
35+
}
3636

37-
@Test
38-
public void testNullWrappedContent_doesNotThrowExceptionOnClose() throws Exception {
39-
MockClassicHttpResponse mockResponse = new MockClassicHttpResponse();
40-
Apache5ResponseContent response =
41-
new Apache5ResponseContent(
42-
null,
43-
mockResponse);
37+
@Test
38+
public void testNullWrappedContent_doesNotThrowExceptionOnClose() throws Exception {
39+
MockClassicHttpResponse mockResponse = new MockClassicHttpResponse();
40+
Apache5ResponseContent response = new Apache5ResponseContent(null, mockResponse);
4441

45-
response.close();
46-
}
42+
response.close();
43+
}
4744
}

0 commit comments

Comments
 (0)