summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortjung2012-10-05 15:38:47 (EDT)
committertjung2012-10-05 15:38:47 (EDT)
commitcac515a62c19103ebedbd71e0cf5b9f4e8e02552 (patch)
tree97c872f97266121669ec8d6ddfbd711ed1657e78
parent426289fa585c6d533f94cf6efc9f1e28d2770260 (diff)
downloadorg.eclipse.etrice-cac515a62c19103ebedbd71e0cf5b9f4e8e02552.zip
org.eclipse.etrice-cac515a62c19103ebedbd71e0cf5b9f4e8e02552.tar.gz
org.eclipse.etrice-cac515a62c19103ebedbd71e0cf5b9f4e8e02552.tar.bz2
[common.tests] TCP Test added
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zipbin15348 -> 14616 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zipbin19606 -> 27670 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zipbin128530 -> 127692 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zipbin37338 -> 37338 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.c.zipbin100355 -> 18750 bytes
-rw-r--r--plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zipbin100453 -> 100394 bytes
-rw-r--r--runtime/org.eclipse.etrice.modellib.java/models/TcpService.room4
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/TCPTest.room160
8 files changed, 162 insertions, 2 deletions
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 95a380b..d018f42 100644
--- 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
Binary files 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 291f654..1a6c9e1 100644
--- 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
Binary files 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 1945693..45398d8 100644
--- 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
Binary files 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 e53a7a2..2508ce9 100644
--- 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
Binary files 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 bd9beef..9cb029f 100644
--- 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
Binary files 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 f998e97..0f282dd 100644
--- 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
Binary files differ
diff --git a/runtime/org.eclipse.etrice.modellib.java/models/TcpService.room b/runtime/org.eclipse.etrice.modellib.java/models/TcpService.room
index 5162759..dcd5662 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 0000000..51b7b28
--- /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 {
+ <established: p0>
+ }
+ action {
+ "// open 5 clients"
+ "for (int i=0;i<p2.getReplication();i++){"
+ "p2[i].open(controlData);"
+ "}"
+ "counter=0;"
+ }
+ }
+ Transition tr1: state1 -> cp cp0 {
+ triggers {
+ <established: p2>
+ }
+ 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<p3.getReplication();i++){"
+ "\tp3[i].send(testData);"
+ "}"
+ "counter=0;"
+ "resultPattern=0;"
+ }
+ }
+ Transition tr8: state2 -> cp cp2 {
+ triggers {
+ <receive: p3>
+ }
+ 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<p2.getReplication();i++){"
+ "\tpattern+=i;"
+ "}"
+ }
+ }
+ Transition tr3: state2 -> state2 {
+ triggers {
+ <receive: p1>
+ }
+ 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