use of org.mobicents.tools.sip.balancer.CallIDAffinityBalancerAlgorithm in project load-balancer by RestComm.
the class RingingFailoverTest method testViaHeaderRewrite.
@Test
public void testViaHeaderRewrite() throws Exception, ParseException {
CallIDAffinityBalancerAlgorithm algorithm = new CallIDAffinityBalancerAlgorithm();
Response response = SipFactory.getInstance().createMessageFactory().createResponse(ringing);
String node = "1.2.3.4";
Integer port = 1234;
Node adNode = new Node(node, node);
adNode.getProperties().put("udpPort", "" + port);
algorithm.balancerContext = new BalancerContext();
algorithm.balancerContext.algorithmClassName = CallIDAffinityBalancerAlgorithm.class.getName();
algorithm.balancerContext.smppToNodeAlgorithmClassName = SmppToNodeRoundRobinAlgorithm.class.getName();
algorithm.balancerContext.smppToProviderAlgorithmClassName = SmppToProviderRoundRobinAlgorithm.class.getName();
algorithm.setConfiguration(new LoadBalancerConfiguration());
InvocationContext ctx = new InvocationContext("0", algorithm.balancerContext);
ctx.sipNodeMap(false).put(new KeySip(adNode, false), adNode);
algorithm.invocationContext = ctx;
algorithm.processExternalResponse(response, false);
algorithm.stop();
assertTrue(response.toString().contains(node + ":" + port));
}
Aggregations