Revision: f42bd1de59a0
Author:   Jean Deruelle <[email protected]>
Date:     Fri Aug 10 13:01:35 2012
Log:      Update Issue 143

Backport to TelScale branch

Committing Patch + Non Regression Test
(cherry picked from commit 34774e44122a4b1a36d7c6fb2e22392b8d58b8a6)

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

Modified:
/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/SipSessionImpl.java
 /sip-servlets-spec/src/main/java/javax/servlet/sip/SipServletResponse.java
/sip-servlets-test-suite/applications/shootist-sip-servlet/src/main/java/org/mobicents/servlet/sip/testsuite/ShootistSipServlet.java /sip-servlets-test-suite/testsuite/src/test/java/org/mobicents/servlet/sip/testsuite/simple/ShootistSipServletTest.java

=======================================
--- /sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/SipSessionImpl.java Mon Jul 30 15:04:45 2012 +++ /sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/session/SipSessionImpl.java Fri Aug 10 13:01:35 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 gov.nist.javax.sip.ServerTransactionExt;
@@ -393,7 +392,9 @@
if(sessionCreatingDialog != null && DialogState.TERMINATED.equals(sessionCreatingDialog.getState()) && !method.equalsIgnoreCase(Request.BYE)) { // don't do it for authentication as the dialog will go back to TERMINATED state, so we should allow to create challenge requests if(sessionCreatingTransactionRequest == null || sessionCreatingTransactionRequest.getLastFinalResponse() == null || - (sessionCreatingTransactionRequest.getLastFinalResponse().getStatus() != 401 && sessionCreatingTransactionRequest.getLastFinalResponse().getStatus() != 407)) { + (sessionCreatingTransactionRequest.getLastFinalResponse().getStatus() != 401 && sessionCreatingTransactionRequest.getLastFinalResponse().getStatus() != 407 && + // http://code.google.com/p/sipservlets/issues/detail?id=143 RFC 4028 Session Timer : Allow sending retry INVITE after receiving 422 response + sessionCreatingTransactionRequest.getLastFinalResponse().getStatus() != SipServletResponse.SC_SESSION_INTERVAL_TOO_SMALL)) { throw new IllegalStateException("cannot create a subsequent request " + method + " because the dialog " + sessionCreatingDialog + " for session " + key + " is in TERMINATED state");
                        }
                }
=======================================
--- /sip-servlets-spec/src/main/java/javax/servlet/sip/SipServletResponse.java Wed Sep 14 03:15:03 2011 +++ /sip-servlets-spec/src/main/java/javax/servlet/sip/SipServletResponse.java Fri Aug 10 13:01:35 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 javax.servlet.sip;

 import java.util.Iterator;
=======================================
--- /sip-servlets-test-suite/applications/shootist-sip-servlet/src/main/java/org/mobicents/servlet/sip/testsuite/ShootistSipServlet.java Thu Aug 2 12:54:24 2012 +++ /sip-servlets-test-suite/applications/shootist-sip-servlet/src/main/java/org/mobicents/servlet/sip/testsuite/ShootistSipServlet.java Fri Aug 10 13:01:35 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;

 import java.io.IOException;
@@ -254,6 +253,14 @@
sendMessage(sipFactory.createApplicationSession(), sipFactory, "408 received");
                                
sipServletResponse.getApplicationSession().invalidate();
                        }
+                       if(sipServletResponse.getStatus() == 422) {
+                               try {
+                                       Thread.sleep(10000);
+                               } catch (InterruptedException e) {
+                                       e.printStackTrace();
+                               }
+                               
sipServletResponse.getSession().createRequest("INVITE").send();
+                       }
                } finally {
                        release();
                }
=======================================
--- /sip-servlets-test-suite/testsuite/src/test/java/org/mobicents/servlet/sip/testsuite/simple/ShootistSipServletTest.java Thu Aug 2 12:54:24 2012 +++ /sip-servlets-test-suite/testsuite/src/test/java/org/mobicents/servlet/sip/testsuite/simple/ShootistSipServletTest.java Fri Aug 10 13:01:35 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,8 +19,8 @@
  * 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.simple;
+
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -831,6 +831,28 @@
assertTrue("sipAppSessionReadyToInvalidate", allMessagesContent.contains("sipAppSessionReadyToInvalidate"));
        }

+       // Tests Issue 143 
http://code.google.com/p/mobicents/issues/detail?id=143
+       public void testShootist422Response() throws Exception {
+               receiverProtocolObjects =new ProtocolObjects(
+                               "sender", "gov.nist", TRANSPORT, AUTODIALOG, 
null, null, null);
+
+ receiver = new TestSipListener(5080, 5070, receiverProtocolObjects, false);
+               receiver.setProvisionalResponsesToSend(new 
ArrayList<Integer>());
+               receiver.setFinalResponseToSend(422);
+               SipProvider senderProvider = receiver.createProvider();
+
+               senderProvider.addSipListener(receiver);
+
+               receiverProtocolObjects.start();
+               tomcat.startTomcat();
+               deployApplication("testErrorResponse", "true");
+               Thread.sleep(TIMEOUT);
+               receiver.setFinalResponseToSend(200);
+               Thread.sleep(TIMEOUT);
+               assertTrue(receiver.isAckReceived());
+       }
+
+
        // Test for SS spec 11.1.6 transaction timeout notification
// Test Issue 2580 http://code.google.com/p/mobicents/issues/detail?id=2580
        public void testTransactionTimeoutResponse() throws Exception {

Reply via email to