use of javax.sip.message.Response in project load-balancer by RestComm.
the class Shootist method processBye.
public void processBye(Request request, ServerTransaction serverTransactionId) {
try {
System.out.println("shootist: got a bye .");
if (serverTransactionId == null) {
System.out.println("shootist: null TID.");
return;
}
Dialog dialog = serverTransactionId.getDialog();
System.out.println("Dialog State = " + dialog.getState());
Response response = messageFactory.createResponse(200, request);
serverTransactionId.sendResponse(response);
System.out.println("shootist: Sending OK.");
System.out.println("Dialog State = " + dialog.getState());
} catch (Exception ex) {
fail("Unexpected exception");
}
}
use of javax.sip.message.Response in project load-balancer by RestComm.
the class SinglePointTest method testTcpToTcp.
@Test
public void testTcpToTcp() throws Exception {
setUp(true);
boolean wasRinging = false;
boolean wasOk = false;
shootistTcp.sendInitialInvite();
Thread.sleep(5000);
shootistTcp.sendBye();
Thread.sleep(5000);
assertTrue(server.getTestSipListener().isInviteReceived());
assertTrue(server.getTestSipListener().isAckReceived());
assertTrue(server.getTestSipListener().getByeReceived());
for (Response res : shootistTcp.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 NodeGracefulShutdownRmiTest 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 FromURIBasedAlgorithmTest method testInviteFromToDifferentNodes.
@Test
public void testInviteFromToDifferentNodes() throws Exception {
balancer.balancerContext.sipHeaderAffinityKeyExclusionPattern = Pattern.compile(".*sip.nexmo.com");
for (int i = 0; i < shootists.length; i++) {
String fromUri = "Anonymous";
// if(i % 2 == 0) {
// fromUri = "Restricted";
// }
shootists[i].sendInitial(fromUri, "sip.nexmo.com", "INVITE", null, null, null);
Thread.sleep(6000);
shootists[i].sendBye();
Thread.sleep(2000);
}
assertEquals(servers[0].getTestSipListener().isInviteReceived(), servers[1].getTestSipListener().isInviteReceived());
assertEquals(servers[0].getTestSipListener().isAckReceived(), servers[1].getTestSipListener().isAckReceived());
assertEquals(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 Ipv6Test method testExternalTcpRequest.
@Test
public void testExternalTcpRequest() throws Exception {
boolean isShootistipv4GetOK = false;
boolean isShootistipv6GetOK = false;
setUp();
shootistipv6.sendInitialInvite();
Thread.sleep(5000);
shootistipv6.sendBye();
Thread.sleep(5000);
shootistipv4.sendInitialInvite();
Thread.sleep(5000);
shootistipv4.sendBye();
Thread.sleep(5000);
for (Response res : shootistipv4.responses) if (res.getStatusCode() == Response.OK)
isShootistipv4GetOK = true;
for (Response res : shootistipv6.responses) if (res.getStatusCode() == Response.OK)
isShootistipv6GetOK = true;
assertTrue(isShootistipv4GetOK);
assertTrue(isShootistipv6GetOK);
assertTrue(ipv6Server.getTestSipListener().isInviteReceived());
assertTrue(ipv6Server.getTestSipListener().isAckReceived());
assertTrue(ipv6Server.getTestSipListener().getByeReceived());
assertTrue(ipv4Server.getTestSipListener().isInviteReceived());
assertTrue(ipv4Server.getTestSipListener().isAckReceived());
assertTrue(ipv4Server.getTestSipListener().getByeReceived());
}
Aggregations