diff options
Diffstat (limited to 'callagent/Tests.st')
-rw-r--r-- | callagent/Tests.st | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/callagent/Tests.st b/callagent/Tests.st index db76558..8479564 100644 --- a/callagent/Tests.st +++ b/callagent/Tests.st @@ -230,4 +230,32 @@ TestCase subclass: MGCPEndpointAllocTest [ endp unblock. self assert: endp isUnused. ] + + testAllocation [ + | trunk endp | + + trunk := MGCPVirtualTrunk createWithDest: '127.0.0.1' numberPorts: 32. + + 1 to: 32 do: [:each | + self assert: ((trunk allocateEndpointIfFailure: []) + used; isUsed). + ]. + + "test an allocation failure" + self assert: (trunk allocateEndpointIfFailure: [true]). + + "now free some endpoints" + (trunk endpointAt: 20) free. + (trunk endpointAt: 5) free. + endp := (trunk allocateEndpointIfFailure: []). + self assert: endp endpointName = '5@mgw'. + + "last_used should be five now" + (trunk endpointAt: 4) free. + endp := (trunk allocateEndpointIfFailure: []). + self assert: endp endpointName = '14@mgw'. + + endp := (trunk allocateEndpointIfFailure: []). + self assert: endp endpointName = '4@mgw'. + ] ] |