use of javax.sip.message.Response in project load-balancer by RestComm.
the class UserBasedAlgorithmTest method testInviteByeLandOnDifferentNodes.
@Test
public void testInviteByeLandOnDifferentNodes() throws Exception {
for (int i = 0; i < shootists.length; i++) {
shootists[i].sendInitialInvite();
Thread.sleep(6000);
shootists[i].sendBye();
Thread.sleep(2000);
}
assertNotEquals(servers[0].getTestSipListener().isInviteReceived(), servers[1].getTestSipListener().isInviteReceived());
assertNotEquals(servers[0].getTestSipListener().isAckReceived(), servers[1].getTestSipListener().isAckReceived());
assertNotEquals(servers[0].getTestSipListener().getByeReceived(), servers[1].getTestSipListener().getByeReceived());
for (Shootist s : shootists) {
boolean wasRinging = false;
boolean wasOk = false;
for (Response res : s.responses) {
if (res.getStatusCode() != Response.RINGING)
wasRinging = true;
if (res.getStatusCode() != Response.OK)
wasOk = true;
}
assertTrue(wasOk);
assertTrue(wasRinging);
}
}
use of javax.sip.message.Response in project load-balancer by RestComm.
the class BTBUATest method testBackToBackUserAgent.
// test back to back use agent
@Test
public void testBackToBackUserAgent() throws Exception {
boolean wasRinging = false;
boolean wasOk = false;
boolean wasInvite = false;
boolean wasAck = false;
boolean wasBye = false;
shootist2.start();
shootist1.start();
shootist1.callerSendsBye = true;
SipURI route = shootist1.addressFactory.createSipURI("lbint", "127.0.0.1:5060");
route.setLrParam();
shootist1.sendInitial(Request.INVITE, shootist1.headerFactory.createRouteHeader(shootist1.addressFactory.createAddress(route)));
Thread.sleep(9000);
shootist1.sendBye();
Thread.sleep(2000);
for (Response res : shootist1.responses) {
if (res.getStatusCode() == Response.RINGING)
wasRinging = true;
if (res.getStatusCode() == Response.OK)
wasOk = true;
}
for (Request req : shootist2.requests) {
if (req.getMethod().equals(Request.INVITE))
wasInvite = true;
if (req.getMethod().equals(Request.ACK))
wasAck = true;
if (req.getMethod().equals(Request.BYE))
wasBye = true;
}
assertEquals(3, shootist2.requests.size());
assertTrue(wasOk);
assertTrue(wasRinging);
assertTrue(wasInvite);
assertTrue(wasAck);
assertTrue(wasBye);
}
use of javax.sip.message.Response in project load-balancer by RestComm.
the class NodeGracefulShutdownTest method testGracefulRemovingNode.
@Test
public void testGracefulRemovingNode() throws Exception {
int okNumber1 = 0;
int okNumber2 = 0;
shootist1.sendInitialInvite();
Thread.sleep(500);
for (AppServer server : servers) if (server.sipListener.getInviteRequest() != null)
server.gracefulShutdown();
Thread.sleep(5000);
shootist1.sendBye();
Thread.sleep(2000);
shootist2.sendInitialInvite();
Thread.sleep(5000);
shootist2.sendBye();
Thread.sleep(2000);
for (Response res : shootist1.responses) if (res.getStatusCode() == Response.OK)
okNumber1++;
for (Response res : shootist2.responses) if (res.getStatusCode() == Response.OK)
okNumber2++;
for (AppServer server : servers) assertNotNull(server.sipListener.getInviteRequest());
assertEquals(2, okNumber1);
assertEquals(2, okNumber2);
}
use of javax.sip.message.Response 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));
}
use of javax.sip.message.Response in project jain-sip.ha by RestComm.
the class SimpleB2BUAHandler method processSubscribe.
public void processSubscribe(RequestEvent requestEvent) {
try {
Response response = messageFactory.createResponse(200, requestEvent.getRequest());
response.addHeader(headerFactory.createHeader(ExpiresHeader.NAME, "3600"));
requestEvent.getServerTransaction().sendResponse(response);
Dialog dialog = getOutgoingDialog();
Request request = dialog.createRequest(Request.SUBSCRIBE);
((SipURI) request.getRequestURI()).setPort(5070);
final ClientTransaction ct = sipProvider.getNewClientTransaction(request);
dialog.sendRequest(ct);
} catch (Exception e) {
((SipStackImpl) sipStack).getStackLogger().logError("unexpected exception", e);
}
}
Aggregations