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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5948 - (show annotations) (download)
Fri Feb 17 15:30:16 2006 UTC (13 years, 8 months ago) by dworley
File MIME type: text/plain
File size: 4927 byte(s)
Setting more svn: properties, and adding EOLs to the ends of files
that need it.

1
2 #include <iostream>
3 #include <memory>
4 #include <list>
5
6 #include "rutil/DataStream.hxx"
7
8 #include "resip/stack/SipMessage.hxx"
9 #include "resip/stack/Helper.hxx"
10 #include "resip/stack/Uri.hxx"
11 #include "resip/stack/ExternalBodyContents.hxx"
12 #include "TestSupport.hxx"
13 #include "rutil/Logger.hxx"
14
15 using namespace resip;
16 using namespace std;
17
18 #define CRLF "\r\n"
19
20 #define RESIPROCATE_SUBSYSTEM Subsystem::TEST
21
22 int
23 main(int argc, char* argv[])
24 {
25 Log::initialize(Log::Cout, Log::Info, argv[0]);
26
27 {
28 Data txt("INVITE sip:bob@biloxi.com SIP/2.0\r\n"
29 "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\r\n"
30 "To: Bob <sip:bob@biloxi.com>\r\n"
31 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n"
32 "Call-ID: a84b4c76e66710\r\n"
33 "CSeq: 314159 INVITE\r\n"
34 "Max-Forwards: 70\r\n"
35 "Contact: <sip:alice@pc33.atlanta.com>\r\n"
36 "Content-Type: message/external-body\r\n"
37 "Content-Length: 57\r\n"
38 "\r\n"
39 "Content-Type: text/plain\r\n"
40 "Content-Length: 11\r\n");
41 try
42 {
43 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt.c_str()));
44 Contents* body = msg->getContents();
45
46 assert(body != 0);
47 ExternalBodyContents* frag = dynamic_cast<ExternalBodyContents*>(body);
48 assert(frag != 0);
49 assert(frag->message().header(h_ContentType) == Mime("text", "plain"));
50 assert(frag->message().header(h_ContentLength).value() == 11);
51 assert(!(frag->message().isRequest() ||frag->message().isResponse()));
52 }
53 catch (BaseException& e)
54 {
55 assert(false);
56 }
57 }
58
59 {
60 Data txt("INVITE sip:bob@biloxi.com SIP/2.0\r\n"
61 "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\r\n"
62 "To: Bob <sip:bob@biloxi.com>\r\n"
63 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n"
64 "Call-ID: a84b4c76e66710\r\n"
65 "CSeq: 314159 INVITE\r\n"
66 "Max-Forwards: 70\r\n"
67 "Contact: <sip:alice@pc33.atlanta.com>\r\n"
68 "Content-Type: message/sipfrag\r\n"
69 "Content-Length: 35\r\n"
70 "\r\n"
71 "INVITE sip:bob@biloxi.com SIP/2.0\r\n");
72 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt.c_str()));
73
74 Contents* body = msg->getContents();
75
76 assert(body);
77 SipFrag* frag = dynamic_cast<SipFrag*>(body);
78 assert(frag);
79 }
80 return 0;
81 }
82
83 /* ====================================================================
84 * The Vovida Software License, Version 1.0
85 *
86 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
87 *
88 * Redistribution and use in source and binary forms, with or without
89 * modification, are permitted provided that the following conditions
90 * are met:
91 *
92 * 1. Redistributions of source code must retain the above copyright
93 * notice, this list of conditions and the following disclaimer.
94 *
95 * 2. Redistributions in binary form must reproduce the above copyright
96 * notice, this list of conditions and the following disclaimer in
97 * the documentation and/or other materials provided with the
98 * distribution.
99 *
100 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
101 * and "Vovida Open Communication Application Library (VOCAL)" must
102 * not be used to endorse or promote products derived from this
103 * software without prior written permission. For written
104 * permission, please contact vocal@vovida.org.
105 *
106 * 4. Products derived from this software may not be called "VOCAL", nor
107 * may "VOCAL" appear in their name, without prior written
108 * permission of Vovida Networks, Inc.
109 *
110 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
111 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
112 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
113 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
114 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
115 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
116 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
117 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
118 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
119 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
120 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
121 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
122 * DAMAGE.
123 *
124 * ====================================================================
125 *
126 * This software consists of voluntary contributions made by Vovida
127 * Networks, Inc. and many individuals on behalf of Vovida Networks,
128 * Inc. For more information on Vovida Networks, Inc., please see
129 * <http://www.vovida.org/>.
130 *
131 */

Properties

Name Value
svn:eol-style native
svn:mime-type text/plain

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27