master moved from 08cba7998a83 to 3966450cbecf

2 new revisions:

Revision: 6cf4aa67ba9f
Author:   Jean Deruelle <[email protected]>
Date:     Fri Apr 18 16:48:28 2014 UTC
Log:      Update Issue 253...
http://code.google.com/p/sipservlets/source/detail?r=6cf4aa67ba9f

Revision: 3966450cbecf
Author:   Jean Deruelle <[email protected]>
Date:     Fri Apr 18 21:47:52 2014 UTC
Log:      Update Issue 253...
http://code.google.com/p/sipservlets/source/detail?r=3966450cbecf

==============================================================================
Revision: 6cf4aa67ba9f
Author:   Jean Deruelle <[email protected]>
Date:     Fri Apr 18 16:48:28 2014 UTC
Log:      Update Issue 253
Update Issue 33

Fix + non regression test

(cherry picked from commit b42eefcee0f056474bc4a4b78a25261b2beae481)
(cherry picked from commit 9d79a49d2af4306a3275b88e124e7d80caebff88)

http://code.google.com/p/sipservlets/source/detail?r=6cf4aa67ba9f

Modified:
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/proxy/ProxyBranchImpl.java /sip-servlets-test-suite/applications/proxy-sip-servlet/src/main/java/org/mobicents/servlet/sip/testsuite/ProxySipServlet.java /sip-servlets-test-suite/testsuite/src/test/java/org/mobicents/servlet/sip/testsuite/TestSipListener.java /sip-servlets-test-suite/testsuite/src/test/java/org/mobicents/servlet/sip/testsuite/proxy/ProxyPrackTest.java

=======================================
--- /sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/proxy/ProxyBranchImpl.java Fri Sep 27 08:36:27 2013 UTC +++ /sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/proxy/ProxyBranchImpl.java Fri Apr 18 16:48:28 2014 UTC
@@ -184,12 +184,21 @@
                try {
                        cancelTimer();
                        if(this.isStarted() && !canceled && !timedOut &&
-                                       
outgoingRequest.getMethod().equalsIgnoreCase(Request.INVITE)) {
+                                       
(outgoingRequest.getMethod().equalsIgnoreCase(Request.INVITE) ||
+                                                       // 
https://code.google.com/p/sipservlets/issues/detail?id=253
+                                                       
outgoingRequest.getMethod().equalsIgnoreCase(Request.PRACK))) {
if(lastResponse != null) { /* According to SIP RFC we should send cancel only if we receive any response first*/
                                        if(logger.isDebugEnabled()) {
logger.debug("Trying to cancel PorxyBranch for outgoing request " + outgoingRequest);
                                        }
-                                       SipServletRequest cancelRequest = 
outgoingRequest.createCancel();
+                                       SipServletRequest cancelRequest = null;
+                                       
if(outgoingRequest.getMethod().equalsIgnoreCase(Request.PRACK)) {
+ // https://code.google.com/p/sipservlets/issues/detail?id=253 in case of PRACK we need to take the original INVITE
+                                               cancelRequest = 
originalRequest.getLinkedRequest().createCancel();
+                                       } else {
+                                               cancelRequest = 
outgoingRequest.createCancel();
+                                       }
+
                                        //Adding reason headers if needed
                                        if(protocol != null && reasonCode != null 
&& reasonText != null
&& protocol.length == reasonCode.length && reasonCode.length == reasonText.length) {
@@ -222,7 +231,9 @@
                                canceled = true;
                        }
                        if(!this.isStarted() &&
-                                       
outgoingRequest.getMethod().equalsIgnoreCase(Request.INVITE)) {
+                                       
(outgoingRequest.getMethod().equalsIgnoreCase(Request.INVITE) ||
+                                                       // 
https://code.google.com/p/sipservlets/issues/detail?id=253
+                                                       
outgoingRequest.getMethod().equalsIgnoreCase(Request.PRACK))) {
                                canceled = true;
                        }
                }
@@ -758,7 +769,7 @@
         */
        public void proxyDialogStateless(SipServletRequestImpl request) {
                if(logger.isDebugEnabled()) {
-                       logger.debug("Proxying request dialog-statelessly" + 
request);
+                       logger.debug("Proxying request dialog-statelessly " + 
request);
                }
                final SipFactoryImpl sipFactoryImpl = proxy.getSipFactoryImpl();
final SipApplicationDispatcher sipApplicationDispatcher = sipFactoryImpl.getSipApplicationDispatcher();
=======================================
--- /sip-servlets-test-suite/applications/proxy-sip-servlet/src/main/java/org/mobicents/servlet/sip/testsuite/ProxySipServlet.java Tue Mar 11 18:46:24 2014 UTC +++ /sip-servlets-test-suite/applications/proxy-sip-servlet/src/main/java/org/mobicents/servlet/sip/testsuite/ProxySipServlet.java Fri Apr 18 16:48:28 2014 UTC
@@ -348,7 +348,7 @@
                                logger.info("doInvite: uri = " + uri);
                                proxy.setParallel(false);
                        }
-                       if (from.contains("update")){
+                       if (from.contains("update") || from.contains("prack")){
                                proxy.setProxyTimeout(40);
                        } else {
                                proxy.setProxyTimeout(4);
=======================================
--- /sip-servlets-test-suite/testsuite/src/test/java/org/mobicents/servlet/sip/testsuite/TestSipListener.java Fri Apr 18 10:10:51 2014 UTC +++ /sip-servlets-test-suite/testsuite/src/test/java/org/mobicents/servlet/sip/testsuite/TestSipListener.java Fri Apr 18 16:48:28 2014 UTC
@@ -518,8 +518,11 @@
                                return;
                        }

-                       if(!sendUpdateAfterUpdate)
+                       if(!sendUpdateAfterUpdate && !waitForCancel)
                                
inviteServerTid.sendResponse(getFinalResponse());
+                       else {
+ logger.info("sendUpdateAfterUpdate or Waiting for CANCEL, stopping the PRACK processing and not sending 200 OK to INVITE");
+                       }
                } catch(Exception e) {
logger.error("Unexpected exception while trying to send the 200 to PRACK " + request, e);
                }
=======================================
--- /sip-servlets-test-suite/testsuite/src/test/java/org/mobicents/servlet/sip/testsuite/proxy/ProxyPrackTest.java Tue Sep 11 21:29:10 2012 UTC +++ /sip-servlets-test-suite/testsuite/src/test/java/org/mobicents/servlet/sip/testsuite/proxy/ProxyPrackTest.java Fri Apr 18 16:48:28 2014 UTC
@@ -1,99 +1,143 @@
 /*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2014, 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
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
  * the License, or (at your option) any later version.
  *
- * This software is distributed in the hope that it will be useful,
+ * This program 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.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero 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.
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>
  */

 package org.mobicents.servlet.sip.testsuite.proxy;

-import java.util.EventObject;
-import java.util.Hashtable;
-
-import javax.sip.DialogTerminatedEvent;
-import javax.sip.IOExceptionEvent;
-import javax.sip.RequestEvent;
-import javax.sip.ResponseEvent;
-import javax.sip.SipListener;
+import javax.sip.ListeningPoint;
 import javax.sip.SipProvider;
-import javax.sip.TimeoutEvent;
-import javax.sip.TransactionTerminatedEvent;
+import javax.sip.address.SipURI;

 import org.apache.log4j.Logger;
 import org.mobicents.servlet.sip.SipServletTestCase;
+import org.mobicents.servlet.sip.testsuite.ProtocolObjects;
+import org.mobicents.servlet.sip.testsuite.TestSipListener;

-public class ProxyPrackTest extends SipServletTestCase implements SipListener {
+public class ProxyPrackTest extends SipServletTestCase {

private static transient Logger logger = Logger.getLogger(ProxyPrackTest.class);

-       protected Shootist shootist;
+       private static final String SESSION_EXPIRED = "sessionExpired";
+ private static final String SESSION_READY_TO_INVALIDATE = "sessionReadyToInvalidate"; + private static final String SIP_SESSION_READY_TO_INVALIDATE = "sipSessionReadyToInvalidate";
+       private static final boolean AUTODIALOG = true;
+       TestSipListener sender;
+       TestSipListener neutral;
+       TestSipListener receiver;
+       ProtocolObjects senderProtocolObjects;
+       ProtocolObjects receiverProtocolObjects;
+       ProtocolObjects neutralProto;

-       protected Shootme shootme;
-
-       protected Cutme cutme;
-
-       protected Hashtable providerTable = new Hashtable();

        private static final int TIMEOUT = 20000;

-       private static final int receiversCount = 1;
-
        public ProxyPrackTest(String name) {
                super(name);
-               this.sipIpAddress = "0.0.0.0";
+               autoDeployOnStartup = false;
        }

        @Override
        public void setUp() throws Exception {
                super.setUp();
-               this.shootist = new Shootist(false, null);
-               this.shootist.usePrack = true;
-               this.shootme = new Shootme(5057);
-               this.shootme.usePrack = true;
-               this.cutme = new Cutme();
+               senderProtocolObjects = new ProtocolObjects("proxy-sender",
+                               "gov.nist", ListeningPoint.UDP, AUTODIALOG, 
null, null, null);
+               receiverProtocolObjects = new ProtocolObjects("proxy-receiver",
+                               "gov.nist", ListeningPoint.UDP, AUTODIALOG, 
null, null, null);
+               neutralProto = new ProtocolObjects("neutral",
+                               "gov.nist", ListeningPoint.UDP, AUTODIALOG, 
null, null, null);
+               sender = new TestSipListener(5080, 5070, senderProtocolObjects, 
false);
+               sender.setRecordRoutingProxyTesting(true);
+               SipProvider senderProvider = sender.createProvider();
+
+ receiver = new TestSipListener(5057, 5070, receiverProtocolObjects, false);
+               receiver.setRecordRoutingProxyTesting(true);
+               SipProvider receiverProvider = receiver.createProvider();
+
+               neutral = new TestSipListener(5058, 5070, neutralProto, false);
+               neutral.setRecordRoutingProxyTesting(true);
+               SipProvider neutralProvider = neutral.createProvider();
+
+               receiverProvider.addSipListener(receiver);
+               senderProvider.addSipListener(sender);
+               neutralProvider.addSipListener(neutral);
+
+               senderProtocolObjects.start();
+               receiverProtocolObjects.start();
+               neutralProto.start();
        }

-       public void testPrackProxying() {
-               this.shootme.init("stackName", null);
-//             this.cutme.init(null);
-               this.shootist.init("prack-useHostName",false, null);
-               for (int q = 0; q < 20; q++) {
-                       if (shootist.ended == false && cutme.canceled == false)
-                               try {
-                                       Thread.sleep(TIMEOUT);
-                               } catch (InterruptedException e) {
-                                       // TODO Auto-generated catch block
-                                       e.printStackTrace();
-                               }
-               }
-               if (!shootist.ended)
-                       fail("Conversation not complete!");
-               if (!shootist.prackOkReceived)
-                       fail("No OK to PRACK received");
-               if (!shootist.okToInviteRecevied)
-                       fail("No OK to INVITE received");
+       public void testPrackProxying() throws Exception {
+               deployApplication();
+               String fromName = "prack-useHostName";
+               String fromSipAddress = "sip-servlets.com";
+               SipURI fromAddress = 
senderProtocolObjects.addressFactory.createSipURI(
+                               fromName, fromSipAddress);
+
+               String toSipAddress = "sip-servlets.com";
+               String toUser = "proxy-receiver";
+               SipURI toAddress = 
senderProtocolObjects.addressFactory.createSipURI(
+                               toUser, toSipAddress);
+
+               String[] headerNames = new String[]{"require"};
+               String[] headerValues = new String[]{"100rel"};
+ sender.sendSipRequest("INVITE", fromAddress, toAddress, null, null, false, headerNames, headerValues, true);
+               Thread.sleep(TIMEOUT);
+               assertEquals(200,sender.getFinalResponseStatus());
+               assertTrue(sender.isOkToPrackReceived());
+               assertTrue(sender.isAckSent());
+               sender.sendBye();
+               Thread.sleep(TIMEOUT);
+               assertTrue(receiver.getByeReceived());
+               assertTrue(sender.getOkToByeReceived());
+       }
+
+       /*
+ * Non Regression test for https://code.google.com/p/sipservlets/issues/detail?id=253
+        */
+       public void testCancelPrackProxying() throws Exception {
+               deployApplication();
+               String fromName = "prack-useHostName";
+               String fromSipAddress = "sip-servlets.com";
+               SipURI fromAddress = 
senderProtocolObjects.addressFactory.createSipURI(
+                               fromName, fromSipAddress);
+
+               String toSipAddress = "sip-servlets.com";
+               String toUser = "proxy-receiver";
+               SipURI toAddress = 
senderProtocolObjects.addressFactory.createSipURI(
+                               toUser, toSipAddress);
+
+               receiver.setWaitForCancel(true);
+               String[] headerNames = new String[]{"require"};
+               String[] headerValues = new String[]{"100rel"};
+ sender.sendSipRequest("INVITE", fromAddress, toAddress, null, null, false, headerNames, headerValues, true);
+               Thread.sleep(TIMEOUT);
+               sender.sendCancel();
+               Thread.sleep(TIMEOUT);
+               assertEquals(487,sender.getFinalResponseStatus());
+
        }

        @Override
        public void tearDown() throws Exception {
-               shootist.destroy();
-               shootme.destroy();
-               //cutme.destroy();
+               senderProtocolObjects.destroy();
+               receiverProtocolObjects.destroy();
+               neutralProto.destroy();
+               logger.info("Test completed");
                super.tearDown();
        }

@@ -113,49 +157,4 @@
                                + 
"/sip-servlets-test-suite/testsuite/src/test/resources/"
+ "org/mobicents/servlet/sip/testsuite/proxy/simple-sip-servlet-dar.properties";
        }
-
-       public void init() {
-               // setupPhones();
-       }
-
-       private SipListener getSipListener(EventObject sipEvent) {
-               SipProvider source = (SipProvider) sipEvent.getSource();
-               SipListener listener = (SipListener) providerTable.get(source);
-               if (listener == null)
-                       throw new RuntimeException("Unexpected null listener");
-               return listener;
-       }
-
-       public void processRequest(RequestEvent requestEvent) {
-               getSipListener(requestEvent).processRequest(requestEvent);
-
-       }
-
-       public void processResponse(ResponseEvent responseEvent) {
-               getSipListener(responseEvent).processResponse(responseEvent);
-
-       }
-
-       public void processTimeout(TimeoutEvent timeoutEvent) {
-               getSipListener(timeoutEvent).processTimeout(timeoutEvent);
-       }
-
-       public void processIOException(IOExceptionEvent exceptionEvent) {
-               fail("unexpected exception");
-
-       }
-
-       public void processTransactionTerminated(
-                       TransactionTerminatedEvent transactionTerminatedEvent) {
-               getSipListener(transactionTerminatedEvent)
-                               
.processTransactionTerminated(transactionTerminatedEvent);
-
-       }
-
-       public void processDialogTerminated(
-                       DialogTerminatedEvent dialogTerminatedEvent) {
-               getSipListener(dialogTerminatedEvent).processDialogTerminated(
-                               dialogTerminatedEvent);
-
-       }
 }

==============================================================================
Revision: 3966450cbecf
Author:   Jean Deruelle <[email protected]>
Date:     Fri Apr 18 21:47:52 2014 UTC
Log:      Update Issue 253
Update Issue 33

adding UPDATE as well

(cherry picked from commit bd7611aaa9f16c62f71da23a09e909a5299324d7)

http://code.google.com/p/sipservlets/source/detail?r=3966450cbecf

Modified:
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/proxy/ProxyBranchImpl.java

=======================================
--- /sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/proxy/ProxyBranchImpl.java Fri Apr 18 16:48:28 2014 UTC +++ /sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/proxy/ProxyBranchImpl.java Fri Apr 18 21:47:52 2014 UTC
@@ -186,14 +186,17 @@
                        if(this.isStarted() && !canceled && !timedOut &&
                                        
(outgoingRequest.getMethod().equalsIgnoreCase(Request.INVITE) ||
                                                        // 
https://code.google.com/p/sipservlets/issues/detail?id=253
-                                                       
outgoingRequest.getMethod().equalsIgnoreCase(Request.PRACK))) {
+                                                       
outgoingRequest.getMethod().equalsIgnoreCase(Request.PRACK) ||
+                                                       // 
https://code.google.com/p/sipservlets/issues/detail?id=33
+                                                       
outgoingRequest.getMethod().equalsIgnoreCase(Request.UPDATE))) {
if(lastResponse != null) { /* According to SIP RFC we should send cancel only if we receive any response first*/
                                        if(logger.isDebugEnabled()) {
logger.debug("Trying to cancel PorxyBranch for outgoing request " + outgoingRequest);
                                        }
                                        SipServletRequest cancelRequest = null;
-                                       
if(outgoingRequest.getMethod().equalsIgnoreCase(Request.PRACK)) {
- // https://code.google.com/p/sipservlets/issues/detail?id=253 in case of PRACK we need to take the original INVITE + if(outgoingRequest.getMethod().equalsIgnoreCase(Request.PRACK) || outgoingRequest.getMethod().equalsIgnoreCase(Request.UPDATE)) { + // https://code.google.com/p/sipservlets/issues/detail?id=253 and https://code.google.com/p/sipservlets/issues/detail?id=33
+                                               // in case of PRACK or UPDATE 
we need to take the original INVITE
                                                cancelRequest = 
originalRequest.getLinkedRequest().createCancel();
                                        } else {
                                                cancelRequest = 
outgoingRequest.createCancel();

--

--- You received this message because you are subscribed to the Google Groups "mobicents-commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to