/[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 1513 - (show annotations) (download)
Thu Jun 19 16:40:21 2003 UTC (16 years, 5 months ago) by ryker
Original Path: main/sip/resiprocate/test/testSipMessageMemory.cxx
File size: 6243 byte(s)
Make sure tests return 0 on successful completion.

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

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27