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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5271 - (hide annotations) (download)
Thu Aug 18 23:43:07 2005 UTC (14 years, 3 months ago) by jason
Original Path: branches/b-directory-reorg/sip/resiprocate/test/testSipMessageMemory.cxx
File size: 6207 byte(s)
new directory reorg proposal
1 jason 1295 #include "resiprocate/SipMessage.hxx"
2     #include "resiprocate/Uri.hxx"
3     #include "resiprocate/test/TestSupport.hxx"
4 derekm 513
5     #include <iostream>
6 jason 639 #include <memory>
7 derekm 513
8 jason 1305 using namespace resip;
9 derekm 513 using namespace std;
10    
11     int
12     main()
13     {
14     {
15 jason 3433 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 jason 567
17 alan 751 auto_ptr<SipMessage> message1(TestSupport::makeMessage(Data(txt1)));
18     auto_ptr<SipMessage> message2(TestSupport::makeMessage(Data(txt1)));
19 jason 567
20     NameAddr local;
21    
22     local = message1->header(h_From);
23     local = message2->header(h_From);
24     }
25    
26     {
27 derekm 513 cerr << "Testing raw header transfer" << endl;
28    
29 jason 3433 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 derekm 513
31 jason 3433 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 derekm 513
33 alan 751 auto_ptr<SipMessage> message1(TestSupport::makeMessage(Data(txt1)));
34     auto_ptr<SipMessage> message2(TestSupport::makeMessage(Data(txt2)));
35 derekm 513
36 jason 567 assert(message1->getRawHeader(Headers::CSeq)->getParserContainer() == 0);
37     assert(message2->getRawHeader(Headers::CSeq)->getParserContainer() == 0);
38 derekm 513
39 jason 567 message1->setRawHeader(message2->getRawHeader(Headers::CSeq), Headers::CSeq);
40     message1->encode(cerr) << endl;
41     assert(message1->header(h_CSeq).sequence() == 6281);
42 derekm 513 }
43    
44     {
45     cerr << "Testing raw header transfer post parse" << endl;
46    
47 jason 3433 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 derekm 513
49 jason 3433 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 derekm 513
51    
52 alan 751 auto_ptr<SipMessage> message1(TestSupport::makeMessage(Data(txt1)));
53     auto_ptr<SipMessage> message2(TestSupport::makeMessage(Data(txt2)));
54 derekm 513
55 jason 567 assert(message1->getRawHeader(Headers::CSeq)->getParserContainer() == 0);
56     assert(message2->getRawHeader(Headers::CSeq)->getParserContainer() == 0);
57 derekm 513
58     // causes parse
59 jason 567 assert(message2->header(h_CSeq).sequence() == 6281);
60 derekm 513 // should have a parsed header
61 jason 567 assert(message2->getRawHeader(Headers::CSeq)->getParserContainer());
62 derekm 513
63     // should still work, but copies
64 jason 567 message1->setRawHeader(message2->getRawHeader(Headers::CSeq), Headers::CSeq);
65     message1->encode(cerr) << endl;
66     assert(message1->header(h_CSeq).sequence() == 6281);
67 derekm 513
68     // should have a parsed header
69 jason 567 assert(message1->getRawHeader(Headers::CSeq)->getParserContainer());
70 derekm 513 }
71 davidb 1097
72     cout << "All OK" << endl;
73 ryker 1513 return 0;
74 derekm 513 }
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