/[resiprocate]/main/resip/stack/test/testApplicationSip.cxx
ViewVC logotype

Contents of /main/resip/stack/test/testApplicationSip.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8161 - (show annotations) (download)
Fri Jul 25 20:54:42 2008 UTC (11 years, 3 months ago) by jmatthewsr
File MIME type: text/plain
File size: 6692 byte(s)
Stream performance enhancements for encoding objects.  New encoding code should use 'EncodeStream','resipCerr' and 'resipCout' for encoding any resip objects.  Merge from b-jmatthewsr-streamperf2 -r 8137:8160.  
1 #include "rutil/DataStream.hxx"
2
3 #include "resip/stack/SipMessage.hxx"
4 #include "resip/stack/Helper.hxx"
5 #include "resip/stack/Uri.hxx"
6 #include "resip/stack/ApplicationSip.hxx"
7 #include "TestSupport.hxx"
8
9 #include <iostream>
10 #include <memory>
11
12 using namespace resip;
13 using namespace std;
14
15 int
16 main()
17 {
18 {
19 Data txt("INVITE sip:bob@biloxi.com SIP/2.0\r\n"
20 "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\r\n"
21 "To: Bob <sip:bob@biloxi.com>\r\n"
22 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n"
23 "Call-ID: a84b4c76e66710\r\n"
24 "CSeq: 314159 INVITE\r\n"
25 "Max-Forwards: 70\r\n"
26 "Contact: <sip:alice@pc33.atlanta.com>\r\n"
27 "Content-Type: application/sip\r\n"
28 "Content-Length: 35\r\n"
29 "\r\n"
30 "INVITE sip:bob@biloxi.com SIP/2.0\r\n");
31
32 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt.c_str()));
33
34 Contents* body = msg->getContents();
35
36 assert(body != 0);
37 ApplicationSip* frag = dynamic_cast<ApplicationSip*>(body);
38 assert(frag != 0);
39
40 std::cerr << "!! ";
41 frag->encode(resipCerr);
42
43 assert(frag->message().header(h_RequestLine).uri().user() == "bob");
44 msg->encode(resipCerr);
45 }
46
47 {
48 Data txt("INVITE sip:bob@biloxi.com SIP/2.0\r\n"
49 "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\r\n"
50 "To: Bob <sip:bob@biloxi.com>\r\n"
51 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n"
52 "Call-ID: a84b4c76e66710\r\n"
53 "CSeq: 314159 INVITE\r\n"
54 "Max-Forwards: 70\r\n"
55 "Contact: <sip:alice@pc33.atlanta.com>\r\n"
56 "Content-Type: application/sip\r\n"
57 "\r\n"
58 "INVITE sip:bob@biloxi.com SIP/2.0\r\n"
59 "From: Alice <sip:alice@atlanta.com>\r\n"
60 "To: Bob <sip:bob@biloxi.com>\r\n"
61 "Contact: <sip:alice@pc33.atlanta.com>\r\n"
62 "Date: Thu, 21 Feb 2002 13:02:03 GMT\r\n"
63 "Call-ID: a84b4c76e66710\r\n"
64 "Cseq: 314159 INVITE\r\n\r\n");
65
66 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt.c_str()));
67
68 Contents* body = msg->getContents();
69
70 assert(body != 0);
71 ApplicationSip* frag = dynamic_cast<ApplicationSip*>(body);
72 assert(frag != 0);
73
74 std::cerr << "!! ";
75 frag->encode(resipCerr);
76
77 assert(frag->message().exists(h_From));
78 assert(frag->message().header(h_From).uri().user() == "alice");
79
80 assert(frag->message().exists(h_CSeq));
81 assert(frag->message().header(h_CSeq).sequence() == 314159);
82
83 msg->encode(resipCerr);
84 }
85
86 // backward compatibiltiy with SipFrag
87 {
88 Data txt("INVITE sip:bob@biloxi.com SIP/2.0\r\n"
89 "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\r\n"
90 "To: Bob <sip:bob@biloxi.com>\r\n"
91 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n"
92 "Call-ID: a84b4c76e66710\r\n"
93 "CSeq: 314159 INVITE\r\n"
94 "Max-Forwards: 70\r\n"
95 "Contact: <sip:alice@pc33.atlanta.com>\r\n"
96 "Content-Type: application/sip\r\n"
97 "\r\n"
98 "INVITE sip:bob@biloxi.com SIP/2.0\r\n"
99 "From: Alice <sip:alice@atlanta.com>\r\n"
100 "To: Bob <sip:bob@biloxi.com>\r\n"
101 "Contact: <sip:alice@pc33.atlanta.com>\r\n"
102 "Date: Thu, 21 Feb 2002 13:02:03 GMT\r\n"
103 "Call-ID: a84b4c76e66710\r\n"
104 "Cseq: 314159 INVITE\r\n\r\n");
105
106 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt.c_str()));
107
108 Contents* body = msg->getContents();
109
110 assert(body != 0);
111 SipFrag* frag = dynamic_cast<SipFrag*>(body);
112 assert(frag != 0);
113
114 std::cerr << "!! ";
115 frag->encode(resipCerr);
116
117 assert(frag->message().exists(h_From));
118 assert(frag->message().header(h_From).uri().user() == "alice");
119
120 assert(frag->message().exists(h_CSeq));
121 assert(frag->message().header(h_CSeq).sequence() == 314159);
122
123 msg->encode(resipCerr);
124 }
125
126 cerr << "\nTEST OK" << endl;
127
128 return 0;
129 }
130
131 /* ====================================================================
132 * The Vovida Software License, Version 1.0
133 *
134 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
135 *
136 * Redistribution and use in source and binary forms, with or without
137 * modification, are permitted provided that the following conditions
138 * are met:
139 *
140 * 1. Redistributions of source code must retain the above copyright
141 * notice, this list of conditions and the following disclaimer.
142 *
143 * 2. Redistributions in binary form must reproduce the above copyright
144 * notice, this list of conditions and the following disclaimer in
145 * the documentation and/or other materials provided with the
146 * distribution.
147 *
148 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
149 * and "Vovida Open Communication Application Library (VOCAL)" must
150 * not be used to endorse or promote products derived from this
151 * software without prior written permission. For written
152 * permission, please contact vocal@vovida.org.
153 *
154 * 4. Products derived from this software may not be called "VOCAL", nor
155 * may "VOCAL" appear in their name, without prior written
156 * permission of Vovida Networks, Inc.
157 *
158 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
159 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
160 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
161 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
162 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
163 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
164 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
165 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
166 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
167 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
168 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
169 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
170 * DAMAGE.
171 *
172 * ====================================================================
173 *
174 * This software consists of voluntary contributions made by Vovida
175 * Networks, Inc. and many individuals on behalf of Vovida Networks,
176 * Inc. For more information on Vovida Networks, Inc., please see
177 * <http://www.vovida.org/>.
178 *
179 */

Properties

Name Value
svn:eol-style native
svn:mime-type text/plain

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27