/[resiprocate]/main/resip/dum/test/testRedirectManager.cxx
ViewVC logotype

Contents of /main/resip/dum/test/testRedirectManager.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8625 - (show annotations) (download)
Wed Oct 14 13:58:10 2009 UTC (10 years, 1 month ago) by sgodin
File size: 5964 byte(s)
-fixed RedirectManager Q-Value ordering function - it was looking for q-value as a uri parameter - also changed to treat no q-value as q=1.0
-modification to repro so that contacts without a q-value are treated as having q=1.0
-removed unused Q value compare fn in ResponseContext
-removed incorrect Q value compare fn in Uri class - q-value is a contact/name-addr parameter, not a uri parameter 
-added a test driver for RedirectManager Q-Value ordering
-cleaned up windows makefile for stack tests
1 #include "resip/dum/RedirectManager.hxx"
2 #include "rutil/Data.hxx"
3 #include "rutil/Logger.hxx"
4
5 using namespace resip;
6
7 #define RESIPROCATE_SUBSYSTEM Subsystem::TEST
8
9 class testRedirectManager : public RedirectManager
10 {
11 public:
12 testRedirectManager() {};
13 virtual ~testRedirectManager() {};
14
15 void testContactOrdering()
16 {
17 Data origRequestTxt("INVITE sip:192.168.2.92:5100;q=1 SIP/2.0\r\n"
18 "To: <sip:yiwen_AT_meet2talk.com@whistler.gloo.net>\r\n"
19 "From: Jason Fischl<sip:jason_AT_meet2talk.com@whistler.gloo.net>;tag=ba1aee2d\r\n"
20 "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"
21 "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"
22 "Call-ID: 6c64b42fce01b007\r\n"
23 "CSeq: 2 INVITE\r\n"
24 "Route: <sip:proxy@192.168.2.220:5060;lr>\r\n"
25 "Contact: <sip:192.168.2.15:5100>\r\n"
26 "Content-Length: 0\r\n"
27 "\r\n");
28 Data redirectResponseTxt(
29 "SIP/2.0 302 Moved temporarily\r\n"
30 "Via: SIP/2.0/UDP 10.10.0.14:15060;branch=z9hG4bK-d8754z-ca637f133a902b1f-1---d8754z-;rport\r\n"
31 "Contact: <sip:4086484899@10.12.0.129:5060;transport=udp;user=phone>;q=0.5\r\n"
32 "Contact: <sip:4086484899@10.12.0.130:5060;transport=udp;user=phone>;q=0.33\r\n"
33 "Contact: <sip:4086484899@10.12.0.127:5060;transport=udp;user=phone>\r\n"
34 "Contact: <sip:4086484899@10.12.0.131:5060;transport=udp;user=phone>;q=0.17\r\n"
35 "Contact: <sip:4086484899@10.12.0.128:5060;transport=udp;user=phone>;q=1.0\r\n"
36 "To: <sip:4086484899@10.11.0.20>;tag=722127811-1255463299834\r\n"
37 "From: <sip:4086484890@10.10.0.14:15060;user=phone>;tag=7fd85658\r\n"
38 "Call-ID: NjQ3MTc4OTdlMjE2NmYyYWY2OGQzNDBlMzhmMjBmMGQ.\r\n"
39 "CSeq: 1 INVITE\r\n"
40 "Content-Length: 0\r\n"
41 "\r\n"
42 );
43 SipMessage* origrequest = SipMessage::make(origRequestTxt, false);
44 SipMessage* redirect = SipMessage::make(redirectResponseTxt, false);
45 if(origrequest && redirect)
46 {
47 TargetSet ts(*origrequest, mOrdering);
48 ts.addTargets(*redirect);
49 SipMessage request;
50 bool result;
51 result = ts.makeNextRequest(request);
52 assert(result);
53 InfoLog(<< "Next Request: " << request);
54 assert(request.header(h_RequestLine).uri().host() == "10.12.0.127");
55 result = ts.makeNextRequest(request);
56 assert(result);
57 InfoLog(<< "Next Request: " << request);
58 assert(request.header(h_RequestLine).uri().host() == "10.12.0.128");
59 result = ts.makeNextRequest(request);
60 assert(result);
61 InfoLog(<< "Next Request: " << request);
62 assert(request.header(h_RequestLine).uri().host() == "10.12.0.129");
63 result = ts.makeNextRequest(request);
64 assert(result);
65 InfoLog(<< "Next Request: " << request);
66 assert(request.header(h_RequestLine).uri().host() == "10.12.0.130");
67 result = ts.makeNextRequest(request);
68 assert(result);
69 InfoLog(<< "Next Request: " << request);
70 assert(request.header(h_RequestLine).uri().host() == "10.12.0.131");
71 }
72 }
73 };
74
75 int
76 main (int argc, char** argv)
77 {
78 testRedirectManager redirectManager;
79
80 redirectManager.testContactOrdering();
81 }
82
83 /* ====================================================================
84 * The Vovida Software License, Version 1.0
85 *
86 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
87 *
88 * Redistribution and use in source and binary forms, with or without
89 * modification, are permitted provided that the following conditions
90 * are met:
91 *
92 * 1. Redistributions of source code must retain the above copyright
93 * notice, this list of conditions and the following disclaimer.
94 *
95 * 2. Redistributions in binary form must reproduce the above copyright
96 * notice, this list of conditions and the following disclaimer in
97 * the documentation and/or other materials provided with the
98 * distribution.
99 *
100 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
101 * and "Vovida Open Communication Application Library (VOCAL)" must
102 * not be used to endorse or promote products derived from this
103 * software without prior written permission. For written
104 * permission, please contact vocal@vovida.org.
105 *
106 * 4. Products derived from this software may not be called "VOCAL", nor
107 * may "VOCAL" appear in their name, without prior written
108 * permission of Vovida Networks, Inc.
109 *
110 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
111 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
112 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
113 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
114 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
115 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
116 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
117 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
118 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
119 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
120 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
121 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
122 * DAMAGE.
123 *
124 * ====================================================================
125 *
126 * This software consists of voluntary contributions made by Vovida
127 * Networks, Inc. and many individuals on behalf of Vovida Networks,
128 * Inc. For more information on Vovida Networks, Inc., please see
129 * <http://www.vovida.org/>.
130 *
131 */

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27