Featured

TeleStax presenting at Crocodile Network & WebRTC SDK Launch

Crocodile is launching a complete real-time communications platform comprising an open cloud signalling network, developer SDK providing session control, management and billing capabilities, and sample WebRTC applications.

It is targeted at individual app designers, company website developers and service providers who would like to incorporate real-time web communications into their applications and services.

The event will happen on Wednesday 22nd May, 2013 which will be streamed live and available at http://lnx.so/croc. Jean Deruelle, TeleStax co-founder has been invited to speak at the event and talk about TeleStax and its WebRTC enabled SIP AS.

Running WebRTC applications on Cloudbees with Mobicents ClickStack

Introduction

Starting with Mobicents SIP Servlets 2.0.0.Final the container now supports WebSocket transport and SIP over Websocket specification. This enable developers to provide a new set of applications, WebRTC applications that brings real time communication to the browser using HTML5.

Check here for a video of the demo application that comes with Mobicents SIP Servlets 2.0.0.Final and read the wiki page for more information for the Mobicent WebRTC demo application.

Cloudbees

CloudBees offers the first Java Platform as a Service (PaaS) that supports the entire application lifecycle, from development through to production. Java developers can quickly and easily create quality software using DEV@cloud. Once the application is ready, instantly deploy it to the cloud using RUN@cloud.

Cloudbees introduced the ClickStart feature to make developer’s life easier. With a provided ClickStack, a user can easily deploy an application to the cloud and start using it.

There is a plethora of ClickStack to be used and recently Mobicent team added one more. the Mobicents Tomcat 7 Clickstack.

Mobicents Sip Servlet Tomcat 7 ClickStack

The Mobicents Sip Servlet Tomcat 7 ClickStack will allow developers to deploy WebRTC applications and use SIP Over WebSocket to the cloud infrastructure of Cloudbees rapidly with no need to setup the container and the infrastructure.

The ClickStack contains the latest Mobicent Sip Servlet 2.1.0 snapshot and the latest Mobicents LoadBalancer.

Deploying a WebRTC Sip Servlet application to Cloudbees

Few modifications need to be made to an application in order to get deployed to the Cloudbees using the Mobicents Tomcat 7 ClickStack.

  • Change the WebSocket port of the container to port 80
  • Define a STUN server
  • Include a mobicents-dar.properties file to the application war, with instructions for the Application Router

When the application is ready you will need to use the Cloudbees SDK in order to deploy the application.

To demonstrate the use of the ClickStack a step by step guide on how to deploy the websocket-b2bua example to Cloudbees follows.

WebSocket-b2bua example to Cloudbees

The WebSocket-b2bua example (https://code.google.com/p/sipservlets/source/browse/#git%2Fsip-servlets-examples%2Fwebsocket-b2bua), needs to be modified as follows.

  • Modify the file https://code.google.com/p/sipservlets/source/browse/sip-servlets-examples/websocket-b2bua/src/main/sipapp/MobicentsWebRTCPhone/js/MobicentsWebRTCPhoneController.js with the following:

    // Default SIP profile to use
    MobicentsWebRTCPhoneController.prototype.DEFAULT_SIP_OUTBOUND_PROXY=”ws://” + window.location.hostname + “:80″;
    MobicentsWebRTCPhoneController.prototype.DEFAULT_SIP_USER_AGENT=”MobicentsWebRTCPhone/0.0.1″
    MobicentsWebRTCPhoneController.prototype.DEFAULT_SIP_USER_AGENT_CAPABILITIES=undefined
    MobicentsWebRTCPhoneController.prototype.DEFAULT_SIP_DOMAIN=”webrtc.mobicents.org”;
    MobicentsWebRTCPhoneController.prototype.DEFAULT_SIP_DISPLAY_NAME=”alice”;
    MobicentsWebRTCPhoneController.prototype.DEFAULT_SIP_USER_NAME=”alice”;
    MobicentsWebRTCPhoneController.prototype.DEFAULT_SIP_LOGIN=undefined;
    MobicentsWebRTCPhoneController.prototype.DEFAULT_SIP_PASSWORD=undefined;
    MobicentsWebRTCPhoneController.prototype.DEFAULT_SIP_CONTACT=”bob”;
    MobicentsWebRTCPhoneController.prototype.DEFAULT_SIP_REGISTER_MODE=true;
    MobicentsWebRTCPhoneController.prototype.DEFAULT_STUN_SERVER= “stun.l.google.com:19302″;

  • Next build and package the application, and include the mobicents-dar.properties file the appropriate routing information for the application, for the websocket-b2bua example the dar properties file is:

    OPTIONS: (“WebsocketSample”, “DAR:From”, “ORIGINATING”, “”, “NO_ROUTE”, “0″)
    REGISTER: (“WebsocketSample”, “DAR:From”, “ORIGINATING”, “”, “NO_ROUTE”, “0″)
    INVITE: (“WebsocketSample”, “DAR:From”, “ORIGINATING”, “”, “NO_ROUTE”, “0″)

     

You can downloaded the final modified example application from here

Deploy the application to Cloudbees Run@Cloud

To deploy the application to Cloudbees Run@Cloud you will need to download and install the Cloudbees SDK (https://developer.cloudbees.com/bin/view/RUN/BeesSDK#HInstallingtheCloudBeesSDK).

With the SDK installed you deploy the application using the following command

bees app:deploy -a websocket-b2bua -t mss-tomcat7 -Rjava_version=1.6 -RPLUGIN.SRC.mss-tomcat7=https://s3.amazonaws.com/clickstacks/mobicents/mss-tomcat7-plugin.zip ./websockets-sip-servlet.war

Important to note:

  • -a websocket-b2bua: Defines the name of the Cloudbees application
  • -RPLUGIN.SRC.mss-tomcat7: Defines the location of the Mobicents Sip Servlets Tomcat 7 Clickstack

 

 

 

First Time @ SIPNOC

In this blog post I will provide a brief overview of my experience at this years SIPNOC 2013 conference. I really can’t say enough about the quality of the event, speakers, and attendees. The organizers did a great job of filtering content to make sure only quality talks made it on stage.

I myself was honored to to have the opportunity to speak at the conference and present TeleStax’s WebRTC technology. I was also surprised when asked to demo the technology and sit in on Thursdays WebRTC BOF with Dr. Alan Johnston. I have to admit it was a bit nerve wrecking and exciting at the same time to present in front of so many smart people but I look forward to doing it again next year. For those interested in knowing what the industry is talking about I highly recommend checking out the slides when you have some spare time.

The content was well organized but one subject seemed to keep coming up “WebRTC” the new kid on the block developed @ Google. To give a brief intro WebRTC is a set of client side technologies by Google allowing web developers to add real-time communications to their web applications. For those of you interested in WebRTC I suggest you check out the Mobicents WebRTC Demo as a starting point.

Advanced Telecom Research Makes It Possible to Deliver Scalable Mobile Phone Service over Existing Web Servers

Telestax’ Mobicents SIP Servlets platform is on par with flagship products from industry giants such as Oracle OCCAS and IBM Web Sphere. In some categories Mobicents is a better choice when it comes to building telecom services with highest level of availability.

 

Read Online.

TeleStax at CommunicAsia 2013

Jean Deruelle, co founder of Telestax, is coming back to Singapore, from June 17th to 21st, to co-present on TeleStax partner’s Ates Networks booth, their BroadApp store and selfcare solutions powered by Mobicents JAIN-SLEE and Mobicents jSS7. If you are present as well, feel free to contact us so that we can meet face to face !

Brand New Management Web UI for TeleScale JSLEE

With its Carrier Grade Performance and High Availability Features, TelScale JAIN-SLEE is the Telecom Application Server of choice for creating and deploying new innovative services bridging the legacy and IMS worlds through an extensive set of Connectors and Enablers allowing to make use of existing legacy SS7 infrastructure as well as addressing today’s all-IP IMS Architecture thus improving the time to market and reduced TCO over existing proprietary solutions to maximize your ARPU. TelScale JAIN-SLEE is full Java and will run on the same hardware and OS the Application Server runs on. Its key features and benefits are:

  • Open Source and Open Standards
  • Service Composition
  • Cloud Communications
  • Carrier Grade Performance
  • Extensive set of SS7 and IP Connectors – Enablers
  • Clustering and High Availability
  • Enterprise Monitoring and Management
  • Distributed Load Balancing and Transparent Failover
  • IMS Ready
  • DoS Attack Prevention
  • Media support

And now we are proud to announce a brand new, modern Web UI for JSLEE Management and Monitoring:

     1 2 3 4 5 6 7 8

Managing and Monitoring TelScale SMSC is a piece of cake with new Web UI!

TelScale SMSC is a robust and carrier proven Open Source SMSC built on a modern extensible middleware platform. It can be adapted to the needs of telecom service providers of different sizes in any country. It is designed not only to provide standard SMSC features, but also enable added value services through integration with OTT social networks and microblogs such as Facebook and Twitter. TelScale SMSC also provides core features for Mobile subscriber to subscriber SMS messaging, Broadcasting campaigns & Group messaging between subscribers. It provides flexible routing mechanism to route a message to ESME over SMPP protocol. The key features and benefits of SMSC are:

  • Open Source
  • Cloud Ready
  • Carrier Grade Performance
  • Extensible and Modern Platform
  • Load Balancing and Transparent Failover
  • TDM and SIGTRAIN Support
  • Enterprise Monitoring and Management
  • Advanced Routine Rules

Here’s a quick look at the product’s brand new UI for Management and Monitoring:

_9pCZrvstKCsVVCMYGjhVEBqGAgM_o0OpgJuO9huO40 5GvgiPVgHpWIxiFPz_kyWBczOF7u-YPUnYToKIlLbNs 5TSkQyYlBxeUbCwHPYYH6PWNKL2PX1Qftxwc9rr6JCM DXBd_cJCAPNyRdWugl0cwFmlAFfxPz_5JctK065qttg RxkkXI9R6uvwj-avdVsQ4wZ3Sk4naRrMXbyB3USKkYc wLEKNRJqYfcaosc2V4aQJGVwK8QgCPvGs4dKqHDu1tM

 

 

RestComm Sample Voice Application: Doctor’s Appointment

In this tutorial, you will learn how to use RestComm to quickly build an Interactive Voirce Response (IVR) application. The sample is based on PHP but, you could also use any programming language of your choice. An xml file is used to store and retrieve data in order to facilitate learning how to build voice applications.

 

Requirements

  • Install RestComm on your computer as explained HERE
  • Setup your local Apache web server as outlined HERE

Creating an application that will automatically make appointments for clients can be very useful for businesses in different settings. This could be applied to out of hours service, when the receptionist is busy or when the Doctor wants to check when he next has an appointment. Care has been taken to keep this example very simple so that you can get a glimpse of the potential and the power of RestComm.

There are 4 files that you need to  create, the content of the files is located further down:

  • welcome-conf.xml
  • handle-doctors-appointment.php
  • handle-doctors-appointment2.php
  • appointment-db.xml

Create the welcome-conf.xml file in the $RESTCOMM_HOME/server/default/deploy/restcomm.war/demo

Use cURL to bind the welcome-conf.xml to RestComm, you can see the example command HERE. All you need to do is change the hello-world.xml to welcome-conf.xml and run the command.

The other files must be created in your web root directory. Because the appointment-db.xml file needs to be updated during the application run time, you need to change the owner and the permission to allow read-write.  See HERE on how to do so.

What the Doctor’s Application Does

The doctors appointment application does a couple of things:

When a user calls, he lands on the welcome-conf.xml file that has been linked to RestComm using the cURL command in the installation documentation. The user is prompted to enter his patient number. In the next handle-doctors-appointment.php file, the user hears a menu of options to choose the day he wants an appointment. The handle-doctors-appointment2.php will set an appointment day or will prompt the use to choose another day if there is already someone schedule for the chosen day.

The example doctors’  application is not complete as you will need to add more logic to make it more robust. For example,

  • prevent patients from booking two appointments
  • let patients delete an appointment
  • make sure a new patient doesn’t override another patient’s appointment
  • add more features to allow patients to choose hours of appointment
  • let patients choose the doctor they want from the list of available doctors

The list can go on but, this should just give you an idea of the possibilities you have using RestComm to quickly build IVR applications.

 

file1 = welcome-conf.xml

file2 = handle-doctors-appointment.php

file3 = handle-doctors-appointment2.php

file4 = appointment-db.xml

You can get the sample patient numbers from the appointment-db.xml file..
Toggle

 


<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather action="http://127.0.0.1/handle-doctors-appointment.php" finishOnKey="*">
<Say>Welcome to the Doctors Appointment Menu.</Say>
<Say>Powered by Telestax RestComm</Say>
<Say>Enter your 4 digit Patient number and press star</Say>
</Gather>
<!-- If customer doesn't input anything, prompt and try again. -->
<Say>Sorry, your input is not  valid</Say>
<Redirect>http://127.0.0.1:8080/restcomm/demo/welcome-conf.xml</Redirect>
</Response>

 

<?php
header(‘Content-type: text/xml’);

echo ‘<?xml version=”1.0″ encoding=”UTF-8″?>’;

$patient_num = (int) ($_REQUEST['Digits']);
$p_len = strlen($patient_num);

echo ‘<Response>’;

//make sure user enter 4 digits and digit not same as default digit
if($p_len == “4″){

$db = simplexml_load_file(“http://127.0.0.1/appointment-db.xml”);

foreach($db->clients as $clientlist){

if($clientlist->patientnum == $patient_num) {
$patient_name = $clientlist->patientname;
}
}

$db->asXml(“/var/www/html/appointment-db.xml”);
echo ‘<Gather action=”http://127.0.0.1/handle-doctors-appointment2.php?p_num=’.$patient_num.’” numDigits=”1″>’;
echo ‘<Say> Hello’.$patient_name.’ </Say>’;
echo ‘<Say>To make an appointment for monday press 1</Say>’;
echo ‘<Say>for tuesday press 2</Say>’;
echo ‘<Say>for wednesday press 3</Say>’;
echo ‘<Say>for thursday press 4</Say>’;
echo ‘<Say>for friday press 5</Say>’;
echo ‘</Gather>’;
echo ‘<Say>You entered an invalid input</Say>’;
echo ‘<Redirect>http://127.0.0.1/handle-doctors-appointment.php?Digits=’.$patient_num.’</Redirect>’;

}else{
echo ‘<Say>You entered an invalid patient number</Say>’;
echo ‘<Redirect>http://127.0.0.1:8080/restcomm/demo/welcome-conf.xml</Redirect>’;
}

echo ‘</Response>’;
?>

 

<?php
header(‘Content-type: text/xml’);

echo ‘<?xml version=”1.0″ encoding=”UTF-8″?>’;

$patient_num = (int) ($_REQUEST['p_num']);
$day_chosen = (int) ($_REQUEST['Digits']);
$input_array = array(“1″,”2″,”3″,”4″,”5″) ;

echo ‘<Response>’;

//open the appointment-db.xml file

$db = simplexml_load_file(“http://127.0.0.1/appointment-db.xml”);

//make sure the user input $day_chosen is in the array
if(in_array($day_chosen, $input_array)){

foreach($db->days as $clientlist){
//if there is already an appointment redirect to previous menu
if($clientlist->busy == “1″ && $clientlist->day == $day_chosen){
echo ‘<Say>The doctor is already busy on’ .$clientlist->dayname.’ </Say>’;
echo ‘<Say>Please choose another day </Say>’;
echo ‘<Redirect>http://127.0.0.1/handle-doctors-appointment.php?Digits=’.$patient_num.’ </Redirect>’;

//if no existing appointment on that day set a new one
}elseif($clientlist->busy == “0″ && $clientlist->day == $day_chosen){
$clientlist->patientnum = $patient_num;
$day_name = $clientlist->dayname;
$clientlist->busy = “1″;
}
}

//get patient name from the appointment-db.xml
foreach($db->clients as $clientlist){
if($clientlist->patientnum == $patient_num) {
$get_patientname = $clientlist->patientname;
}
}
//update the appointment-db.xml file with changes
$db->asXml(“/var/www/html/appointment-db.xml”);

echo ‘<Say>Hello ‘.$get_patientname.’Your appointment for ‘.$day_name.’ has been validated</Say>’;
echo ‘<Say>Goodbye!</Say>’;

}else{
echo ‘<Say>You entered an invalid input</Say>’;
echo ‘<Redirect>http://127.0.0.1/handle-doctors-appointment.php?Digits=’.$patient_num.’ </Redirect>’;

}

echo ‘</Response>’;
?>

<?xml version=”1.0″ encoding=”UTF-8″?>
<appointment>
<days>
<day>1</day>
<dayname>Monday</dayname>
<busy>0</busy>
<patientnum>1111</patientnum>
<patientname/>
</days>
<days>
<day>2</day>
<dayname>Tuesday</dayname>
<busy>0</busy>
<patientnum></patientnum>
<patientname/>
</days>
<days>
<day>3</day>
<dayname>Wednesday</dayname>
<busy>0</busy>
<patientnum></patientnum>
<patientname/>
</days>
<days>
<day>4</day>
<dayname>Thursday</dayname>
<busy>0</busy>
<patientnum/>
<patientname/>
</days>
<days>
<day>5</day>
<dayname>Friday</dayname>
<busy>0</busy>
<patientnum/>
<patientname/>
</days>

<clients>
<patientnum>1111</patientnum>
<patientname>James</patientname>
</clients>
<clients>
<patientnum>2222</patientnum>
<patientname>Mary</patientname>
</clients>
<clients>
<patientnum>3333</patientnum>
<patientname>David</patientname>
</clients>

</appointment>

 

Telestax at IMS World Forum 2013 and WebRTC Workshop

Jean Deruelle, co founder of Telestax, is coming back to Barcelona, Spain from April 22nd to 25th. The WebRTC Workshop at IMS World Forum is where he will be doing a WebRTC Video Conferencing presentation with our partner Medooze. You can read more about the event and schedule at Alan Quayle’s blog, one of the key presenters and organizers. So if you’re in the area or attending IMS World Forum and want to meet, contact us quickly.

Mobicents Sip Servlet extension to Arquillian Tutorial

Introduction

The Mobicents Sip Servlet extension to Arquillian 1.0.0-CR1 release introduces two Maven archetypes to help you quickly setup a test project.

This tutorial will walk you through the basic steps to create a testing project.

First pick one on of the Mobicent Sip Servlet Arquillian containers depending on your needs:

  • For embedded Tomcat 6 container based on Mobicents Sip Servlets 1.7.0 (Java Servlets 2.5) create a maven project using the following maven archetype:
    mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-sipapp-test -Dversion=1.0-SNAPSHOT -DarchetypeArtifactId=mss-testing-embeddedTomcat6-archetype -DarchetypeGroupId=org.mobicents.servlet.sip.archetypes -DarchetypeVersion=1.0
  • For embedded Tomcat 7 container based on Mobicents Sip Servlets 2.0.0 (Java Servlets 3.0) create a maven project using the following maven archetype:
    mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-sipapp-test -Dversion=1.0-SNAPSHOT -DarchetypeArtifactId=mss-testing-embeddedTomcat7-archetype -DarchetypeGroupId=org.mobicents.servlet.sip.archetypes -DarchetypeVersion=1.0

The created project will contain everything you need to get started:

  • The required dependencies 
  • Mobicents Sip Servlet Arquillian container
  • SipUnit
  • A SIP servlet class
  • The test class

Create the project

So lets get started:

  • Open a console window and issue the command:
    mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-sipapp-test -Dversion=1.0-SNAPSHOT -DarchetypeArtifactId=mss-testing-embeddedTomcat6-archetype -DarchetypeGroupId=org.mobicents.servlet.sip.archetypes -DarchetypeVersion=1.0
  • Once the Maven Archetype plugin creates the project, change to the my-sipapp-test directory
  • You can quickly check that everything is setup correctly by running the test using the command: mvn test
  • Now lets prepare the project for import to Eclipse with the command: mvn clean eclipse:clean eclipse:eclipse
  • Next go to Eclipse and import the project to the workspace

Project Structure

The structure of the created project will be:

Project Structure

Project Structure

  • The folder src/test/java contains the test class.
  • The folder src/test/resources contains the required fot the test, configuration and resource files.
  • The folder src/main/java contains the SIP servlet class. This is the actual SIP Servlet application we need to test.

Next lets discus each of the folder’s contents.

SIP Servlet application

The SimpleSipServlet.java class is the SIP Servlet application that we need to test.

@javax.servlet.sip.annotation.SipServlet(loadOnStartup=1, applicationName="SimpleSipServletApplication")
public class SimpleSipServlet extends SipServlet {

private static final long serialVersionUID = -7779271585280911979L;
private static Logger logger = Logger.getLogger(SimpleSipServlet.class);

@Override
protected void doInvite(SipServletRequest req) throws ServletException,IOException {
logger.info(“INVITE message received: “+req.toString());
logger.info(“Sending 100 TRYING”);
SipServletResponse trying = req.createResponse(SipServletResponse.SC_TRYING);
trying.send();

logger.info(“Sending 180 RINGING”);
SipServletResponse ringing = req.createResponse(SipServletResponse.SC_RINGING);
ringing.send();

logger.info(“Sending 200 OK”);
SipServletResponse ok = req.createResponse(SipServletResponse.SC_OK);
ok.send();
}

@Override
protected void doAck(SipServletRequest req) throws ServletException, IOException {
logger.info(“ACK received: “+req.toString());
super.doAck(req);
}

@Override
protected void doBye(SipServletRequest req) throws ServletException, IOException {
logger.info(“BYE received: “+req.toString());
SipServletResponse ok = req.createResponse(SipServletResponse.SC_OK);
ok.send();
}
}

The application will handle INVITE, ACK and BYE messages.

When a new INVITE message arrives, the application will send 100 TRYING, 180 RINGING and finally 200 OK responses.  When a BYE received, the application will send a 200 OK response.

This is the behavior that we will assert later in the test method.

Test resources and configuration

  • arquillian.xml: Arquillian controlled containers, such as Mobicents Sip Servlet Arquillian Embedded Tomcat 6 container, need arquillian.xml in order to configure parts of the server such as HTTP and SIP connectors ports and the IP Address that the connectors will bind to.
  • log4j.xml: This is the configuration for Log4J. You can change the loglevel here
  • in-container-sip.xml: The sip.xml deployment descriptor that will be used to created test archive.
  • test-dar.properties: The configuration needed for the Sip Servlet Application Router.

Test class

The SimpleSipServletTest.java is the test class of the project. Here we assembly the test archive, we setup and tear down the pre-requisite components for the test , such as the SIP client,  and we define the test methods.

@RunWith(Arquillian.class)
public class SimpleSipServletTest {

private static Logger logger = Logger.getLogger(SimpleSipServletTest.class);

//SipUnit related components
private SipStack sipUnitStack;
private SipCall sipUnitCall;
private SipPhone sipUnitPhone;
private static SipStackTool sipStackTool;

private static String toUri = “sip:sipservletapp@127.0.0.1:5070″;

@BeforeClass
public static void beforeClass(){
sipStackTool = new SipStackTool(“mySipUnitStackTool”);
}

@Before
public void setUp() throws Exception
{
logger.info(“Setting up SipUnit”);
//Create the sipCall and start listening for messages

//.SipStackTool.initializeSipStack(String myTransport, String myHost, String myPort, String outboundProxy)
sipUnitStack = sipStackTool.initializeSipStack(SipStack.PROTOCOL_UDP, “127.0.0.1″, “5080″, “127.0.0.1:5070″);
//SipStack.createSipPhone(String proxyHost, String proxyProto, int proxyPort, String myURI)
sipUnitPhone = sipUnitStack.createSipPhone(“127.0.0.1″, SipStack.PROTOCOL_UDP, 5070, “sip:sipunit@here.com”);
sipUnitCall = sipUnitPhone.createSipCall();
sipUnitCall.listenForIncomingCall();
}

@After
public void tearDown() throws Exception
{
logger.info(“Tear down SipUnit”);
if(sipUnitCall != null) sipUnitCall.disposeNoBye();
if(sipUnitPhone != null) sipUnitPhone.dispose();
if(sipUnitStack != null) sipUnitStack.dispose();
}

@Deployment(name=”simple”, managed=true, testable=false)
public static WebArchive createTestArchive()
{
//Create a test archive named: simplesipservlet.war
WebArchive webArchive = ShrinkWrap.create(WebArchive.class, “simplesipservlet.war”);
//Include the SimpleSipServlet.class from /src/main/java
webArchive.addClasses(SimpleSipServlet.class);
//Include as WEB-INF resource sip.xml the in-container-sip.xml from src/test/resources
webArchive.addAsWebInfResource(“in-container-sip.xml”, “sip.xml”);

return webArchive;
}

@Test
public void testInitiateCall() {

//Initiate a new call
assertTrue(sipUnitCall.initiateOutgoingCall(toUri, null));

//Wait for answer
assertTrue(sipUnitCall.waitForAnswer(5000));
assertEquals(SipServletResponse.SC_OK, sipUnitCall.getLastReceivedResponse().getStatusCode());

//Send ACK to 200 OK
assertTrue(sipUnitCall.sendInviteOkAck());

//Disconnect call and wait for 200 ok to BYE
assertTrue(sipUnitCall.disconnect());
assertEquals(SipServletResponse.SC_OK,sipUnitCall.getLastReceivedResponse().getStatusCode());
}
}

Lets go through the important parts of the test class:

  • We need to annotate our test class with @RunWith(Arquillian.class) in order Arquillian to pick up the test
  • Using JUnit 4 @Before, @After and @BeforeClass annotations, we setup the SipUnit, the SIP client that will be used in our test method later
  • The methods createTestArchive() that is annotated with @Deployment, will be called by Arquillian to get the test archive and deploy it. In this method:
    • We create a test archive with name simplesipservlet.war archive:
      WebArchive webArchive = ShrinkWrap.create(WebArchive.class, “simplesipservlet.war”);
    • We add the SIP servlet SimpleSipServlet.class class:
      webArchive.addClasses(SimpleSipServlet.class);
    • We add the required SIP Servlets deployment descriptor sip.xml:
      webArchive.addAsWebInfResource(“in-container-sip.xml”, “sip.xml”);
    • And finally we return the test archive:
      return webArchive;
  • Last is the test method annotated with JUnit 4 @Test. Here SipUnit will interact with the SIP Servlet application and will assert the results.
    • SipUnit will initiate a call to the application
      assertTrue(sipUnitCall.initiateOutgoingCall(toUri, null));
    • Then will wait for an answer and will check that the answer is a 200 OK
      assertTrue(sipUnitCall.waitForAnswer(5000));
      assertEquals(SipServletResponse.SC_OK, sipUnitCall.getLastReceivedResponse().getStatusCode());
    • Next will send an ACK
      assertTrue(sipUnitCall.sendInviteOkAck());
    • And finally will disconnect this call:
      assertTrue(sipUnitCall.disconnect());
      assertEquals(SipServletResponse.SC_OK,sipUnitCall.getLastReceivedResponse().getStatusCode());

 

Running the test

Now we are ready to run the test.

Right click on the SimpleSipServletTest.java and choose Run As -> JUnit test. You will see a lot of messages in the console and finally the GREEN bar of the JUnit result:

JUnit Result

JUnit Result

You can also run the test from the console using Maven surefire plugin. Just open a console in the project’s directory and run the test with the command: mvn test.

Resources