/[resiprocate]/main/sip/resiprocate/test/testSipMessageMemory.cxx
ViewVC logotype

Annotation of /main/sip/resiprocate/test/testSipMessageMemory.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 513 - (hide annotations) (download)
Wed Nov 6 19:38:37 2002 UTC (17 years, 2 months ago) by derekm
File size: 5669 byte(s)
moved tests from sipstack directory to test directory

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

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27