Skip to content

Commit

Permalink
MSS-119 #Comment test for the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
gvagenas committed Sep 24, 2014
1 parent 53a9b1d commit 23849e9
Show file tree
Hide file tree
Showing 8 changed files with 608 additions and 7 deletions.
317 changes: 317 additions & 0 deletions sip-servlets-arquillian-testsuite/ProxyTest/pom.xml
@@ -0,0 +1,317 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>sip-servlets-arquillian-testsuite</artifactId>
<groupId>org.mobicents.servlet.sip.arquillian.testsuite</groupId>
<version>2.1.0-SNAPSHOT</version>
</parent>

<groupId>org.mobicents.servlet.sip.arquillian.testsuite</groupId>
<artifactId>ProxyTest</artifactId>
<version>2.1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>My Mobicents Sip Servlet test project on embedded Tomcat7</name>
<url>https://code.google.com/p/commtesting/</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<mss.arquillian.version>7.0.3.49</mss.arquillian.version>
<mss.shrinkwrap.version>7.0.3.42</mss.shrinkwrap.version>
<shrinkwrap.resolver.version>2.0.0-alpha-4</shrinkwrap.resolver.version>

<arquillian.version>1.0.3.Final</arquillian.version>
<sipservlets.version>7.0.3-TelScale-SNAPSHOT</sipservlets.version>
<!-- <sipservletapi.version>7.0.3.272</sipservletapi.version> -->
<sipservletapi.version>7.0.3-TelScale-SNAPSHOT</sipservletapi.version>
<version.org.apache.tomcat>7.0.29</version.org.apache.tomcat>
<junit.version>4.11</junit.version>
<sipunit.version>2.0.0</sipunit.version>
<log4j.version>1.2.17</log4j.version>

</properties>

<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>

<!-- Arquiilian/Junit Dependencies -->
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>${arquillian.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.cafesip.sipunit</groupId>
<artifactId>sipunit</artifactId>
<version>${sipunit.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mobicents.arquillian.container</groupId>
<artifactId>mss-tomcat-embedded-7</artifactId>
<version>${mss.arquillian.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mobicents.arquillian.container</groupId>
<artifactId>mss-arquillian-container-api</artifactId>
<version>${mss.arquillian.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mobicents.arquillian.container</groupId>
<artifactId>mss-arquillian-utilities-extension</artifactId>
<version>${mss.arquillian.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mobicents.shrinkwrap.container</groupId>
<artifactId>shrinkwrap-container-mobicents</artifactId>
<version>${mss.shrinkwrap.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

<!-- Mobicents Sip Servlet Dependencies -->
<dependency>
<groupId>org.mobicents.servlet.sip</groupId>
<artifactId>sip-servlets-application-router</artifactId>
<version>${sipservlets.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.mobicents.servlet.sip.containers</groupId>
<artifactId>sip-servlets-catalina-7</artifactId>
<version>${sipservletapi.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mobicents.servlet.sip.containers</groupId>
<artifactId>sip-servlets-tomcat-7</artifactId>
<version>${sipservletapi.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mobicents.servlet.sip</groupId>
<artifactId>sip-servlets-core-api</artifactId>
<version>${sipservletapi.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mobicents.servlet.sip</groupId>
<artifactId>sip-servlets-spec</artifactId>
<version>${sipservletapi.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mobicents.servlet.sip</groupId>
<artifactId>sip-servlets-impl</artifactId>
<version>${sipservletapi.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mobicents.servlet.sip</groupId>
<artifactId>sip-servlets-client</artifactId>
<version>${sipservletapi.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>

<!-- <dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<scope>test</scope>
</dependency> -->

<dependency>
<groupId>org.mobicents.servlet.sip</groupId>
<artifactId>sip-servlets-application-router</artifactId>
<version>${sipservletapi.version}</version>
<scope>test</scope>
</dependency>



<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>

<!-- Apache Tomcat Dependencies -->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>${version.org.apache.tomcat}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-coyote</artifactId>
<version>${version.org.apache.tomcat}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jasper</artifactId>
<version>${version.org.apache.tomcat}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>javax.sip</groupId>
<artifactId>jain-sip-api</artifactId>
<version>1.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>javax.sip</groupId>
<artifactId>jain-sip-ri</artifactId>
<version>7.0.3.203</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<useProjectReferences>false</useProjectReferences>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>

<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<configuration>
<filesets>
<fileset>
<directory>${basedir}</directory>
<includes>
<include>logs/</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>telscale-releases-repository</id>
<name>TelScale Releases Repository</name>
<url>http://telestax.artifactoryonline.com/telestax/releases</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
<repository>
<id>telscale-snapshots-repository</id>
<name>TelScale Snapshots Repository</name>
<url>http://telestax.artifactoryonline.com/telestax/snapshots</url>
<releases>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
<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>
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
</repositories>

</project>
@@ -0,0 +1,74 @@
/*
* TeleStax, Open Source Cloud Communications
* Copyright 2011-2013, Telestax Inc and individual contributors
* by the @authors tag.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.mobicents.servlet.sip.arquillian.testsuite;

import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.sip.Proxy;
import javax.servlet.sip.ProxyBranch;
import javax.servlet.sip.SipServlet;
import javax.servlet.sip.SipServletRequest;
import javax.servlet.sip.URI;

import org.apache.log4j.Logger;
import org.mobicents.javax.servlet.sip.ProxyBranchListener;
import org.mobicents.javax.servlet.sip.ResponseType;

/**
* @author <a href="mailto:gvagenas@gmail.com">gvagenas</a>
*
*/
@javax.servlet.sip.annotation.SipServlet(loadOnStartup=1, applicationName="SimpleSipServletApplication")
@javax.servlet.sip.annotation.SipListener
public class ProxySipServlet extends SipServlet implements ProxyBranchListener {

private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(ProxySipServlet.class);

@Override
public void init(ServletConfig servletConfig) throws ServletException {
logger.info("the proxy sip servlet has been started");
super.init(servletConfig);
}

@Override
protected void doRegister(SipServletRequest req) throws ServletException, IOException {
logger.info("Got REGISTER: \n"+req+"\n");
req.createResponse(200).send();
}

@Override
protected void doInvite(SipServletRequest request) throws ServletException, IOException {
URI toURI = request.getTo().getURI();
Proxy proxy = request.getProxy();
proxy.setRecordRoute(true);
proxy.setProxyTimeout(3); // Set the proxy timeout in seconds
proxy.proxyTo(toURI);
}

@Override
public void onProxyBranchResponseTimeout(ResponseType responseType, ProxyBranch proxyBranch) {
logger.info("onProxyBranchResponseTimeout callback was called. responseType = " + responseType + " , branch = " + proxyBranch + ", request " + proxyBranch.getRequest() + ", response " + proxyBranch.getResponse());
//Just clean up here, container will send back 408 Request Timeout
}
}

0 comments on commit 23849e9

Please sign in to comment.