use of com.predic8.membrane.core.transport.http.HttpClient in project service-proxy by membrane.
the class LargeBodyTest method largeChunked.
@Test
public void largeChunked() throws Exception {
setup();
long len = Integer.MAX_VALUE + 1l;
Exchange e = new Request.Builder().post("http://localhost:3041/foo").body(len, new ConstantInputStream(len)).header(TRANSFER_ENCODING, CHUNKED).buildExchange();
new HttpClient(hcc).call(e);
}
use of com.predic8.membrane.core.transport.http.HttpClient in project service-proxy by membrane.
the class LoadBalancingInterceptorTest method testFailOverOnConnectionRefused.
@Test
public void testFailOverOnConnectionRefused() throws Exception {
balancingInterceptor.setDispatchingStrategy(roundRobinStrategy);
HttpClient client = new HttpClient();
client.getParams().setParameter(HttpProtocolParams.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
assertEquals(200, client.executeMethod(getPostMethod()));
assertEquals(1, mockInterceptor1.getCount());
assertEquals(0, mockInterceptor2.getCount());
assertEquals(200, client.executeMethod(getPostMethod()));
assertEquals(1, mockInterceptor1.getCount());
assertEquals(1, mockInterceptor2.getCount());
service1.shutdown();
Thread.sleep(1000);
assertEquals(200, client.executeMethod(getPostMethod()));
assertEquals(1, mockInterceptor1.getCount());
assertEquals(2, mockInterceptor2.getCount());
assertEquals(200, client.executeMethod(getPostMethod()));
assertEquals(3, mockInterceptor2.getCount());
}
use of com.predic8.membrane.core.transport.http.HttpClient in project service-proxy by membrane.
the class LoadBalancingInterceptorTest method testFailOverOnStatus500.
@Test
public void testFailOverOnStatus500() throws Exception {
balancingInterceptor.setDispatchingStrategy(roundRobinStrategy);
HttpClient client = new HttpClient();
client.getParams().setParameter(HttpProtocolParams.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
assertEquals(200, client.executeMethod(getPostMethod()));
assertEquals(1, mockInterceptor1.getCount());
assertEquals(0, mockInterceptor2.getCount());
assertEquals(200, client.executeMethod(getPostMethod()));
assertEquals(1, mockInterceptor1.getCount());
assertEquals(1, mockInterceptor2.getCount());
((ServiceProxy) service1.getRuleManager().getRules().get(0)).getInterceptors().add(0, new AbstractInterceptor() {
@Override
public Outcome handleRequest(Exchange exc) throws Exception {
exc.setResponse(Response.internalServerError().build());
return Outcome.ABORT;
}
});
assertEquals(200, client.executeMethod(getPostMethod()));
assertEquals(1, mockInterceptor1.getCount());
assertEquals(2, mockInterceptor2.getCount());
assertEquals(200, client.executeMethod(getPostMethod()));
assertEquals(3, mockInterceptor2.getCount());
}
use of com.predic8.membrane.core.transport.http.HttpClient in project service-proxy by membrane.
the class LoadBalancingInterceptorTest method testExpect100Continue.
@Test
public void testExpect100Continue() throws Exception {
balancingInterceptor.setDispatchingStrategy(roundRobinStrategy);
HttpClient client = new HttpClient();
Http11Test.initExpect100ContinueWithFastFail(client);
PostMethod vari = getPostMethod();
int status = client.executeMethod(vari);
assertEquals(200, status);
assertEquals(1, mockInterceptor1.getCount());
assertEquals(0, mockInterceptor2.getCount());
assertEquals(200, client.executeMethod(getPostMethod()));
assertEquals(1, mockInterceptor1.getCount());
assertEquals(1, mockInterceptor2.getCount());
assertEquals(200, client.executeMethod(getPostMethod()));
assertEquals(2, mockInterceptor1.getCount());
assertEquals(1, mockInterceptor2.getCount());
assertEquals(200, client.executeMethod(getPostMethod()));
assertEquals(2, mockInterceptor1.getCount());
assertEquals(2, mockInterceptor2.getCount());
}
use of com.predic8.membrane.core.transport.http.HttpClient in project service-proxy by membrane.
the class LBNotificationClient method notifiyClusterManager.
private Response notifiyClusterManager() throws Exception {
HttpClient client = new HttpClient();
Exchange exc = new Exchange(null);
Request r = MessageUtil.getPostRequest(getRequestURL());
r.setBodyContent(new byte[0]);
exc.setRequest(r);
exc.getDestinations().add(getRequestURL());
Response res = client.call(exc).getResponse();
return res;
}
Aggregations