smalltalk
/
osmo-st-sip
Archived
1
0
Fork 0

callagent: Create a simple test that verifies creation of a call

This commit is contained in:
Holger Hans Peter Freyther 2014-02-13 16:27:26 +01:00
parent 193126c287
commit fc2f937a60
3 changed files with 88 additions and 0 deletions

View File

@ -0,0 +1,41 @@
"
(C) 2014 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/>.
"
TestCase subclass: SIPCallAgentTest [
<category: 'OsmoSIP-Callagent-Tests'>
<comment: 'I will test some basic call agent high-level interaction'>
testSimpleInvite [
| transport agent call sent msg |
sent := OrderedCollection new.
transport := SIPTransportMock new
onData: [:datagram | sent add: datagram];
yourself.
agent := SIPUserAgent createOn: transport.
call := SIPCall fromUser: 'test' host: '127.0.0.1' port: 5060 to: 'sip:127.0.0.1' on: agent.
call createCall: 'dummy-sdp'.
self assert: call state equals: SIPCall stateInvite.
self assert: sent size equals: 1.
msg := SIPParser parse: sent first data.
self assert: msg class verb equals: SIPInviteRequest verb.
self assert: (msg parameter: 'CSeq' ifAbsent: [-1]) number equals: 1.
call cancel.
self assert: call state equals: SIPCall stateCancel.
]
]

View File

@ -0,0 +1,44 @@
"
(C) 2014 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/>.
"
SIPTransport subclass: SIPTransportMock [
| on_data |
<category: 'OsmoSIP-Callagent-Tests'>
<comment: 'I help with simulating the network layer and keep track
of messages sent and have a way to inject a specific response.'>
SIPTransportMock class >> type [
^'MOCK'
]
onData: aBlock [
on_data := aBlock
]
address [
^'0.0.0.0'
]
port [
^5060
]
queueDatagram: aDatagram [
on_data value: aDatagram
]
]

View File

@ -32,10 +32,13 @@
<sunit>Osmo.SIPParserTest</sunit>
<sunit>Osmo.SIPRequestTest</sunit>
<sunit>Osmo.SIPUdpTransportTest</sunit>
<sunit>Osmo.SIPCallAgentTest</sunit>
<sunit>Osmo.SIPDigestTest</sunit>
<filein>grammar/SIPGrammarTest.st</filein>
<filein>callagent/SIPParserTest.st</filein>
<filein>callagent/Tests.st</filein>
<filein>callagent/tests/SIPCallAgentTest.st</filein>
<filein>callagent/tests/SIPDigestTest.st</filein>
<filein>callagent/tests/SIPTransportMock.st</filein>
</test>
</package>