Revision: a38edbf661a9
Author: Jean Deruelle <[email protected]>
Date: Fri Aug 10 10:23:29 2012
Log: Update Issue 126
Non Regression test + backport of original fix
http://code.google.com/p/sipservlets/source/detail?r=a38edbf661a9
Modified:
/sip-servlets-core-api/src/main/java/org/mobicents/servlet/sip/core/session/MobicentsSipApplicationSession.java
/sip-servlets-core-api/src/main/java/org/mobicents/servlet/sip/core/session/MobicentsSipSession.java
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/SipApplicationSessionImpl.java
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/MobicentsSipApplicationSessionFacade.java
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipFactoryImpl.java
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletMessageImpl.java
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletRequestImpl.java
/sip-servlets-test-suite/applications/call-forwarding-b2bua-servlet/src/main/java/org/mobicents/servlet/sip/testsuite/b2bua/CallForwardingB2BUASipServlet.java
/sip-servlets-test-suite/testsuite/src/test/java/org/mobicents/servlet/sip/testsuite/callcontroller/CallForwardingB2BUAJunitTest.java
=======================================
---
/sip-servlets-core-api/src/main/java/org/mobicents/servlet/sip/core/session/MobicentsSipApplicationSession.java
Tue Oct 4 20:25:16 2011
+++
/sip-servlets-core-api/src/main/java/org/mobicents/servlet/sip/core/session/MobicentsSipApplicationSession.java
Fri Aug 10 10:23:29 2012
@@ -1,6 +1,6 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and individual contributors
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
@@ -19,7 +19,6 @@
* 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.core.session;
import java.util.Set;
=======================================
---
/sip-servlets-core-api/src/main/java/org/mobicents/servlet/sip/core/session/MobicentsSipSession.java
Wed Oct 12 05:51:16 2011
+++
/sip-servlets-core-api/src/main/java/org/mobicents/servlet/sip/core/session/MobicentsSipSession.java
Fri Aug 10 10:23:29 2012
@@ -1,6 +1,6 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and individual contributors
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
@@ -19,7 +19,6 @@
* 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.core.session;
import java.io.Serializable;
=======================================
---
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/SipApplicationSessionImpl.java
Fri Jul 27 05:50:42 2012
+++
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/SipApplicationSessionImpl.java
Fri Aug 10 10:23:29 2012
@@ -1,6 +1,6 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and individual contributors
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
@@ -19,7 +19,6 @@
* 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.core.session;
import java.io.IOException;
=======================================
---
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/MobicentsSipApplicationSessionFacade.java
Tue Oct 4 20:25:16 2011
+++
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/MobicentsSipApplicationSessionFacade.java
Fri Aug 10 10:23:29 2012
@@ -1,6 +1,6 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and individual contributors
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
@@ -19,7 +19,6 @@
* 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.message;
import java.io.Externalizable;
=======================================
---
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipFactoryImpl.java
Thu Aug 2 12:54:24 2012
+++
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipFactoryImpl.java
Fri Aug 10 10:23:29 2012
@@ -1,6 +1,6 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and individual contributors
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
@@ -367,10 +367,10 @@
}
final SipServletRequestImpl origRequestImpl = (SipServletRequestImpl)
origRequest;
- final MobicentsSipSession originalSession =
origRequestImpl.getSipSession();
- final MobicentsSipApplicationSession originalAppSession =
originalSession
- .getSipApplicationSession();
-
+ final MobicentsSipApplicationSession originalAppSession =
(MobicentsSipApplicationSession)
origRequestImpl.getApplicationSession(false);
+ if (originalAppSession == null) {
+ throw new IllegalStateException("original request's app session does
not exists");
+ }
final Request newRequest = (Request)
origRequestImpl.message.clone();
((MessageExt)newRequest).setApplicationData(null);
@@ -453,11 +453,16 @@
}
}
-
newFromHeader.setTag(ApplicationRoutingHeaderComposer.getHash(getSipApplicationDispatcher(),
originalSession.getKey().getApplicationName(),
originalAppSession.getKey().getId()));
+
newFromHeader.setTag(ApplicationRoutingHeaderComposer.getHash(getSipApplicationDispatcher(),
originalAppSession.getKey().getApplicationName(),
originalAppSession.getKey().getId()));
- final MobicentsSipSessionKey key =
SessionManagerUtil.getSipSessionKey(originalAppSession.getKey().getId(),
originalSession.getKey().getApplicationName(), newRequest, false);
+ final MobicentsSipSessionKey key =
SessionManagerUtil.getSipSessionKey(originalAppSession.getKey().getId(),
originalAppSession.getKey().getApplicationName(), newRequest, false);
final MobicentsSipSession session =
originalAppSession.getSipContext().getSipManager().getSipSession(key, true,
this, originalAppSession);
- session.setHandler(originalSession.getHandler());
+ final MobicentsSipSession originalSession =
origRequestImpl.getSipSession();
+ if(originalSession != null) {
+
session.setHandler(originalSession.getHandler());
+ } else if(originalAppSession.getCurrentRequestHandler()
!= null) {
+
session.setHandler(originalAppSession.getCurrentRequestHandler());
+ }
final SipServletRequestImpl newSipServletRequest =
(SipServletRequestImpl)
mobicentsSipServletMessageFactory.createSipServletRequest(
newRequest,
=======================================
---
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletMessageImpl.java
Wed May 23 12:37:19 2012
+++
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletMessageImpl.java
Fri Aug 10 10:23:29 2012
@@ -1,6 +1,6 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and individual contributors
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
@@ -19,7 +19,6 @@
* 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.message;
import gov.nist.javax.sip.header.HeaderExt;
=======================================
---
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletRequestImpl.java
Mon Jul 30 15:04:45 2012
+++
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/message/SipServletRequestImpl.java
Fri Aug 10 10:23:29 2012
@@ -1,6 +1,6 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and individual contributors
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
@@ -19,7 +19,6 @@
* 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.message;
import gov.nist.javax.sip.DialogExt;
=======================================
---
/sip-servlets-test-suite/applications/call-forwarding-b2bua-servlet/src/main/java/org/mobicents/servlet/sip/testsuite/b2bua/CallForwardingB2BUASipServlet.java
Mon Feb 20 01:34:14 2012
+++
/sip-servlets-test-suite/applications/call-forwarding-b2bua-servlet/src/main/java/org/mobicents/servlet/sip/testsuite/b2bua/CallForwardingB2BUASipServlet.java
Fri Aug 10 10:23:29 2012
@@ -1,6 +1,6 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and individual contributors
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
@@ -19,7 +19,6 @@
* 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.testsuite.b2bua;
import java.io.File;
@@ -85,6 +84,8 @@
new
String[]{"sip:[email protected]", "sip:forward-receiver-forking-pending@"
+ System.getProperty("org.mobicents.testsuite.testhostaddr") + ":5070"});
forwardingUris.put("sip:[email protected]",
new
String[]{"sip:[email protected]", "sip:forward-receiver-factory-same-callID@"
+ System.getProperty("org.mobicents.testsuite.testhostaddr") + ":5090"});
+
forwardingUris.put("sip:forward-sender-factory-same-callid-kill-original-sess...@sip-servlets.com",
+ new
String[]{"sip:forward-receiver-factory-same-callid-kill-original-sess...@sip-servlets.com", "sip:forward-receiver-factory-same-callI-kill-original-sessionD@"
+ System.getProperty("org.mobicents.testsuite.testhostaddr") + ":5090"});
forwardingUris.put("sip:[email protected]",
new
String[]{"sip:[email protected]", "sip:forward-receiver@" +
System.getProperty("org.mobicents.testsuite.testhostaddr") + ":5090"});
forwardingUris.put("sip:[email protected]",
@@ -346,6 +347,10 @@
SipApplicationSession appSession = origReq.getApplicationSession();
SipServletRequest newRequest = null;
if(((SipURI)origReq.getFrom().getURI()).getUser().contains("same-callID")) {
+
if(((SipURI)origReq.getFrom().getURI()).getUser().contains("kill-original-session"))
{
+
origReq.createResponse(SipServletResponse.SC_BUSY_HERE).send();
+ origReq.getSession().invalidate();
+ }
newRequest = sipFactory.createRequest(origReq, true);
newRequest.setRequestURI(to);
} else {
@@ -355,11 +360,15 @@
newRequest.setContent(origReq.getContent(),
origReq.getContentType());
}
newRequest.setHeader("Allow", "INVITE, ACK, CANCEL, BYE, REFER,
UPDATE, INFO");
- b2buaHelper.linkSipSessions(origReq.getSession(),
newRequest.getSession()); //Linking sessions!
- origReq.getSession().setAttribute("originalRequest", origReq);
- logger.info("forkedRequest = " + newRequest);
- newRequest.getSession().setAttribute("originalRequest", origReq);
- newRequest.getB2buaHelper().linkSipSessions(origReq.getSession(),
newRequest.getSession()); //Linking sessions!
+
if(!((SipURI)origReq.getFrom().getURI()).getUser().contains("kill-original-session"))
{
+ b2buaHelper.linkSipSessions(origReq.getSession(),
newRequest.getSession()); //Linking sessions!
+ origReq.getSession().setAttribute("originalRequest", origReq);
+ }
+ logger.info("forkedRequest = " + newRequest);
+
if(!((SipURI)origReq.getFrom().getURI()).getUser().contains("kill-original-session"))
{
+ newRequest.getSession().setAttribute("originalRequest",
origReq);
+ newRequest.getB2buaHelper().linkSipSessions(origReq.getSession(),
newRequest.getSession()); //Linking sessions!
+ }
outgoingSession = newRequest.getSession();
if(origReq.getFrom().getURI().toString().contains("myself")) {
@@ -491,6 +500,13 @@
SipSession originalSession =
sipServletResponse.getRequest().getB2buaHelper().getLinkedSession(sipServletResponse.getSession());
+
if(((SipURI)sipServletResponse.getFrom().getURI()).getUser().contains("same-callID-kill-original-session"))
{
+
sipServletResponse.getSession().setAttribute(ACT_AS_UAS, true);
+ SipServletRequest ackRequest =
sipServletResponse.createAck();
+ logger.info("Sending " + ackRequest);
+ ackRequest.send();
+ }
+
if(sipServletResponse.getApplicationSession().getAttribute(TEST_USE_LINKED_REQUEST) !=
null) {
if(getServletContext().getInitParameter("checkOriginalRequestMapSize") !=
null && ((B2buaHelperImpl)b2buaHelper).getOriginalRequestMap().size() != 2
&& cSeqValue.indexOf("INVITE") != -1) {
logger.error("originalRequestMap size is wrong " +
((B2buaHelperImpl)b2buaHelper).getOriginalRequestMap().size());
=======================================
---
/sip-servlets-test-suite/testsuite/src/test/java/org/mobicents/servlet/sip/testsuite/callcontroller/CallForwardingB2BUAJunitTest.java
Thu Sep 8 02:20:56 2011
+++
/sip-servlets-test-suite/testsuite/src/test/java/org/mobicents/servlet/sip/testsuite/callcontroller/CallForwardingB2BUAJunitTest.java
Fri Aug 10 10:23:29 2012
@@ -1,6 +1,6 @@
/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and individual contributors
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
@@ -19,7 +19,6 @@
* 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.testsuite.callcontroller;
import gov.nist.javax.sip.message.MessageExt;
@@ -253,6 +252,47 @@
assertTrue(sender.getAllMessagesContent().contains("sipApplicationSessionReadyToBeInvalidated"));
assertEquals(((MessageExt)sender.getInviteRequest()).getCallIdHeader().getCallId(),
((MessageExt)receiver.getInviteRequest()).getCallIdHeader().getCallId());
}
+
+ // Non regression test for
http://code.google.com/p/sipservlets/issues/detail?id=126
+ public void
testCallForwardingCallerSendByeUseSameCallIDOriginalSessionTerminated()
throws Exception {
+ sender = new TestSipListener(5080, 5070, senderProtocolObjects,
false);
+ SipProvider senderProvider = sender.createProvider();
+
+ receiver = new TestSipListener(5090, 5070, receiverProtocolObjects,
true);
+ SipProvider receiverProvider = receiver.createProvider();
+
+ receiverProvider.addSipListener(receiver);
+ senderProvider.addSipListener(sender);
+
+ senderProtocolObjects.start();
+ receiverProtocolObjects.start();
+
+ String fromName
= "forward-sender-factory-same-callID-kill-original-session";
+ String fromSipAddress = "sip-servlets.com";
+ SipURI fromAddress =
senderProtocolObjects.addressFactory.createSipURI(
+ fromName, fromSipAddress);
+
+ String toSipAddress = "sip-servlets.com";
+ String toUser = "receiver";
+ SipURI toAddress =
senderProtocolObjects.addressFactory.createSipURI(
+ toUser, toSipAddress);
+
+ //receiver.setTimeToWaitBeforeBye(TIMEOUT*2);
+ sender.sendSipRequest("INVITE", fromAddress, toAddress, null, null,
false);
+ Thread.sleep(TIMEOUT);
+ assertTrue(receiver.isAckReceived());
+ Thread.sleep(TIMEOUT*2);
+ assertTrue(receiver.getOkToByeReceived());
+
+ Iterator<String> allMessagesIterator =
sender.getAllMessagesContent().iterator();
+ while (allMessagesIterator.hasNext()) {
+ String message = (String) allMessagesIterator.next();
+ logger.info(message);
+ }
+ assertEquals(1, sender.getAllMessagesContent().size());
+
assertTrue(sender.getAllMessagesContent().contains("sipApplicationSessionReadyToBeInvalidated"));
+
assertEquals(((MessageExt)sender.getInviteRequest()).getCallIdHeader().getCallId(),
((MessageExt)receiver.getInviteRequest()).getCallIdHeader().getCallId());
+ }
public void testCallForwardingCalleeSendBye() throws Exception {
sender = new TestSipListener(5080, 5070, senderProtocolObjects,
false);