use of org.apache.http.client.fluent.Response in project moco by dreamhead.
the class MocoConnectionTest method should_not_keep_alive_for_close_request.
@Test
public void should_not_keep_alive_for_close_request() throws Exception {
server.response("foo");
running(server, new Runnable() {
@Override
public void run() throws Exception {
Response response = Request.Get(root()).addHeader("Connection", "close").execute();
assertThat(response.returnResponse().getFirstHeader("Connection"), nullValue());
}
});
}
use of org.apache.http.client.fluent.Response in project moco by dreamhead.
the class MocoConnectionTest method should_not_have_keep_alive_header_for_1_1_keep_alive_request.
@Test
public void should_not_have_keep_alive_header_for_1_1_keep_alive_request() throws Exception {
server.response("foo");
running(server, new com.github.dreamhead.moco.Runnable() {
@Override
public void run() throws Exception {
Response response = Request.Get(root()).version(HttpVersion.HTTP_1_1).addHeader("Connection", "keep-alive").execute();
assertThat(response.returnResponse().getFirstHeader("Connection"), nullValue());
}
});
}
use of org.apache.http.client.fluent.Response in project sling by apache.
the class SimpleHttpDistributionTransportTest method testDeliverPackage.
@Test
public void testDeliverPackage() throws Exception {
DistributionTransportSecret secret = mock(DistributionTransportSecret.class);
Map<String, String> credentialsMap = new HashMap<String, String>();
credentialsMap.put("username", "foo");
credentialsMap.put("password", "foo");
when(secret.asCredentialsMap()).thenReturn(credentialsMap);
DistributionTransportSecretProvider secretProvider = mock(DistributionTransportSecretProvider.class);
when(secretProvider.getSecret(any(URI.class))).thenReturn(secret);
Executor executor = mock(Executor.class);
Response response = mock(Response.class);
when(executor.execute(any(Request.class))).thenReturn(response);
DistributionEndpoint endpoint = new DistributionEndpoint("http://127.0.0.1:8080/some/resource");
DistributionPackageBuilder packageBuilder = mock(DistributionPackageBuilder.class);
SimpleHttpDistributionTransport simpleHttpDistributionTransport = new SimpleHttpDistributionTransport(mock(DefaultDistributionLog.class), endpoint, packageBuilder, secretProvider, new HttpConfiguration(1000, 1000));
ResourceResolver resourceResolver = mock(ResourceResolver.class);
DistributionPackage distributionPackage = mock(DistributionPackage.class);
when(distributionPackage.getInfo()).thenReturn(new DistributionPackageInfo("type"));
InputStream stream = mock(InputStream.class);
when(distributionPackage.createInputStream()).thenReturn(stream);
DistributionTransportContext distributionContext = mock(DistributionTransportContext.class);
when(distributionContext.get(any(String.class), same(Executor.class))).thenReturn(executor);
when(distributionContext.containsKey(any(String.class))).thenReturn(true);
simpleHttpDistributionTransport.deliverPackage(resourceResolver, distributionPackage, distributionContext);
}
Aggregations