Search in sources :

Example 56 with SipURI

use of javax.sip.address.SipURI in project load-balancer by RestComm.

the class InternalTransportTest method testOKRingingLandOnDifferentNodes.

@Test
public void testOKRingingLandOnDifferentNodes() throws Exception {
    EventListener failureEventListener = new EventListener() {

        @Override
        public void uasAfterResponse(int statusCode, AppServer source) {
        }

        @Override
        public void uasAfterRequestReceived(String method, AppServer source) {
        // TODO Auto-generated method stub
        }

        @Override
        public void uacAfterRequestSent(String method, AppServer source) {
        // TODO Auto-generated method stub
        }

        @Override
        public void uacAfterResponse(int statusCode, AppServer source) {
            if (statusCode == 180) {
                ringingAppServer = source;
            } else if (statusCode == 200) {
                okAppServer = source;
            }
        }
    };
    for (AppServer as : servers) as.setEventListener(failureEventListener);
    shootist.callerSendsBye = true;
    String fromName = "sender";
    String fromHost = "sip-servlets.com";
    SipURI fromAddress = servers[0].protocolObjects.addressFactory.createSipURI(fromName, fromHost);
    String toUser = "replaces";
    String toHost = "sip-servlets.com";
    SipURI toAddress = servers[0].protocolObjects.addressFactory.createSipURI(toUser, toHost);
    SipURI ruri = servers[0].protocolObjects.addressFactory.createSipURI("usera", "127.0.0.1:5033");
    ruri.setTransportParam(ListeningPointExt.WSS);
    ruri.setLrParam();
    SipURI route = servers[0].protocolObjects.addressFactory.createSipURI("lbint", "127.0.0.1:5065");
    route.setParameter("node_host", "127.0.0.1");
    route.setParameter("node_port", "4060");
    route.setTransportParam(ListeningPoint.TCP);
    route.setLrParam();
    shootist.start();
    servers[0].sipListener.sendSipRequest("INVITE", fromAddress, toAddress, null, route, false, null, null, ruri);
    Thread.sleep(16000);
    assertTrue(shootist.inviteRequest.getHeader(RecordRouteHeader.NAME).toString().contains("node_host"));
    assertNotSame(ringingAppServer, okAppServer);
    assertNotNull(ringingAppServer);
    assertNotNull(okAppServer);
}
Also used : AppServer(org.mobicents.tools.sip.balancer.AppServer) EventListener(org.mobicents.tools.sip.balancer.EventListener) SipURI(javax.sip.address.SipURI) SinglePointTest(org.mobicents.tools.sip.balancer.SinglePointTest) Test(org.junit.Test)

Example 57 with SipURI

use of javax.sip.address.SipURI in project load-balancer by RestComm.

the class TcpWorstCaseAffinityTest method testOKRingingLandOnDifferentNodes.

@Test
public void testOKRingingLandOnDifferentNodes() {
    EventListener failureEventListener = new EventListener() {

        @Override
        public void uasAfterResponse(int statusCode, AppServer source) {
        }

        @Override
        public void uasAfterRequestReceived(String method, AppServer source) {
        // TODO Auto-generated method stub
        }

        @Override
        public void uacAfterRequestSent(String method, AppServer source) {
        // TODO Auto-generated method stub
        }

        @Override
        public void uacAfterResponse(int statusCode, AppServer source) {
            if (statusCode == 180) {
                ringingAppServer = source;
            } else if (statusCode == 200) {
                okAppServer = source;
            }
        }
    };
    for (AppServer as : servers) as.setEventListener(failureEventListener);
    shootist.callerSendsBye = true;
    String fromName = "sender";
    String fromHost = "sip-servlets.com";
    try {
        SipURI fromAddress = servers[0].protocolObjects.addressFactory.createSipURI(fromName, fromHost);
        String toUser = "replaces";
        String toHost = "sip-servlets.com";
        SipURI toAddress = servers[0].protocolObjects.addressFactory.createSipURI(toUser, toHost);
        SipURI ruri = servers[0].protocolObjects.addressFactory.createSipURI("usera", "127.0.0.1:5033");
        ruri.setLrParam();
        SipURI route = servers[0].protocolObjects.addressFactory.createSipURI("lbint", "127.0.0.1:5065");
        route.setParameter("node_host", "127.0.0.1");
        route.setParameter("node_port", "4060");
        route.setTransportParam(ListeningPoint.TCP);
        route.setLrParam();
        shootist.start();
        servers[0].sipListener.sendSipRequest("INVITE", fromAddress, toAddress, null, route, false, null, null, ruri);
    } catch (Exception e) {
        System.err.print("Exception : " + e);
    }
    Helper.sleep(5000);
    assertTrue(shootist.inviteRequest.getHeader(RecordRouteHeader.NAME).toString().contains("node_host"));
    assertNotSame(ringingAppServer, okAppServer);
    assertNotNull(ringingAppServer);
    assertNotNull(okAppServer);
}
Also used : AppServer(org.mobicents.tools.sip.balancer.AppServer) EventListener(org.mobicents.tools.sip.balancer.EventListener) SipURI(javax.sip.address.SipURI) Test(org.junit.Test)

Example 58 with SipURI

use of javax.sip.address.SipURI in project load-balancer by RestComm.

the class TerminaitingSslTest method testOKRingingLandOnDifferentNodes.

@Test
public void testOKRingingLandOnDifferentNodes() throws Exception {
    EventListener failureEventListener = new EventListener() {

        @Override
        public void uasAfterResponse(int statusCode, AppServer source) {
        }

        @Override
        public void uasAfterRequestReceived(String method, AppServer source) {
        // TODO Auto-generated method stub
        }

        @Override
        public void uacAfterRequestSent(String method, AppServer source) {
        // TODO Auto-generated method stub
        }

        @Override
        public void uacAfterResponse(int statusCode, AppServer source) {
            if (statusCode == 180) {
                ringingAppServer = source;
            } else if (statusCode == 200) {
                okAppServer = source;
            }
        }
    };
    for (AppServer as : servers) as.setEventListener(failureEventListener);
    shootist.callerSendsBye = true;
    String fromName = "sender";
    String fromHost = "sip-servlets.com";
    SipURI fromAddress = servers[0].protocolObjects.addressFactory.createSipURI(fromName, fromHost);
    String toUser = "replaces";
    String toHost = "sip-servlets.com";
    SipURI toAddress = servers[0].protocolObjects.addressFactory.createSipURI(toUser, toHost);
    SipURI ruri = servers[0].protocolObjects.addressFactory.createSipURI("usera", "127.0.0.1:5033");
    ruri.setTransportParam(ListeningPoint.TLS);
    ruri.setLrParam();
    SipURI route = servers[0].protocolObjects.addressFactory.createSipURI("lbint", "127.0.0.1:5065");
    route.setParameter("node_host", "127.0.0.1");
    route.setParameter("node_port", "4060");
    route.setTransportParam(ListeningPoint.TCP);
    route.setLrParam();
    shootist.start();
    // servers[0].sipListener.sendSipRequest("INVITE", fromAddress, toAddress, null, null, false);
    servers[0].sipListener.sendSipRequest("INVITE", fromAddress, toAddress, null, route, false, null, null, ruri);
    Thread.sleep(16000);
    assertTrue(shootist.inviteRequest.getHeader(RecordRouteHeader.NAME).toString().contains("node_host"));
    assertNotSame(ringingAppServer, okAppServer);
    assertNotNull(ringingAppServer);
    assertNotNull(okAppServer);
}
Also used : AppServer(org.mobicents.tools.sip.balancer.AppServer) EventListener(org.mobicents.tools.sip.balancer.EventListener) SipURI(javax.sip.address.SipURI) SinglePointTest(org.mobicents.tools.sip.balancer.SinglePointTest) Test(org.junit.Test)

Example 59 with SipURI

use of javax.sip.address.SipURI in project load-balancer by RestComm.

the class TlsWorstCaseAffinityTest method testOKRingingLandOnDifferentNodes.

// @Test
public void testOKRingingLandOnDifferentNodes() throws Exception {
    EventListener failureEventListener = new EventListener() {

        @Override
        public void uasAfterResponse(int statusCode, AppServer source) {
        }

        @Override
        public void uasAfterRequestReceived(String method, AppServer source) {
        // TODO Auto-generated method stub
        }

        @Override
        public void uacAfterRequestSent(String method, AppServer source) {
        // TODO Auto-generated method stub
        }

        @Override
        public void uacAfterResponse(int statusCode, AppServer source) {
            if (statusCode == 180) {
                ringingAppServer = source;
            } else if (statusCode == 200) {
                okAppServer = source;
            }
        }
    };
    for (AppServer as : servers) as.setEventListener(failureEventListener);
    shootist.callerSendsBye = true;
    String fromName = "sender";
    String fromHost = "sip-servlets.com";
    SipURI fromAddress = servers[0].protocolObjects.addressFactory.createSipURI(fromName, fromHost);
    String toUser = "replaces";
    String toHost = "sip-servlets.com";
    SipURI toAddress = servers[0].protocolObjects.addressFactory.createSipURI(toUser, toHost);
    SipURI ruri = servers[0].protocolObjects.addressFactory.createSipURI("usera", "127.0.0.1:5033");
    ruri.setLrParam();
    SipURI route = servers[0].protocolObjects.addressFactory.createSipURI("lbint", "127.0.0.1:5066");
    route.setParameter("node_host", "127.0.0.1");
    route.setParameter("node_port", "4060");
    route.setTransportParam(ListeningPoint.TLS);
    route.setLrParam();
    shootist.start();
    // servers[0].sipListener.sendSipRequest("INVITE", fromAddress, toAddress, null, null, false);
    servers[0].sipListener.sendSipRequest("INVITE", fromAddress, toAddress, null, route, false, null, null, ruri);
    Thread.sleep(16000);
    assertTrue(shootist.inviteRequest.getHeader(RecordRouteHeader.NAME).toString().contains("node_host"));
    assertNotSame(ringingAppServer, okAppServer);
    assertNotNull(ringingAppServer);
    assertNotNull(okAppServer);
}
Also used : AppServer(org.mobicents.tools.sip.balancer.AppServer) EventListener(org.mobicents.tools.sip.balancer.EventListener) SipURI(javax.sip.address.SipURI)

Example 60 with SipURI

use of javax.sip.address.SipURI in project load-balancer by RestComm.

the class WsWorstCaseAffinityTest method testOKRingingLandOnDifferentNodes.

@Test
public void testOKRingingLandOnDifferentNodes() throws Exception {
    EventListener failureEventListener = new EventListener() {

        @Override
        public void uasAfterResponse(int statusCode, AppServer source) {
        }

        @Override
        public void uasAfterRequestReceived(String method, AppServer source) {
        // TODO Auto-generated method stub
        }

        @Override
        public void uacAfterRequestSent(String method, AppServer source) {
        // TODO Auto-generated method stub
        }

        @Override
        public void uacAfterResponse(int statusCode, AppServer source) {
            if (statusCode == 180) {
                ringingAppServer = source;
            } else if (statusCode == 200) {
                okAppServer = source;
            }
        }
    };
    for (AppServer as : servers) as.setEventListener(failureEventListener);
    shootist.callerSendsBye = true;
    String fromName = "sender";
    String fromHost = "sip-servlets.com";
    SipURI fromAddress = servers[0].protocolObjects.addressFactory.createSipURI(fromName, fromHost);
    String toUser = "replaces";
    String toHost = "sip-servlets.com";
    SipURI toAddress = servers[0].protocolObjects.addressFactory.createSipURI(toUser, toHost);
    SipURI ruri = servers[0].protocolObjects.addressFactory.createSipURI("usera", "127.0.0.1:5033");
    ruri.setLrParam();
    SipURI route = servers[0].protocolObjects.addressFactory.createSipURI("lbint", "127.0.0.1:5065");
    route.setParameter("node_host", "127.0.0.1");
    route.setParameter("node_port", "4060");
    route.setTransportParam(ListeningPointExt.WS);
    route.setLrParam();
    shootist.start();
    // servers[0].sipListener.sendSipRequest("INVITE", fromAddress, toAddress, null, null, false);
    servers[0].sipListener.sendSipRequest("INVITE", fromAddress, toAddress, null, route, false, null, null, ruri);
    Thread.sleep(16000);
    assertTrue(shootist.inviteRequest.getHeader(RecordRouteHeader.NAME).toString().contains("node_host"));
    assertNotSame(ringingAppServer, okAppServer);
    assertNotNull(ringingAppServer);
    assertNotNull(okAppServer);
}
Also used : AppServer(org.mobicents.tools.sip.balancer.AppServer) EventListener(org.mobicents.tools.sip.balancer.EventListener) SipURI(javax.sip.address.SipURI) Test(org.junit.Test)

Aggregations

SipURI (javax.sip.address.SipURI)70 ParseException (java.text.ParseException)27 Request (javax.sip.message.Request)24 Address (javax.sip.address.Address)22 InvalidArgumentException (javax.sip.InvalidArgumentException)20 ViaHeader (javax.sip.header.ViaHeader)20 SipException (javax.sip.SipException)19 ToHeader (javax.sip.header.ToHeader)18 ContactHeader (javax.sip.header.ContactHeader)17 FromHeader (javax.sip.header.FromHeader)17 Test (org.junit.Test)17 RouteHeader (javax.sip.header.RouteHeader)16 AppServer (org.mobicents.tools.sip.balancer.AppServer)16 EventListener (org.mobicents.tools.sip.balancer.EventListener)16 CSeqHeader (javax.sip.header.CSeqHeader)13 CallIdHeader (javax.sip.header.CallIdHeader)13 Header (javax.sip.header.Header)13 MaxForwardsHeader (javax.sip.header.MaxForwardsHeader)13 RecordRouteHeader (javax.sip.header.RecordRouteHeader)13 URI (javax.sip.address.URI)11