module PingPong { // written by Bernard Stepien // bernard.stepien@sympatico.ca // templates template charstring thePongTemplate := "pong"; type charstring address; // communication configuration definitions type port PingPongPortType message { out charstring; in charstring; } type component MTCType { var charstring theWrongResponse; port PingPongPortType ping_pong_port; } type component SystemType { port PingPongPortType system_ping_pong_port; } testcase PlayPingPong() runs on MTCType system SystemType { map(mtc:ping_pong_port, system:system_ping_pong_port); ping_pong_port.send("ping"); alt { [] ping_pong_port.receive(thePongTemplate) { log("received a pong"); setverdict(pass) } [] ping_pong_port.receive("net") { log("received a net"); setverdict(inconc) } [] ping_pong_port.receive { log("did not receive a pong"); setverdict(fail) } }; stop } testcase FailingPingPong() runs on MTCType system SystemType { map(mtc:ping_pong_port, system:system_ping_pong_port); ping_pong_port.send("shplack"); alt { [] ping_pong_port.receive("pong") { log("received a pong"); setverdict(pass) } [] ping_pong_port.receive(charstring:?) -> value theWrongResponse { log("did not receive a pong, instead receive:" & theWrongResponse); setverdict(fail) } }; stop } control { execute (PlayPingPong()); execute (FailingPingPong()); } } with { encode "PingPong"; }