20
Testing SIP Applications with Arquillian and SipUnit Annual Mobicents Community Summit Rio de Janeiro, October 3-8, 2012 George Vagenas CDI Telco Framework & SIP Testing project lead

Mobicents Summit 2012 - George Vagenas - Testing SIP Applications with Arquillian and SipUnit

Embed Size (px)

Citation preview

Page 1: Mobicents Summit 2012 - George Vagenas - Testing SIP Applications with Arquillian and SipUnit

Testing SIP Applications with Arquillian and SipUnit

Annual Mobicents Community Summit

Rio de Janeiro, October 3-8, 2012

George VagenasCDI Telco Framework & SIP Testing project lead

Page 2: Mobicents Summit 2012 - George Vagenas - Testing SIP Applications with Arquillian and SipUnit

Agenda

● Introduction

○ SipServlets applications testing

○ Arquillian extension for SipServlets

○ SipUnit

● Arquillian Extension for SipServlets○ Features

○ MSS Tomcat 6 & Tomcat 7 containers

● SipUnit

○ Features

Page 3: Mobicents Summit 2012 - George Vagenas - Testing SIP Applications with Arquillian and SipUnit

Past year achievements

● Arquillian Extension for SipServlets 1.0.0.ALPHA1

● Telestax took over leadership of SipUnit● SipUnit 2.0.0

Page 4: Mobicents Summit 2012 - George Vagenas - Testing SIP Applications with Arquillian and SipUnit

SipServlets applications testing

Requirements:● Manage SipServlets enabled container● Manage test archive● Integration with a testing framework (JUnit

or TestNG) ● SIP Client (UAC/UAS) to interact with the

SipServlet application

Page 5: Mobicents Summit 2012 - George Vagenas - Testing SIP Applications with Arquillian and SipUnit

Arquillian Extension for SipServletsArquillian testing framework, seeks to minimize the burden on the developer to author integration tests by handling all aspects of test execution, including:● managing the lifecycle of the container (start/stop),● bundling the test class with dependent classes and

resources into a deployable archive,● enhancing the test class (e.g., resolving @Inject, @EJB

and @Resource injections),● deploying the archive to test (deploy/undeploy) and

capturing results and failures.

Page 6: Mobicents Summit 2012 - George Vagenas - Testing SIP Applications with Arquillian and SipUnit

Arquillian Extension for SipServletsMobicents brings the Sip Servlets Arquillian container for testing converged applications.

Container is based on:● Tomcat 6.x● Tomcat 7.x

Page 7: Mobicents Summit 2012 - George Vagenas - Testing SIP Applications with Arquillian and SipUnit

Arquillian Extension for SipServletsExtras● Annotations

○ @ContextParam○ @ContextParamMap○ @ConcurrencyControlMode

● Helper classes○ ContextParamTool○ SipStackTool

● Lifecycle extension to provide finer grained control over container's and test's lifecycle

Page 8: Mobicents Summit 2012 - George Vagenas - Testing SIP Applications with Arquillian and SipUnit

Arquillian Extension for SipServlets● Finer grained control over the test's lifecycle

and the container's lifecycle● Override container configuration as needed● The integration is completely transparent,

which means you can launch the tests and get the test results using existing IDE, Ant and Maven test plugins without any add-ons.

Page 9: Mobicents Summit 2012 - George Vagenas - Testing SIP Applications with Arquillian and SipUnit

Arquillian Extension for SipServlets● CTF can be optionally enabled in order to

enrich the test or the test archive.● On the same test we can have

○ Multiple test archives○ Multiple container configuration

Page 10: Mobicents Summit 2012 - George Vagenas - Testing SIP Applications with Arquillian and SipUnit

Arquillian Extension for SipServlets

<container qualifier="mss-tomcat-embedded-6" default="true" mode="manual">

<configuration><property name="tomcatHome">target/mss-tomcat-embedded-

6</property><property name="workDir">work</property><property name="bindHttpPort">8888</property><property name="unpackArchive">true</property><property name="sipConnectors">:5070,:5070/TCP</property><property name="bindAddress">127.0.0.1</property><property name="sipApplicationRouterProviderClassName">org.

mobicents.servlet.sip.router.DefaultApplicationRouterProvider</property></configuration>

</container>

Page 11: Mobicents Summit 2012 - George Vagenas - Testing SIP Applications with Arquillian and SipUnit

Arquillian Extension for SipServlets@RunWith(Arquillian.class)public class ShootistSipServletTest extends SipTestCase {@Deployment(name="simpleArchive", managed=false)

public static WebArchive createTestArchive(){WebArchive webArchive = ShrinkWrap.create(WebArchive.class,"shootistsipservlet.war");webArchive.addClasses(ShootistSipServlet.class);webArchive.addAsWebInfResource("in-container-sip.xml", "sip.xml");return webArchive;}

Page 12: Mobicents Summit 2012 - George Vagenas - Testing SIP Applications with Arquillian and SipUnit

Arquillian Extension for SipServlets

@Test @ContextParam(name="cancel", value="true")public void testShootist() throws Exception {

SipStackTool sipStackTool = new SipStackTool();receiver = sipStackTool.initializeSipStack(SipStack.PROTOCOL_UDP,

"127.0.0.1", "5080", "127.0.0.1:5070");sipPhone = receiver.createSipPhone("127.0.0.1", SipStack.

PROTOCOL_UDP, 5070, "sip:[email protected]");sipCall = sipPhone.createSipCall();sipCall.listenForIncomingCall();deployer.deploy("simpleArchive");assertTrue(sipCall.waitForIncomingCall(timeout));assertTrue(sipCall.sendIncomingCallResponse(Response.TRYING,"

Trying", timeout));

Page 13: Mobicents Summit 2012 - George Vagenas - Testing SIP Applications with Arquillian and SipUnit

Arquillian Extension for SipServlets

What comes next:● Mobicents Sip Servlets AS7 container

Page 14: Mobicents Summit 2012 - George Vagenas - Testing SIP Applications with Arquillian and SipUnit

SipUnit

SipUnit provides a test environment geared toward unit testing SIP applications.

The primary goal of SipUnit is to abstract the details of SIP messaging/call handling and facilitate free-flowing, sequential test code so that a test target can be exercised quickly and painlessly

Page 15: Mobicents Summit 2012 - George Vagenas - Testing SIP Applications with Arquillian and SipUnit

SipUnit features

● Maven artifacts● Junit 4 support● TLS support● SIP UAC & UAS● uses the JAIN-SIP reference implementation as its

underlying SIP stack/engine● JUnit-like test development and execution environment

with SIP-specific assertions added ● Different levels of SIP handling abstraction depending

on test case needs. If you don't care how a setup call gets established, use the highest level - SipPhone.makeCall().

Page 16: Mobicents Summit 2012 - George Vagenas - Testing SIP Applications with Arquillian and SipUnit

SipUnit features

● Support for registration and call handling with or without authentication

● Support for presence subscription handling (SUBSCRIBE/NOTIFY)

● CANCEL handling● Support for MESSAGE● REFER and associated subscription handling● Support for NAT traversal (STUN)● Support for testcase-specified timeouts● A test can act as more than one network element - ie, it

can act as both the caller and callee endpoints to test a network element between the two.

Page 17: Mobicents Summit 2012 - George Vagenas - Testing SIP Applications with Arquillian and SipUnit

SipUnit example

b.listenForIncomingCall();

a.initiateOutgoingCall("sip:[email protected]", null);

b.waitForIncomingCall(5000);

b.sendIncomingCallResponse(Response.RINGING, "Ringing", 0);

a.waitOutgoingCallResponse(10000);

b.sendIncomingCallResponse(Response.OK, "Answer - Hello world", 0);

a.waitOutgoingCallResponse(10000);

a.sendInviteOkAck();

Page 18: Mobicents Summit 2012 - George Vagenas - Testing SIP Applications with Arquillian and SipUnit

SipUnit download

● Binary: http://code.google.com/p/commtesting/downloads/list

● Maven artifact <dependency> <groupId>org.cafesip.sipunit</groupId> <artifactId>sipunit</artifactId> <version>2.0.0</version></dependency><repository>

<id>mobicents-public-repository-group</id><name>Mobicens Public Maven Repository Group</name><url>https://oss.sonatype.org/content/groups/public</url><layout>default</layout><releases>

<enabled>true</enabled><updatePolicy>never</updatePolicy>

</releases><snapshots>

<enabled>true</enabled><updatePolicy>never</updatePolicy>

</snapshots></repository>

Page 19: Mobicents Summit 2012 - George Vagenas - Testing SIP Applications with Arquillian and SipUnit

SipServletes Commtesting links

● Project site: http://code.google.com/p/commtesting/

● SipServlets Arquillian Extension Documentation: https://mobicents.ci.cloudbees.com/view/SIP%20Testing/job/sipservlets.arquillian/lastSuccessfulBuild/artifact/documentation/html_single/index.html

● SipUnit Documentation: https://mobicents.ci.cloudbees.com/job/SipUnit/lastSuccessfulBuild/artifact/sipunit/docs/jdocbook-mobicents/target/docbook/publish/en-US/html_single/index.html

Page 20: Mobicents Summit 2012 - George Vagenas - Testing SIP Applications with Arquillian and SipUnit

Contact

George [email protected]

Thank you