mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
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:
parent
0535d9b5e1
commit
69e158d77d
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user