callagent: Add testcase for the allocation FSM of an endpoint
Verify the legal transitions and the non-legal ones (exceptions are thrown in that case).
This commit is contained in:
parent
03348c1e8d
commit
56f86debce
|
@ -91,7 +91,7 @@ Object subclass: MGCPEndpoint [
|
|||
free [
|
||||
<category: 'allocation'>
|
||||
self requireState: self class stateUsed.
|
||||
state := self class stateUsed.
|
||||
state := self class stateUnused.
|
||||
]
|
||||
|
||||
tryBlock [
|
||||
|
|
|
@ -185,3 +185,49 @@ TestCase subclass: MGCPTransactionTest [
|
|||
self dropAgent stop.
|
||||
]
|
||||
]
|
||||
|
||||
TestCase subclass: MGCPEndpointAllocTest [
|
||||
testStateTransition [
|
||||
| trunk endp |
|
||||
|
||||
trunk := MGCPVirtualTrunk createWithDest: '127.0.0.1' numberPorts: 32.
|
||||
endp := trunk endpointAt: 1.
|
||||
|
||||
"Initial..."
|
||||
self assert: endp isUnused.
|
||||
|
||||
"Reserve..."
|
||||
endp reserve.
|
||||
self assert: endp isReserved.
|
||||
self should: [endp reserve] raise: Error.
|
||||
self should: [endp free] raise: Error.
|
||||
self should: [endp unblock] raise: Error.
|
||||
self deny: endp tryBlock.
|
||||
|
||||
"Move to used..."
|
||||
endp used.
|
||||
self assert: endp isUsed.
|
||||
self should: [endp reserve] raise: Error.
|
||||
self should: [endp used] raise: Error.
|
||||
self should: [endp unblock] raise: Error.
|
||||
self deny: endp tryBlock.
|
||||
|
||||
"Move to free..."
|
||||
endp free.
|
||||
self assert: endp isUnused.
|
||||
self should: [endp used] raise: Error.
|
||||
self should: [endp unblock] raise: Error.
|
||||
self assert: endp tryBlock.
|
||||
|
||||
"Now try to block it..."
|
||||
self assert: endp isBlocked.
|
||||
self should: [endp reserve] raise: Error.
|
||||
self should: [endp free] raise: Error.
|
||||
self should: [endp used] raise: Error.
|
||||
self deny: endp tryBlock.
|
||||
|
||||
"Now unblock and restore"
|
||||
endp unblock.
|
||||
self assert: endp isUnused.
|
||||
]
|
||||
]
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
<test>
|
||||
<sunit>Osmo.MGCPGrammarTest</sunit>
|
||||
<sunit>Osmo.MGCPCommandTest</sunit>
|
||||
<sunit>Osmo.MGCPEndpointAllocTest</sunit>
|
||||
<sunit>Osmo.MGCPTransactionTest</sunit>
|
||||
<filein>grammar/MGCPGrammarTest.st</filein>
|
||||
<filein>callagent/Tests.st</filein>
|
||||
|
|
Reference in New Issue