From cac515a62c19103ebedbd71e0cf5b9f4e8e02552 Mon Sep 17 00:00:00 2001 From: tjung Date: Fri, 5 Oct 2012 21:38:47 +0200 Subject: [common.tests] TCP Test added --- .../contents/org.eclipse.etrice.modellib.c.zip | Bin 15348 -> 14616 bytes .../contents/org.eclipse.etrice.modellib.java.zip | Bin 19606 -> 27670 bytes .../contents/org.eclipse.etrice.runtime.c.zip | Bin 128530 -> 127692 bytes .../contents/org.eclipse.etrice.runtime.java.zip | Bin 37338 -> 37338 bytes .../contents/org.eclipse.etrice.tutorials.c.zip | Bin 100355 -> 18750 bytes .../contents/org.eclipse.etrice.tutorials.java.zip | Bin 100453 -> 100394 bytes .../models/TcpService.room | 4 +- .../models/TCPTest.room | 160 +++++++++++++++++++++ 8 files changed, 162 insertions(+), 2 deletions(-) create mode 100644 tests/org.eclipse.etrice.generator.common.tests/models/TCPTest.room diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip index 95a380bd4..d018f424e 100644 Binary files a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip and b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip differ diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip index 291f65468..1a6c9e13c 100644 Binary files a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip and b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip differ diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip index 1945693cc..45398d89b 100644 Binary files a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip and b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip differ diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip index e53a7a2b7..2508ce9cb 100644 Binary files a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip and b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip differ diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.c.zip index bd9beef4d..9cb029f42 100644 Binary files a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.c.zip and b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.c.zip differ diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip index f998e97b1..0f282ddde 100644 Binary files a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip and b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip differ diff --git a/runtime/org.eclipse.etrice.modellib.java/models/TcpService.room b/runtime/org.eclipse.etrice.modellib.java/models/TcpService.room index 51627599f..dcd5662c7 100644 --- a/runtime/org.eclipse.etrice.modellib.java/models/TcpService.room +++ b/runtime/org.eclipse.etrice.modellib.java/models/TcpService.room @@ -148,7 +148,7 @@ RoomModel room.basic.service.tcp { } action { "try{" - "outStreams.get(data.getConnectionId()).write(data.data);" + "outStreams.get(data.getConnectionId()).write(data.getData(),0,data.length);" "}catch(IOException e){" "System.err.println(e.toString());" "}" @@ -173,7 +173,7 @@ RoomModel room.basic.service.tcp { "import java.io.*;" " - class ClientRxThread extends Thread{ + class ClientRxThread extends Thread{ private Socket sock; PTcpPayloadPort port; public ClientRxThread (PTcpPayloadPort port, Socket sock){ diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/TCPTest.room b/tests/org.eclipse.etrice.generator.common.tests/models/TCPTest.room new file mode 100644 index 000000000..51b7b2896 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.common.tests/models/TCPTest.room @@ -0,0 +1,160 @@ +RoomModel TCPTest { + import room.basic.types.* from "Types.room" + import room.basic.service.tcp.* from "TcpService.room" + + SubSystemClass TCPTestSubSys { + ActorRef TCPTestTopRef:TCPTestTop + } + ActorClass TCPTestTop { + Structure { + ActorRef ref0: ATcpServer + ActorRef ref1 [ 5 ]: ATcpClient + ActorRef ref2: Tester + Binding ref2.p1 and ref0.PayloadPort + Binding ref2.p0 and ref0.ControlPort + Binding ref2.p2 and ref1.ControlPort + Binding ref2.p3 and ref1.PayloadPort + } + Behavior { } + } + + ActorClass Tester { + Interface { + conjugated Port p0: PTcpControl + conjugated Port p1: PTcpPayload + conjugated Port p2 [5]: PTcpControl + conjugated Port p3 [5]: PTcpPayload + } + Structure { + external Port p0 + external Port p1 + external Port p2 + external Port p3 + Attribute controlData:DTcpControl + Attribute testData:DTcpPayload + Attribute counter:int32 + Attribute resultPattern:int32 + Attribute pattern:int32 + Attribute caseId: int32 + Attribute resultlist[3]: int16 = "{1,2,3}" + + } + Behavior { + Operation Tester() { + "caseId = etUnit_openAll(\"tmp\", \"TCPTest\", \"org.eclipse.etrice.generator.common.tests.TCPTest\", \"TCPTest_case\");" + } + Operation ~Tester() { + "etUnit_closeAll(caseId);" + } + StateMachine { + Transition init: initial -> state0 { + action { + "EXPECT_ORDER_START(caseId,resultlist,3);" + "EXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 1);" + "// open Server" + "controlData.setIPAddr(\"127.0.0.1\");" + "controlData.setTcpPort(4711);" + "p0.open(controlData);" + } + } + Transition tr0: state0 -> state1 { + triggers { + + } + action { + "// open 5 clients" + "for (int i=0;i cp cp0 { + triggers { + + } + action { + "counter++;" + } + } + Transition tr4: cp cp0 -> state1 + Transition tr5: cp cp0 -> state2 { + cond { + "counter>=p2.getReplication()" + } + action { + "String s=new String (\"Test!\");" + "testData.setData(s.getBytes());" + "testData.setLength(s.length());" + "testData.setConnectionId(0);" + "for (int i=0; i cp cp2 { + triggers { + + } + action { + "resultPattern+=p3.getIndexOf(ifitem);" + "//System.out.printf(\"c:%d, Idx:%d!\\n\", counter,p3.getIndexOf(ifitem));" + "counter++;" + } + } + Transition tr9: cp cp2 -> state2 + Transition tr10: cp cp2 -> cp cp1 { + cond { + "counter>=p2.getReplication()" + } + action { + "int i;" + "p0.close();" + "// close all clients" + "p2.close();" + "pattern=0;" + "for (i=0;i state2 { + triggers { + + } + action { + "p1.send(data);" + } + } + Transition tr2: cp cp1 -> test_failed + Transition tr6: cp cp1 -> test_ok { + cond { + "pattern==resultPattern" + } + } + ChoicePoint cp0 + ChoicePoint cp2 + ChoicePoint cp1 + State state0 + State state1 + State state2 + State test_ok { + entry { + "EXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 2);" + "EXPECT_ORDER_END(caseId,\"<|MODEL_LOCATION|>\", 3);" + "etUnit_testFinished(caseId);" + } + } + State test_failed { + entry { + "EXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "EXPECT_ORDER_END(caseId,\"<|MODEL_LOCATION|>\", 3);" + "etUnit_testFinished(caseId);" + } + } + } + } + } +} \ No newline at end of file -- cgit v1.2.3