use of com.atlassian.httpclient.api.factory.HttpClientOptions in project jira-plugin by jenkinsci.
the class ApacheAsyncHttpClientTest method simple_get_with_proxy.
@Test
public void simple_get_with_proxy() throws Exception {
ProxyTestHandler testHandler = new ProxyTestHandler();
prepare(testHandler);
Jenkins.get().proxy = new ProxyConfiguration("localhost", connector.getLocalPort(), "foo", "bar");
ApacheAsyncHttpClient httpClient = new ApacheAsyncHttpClient(null, buildApplicationProperties(), new NoOpThreadLocalContextManager(), new HttpClientOptions());
Response response = //
httpClient.newRequest("http://jenkins.io").get().get(30, TimeUnit.SECONDS);
Assert.assertEquals(200, response.getStatusCode());
Assert.assertEquals(CONTENT_RESPONSE, IOUtils.toString(response.getEntityStream()));
}
use of com.atlassian.httpclient.api.factory.HttpClientOptions in project jira-plugin by jenkinsci.
the class ApacheAsyncHttpClientTest method simple_post_with_proxy.
@Test
public void simple_post_with_proxy() throws Exception {
ProxyTestHandler testHandler = new ProxyTestHandler();
prepare(testHandler);
Jenkins.getInstance().proxy = new ProxyConfiguration("localhost", connector.getLocalPort(), "foo", "bar");
ApacheAsyncHttpClient httpClient = new ApacheAsyncHttpClient(null, buildApplicationProperties(), new NoOpThreadLocalContextManager(), new HttpClientOptions());
Response response = //
httpClient.newRequest("http://jenkins.io").setEntity(//
"FOO").setContentType(//
"text").post().get(30, TimeUnit.SECONDS);
// we are sure to hit the proxy first :-)
Assert.assertEquals(200, response.getStatusCode());
Assert.assertEquals(CONTENT_RESPONSE, IOUtils.toString(response.getEntityStream()));
Assert.assertEquals("FOO", testHandler.postReceived);
}
use of com.atlassian.httpclient.api.factory.HttpClientOptions in project jira-plugin by jenkinsci.
the class ApacheAsyncHttpClientTest method simple_get_with_non_proxy_host.
@Test
public void simple_get_with_non_proxy_host() throws Exception {
ProxyTestHandler testHandler = new ProxyTestHandler();
prepare(testHandler);
Jenkins.getInstance().proxy = new ProxyConfiguration("localhost", connector.getLocalPort(), "foo", "bar", "www.apache.org");
ApacheAsyncHttpClient httpClient = new ApacheAsyncHttpClient(null, buildApplicationProperties(), new NoOpThreadLocalContextManager(), new HttpClientOptions());
Response response = httpClient.newRequest("http://www.apache.org").get().get(30, TimeUnit.SECONDS);
Assert.assertEquals(200, response.getStatusCode());
// Assert.assertEquals( CONTENT_RESPONSE, IOUtils.toString( response.getEntityStream() ) );
}
use of com.atlassian.httpclient.api.factory.HttpClientOptions in project jira-plugin by jenkinsci.
the class ApacheAsyncHttpClientTest method simple_get.
@Test
public void simple_get() throws Exception {
TestHandler testHandler = new TestHandler();
prepare(testHandler);
ApacheAsyncHttpClient httpClient = new ApacheAsyncHttpClient(null, buildApplicationProperties(), new NoOpThreadLocalContextManager(), new HttpClientOptions());
Response response = //
httpClient.newRequest("http://localhost:" + connector.getLocalPort() + "/foo").get().get(10, TimeUnit.SECONDS);
Assert.assertEquals(200, response.getStatusCode());
Assert.assertEquals(CONTENT_RESPONSE, IOUtils.toString(response.getEntityStream()));
}
Aggregations