Skip to content

Commit

Permalink
fix npe
Browse files Browse the repository at this point in the history
  • Loading branch information
ldetmer committed Dec 4, 2024
1 parent 6036be3 commit cd96869
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,23 @@

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

import static org.junit.Assert.assertNotNull;

import java.io.InputStream;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
import org.junit.Test;
import java.io.InputStream;

import static org.junit.Assert.assertNotNull;

public class Apache5HttpResponseTest {
@Test
public void testNullContent() throws Exception {
HttpUriRequestBase base = new HttpPost("http://www.google.com");
MockClassicHttpResponse mockResponse = new MockClassicHttpResponse();
mockResponse.setEntity(null);
Apache5HttpResponse response =
new Apache5HttpResponse(
base,
mockResponse);
@Test
public void testNullContent() throws Exception {
HttpUriRequestBase base = new HttpPost("http://www.google.com");
MockClassicHttpResponse mockResponse = new MockClassicHttpResponse();
mockResponse.setEntity(null);
Apache5HttpResponse response = new Apache5HttpResponse(base, mockResponse);

InputStream content =
response.getContent();
InputStream content = response.getContent();

assertNotNull(content);
}
assertNotNull(content);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,26 @@
import org.junit.Test;

public class Apache5ResponseContentTest {
@Test
public void testNullResponseContent_doesNotThrowExceptionOnClose() throws Exception {
Apache5ResponseContent response =
new Apache5ResponseContent(
new InputStream() {
@Override
public int read() throws IOException {
return 0;
}
},
null);
@Test
public void testNullResponseContent_doesNotThrowExceptionOnClose() throws Exception {
Apache5ResponseContent response =
new Apache5ResponseContent(
new InputStream() {
@Override
public int read() throws IOException {
return 0;
}
},
null);

response.close();
}
response.close();
}

@Test
public void testNullWrappedContent_doesNotThrowExceptionOnClose() throws Exception {
MockClassicHttpResponse mockResponse = new MockClassicHttpResponse();
Apache5ResponseContent response =
new Apache5ResponseContent(
null,
mockResponse);
@Test
public void testNullWrappedContent_doesNotThrowExceptionOnClose() throws Exception {
MockClassicHttpResponse mockResponse = new MockClassicHttpResponse();
Apache5ResponseContent response = new Apache5ResponseContent(null, mockResponse);

response.close();
}
response.close();
}
}

0 comments on commit cd96869

Please sign in to comment.