1 |
|
package org.apache.commons.httpclient; |
2 |
|
|
3 |
|
import org.apache.commons.httpclient.HttpClient; |
4 |
|
import org.apache.commons.httpclient.methods.GetMethod; |
5 |
|
import org.apache.commons.httpclient.params.HttpClientParams; |
6 |
|
import org.apache.commons.httpclient.params.HttpMethodParams; |
7 |
|
import org.junit.Test; |
8 |
|
|
|
|
| 62.5% |
Uncovered Elements: 6 (16) |
Complexity: 2 |
Complexity Density: 0.13 |
|
9 |
|
public class HttpClientTest { |
10 |
|
|
|
|
| 60% |
Uncovered Elements: 6 (15) |
Complexity: 2 |
Complexity Density: 0.13 |
1
PASS
|
|
11 |
1
|
@Test... |
12 |
|
public void test1() { |
13 |
1
|
try { |
14 |
1
|
String url = "http://localhost:8070"; |
15 |
1
|
GetMethod method = new GetMethod(url); |
16 |
1
|
HttpClient client = new HttpClient(); |
17 |
1
|
HttpClientParams clientParams = client.getParams(); |
18 |
1
|
HttpMethodRetryHandler retryHandler = new DefaultHttpMethodRetryHandler(0, false); |
19 |
1
|
clientParams.setParameter(HttpMethodParams.RETRY_HANDLER, retryHandler); |
20 |
|
|
21 |
1
|
int result = client.executeMethod(method); |
22 |
0
|
Header[] headers = method.getResponseHeaders(); |
23 |
0
|
for (Header header : headers) { |
24 |
0
|
String name = header.getName(); |
25 |
0
|
String value = header.getValue(); |
26 |
0
|
System.out.println(name + "=" + value); |
27 |
|
} |
28 |
0
|
System.out.println(result); |
29 |
|
} catch (Throwable t) { |
30 |
1
|
t.printStackTrace(); |
31 |
|
} |
32 |
|
} |
33 |
|
} |