use of com.predic8.membrane.core.interceptor.balancer.RoundRobinStrategy in project service-proxy by membrane.
the class LoadBalancingInterceptorTest method testRoundRobinDispachingStrategy.
@Test
public void testRoundRobinDispachingStrategy() throws Exception {
balancingInterceptor.setDispatchingStrategy(roundRobinStrategy);
HttpClient client = new HttpClient();
client.getParams().setParameter(HttpProtocolParams.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
PostMethod vari = getPostMethod();
int status = client.executeMethod(vari);
// System.out.println(new String(vari.getResponseBody()));
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());
}
Aggregations