Refactor TestHttp.testHttpclient to avoid the Exception Suppression (#6733)

* Refactor TestHttp.testHttpclient to avoid the Exception Suppression

* Remove the unnecessary import
This commit is contained in:
Codegass 2022-10-09 05:52:32 -04:00 committed by GitHub
parent 0535d9b5e1
commit 69e158d77d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,7 +26,6 @@ import java.io.OutputStream;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpHead;
import org.apache.http.impl.client.DefaultHttpClient;
@ -41,7 +40,7 @@ import junit.framework.Assert;
public class TestHttp extends AbstractTestNGSpringContextTests {
@Test
@Parameters("template-url")
public void testHttpclient(String templateUrl) {
public void testHttpclient(String templateUrl) throws IOException {
final HttpHead method = new HttpHead(templateUrl);
final DefaultHttpClient client = new DefaultHttpClient();
@ -62,20 +61,9 @@ public class TestHttp extends AbstractTestNGSpringContextTests {
output = new BufferedOutputStream(new FileOutputStream(localFile));
entity.writeTo(output);
} catch (final ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (final IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (output != null) {
output.close();
}
} catch (final IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
if (output != null) {
output.close();
}
}