/[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 751 - (hide annotations) (download)
Tue Nov 26 21:37:18 2002 UTC (17 years ago) by alan
Original Path: main/sip/resiprocate/test/testSipMessageMemory.cxx
File size: 6209 byte(s)
ported makeMessage to new location

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

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27