2011-06-13 17:56:35 +00:00
|
|
|
"
|
|
|
|
(C) 2011 by Holger Hans Peter Freyther
|
|
|
|
All Rights Reserved
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
"
|
|
|
|
|
|
|
|
PackageLoader fileInPackage: 'PetitParserTests'.
|
|
|
|
|
|
|
|
PP.PPCompositeParserTest subclass: SIPParserTest [
|
|
|
|
<comment: 'I excercise the SIPParser a bit'>
|
|
|
|
|
|
|
|
parserClass [
|
|
|
|
<category: 'accessing'>
|
|
|
|
^ SIPParser
|
|
|
|
]
|
|
|
|
|
2011-06-30 09:41:50 +00:00
|
|
|
testResponseData [
|
|
|
|
^ (WriteStream on: (String new))
|
|
|
|
nextPutAll: 'SIP/2.0 480 Temporarily Unavailable'; cr; nl;
|
|
|
|
nextPutAll: 'Via: SIP/2.0/UDP 172.16.254.34;branch=z9hG4bKMzQ4NTQzNDgxNCwyNDE1Nw__'; cr; nl;
|
|
|
|
nextPutAll: 'From: <sip:1000@on-waves.com>;tag=MzQ4NTQ0MTg2NzIyNDEwNjkyNjY_'; cr; nl;
|
|
|
|
nextPutAll: 'To: <sip:9198@172.16.1.72>;tag=42eBv22Fj314N;abc=def;kbc;ajk'; cr; nl;
|
|
|
|
nextPutAll: 'Call-ID: MzY3NzE3ODgyNw__@xiaoyu'; cr; nl;
|
|
|
|
nextPutAll: 'CSeq: 1 INVITE'; cr; nl;
|
|
|
|
nextPutAll: 'User-Agent: FreeSWITCH-mod_sofia/1.0.head-git-dff41af 2011-04-20 14-11-24 +0200'; cr; nl;
|
|
|
|
nextPutAll: 'Accept: application/sdp'; cr; nl;
|
|
|
|
nextPutAll: 'Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, UPDATE, INFO, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE'; cr; nl;
|
|
|
|
nextPutAll: 'Supported: timer, precondition, path, replaces'; cr; nl;
|
|
|
|
nextPutAll: 'Allow-Events: talk, hold, presence, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer'; cr; nl;
|
|
|
|
nextPutAll: 'Reason: Q.850;cause=96;text="MANDATORY_IE_MISSING"'; cr; nl;
|
|
|
|
nextPutAll: 'Content-Length: 0'; cr; nl;
|
|
|
|
nextPutAll: 'Remote-Party-ID: "9198" <sip:9198@172.16.1.72>;party=calling;privacy=off;screen=no'; cr; nl; cr;nl;
|
|
|
|
contents.
|
|
|
|
]
|
|
|
|
|
2011-06-13 17:56:35 +00:00
|
|
|
testResponse [
|
2011-06-30 09:41:50 +00:00
|
|
|
| data res |
|
|
|
|
|
|
|
|
res := self parse: self testResponseData.
|
|
|
|
self assert: res asDatagram = self testResponseData.
|
2011-06-13 21:09:02 +00:00
|
|
|
self assert: (res parameter: 'Via') branch = 'z9hG4bKMzQ4NTQzNDgxNCwyNDE1Nw__'.
|
2011-06-14 17:34:54 +00:00
|
|
|
self assert: (res parameter: 'CSeq') number = 1.
|
|
|
|
self assert: (res parameter: 'CSeq') method = 'INVITE'.
|
2011-06-30 09:35:38 +00:00
|
|
|
self assert: (res parameter: 'To') tag = '42eBv22Fj314N'.
|
|
|
|
self assert: ((res parameter: 'To') valueAt: 'abc') = 'def'.
|
|
|
|
self assert: ((res parameter: 'To') valueAt: 'kbc') = nil.
|
|
|
|
self assert: ((res parameter: 'To') valueAt: 'ajk') = nil.
|
|
|
|
self should: [((res parameter: 'To') valueAt: 'foo')] raise: SystemExceptions.NotFound.
|
2011-06-13 17:56:35 +00:00
|
|
|
]
|
|
|
|
]
|