1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
/******************************************************************************
* Copyright (c) 2000-2021 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* Contributors:
* Szabo, Bence Janos
*
******************************************************************************/
module AddressPortNegTest {
type record SIP_address_type
{
charstring host optional, // hostname, IPv4 or IPv6
integer portField optional, // represented as an integer
boolean tcporudp optional // true if TCP false if UDP
}
type SIP_address_type address;
type port PortType1 message {
inout integer;
} with {extension "address"}
type port PortType2 message {
inout integer;
}
type component TestCaseComp {
port PortType1 p1;
}
type component TestCaseComp2 {
port PortType2 p1;
}
type component SystemComp {
port PortType1 p1;
}
testcase tc_neg_address_port_not_mapped() runs on TestCaseComp system SystemComp {
var address v_addr := {"Host", 4400, false}
@try {
p1.send(5) to v_addr;
setverdict(fail, "Send operation succeeded. Expected error.");
}
@catch (msg) {
if (match(msg, pattern "*Dynamic test case error: Port p1 has neither connections nor mappings. Message cannot be sent on it.")) {
setverdict(pass);
}
else {
setverdict(fail, "Incorrect error message received (receive test): ", msg);
}
}
// After map it is good
map(self:p1, system:p1);
p1.send(5) to v_addr;
setverdict(pass);
}
testcase tc_neg_address_port_not_mapped_system() runs on TestCaseComp system SystemComp {
@try {
p1.send(5) to system;
setverdict(fail, "Send operation succeeded. Expected error.");
}
@catch (msg) {
if (match(msg, pattern "*Dynamic test case error: Port p1 has neither connections nor mappings. Message cannot be sent on it.")) {
setverdict(pass);
}
else {
setverdict(fail, "Incorrect error message received (receive test): ", msg);
}
}
// After map it is good
map(self:p1, system:p1);
p1.send(5) to system;
setverdict(pass);
}
testcase tc_neg_port_not_mapped_system() runs on TestCaseComp2 system SystemComp {
@try {
p1.send(5) to system;
setverdict(fail, "Send operation succeeded. Expected error.");
}
@catch (msg) {
if (match(msg, pattern "*Dynamic test case error: Port p1 has neither connections nor mappings. Message cannot be sent on it.")) {
setverdict(pass);
}
else {
setverdict(fail, "Incorrect error message received (receive test): ", msg);
}
}
// After map it is good
map(self:p1, system:p1);
p1.send(5) to system;
setverdict(pass);
}
control {
execute(tc_neg_address_port_not_mapped());
execute(tc_neg_address_port_not_mapped_system());
execute(tc_neg_port_not_mapped_system());
}
}
|