|
reSIProcate/DialogUsageManager
9694
|
00001 #include "resip/dum/RedirectManager.hxx" 00002 #include "rutil/Data.hxx" 00003 #include "rutil/Logger.hxx" 00004 00005 using namespace resip; 00006 00007 #define RESIPROCATE_SUBSYSTEM Subsystem::TEST 00008 00009 class testRedirectManager : public RedirectManager 00010 { 00011 public: 00012 testRedirectManager() {}; 00013 virtual ~testRedirectManager() {}; 00014 00015 void testContactOrdering() 00016 { 00017 Data origRequestTxt("INVITE sip:192.168.2.92:5100;q=1 SIP/2.0\r\n" 00018 "To: <sip:yiwen_AT_meet2talk.com@whistler.gloo.net>\r\n" 00019 "From: Jason Fischl<sip:jason_AT_meet2talk.com@whistler.gloo.net>;tag=ba1aee2d\r\n" 00020 "Via: SIP/2.0/UDP 192.168.2.220:5060;branch=z9hG4bK-c87542-da4d3e6a.0-1--c87542-;rport=5060;received=192.168.2.220;stid=579667358\r\n" 00021 "Via: SIP/2.0/UDP 192.168.2.15:5100;branch=z9hG4bK-c87542-579667358-1--c87542-;rport=5100;received=192.168.2.15\r\n" 00022 "Call-ID: 6c64b42fce01b007\r\n" 00023 "CSeq: 2 INVITE\r\n" 00024 "Route: <sip:proxy@192.168.2.220:5060;lr>\r\n" 00025 "Contact: <sip:192.168.2.15:5100>\r\n" 00026 "Content-Length: 0\r\n" 00027 "\r\n"); 00028 Data redirectResponseTxt( 00029 "SIP/2.0 302 Moved temporarily\r\n" 00030 "Via: SIP/2.0/UDP 10.10.0.14:15060;branch=z9hG4bK-524287-1---ca637f133a902b1f;rport\r\n" 00031 "Contact: <sip:4086484899@10.12.0.129:5060;transport=udp;user=phone>;q=0.5\r\n" 00032 "Contact: <sip:4086484899@10.12.0.130:5060;transport=udp;user=phone>;q=0.33\r\n" 00033 "Contact: <sip:4086484899@10.12.0.127:5060;transport=udp;user=phone>\r\n" 00034 "Contact: <sip:4086484899@10.12.0.131:5060;transport=udp;user=phone>;q=0.17\r\n" 00035 "Contact: <sip:4086484899@10.12.0.128:5060;transport=udp;user=phone>;q=1.0\r\n" 00036 "To: <sip:4086484899@10.11.0.20>;tag=722127811-1255463299834\r\n" 00037 "From: <sip:4086484890@10.10.0.14:15060;user=phone>;tag=7fd85658\r\n" 00038 "Call-ID: NjQ3MTc4OTdlMjE2NmYyYWY2OGQzNDBlMzhmMjBmMGQ.\r\n" 00039 "CSeq: 1 INVITE\r\n" 00040 "Content-Length: 0\r\n" 00041 "\r\n" 00042 ); 00043 SipMessage* origrequest = SipMessage::make(origRequestTxt, false); 00044 SipMessage* redirect = SipMessage::make(redirectResponseTxt, false); 00045 if(origrequest && redirect) 00046 { 00047 TargetSet ts(*origrequest, mOrdering); 00048 ts.addTargets(*redirect); 00049 SipMessage request; 00050 bool result; 00051 result = ts.makeNextRequest(request); 00052 assert(result); 00053 InfoLog(<< "Next Request: " << request); 00054 assert(request.header(h_RequestLine).uri().host() == "10.12.0.127"); 00055 result = ts.makeNextRequest(request); 00056 assert(result); 00057 InfoLog(<< "Next Request: " << request); 00058 assert(request.header(h_RequestLine).uri().host() == "10.12.0.128"); 00059 result = ts.makeNextRequest(request); 00060 assert(result); 00061 InfoLog(<< "Next Request: " << request); 00062 assert(request.header(h_RequestLine).uri().host() == "10.12.0.129"); 00063 result = ts.makeNextRequest(request); 00064 assert(result); 00065 InfoLog(<< "Next Request: " << request); 00066 assert(request.header(h_RequestLine).uri().host() == "10.12.0.130"); 00067 result = ts.makeNextRequest(request); 00068 assert(result); 00069 InfoLog(<< "Next Request: " << request); 00070 assert(request.header(h_RequestLine).uri().host() == "10.12.0.131"); 00071 } 00072 } 00073 }; 00074 00075 int 00076 main (int argc, char** argv) 00077 { 00078 testRedirectManager redirectManager; 00079 00080 redirectManager.testContactOrdering(); 00081 } 00082 00083 /* ==================================================================== 00084 * The Vovida Software License, Version 1.0 00085 * 00086 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00087 * 00088 * Redistribution and use in source and binary forms, with or without 00089 * modification, are permitted provided that the following conditions 00090 * are met: 00091 * 00092 * 1. Redistributions of source code must retain the above copyright 00093 * notice, this list of conditions and the following disclaimer. 00094 * 00095 * 2. Redistributions in binary form must reproduce the above copyright 00096 * notice, this list of conditions and the following disclaimer in 00097 * the documentation and/or other materials provided with the 00098 * distribution. 00099 * 00100 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00101 * and "Vovida Open Communication Application Library (VOCAL)" must 00102 * not be used to endorse or promote products derived from this 00103 * software without prior written permission. For written 00104 * permission, please contact vocal@vovida.org. 00105 * 00106 * 4. Products derived from this software may not be called "VOCAL", nor 00107 * may "VOCAL" appear in their name, without prior written 00108 * permission of Vovida Networks, Inc. 00109 * 00110 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00111 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00112 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00113 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00114 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00115 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00116 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00117 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00118 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00119 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00120 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00121 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00122 * DAMAGE. 00123 * 00124 * ==================================================================== 00125 * 00126 * This software consists of voluntary contributions made by Vovida 00127 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00128 * Inc. For more information on Vovida Networks, Inc., please see 00129 * <http://www.vovida.org/>. 00130 * 00131 */
1.7.5.1