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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5295 - (show annotations) (download)
Mon Aug 22 00:30:05 2005 UTC (14 years, 3 months ago) by jason
File size: 6207 byte(s)
merged 5270:HEAD from b-directory-reorg
1 #include "resip/stack/SipMessage.hxx"
2 #include "resip/stack/Uri.hxx"
3 #include "resip/stack/test/TestSupport.hxx"
4
5 #include <iostream>
6 #include <memory>
7
8 using namespace resip;
9 using namespace std;
10
11 int
12 main()
13 {
14 {
15 char *txt1 = "REGISTER sip:registrar.biloxi.com SIP/2.0\r\nVia: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=z9hG4bKnashds7\r\nMax-Forwards: 70\r\nTo: Bob <sip:bob@biloxi.com>\r\nFrom: Bob <sip:bob@biloxi.com>;tag=456248\r\nCall-ID: 843817637684230@998sdasdh09\r\nCSeq: 1826 REGISTER\r\nContact: <sip:bob@192.0.2.4>\r\nExpires: 7200\r\nContent-Length: 0\r\n\r\n";
16
17 auto_ptr<SipMessage> message1(TestSupport::makeMessage(Data(txt1)));
18 auto_ptr<SipMessage> message2(TestSupport::makeMessage(Data(txt1)));
19
20 NameAddr local;
21
22 local = message1->header(h_From);
23 local = message2->header(h_From);
24 }
25
26 {
27 cerr << "Testing raw header transfer" << endl;
28
29 char *txt1 = "REGISTER sip:registrar.biloxi.com SIP/2.0\r\nVia: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=z9hG4bKnashds7\r\nMax-Forwards: 70\r\nTo: Bob <sip:bob@biloxi.com>\r\nFrom: Bob <sip:bob@biloxi.com>;tag=456248\r\nCall-ID: 843817637684230@998sdasdh09\r\nCSeq: 1826 REGISTER\r\nContact: <sip:bob@192.0.2.4>\r\nExpires: 7200\r\nContent-Length: 0\r\n\r\n";
30
31 char *txt2 = "REGISTER sip:registrar.ixolib.com SIP/2.0\r\nVia: SIP/2.0/UDP qoqspc.ixolib.com:5060;branch=2222222222\r\nMax-Forwards: 70\r\nTo: Qoq <sip:qoq@ixolib.com>\r\nFrom: Qoq <sip:qoq@ixolib.com>;tag=456248\r\nCall-ID: 111111111111111\r\nCSeq: 6281 REGISTER\r\nContact: <sip:qoq@192.0.2.4>\r\nExpires: 7200\r\nContent-Length: 0\r\n\r\n";
32
33 auto_ptr<SipMessage> message1(TestSupport::makeMessage(Data(txt1)));
34 auto_ptr<SipMessage> message2(TestSupport::makeMessage(Data(txt2)));
35
36 assert(message1->getRawHeader(Headers::CSeq)->getParserContainer() == 0);
37 assert(message2->getRawHeader(Headers::CSeq)->getParserContainer() == 0);
38
39 message1->setRawHeader(message2->getRawHeader(Headers::CSeq), Headers::CSeq);
40 message1->encode(cerr) << endl;
41 assert(message1->header(h_CSeq).sequence() == 6281);
42 }
43
44 {
45 cerr << "Testing raw header transfer post parse" << endl;
46
47 char *txt1 = "REGISTER sip:registrar.biloxi.com SIP/2.0\r\nVia: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=z9hG4bKnashds7\r\nMax-Forwards: 70\r\nTo: Bob <sip:bob@biloxi.com>\r\nFrom: Bob <sip:bob@biloxi.com>;tag=456248\r\nCall-ID: 843817637684230@998sdasdh09\r\nCSeq: 1826 REGISTER\r\nContact: <sip:bob@192.0.2.4>\r\nExpires: 7200\r\nContent-Length: 0\r\n\r\n";
48
49 char *txt2 = "REGISTER sip:registrar.ixolib.com SIP/2.0\r\nVia: SIP/2.0/UDP qoqspc.ixolib.com:5060;branch=2222222222\r\nMax-Forwards: 70\r\nTo: Qoq <sip:qoq@ixolib.com>\r\nFrom: Qoq <sip:qoq@ixolib.com>;tag=456248\r\nCall-ID: 111111111111111\r\nCSeq: 6281 REGISTER\r\nContact: <sip:qoq@192.0.2.4>\r\nExpires: 7200\r\nContent-Length: 0\r\n\r\n";
50
51
52 auto_ptr<SipMessage> message1(TestSupport::makeMessage(Data(txt1)));
53 auto_ptr<SipMessage> message2(TestSupport::makeMessage(Data(txt2)));
54
55 assert(message1->getRawHeader(Headers::CSeq)->getParserContainer() == 0);
56 assert(message2->getRawHeader(Headers::CSeq)->getParserContainer() == 0);
57
58 // causes parse
59 assert(message2->header(h_CSeq).sequence() == 6281);
60 // should have a parsed header
61 assert(message2->getRawHeader(Headers::CSeq)->getParserContainer());
62
63 // should still work, but copies
64 message1->setRawHeader(message2->getRawHeader(Headers::CSeq), Headers::CSeq);
65 message1->encode(cerr) << endl;
66 assert(message1->header(h_CSeq).sequence() == 6281);
67
68 // should have a parsed header
69 assert(message1->getRawHeader(Headers::CSeq)->getParserContainer());
70 }
71
72 cout << "All OK" << endl;
73 return 0;
74 }
75
76
77 /* ====================================================================
78 * The Vovida Software License, Version 1.0
79 *
80 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
81 *
82 * Redistribution and use in source and binary forms, with or without
83 * modification, are permitted provided that the following conditions
84 * are met:
85 *
86 * 1. Redistributions of source code must retain the above copyright
87 * notice, this list of conditions and the following disclaimer.
88 *
89 * 2. Redistributions in binary form must reproduce the above copyright
90 * notice, this list of conditions and the following disclaimer in
91 * the documentation and/or other materials provided with the
92 * distribution.
93 *
94 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
95 * and "Vovida Open Communication Application Library (VOCAL)" must
96 * not be used to endorse or promote products derived from this
97 * software without prior written permission. For written
98 * permission, please contact vocal@vovida.org.
99 *
100 * 4. Products derived from this software may not be called "VOCAL", nor
101 * may "VOCAL" appear in their name, without prior written
102 * permission of Vovida Networks, Inc.
103 *
104 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
105 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
106 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
107 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
108 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
109 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
110 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
111 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
112 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
113 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
114 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
115 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
116 * DAMAGE.
117 *
118 * ====================================================================
119 *
120 * This software consists of voluntary contributions made by Vovida
121 * Networks, Inc. and many individuals on behalf of Vovida Networks,
122 * Inc. For more information on Vovida Networks, Inc., please see
123 * <http://www.vovida.org/>.
124 *
125 */

Properties

Name Value
svn:eol-style LF

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27