4
#include "resip/stack/MultipartMixedContents.hxx"
5
#include "resip/stack/MultipartRelatedContents.hxx"
6
#include "resip/stack/PlainContents.hxx"
7
#include "resip/stack/SipMessage.hxx"
8
#include "resip/stack/test/TestSupport.hxx"
9
#include "rutil/ParseBuffer.hxx"
11
using namespace resip;
18
const Data txt("--example-1\r\n"
19
"Content-Type: text/plain\r\n"
20
"Content-ID: <1_950120.aaCC@XIson.com>\r\n"
31
"Content-Type: text/plain\r\n"
32
"Content-Description: The fixed length records\r\n"
33
"Content-Transfer-Encoding: base64\r\n"
34
"Content-ID: <2_950120.aaCB@XIson.com>\r\n"
36
"T2xkIE1hY0RvbmFsZCBoYWQgYSBmYXJtCkUgSS\r\n"
37
"BFIEkgTwpBbmQgb24gaGlzIGZhcm0gaGUgaGFk\r\n"
38
"IHNvbWUgZHVja3MKRSBJIEUgSSBPCldpdGggYS\r\n"
39
"BxdWFjayBxdWFjayBoZXJlLAphIHF1YWNrIHF1\r\n"
40
"YWNrIHRoZXJlLApldmVyeSB3aGVyZSBhIHF1YW\r\n"
41
"NrIHF1YWNrCkUgSSBFIEkgTwo=\r\n"
46
const Data contentsTxt = ("Multipart/Related; boundary=example-1\r\n"
47
" start=\"<950120.aaCC@XIson.com>\";\r\n"
48
" type=\"Application/X-FixedRecord\"\r\n"
49
" start-info=\"-o ps\"\r\n");
51
ParseBuffer pb(contentsTxt.data(), contentsTxt.size());
53
contentType.parse(pb);
55
HeaderFieldValue hfv(txt.data(), txt.size());
56
MultipartRelatedContents mpc(hfv, contentType);
58
assert(mpc.parts().size() == 2);
60
PlainContents *f = dynamic_cast<PlainContents*>(mpc.parts().front());
64
mpc.encode(resipCerr);
68
const Data txt("INVITE sip:bob@biloxi.com SIP/2.0\r\n"
69
"To: <sip:bob@biloxi.com>\r\n"
70
"From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n"
73
"Content-Type: Multipart/Related; boundary=example-1;"
74
"start=\"<950120.aaCC@XIson.com>\";"
75
"type=\"Application/X-FixedRecord\";start-info=\"-o ps\"\r\n"
78
"Content-Type: text/plain\r\n"
79
"Content-ID: <1_950120.aaCC@XIson.com>\r\n"
90
"Content-Type: text/plain\r\n"
91
"Content-Description: The fixed length records\r\n"
92
"Content-Transfer-Encoding: base64\r\n"
93
"Content-ID: <2_950120.aaCB@XIson.com>\r\n"
95
"T2xkIE1hY0RvbmFsZCBoYWQgYSBmYXJtCkUgSS\r\n"
96
"BFIEkgTwpBbmQgb24gaGlzIGZhcm0gaGUgaGFk\r\n"
97
"IHNvbWUgZHVja3MKRSBJIEUgSSBPCldpdGggYS\r\n"
98
"BxdWFjayBxdWFjayBoZXJlLAphIHF1YWNrIHF1\r\n"
99
"YWNrIHRoZXJlLApldmVyeSB3aGVyZSBhIHF1YW\r\n"
100
"NrIHF1YWNrCkUgSSBFIEkgTwo=\r\n"
104
auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt.c_str()));
106
MultipartRelatedContents* mpc = dynamic_cast<MultipartRelatedContents*>(msg->getContents());
108
assert(mpc->parts().size() == 2);
109
PlainContents *f11 = dynamic_cast<PlainContents*>(mpc->parts().front());
112
MultipartRelatedContents::Parts::const_iterator i = mpc->parts().begin(); i++;
113
PlainContents *f12 = dynamic_cast<PlainContents*>(*i);
119
DataStream str(buff);
124
auto_ptr<SipMessage> msg1(TestSupport::makeMessage(buff.c_str()));
125
MultipartRelatedContents* mpc = dynamic_cast<MultipartRelatedContents*>(msg->getContents());
127
assert(mpc->parts().size() == 2);
128
PlainContents *f21 = dynamic_cast<PlainContents*>(mpc->parts().front());
131
MultipartRelatedContents::Parts::const_iterator i = mpc->parts().begin(); i++;
132
PlainContents *f22 = dynamic_cast<PlainContents*>(*i);
136
assert(f11->getBodyData() == f21->getBodyData());
137
assert(f12->getBodyData() == f22->getBodyData());
141
cerr << endl << "All OK" << endl;
145
/* ====================================================================
146
* The Vovida Software License, Version 1.0
148
* Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
150
* Redistribution and use in source and binary forms, with or without
151
* modification, are permitted provided that the following conditions
154
* 1. Redistributions of source code must retain the above copyright
155
* notice, this list of conditions and the following disclaimer.
157
* 2. Redistributions in binary form must reproduce the above copyright
158
* notice, this list of conditions and the following disclaimer in
159
* the documentation and/or other materials provided with the
162
* 3. The names "VOCAL", "Vovida Open Communication Application Library",
163
* and "Vovida Open Communication Application Library (VOCAL)" must
164
* not be used to endorse or promote products derived from this
165
* software without prior written permission. For written
166
* permission, please contact vocal@vovida.org.
168
* 4. Products derived from this software may not be called "VOCAL", nor
169
* may "VOCAL" appear in their name, without prior written
170
* permission of Vovida Networks, Inc.
172
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
173
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
174
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
175
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
176
* NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
177
* IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
178
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
179
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
180
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
181
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
182
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
183
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
186
* ====================================================================
188
* This software consists of voluntary contributions made by Vovida
189
* Networks, Inc. and many individuals on behalf of Vovida Networks,
190
* Inc. For more information on Vovida Networks, Inc., please see
191
* <http://www.vovida.org/>.