Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Belle2017-09-13 14:46:38 +0000
committerJan Belle2017-09-13 14:46:38 +0000
commit845441c200d2780920d2e1769e7a8758e2846c76 (patch)
tree7dc4b8f77ffe32bba94a4f9290bed34b79d45be4 /tests/org.eclipse.etrice.generator.java.tests/models
parent9e42fbde145d3de9dabbb4ee88d100ce6d5efcb7 (diff)
downloadorg.eclipse.etrice-845441c200d2780920d2e1769e7a8758e2846c76.tar.gz
org.eclipse.etrice-845441c200d2780920d2e1769e7a8758e2846c76.tar.xz
org.eclipse.etrice-845441c200d2780920d2e1769e7a8758e2846c76.zip
[tests] gradle build for runtime and generator tests
Diffstat (limited to 'tests/org.eclipse.etrice.generator.java.tests/models')
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest1.etmap11
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest1.room182
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest2.etmap11
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest2.room236
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest3.room235
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest4.room97
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest5.room149
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest6.room243
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest7.etmap11
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest7.room375
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/models/DynamicConfigTest.config121
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/models/DynamicConfigTest.etmap9
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/models/DynamicConfigTest.room202
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/models/DynamicConfigTest.rt-config20
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/models/StoreRestoreTest.room217
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/models/TCPTest.room160
16 files changed, 2279 insertions, 0 deletions
diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest1.etmap b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest1.etmap
new file mode 100644
index 000000000..760374536
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest1.etmap
@@ -0,0 +1,11 @@
+MappingModel DynamicActorTest1 {
+ import DynamicActorTest1.* from "DynamicActorTest1.room"
+ import room.generic.physical.* from "../../org.eclipse.etrice.generator.common.tests/models/GenericPhysical.etphys"
+
+ Mapping JavaGenTests -> GenericPhysicalSystem {
+ SubSystemMapping da1Test -> node {
+ ThreadMapping defaultThread -> DefaultPhysicalThread
+ }
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest1.room b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest1.room
new file mode 100644
index 000000000..8701a556f
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest1.room
@@ -0,0 +1,182 @@
+RoomModel DynamicActorTest1 {
+
+ import room.basic.test.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Tests.room"
+ import room.basic.types.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Types.room"
+
+ LogicalSystem JavaGenTests {
+ SubSystemRef da1Test : SubSystem_DynamicActorTest1
+ }
+
+ SubSystemClass SubSystem_DynamicActorTest1 {
+ ActorRef appl : Appl
+
+ LogicalThread defaultThread
+ }
+
+ ActorClass Appl {
+ Structure {
+ ActorRef cont: Container
+ }
+ Behavior { }
+ }
+
+ ActorClass Container {
+ Structure {
+ conjugated Port p0: PC
+ Attribute caseId: int32
+ optional ActorRef opt: Optional
+
+ Binding p0 and opt.p0
+ }
+ Behavior {
+ ctor {
+ "caseId = etUnit_openAll(\".\", \"DynamicActorTest1\", \"org.eclipse.etrice.generator.common.tests.DynamicActorTest1\", \"DynamicActorTest1_case\");"
+ }
+ dtor {
+ "etUnit_closeAll(caseId);"
+ }
+
+ StateMachine {
+ Transition init: initial -> CreateOptional2 { }
+ Transition tr0: CreateOptional2 -> CreateOptional1 {
+ triggers {
+ <hello: p0>
+ }
+ action {
+ "EXPECT_TRUE(caseId, \"<|MODEL_LOCATION|>\", txt.equals(\"AC3:/JavaGenTests/da1Test/appl/cont/opt/sub2/deep_sub\"));"
+ "opt.destroyOptionalActor();"
+ }
+ }
+ Transition tr2: CreateOptional1 -> ReceivedHelloAgain {
+ triggers {
+ <hello: p0>
+ }
+ action {
+ "EXPECT_TRUE(caseId, \"<|MODEL_LOCATION|>\", txt.equals(\"AC1:/JavaGenTests/da1Test/appl/cont/opt/sub1\"));"
+ "opt.destroyOptionalActor();"
+ }
+ }
+ State CreateOptional2 {
+ entry {
+ "opt.createOptionalActor(\"Optional2\", getThread());"
+ "p0.sayHello();"
+ }
+ }
+ State CreateOptional1 {
+ entry {
+ "opt.createOptionalActor(\"Optional1\", getThread());"
+ "p0.sayHello();"
+ }
+ }
+ State ReceivedHelloAgain {
+ entry {
+ "IRTObject opt = getChild(\"opt\");"
+ "int size = opt.getChildren().size();"
+ ""
+ "// we expect the RTSystemPort and the InterfaceItemBroker"
+ "EXPECT_EQUAL_INT32(caseId, \"<|MODEL_LOCATION|>\", 2, size);"
+ ""
+ "etUnit_testFinished(caseId);"
+ }
+ }
+ }
+ }
+ }
+
+ // the class that is referenced as optional by the Container
+ // since it is abstract it just serves as an interface
+ abstract ActorClass Optional {
+ Interface {
+ Port p0: PC
+ }
+ Structure { }
+ Behavior { }
+ }
+
+ // a sub class of Optional which is valid as optional actor
+ ActorClass Optional1 extends Optional {
+ Structure {
+ ActorRef sub1: AC1
+ Binding p0 and sub1.p0
+ }
+ Behavior { }
+ }
+
+ // a sub class of Optional which is valid as optional actor
+ ActorClass Optional2 extends Optional {
+ Structure {
+ ActorRef sub2: AC2
+ Binding p0 and sub2.p0
+ }
+ Behavior { }
+ }
+
+ // the following actor classes are part of the possible optional instance sub trees
+
+ ActorClass AC1 {
+ Interface {
+ Port p0: PC
+ }
+ Structure {
+ external Port p0
+ }
+ Behavior {
+ StateMachine {
+ Transition init: initial -> Ready { }
+ Transition tr0: Ready -> Ready {
+ triggers {
+ <sayHello: p0>
+ }
+ action {
+ "p0.hello(\"AC1:\"+getInstancePath());"
+ }
+ }
+ State Ready
+ }
+ }
+ }
+
+ ActorClass AC2 {
+ Interface {
+ Port p0: PC
+ }
+ Structure {
+ ActorRef deep_sub: AC3
+ Binding p0 and deep_sub.p0
+ }
+ Behavior { }
+ }
+
+ ActorClass AC3 {
+ Interface {
+ Port p0: PC
+ }
+ Structure {
+ external Port p0
+ }
+ Behavior {
+ StateMachine {
+ Transition init: initial -> Ready { }
+ Transition tr0: Ready -> Ready {
+ triggers {
+ <sayHello: p0>
+ }
+ action {
+ "p0.hello(\"AC3:\"+getInstancePath());"
+ }
+ }
+ State Ready
+ }
+ }
+ }
+
+ // a simple protocol that is used to demonstrate that actors are connected
+ ProtocolClass PC {
+ incoming {
+ Message sayHello()
+ }
+ outgoing {
+ Message hello(txt: string)
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest2.etmap b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest2.etmap
new file mode 100644
index 000000000..e13a69c66
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest2.etmap
@@ -0,0 +1,11 @@
+MappingModel DynamicActorTest1 {
+ import DynamicActorTest2.* from "DynamicActorTest2.room"
+ import room.generic.physical.* from "../../org.eclipse.etrice.generator.common.tests/models/GenericPhysical.etphys"
+
+ Mapping JavaGenTests -> GenericPhysicalSystem {
+ SubSystemMapping da2Test -> node {
+ ThreadMapping defaultThread -> DefaultPhysicalThread
+ }
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest2.room b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest2.room
new file mode 100644
index 000000000..ba0f65f9b
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest2.room
@@ -0,0 +1,236 @@
+RoomModel DynamicActorTest2 {
+
+ import room.basic.test.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Tests.room"
+ import room.basic.types.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Types.room"
+
+ LogicalSystem JavaGenTests {
+ SubSystemRef da2Test : SubSystem_DynamicActorTest2
+ }
+
+ SubSystemClass SubSystem_DynamicActorTest2 {
+ ActorRef appl : Appl
+
+ LogicalThread defaultThread
+ }
+
+ ActorClass Appl {
+ Structure {
+ ActorRef cont: Container
+ }
+ Behavior { }
+ }
+
+ ActorClass Container {
+ Structure {
+ conjugated Port p0[*]: PC
+ Attribute caseId: int32
+ optional ActorRef optarray[*]: Optional
+
+ Binding p0 and optarray.p0
+ }
+ Behavior {
+ ctor {
+ "caseId = etUnit_openAll(\".\", \"DynamicActorTest2\", \"org.eclipse.etrice.generator.common.tests.DynamicActorTest2\", \"DynamicActorTest2_case\");"
+ }
+ dtor {
+ "etUnit_closeAll(caseId);"
+ }
+
+ StateMachine {
+ Transition init: initial -> CreateOptional2 { }
+ Transition tr0: CreateOptional2 -> CreateOptional1 {
+ triggers {
+ <hello: p0>
+ }
+ action {
+ "EXPECT_TRUE(caseId, \"<|MODEL_LOCATION|>\", txt.equals(\"AC3:/JavaGenTests/da2Test/appl/cont/optarray:0/sub2/deep_sub\"));"
+ }
+ }
+ Transition tr2: CreateOptional1 -> ReceivedHelloAgain {
+ triggers {
+ <hello: p0>
+ }
+ action {
+ "EXPECT_TRUE(caseId, \"<|MODEL_LOCATION|>\", txt.equals(\"AC3:/JavaGenTests/da2Test/appl/cont/optarray:0/sub2/deep_sub\"));"
+ }
+ }
+ Transition tr1: ReceivedHelloAgain -> Destroy0 {
+ triggers {
+ <hello: p0>
+ }
+ action {
+ "EXPECT_TRUE(caseId, \"<|MODEL_LOCATION|>\", txt.equals(\"AC1:/JavaGenTests/da2Test/appl/cont/optarray:1/sub1\"));"
+ }
+ }
+ Transition tr3: Destroy0 -> Destroy1Create2 {
+ triggers {
+ <hello: p0>
+ }
+ action {
+ "EXPECT_TRUE(caseId, \"<|MODEL_LOCATION|>\", txt.equals(\"AC1:/JavaGenTests/da2Test/appl/cont/optarray:1/sub1\"));"
+ }
+ }
+ Transition tr4: Destroy1Create2 -> Done {
+ triggers {
+ <hello: p0>
+ }
+ action {
+ "EXPECT_TRUE(caseId, \"<|MODEL_LOCATION|>\", txt.equals(\"AC3:/JavaGenTests/da2Test/appl/cont/optarray:1/sub2/deep_sub\"));"
+ }
+ }
+ State CreateOptional2 {
+ entry {
+ "optarray.createOptionalActor(\"Optional2\", getThread());"
+ "p0.sayHello();"
+ }
+ }
+ State CreateOptional1 {
+ entry {
+ "optarray.createOptionalActor(\"Optional1\", getThread());"
+ "p0.sayHello();"
+ }
+ }
+ State ReceivedHelloAgain
+ State Destroy0 {
+ entry {
+ "optarray.destroyOptionalActor(0);"
+ "p0.sayHello();"
+ }
+ }
+ State Destroy1Create2 {
+ entry {
+ "optarray.destroyOptionalActor(1);"
+ ""
+ "IRTObject opt = getChild(\"optarray\");"
+ "int size = opt.getChildren().size();"
+ ""
+ "// we expect the RTSystemPort and the InterfaceItemBroker"
+ "EXPECT_EQUAL_INT32(caseId, \"<|MODEL_LOCATION|>\", 2, size);"
+ ""
+ "optarray.createOptionalActor(\"Optional2\", getThread());"
+ "p0.sayHello();"
+ }
+ }
+ State Done {
+ entry {
+ "IRTObject opt = getChild(\"optarray\");"
+ "int size = opt.getChildren().size();"
+ ""
+ "// we expect the RTSystemPort and the InterfaceItemBroker"
+ "// plus an instance of Optional2"
+ "// plus 3 sub ports of RTSystemPort"
+ "EXPECT_EQUAL_INT32(caseId, \"<MODEL_LOCATION|>\", 6, size);"
+ ""
+ "// we grab the leaf actor of the optional sub tree"
+ "IRTObject leafActor = getObject(\"/JavaGenTests/da2Test/appl/cont/optarray/optarray:1/sub2/deep_sub\");"
+ "size = leafActor.getChildren().size();"
+ ""
+ "// we expect an RTSystemPort and p0"
+ "EXPECT_EQUAL_INT32(caseId, \"<MODEL_LOCATION|>\", 2, size);"
+ ""
+ "EXPECT_TRUE(caseId, \"<MODEL_LOCATION|>\", leafActor.getInstancePath().equals(\"/JavaGenTests/da2Test/appl/cont/optarray:1/sub2/deep_sub\"));"
+ ""
+ "etUnit_testFinished(caseId);"
+ }
+ }
+ }
+ }
+ }
+
+ // the class that is referenced as optional by the Container
+ // since it is abstract it just serves as an interface
+ abstract ActorClass Optional {
+ Interface {
+ Port p0: PC
+ }
+ Structure { }
+ Behavior { }
+ }
+
+ // a sub class of Optional which is valid as optional actor
+ ActorClass Optional1 extends Optional {
+ Structure {
+ ActorRef sub1: AC1
+ Binding p0 and sub1.p0
+ }
+ Behavior { }
+ }
+
+ // a sub class of Optional which is valid as optional actor
+ ActorClass Optional2 extends Optional {
+ Structure {
+ ActorRef sub2: AC2
+ Binding p0 and sub2.p0
+ }
+ Behavior { }
+ }
+
+ // the following actor classes are part of the possible optional instance sub trees
+
+ ActorClass AC1 {
+ Interface {
+ Port p0: PC
+ }
+ Structure {
+ external Port p0
+ }
+ Behavior {
+ StateMachine {
+ Transition init: initial -> Ready { }
+ Transition tr0: Ready -> Ready {
+ triggers {
+ <sayHello: p0>
+ }
+ action {
+ "p0.hello(\"AC1:\"+getInstancePath());"
+ }
+ }
+ State Ready
+ }
+ }
+ }
+
+ ActorClass AC2 {
+ Interface {
+ Port p0: PC
+ }
+ Structure {
+ ActorRef deep_sub: AC3
+ Binding p0 and deep_sub.p0
+ }
+ Behavior { }
+ }
+
+ ActorClass AC3 {
+ Interface {
+ Port p0: PC
+ }
+ Structure {
+ external Port p0
+ }
+ Behavior {
+ StateMachine {
+ Transition init: initial -> Ready { }
+ Transition tr0: Ready -> Ready {
+ triggers {
+ <sayHello: p0>
+ }
+ action {
+ "p0.hello(\"AC3:\"+getInstancePath());"
+ }
+ }
+ State Ready
+ }
+ }
+ }
+
+ // a simple protocol that is used to demonstrate that actors are connected
+ ProtocolClass PC {
+ incoming {
+ Message sayHello()
+ }
+ outgoing {
+ Message hello(txt: string)
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest3.room b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest3.room
new file mode 100644
index 000000000..e757ba820
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest3.room
@@ -0,0 +1,235 @@
+RoomModel DynamicActorTest3 {
+
+ import room.basic.test.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Tests.room"
+ import room.basic.types.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Types.room"
+
+ ActorClass Appl {
+ @TestInstance
+ Structure {
+ ActorRef cont: Controller
+ }
+ Behavior { }
+ }
+
+ ActorClass Controller {
+ Structure {
+ conjugated Port pwrk: PWorker
+ conjugated Port opt: PC
+ Attribute caseId: int32
+ ActorRef worker: Worker
+ Binding pwrk and worker.fct
+ Binding opt and worker.opt
+ }
+ Behavior {
+ ctor {
+ "caseId = etUnit_openAll(\".\", \"DynamicActorTest3\", \"org.eclipse.etrice.generator.common.tests.DynamicActorTest3\", \"DynamicActorTest3_case\");"
+ }
+ dtor {
+ "etUnit_closeAll(caseId);"
+ }
+ StateMachine {
+ Transition init: initial -> createOpt1 { }
+ Transition tr0: createOpt1 -> SendHello {
+ triggers {
+ <ok: pwrk>
+ }
+ }
+ Transition tr1: SendHello -> TryCreateInvalid {
+ triggers {
+ <hello: opt>
+ }
+ action {
+ "System.out.println(\"controller received \"+txt);"
+ }
+ }
+ Transition tr2: createOpt1 -> UnexpectedError {
+ triggers {
+ <error: pwrk>
+ }
+ }
+ Transition tr3: TryCreateInvalid -> ExpectedError {
+ triggers {
+ <error: pwrk>
+ }
+ }
+ State createOpt1 {
+ entry {
+ "pwrk.create(\"Optional1\");"
+ }
+ }
+ State SendHello {
+ entry {
+ "opt.sayHello();"
+ }
+ }
+ State TryCreateInvalid {
+ entry {
+ "pwrk.create(\"Optional\");"
+ }
+ }
+ State UnexpectedError
+ State ExpectedError {
+ entry {
+ "etUnit_testFinished(caseId);"
+ }
+ }
+ }
+ }
+ }
+
+ ActorClass Worker {
+ Interface {
+ Port fct: PWorker
+ Port opt: PC
+ }
+ Structure {
+ external Port fct
+ optional ActorRef optRef: Optional
+ Binding opt and optRef.p0
+ }
+ Behavior {
+ // this method prints the passed message and then dumps the object tree consisting of actors and ports
+ Operation dumpTree(msg: string) {
+ "System.out.println(msg);"
+ "System.out.println(((org.eclipse.etrice.runtime.java.messaging.RTObject)getRoot()).toStringRecursive());"
+ }
+
+ StateMachine {
+ Transition init: initial -> Ready { }
+ Transition tr0: Ready -> Ready {
+ triggers {
+ <create: fct>
+ }
+ action {
+ "if (optRef.createOptionalActor(ac, getThread()))"
+ "\tfct.ok();"
+ "else"
+ "\tfct.error();"
+ }
+ }
+ State Ready
+ }
+ }
+ }
+
+ // the class that is referenced as optional by the Worker
+ // since it is abstract it just serves as an interface
+ abstract ActorClass Optional {
+ Interface {
+ Port p0: PC
+ }
+ Structure { }
+ Behavior { }
+ }
+
+ // a sub class of Optional which is valid as optional actor
+ ActorClass Optional1 extends Optional {
+ Structure {
+ ActorRef sub1: AC1
+ Binding p0 and sub1.p0
+ }
+ Behavior { }
+ }
+
+ // a sub class of Optional which is valid as optional actor
+ ActorClass Optional2 extends Optional {
+ Structure {
+ ActorRef sub2: AC2
+ Binding p0 and sub2.p0
+ }
+ Behavior { }
+ }
+
+ // the following actor classes are part of the possible optional instance sub trees
+
+ ActorClass AC1 {
+ Interface {
+ Port p0: PC
+ }
+ Structure {
+ external Port p0
+ conjugated Port hlp: PC
+ ActorRef helper: AC3
+ Binding hlp and helper.p0
+ }
+ Behavior {
+ StateMachine {
+ Transition init: initial -> Ready { }
+ Transition tr0: Ready -> AskHelper {
+ triggers {
+ <sayHello: p0>
+ }
+ }
+ Transition tr1: AskHelper -> Ready {
+ triggers {
+ <hello: hlp>
+ }
+ action {
+ "System.out.println(\"helper said \"+txt);"
+ "p0.hello(\"this is AC1, instance \"+getInstancePath());"
+ }
+ }
+ State Ready
+ State AskHelper {
+ entry {
+ "hlp.sayHello();"
+ }
+ }
+ }
+ }
+ }
+
+ ActorClass AC2 {
+ Interface {
+ Port p0: PC
+ }
+ Structure {
+ ActorRef deep_sub: AC3
+ Binding p0 and deep_sub.p0
+ }
+ Behavior { }
+ }
+
+ ActorClass AC3 {
+ Interface {
+ Port p0: PC
+ }
+ Structure {
+ external Port p0
+ }
+ Behavior {
+ StateMachine {
+ Transition init: initial -> Ready { }
+ Transition tr0: Ready -> Ready {
+ triggers {
+ <sayHello: p0>
+ }
+ action {
+ "p0.hello(\"this is AC3, instance \"+getInstancePath());"
+ }
+ }
+ State Ready
+ }
+ }
+ }
+
+ // a simple protocol that is used to demonstrate that actors are connected
+ ProtocolClass PC {
+ incoming {
+ Message sayHello()
+ }
+ outgoing {
+ Message hello(txt: string)
+ }
+ }
+
+ ProtocolClass PWorker {
+ incoming {
+ Message create(ac: string)
+ }
+ outgoing {
+ Message ok()
+ Message error()
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest4.room b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest4.room
new file mode 100644
index 000000000..7c3b95b27
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest4.room
@@ -0,0 +1,97 @@
+RoomModel DynamicActorTest4 {
+
+ import room.basic.test.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Tests.room"
+ import room.basic.types.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Types.room"
+
+ ActorClass Appl {
+ @TestInstance
+ Structure {
+ ActorRef cont: Container
+ }
+ Behavior { }
+ }
+
+ ActorClass Container {
+ Structure {
+ conjugated Port p0: PC
+ Attribute caseId: int32
+ optional ActorRef opt: Optional
+
+ Binding p0 and opt.p0
+ }
+ Behavior {
+ ctor {
+ "caseId = etUnit_openAll(\".\", \"DynamicActorTest4\", \"org.eclipse.etrice.generator.common.tests.DynamicActorTest4\", \"DynamicActorTest4_case\");"
+ }
+ dtor {
+ "etUnit_closeAll(caseId);"
+ }
+
+ // this method prints the passed message and then dumps the object tree consisting of actors and ports
+ Operation dumpTree(msg: string) {
+ "System.out.println(msg);"
+ "System.out.println(((org.eclipse.etrice.runtime.java.messaging.RTObject)getRoot()).toStringRecursive());"
+ }
+
+ StateMachine {
+ Transition init: initial -> CreateOptional { }
+ Transition tr0: CreateOptional -> Done {
+ triggers {
+ <hello: p0>
+ }
+ action {
+ "System.out.println(txt+\"\\n\");"
+ "opt.destroyOptionalActor();"
+ "dumpTree(\"after deletion of Optional2\");"
+ }
+ }
+ State CreateOptional {
+ entry {
+ "opt.createOptionalActor(\"Optional\", getThread());"
+ "p0.sayHello();"
+ }
+ }
+ State Done {
+ entry {
+ "etUnit_testFinished(caseId);"
+ }
+ }
+ }
+ }
+ }
+
+ // the class that is referenced as optional by the Container
+ // It has an external end port and implements the behavior itself
+ ActorClass Optional {
+ Interface {
+ Port p0: PC
+ }
+ Structure {
+ external Port p0
+ }
+ Behavior {
+ StateMachine {
+ Transition init: initial -> Ready { }
+ Transition tr0: Ready -> Ready {
+ triggers {
+ <sayHello: p0>
+ }
+ action {
+ "p0.hello(\"this is AC1, instance \"+getInstancePath());"
+ }
+ }
+ State Ready
+ }
+ }
+ }
+
+ // a simple protocol that is used to demonstrate that actors are connected
+ ProtocolClass PC {
+ incoming {
+ Message sayHello()
+ }
+ outgoing {
+ Message hello(txt: string)
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest5.room b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest5.room
new file mode 100644
index 000000000..7b761f781
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest5.room
@@ -0,0 +1,149 @@
+RoomModel DynamicActorTest5 {
+
+ import room.basic.test.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Tests.room"
+ import room.basic.types.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Types.room"
+
+ ActorClass Appl {
+ @TestInstance
+ Structure {
+ ActorRef cont: Container
+ }
+ Behavior { }
+ }
+
+ ActorClass Container {
+ Structure {
+ conjugated Port p0: PC
+ Attribute caseId: int32
+ optional ActorRef opt: Optional2
+
+ Binding p0 and opt.p0
+ }
+ Behavior {
+ ctor {
+ "caseId = etUnit_openAll(\".\", \"DynamicActorTest5\", \"org.eclipse.etrice.generator.common.tests.DynamicActorTest5\", \"DynamicActorTest5_case\");"
+ }
+ dtor {
+ "etUnit_closeAll(caseId);"
+ }
+
+ // this method prints the passed message and then dumps the object tree consisting of actors and ports
+ Operation dumpTree(msg: string) {
+ "System.out.println(msg);"
+ "System.out.println(((org.eclipse.etrice.runtime.java.messaging.RTObject)getRoot()).toStringRecursive());"
+ }
+
+ StateMachine {
+ Transition init: initial -> CreateOptional2 { }
+ Transition tr0: CreateOptional2 -> Done {
+ triggers {
+ <hello: p0>
+ }
+ action {
+ "dumpTree(\"after received hello\");"
+ ""
+ "System.out.println(\"received \"+txt);"
+ ""
+ "etUnit_testFinished(caseId);"
+ }
+ }
+ State CreateOptional2 {
+ entry {
+ "opt.createOptionalActor(\"Optional2\", getThread());"
+ "dumpTree(\"after creation of Optional2\");"
+ ""
+ "// at this point the port isn\'t connected since"
+ "// the init message isn\'t processed yet"
+ "// - so no peer port exists"
+ "p0.sayHello();"
+ }
+ }
+ State Done
+ }
+ }
+ }
+
+ ActorClass Optional1 {
+ Interface {
+ Port p0: PC
+ }
+ Structure {
+ ActorRef sub1: AC1
+ Binding p0 and sub1.p0
+ }
+ Behavior { }
+ }
+
+ ActorClass Optional2 {
+ Interface {
+ Port p0: PC
+ }
+ Structure {
+ ActorRef sub2: AC2
+ Binding p0 and sub2.p0
+ }
+ Behavior { }
+ }
+
+ // the following actor classes are part of the possible optional instance sub trees
+
+ ActorClass AC1 {
+ Interface {
+ Port p0: PC
+ }
+ Structure {
+ external Port p0
+ }
+ Behavior {
+ StateMachine {
+ Transition init: initial -> Ready { }
+ State Ready {
+ entry {
+ "p0.hello(\"this is AC1, instance \"+getInstancePath());"
+ }
+ }
+ }
+ }
+ }
+
+ ActorClass AC2 {
+ Interface {
+ Port p0: PC
+ }
+ Structure {
+ ActorRef deep_sub: AC3
+ Binding p0 and deep_sub.p0
+ }
+ Behavior { }
+ }
+
+ ActorClass AC3 {
+ Interface {
+ Port p0: PC
+ }
+ Structure {
+ optional ActorRef nestedOpt: Optional1
+ Binding p0 and nestedOpt.p0
+ }
+ Behavior {
+ StateMachine {
+ Transition init: initial -> Ready { }
+ State Ready {
+ entry {
+ "nestedOpt.createOptionalActor(\"Optional1\", getThread());"
+ }
+ }
+ }
+ }
+ }
+
+ // a simple protocol that is used to demonstrate that actors are connected
+ ProtocolClass PC {
+ incoming {
+ Message sayHello()
+ }
+ outgoing {
+ Message hello(txt: string)
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest6.room b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest6.room
new file mode 100644
index 000000000..a38e80330
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest6.room
@@ -0,0 +1,243 @@
+RoomModel DynamicActorTest6 {
+
+ import room.basic.test.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Tests.room"
+ import room.basic.types.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Types.room"
+
+ ActorClass Appl {
+ @TestInstance
+ Structure {
+ ActorRef ctrl: Controller
+ }
+ Behavior { }
+ }
+
+ ActorClass Controller {
+ Structure {
+ conjugated Port pcont: PCtrl
+ conjugated Port pout: PC
+ conjugated Port pin: PC
+ Attribute caseId: int32
+ ActorRef cont: Container
+ Binding pcont and cont.fct
+ Binding pout and cont.pin
+ Binding pin and cont.pout
+ }
+ Behavior {
+ ctor {
+ "caseId = etUnit_openAll(\".\", \"DynamicActorTest6\", \"org.eclipse.etrice.generator.common.tests.DynamicActorTest6\", \"DynamicActorTest6_case\");"
+ }
+ dtor {
+ "etUnit_closeAll(caseId);"
+ }
+ StateMachine {
+ Transition init: initial -> CreateOptionals { }
+ Transition tr0: CreateOptionals -> Sending {
+ triggers {
+ <done: pcont>
+ }
+ }
+ Transition tr1: Sending -> Destroy {
+ triggers {
+ <hello: pin>
+ }
+ action {
+ "System.out.println(\"Controller received: \"+txt);"
+ }
+ }
+ Transition tr2: Destroy -> CreateAgain {
+ triggers {
+ <done: pcont>
+ }
+ }
+ Transition tr3: CreateAgain -> SendAgain {
+ triggers {
+ <done: pcont>
+ }
+ }
+ Transition tr4: SendAgain -> Done {
+ triggers {
+ <hello: pin>
+ }
+ action {
+ "System.out.println(\"Controller received: \"+txt);"
+ }
+ }
+ State CreateOptionals {
+ entry {
+ "pcont.createOpts();"
+ }
+ }
+ State Sending {
+ entry {
+ "pout.sayHello();"
+ }
+ }
+ State Done {
+ entry {
+ "etUnit_testFinished(caseId);"
+ }
+ }
+ State Destroy {
+ entry {
+ "pcont.destroyOpts();"
+ }
+ }
+ State CreateAgain {
+ entry {
+ "pcont.createOpts();"
+ }
+ }
+ State SendAgain {
+ entry {
+ "pout.sayHello();"
+ }
+ }
+ }
+ }
+ }
+
+ ActorClass Container {
+ Interface {
+ Port fct: PCtrl
+ Port pout: PC
+ Port pin: PC
+ }
+ Structure {
+ external Port fct
+ optional ActorRef opt1: Optional1
+ optional ActorRef opt2: Optional2
+ Binding opt1.pout and opt2.pin
+ Binding pin and opt1.pin
+ Binding pout and opt2.pout
+ }
+ Behavior {
+ // this method prints the passed message and then dumps the object tree consisting of actors and ports
+ Operation dumpTree(msg: string) {
+ "System.out.println(msg);"
+ "System.out.println(((org.eclipse.etrice.runtime.java.messaging.RTObject)getRoot()).toStringRecursive());"
+ }
+ StateMachine {
+ Transition init: initial -> Ready { }
+ Transition tr0: Ready -> Ready {
+ triggers {
+ <createOpts: fct>
+ }
+ action {
+ "opt1.createOptionalActor(\"Optional1\", getThread());"
+ "opt2.createOptionalActor(\"Optional2\", getThread());"
+ "dumpTree(\"after creation of op1 and opt2\");"
+ "fct.done();"
+ }
+ }
+ Transition tr1: Ready -> Ready {
+ triggers {
+ <destroyOpts: fct>
+ }
+ action {
+ "opt1.destroyOptionalActor();"
+ "opt2.destroyOptionalActor();"
+ "fct.done();"
+ }
+ }
+ State Ready
+ }
+ }
+ }
+
+ ActorClass Optional1 {
+ Interface {
+ Port pout: PC
+ Port pin: PC
+ }
+ Structure {
+ ActorRef sub1: AC1
+ Binding pin and sub1.pin
+ Binding pout and sub1.pout
+ }
+ Behavior { }
+ }
+
+ ActorClass Optional2 {
+ Interface {
+ Port pout: PC
+ conjugated Port pin: PC
+ }
+ Structure {
+ ActorRef sub2: AC2
+ Binding pout and sub2.pout
+ Binding pin and sub2.pin
+ }
+ Behavior { }
+ }
+
+ ActorClass AC1 {
+ Interface {
+ Port pout: PC
+ Port pin: PC
+ }
+ Structure {
+ external Port pout
+ external Port pin
+ }
+ Behavior {
+ StateMachine {
+ Transition init: initial -> Ready { }
+ Transition tr0: Ready -> Ready {
+ triggers {
+ <sayHello: pin>
+ }
+ action {
+ "pout.hello(\"this is AC1, instance \"+getInstancePath());"
+ }
+ }
+ State Ready
+ }
+ }
+ }
+
+ ActorClass AC2 {
+ Interface {
+ Port pout: PC
+ conjugated Port pin: PC
+ }
+ Structure {
+ external Port pout
+ external Port pin
+ }
+ Behavior {
+ StateMachine {
+ Transition init: initial -> Ready { }
+ Transition tr0: Ready -> Ready {
+ triggers {
+ <hello: pin>
+ }
+ action {
+ "System.out.println(\"AC2 received \"+txt);"
+ ""
+ "pout.hello(\"AC2: forwarding \"+txt);"
+ }
+ }
+ State Ready
+ }
+ }
+ }
+
+ ProtocolClass PC {
+ incoming {
+ Message sayHello()
+ }
+ outgoing {
+ Message hello(txt: string)
+ }
+ }
+
+ ProtocolClass PCtrl {
+ incoming {
+ Message createOpts()
+ Message destroyOpts()
+ }
+ outgoing {
+ Message done()
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest7.etmap b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest7.etmap
new file mode 100644
index 000000000..4bd054cd2
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest7.etmap
@@ -0,0 +1,11 @@
+MappingModel DynamicActorTest1 {
+ import DynamicActorTest7.* from "DynamicActorTest7.room"
+ import room.generic.physical.* from "../../org.eclipse.etrice.generator.common.tests/models/GenericPhysical.etphys"
+
+ Mapping JavaGenTests -> GenericPhysicalSystem {
+ SubSystemMapping da7Test -> node {
+ ThreadMapping defaultThread -> DefaultPhysicalThread
+ }
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest7.room b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest7.room
new file mode 100644
index 000000000..32648c0e6
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicActorTest7.room
@@ -0,0 +1,375 @@
+RoomModel DynamicActorTest7 {
+
+ import room.basic.test.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Tests.room"
+ import room.basic.types.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Types.room"
+
+ LogicalSystem JavaGenTests {
+ SubSystemRef da7Test : SubSystem_DynamicActorTest7
+ }
+
+ SubSystemClass SubSystem_DynamicActorTest7 {
+ ActorRef main : Appl
+
+ LogicalThread defaultThread
+ }
+
+ ActorClass Appl {
+ Structure {
+ ActorRef cont: Container
+ }
+ Behavior { }
+ }
+
+ ActorClass Container {
+ Structure {
+ usercode1 {
+ "import java.io.File;"
+ }
+ usercode2 {
+ "private static final String FIRST_OPT_OBJ = \"firstOpt.obj\";"
+ "private static final String SECOND_OPT_OBJ = \"secondOpt.obj\";"
+ }
+ conjugated Port op: PStep
+ conjugated Port opa [*]: PStep
+
+ Attribute caseId: int32
+
+ optional ActorRef opt: Optional
+ optional ActorRef optarr [*]: Optional
+
+ Binding op and opt.fct
+ Binding opa and optarr.fct
+ }
+ Behavior {
+ ctor {
+ "caseId = etUnit_openAll(\".\", \"DynamicActorTest7\", \"org.eclipse.etrice.generator.common.tests.DynamicActorTest7\", \"DynamicActorTest7_case\");"
+ }
+ dtor {
+ "etUnit_closeAll(caseId);"
+ }
+ Operation clean() {
+ "File f = new File(FIRST_OPT_OBJ);"
+ "if (f.exists())"
+ "\tf.delete();"
+ }
+ StateMachine {
+ Transition init: initial -> Init { }
+ Transition tr0: Init -> DestroyAndCreate {
+ triggers {
+ <hello: op>
+ }
+ action {
+ "System.out.println(\"received \"+txt);"
+ }
+ }
+ Transition tr1: DestroyAndCreate -> DestroyAndRestore {
+ triggers {
+ <hello: op>
+ }
+ action {
+ "System.out.println(\"received \"+txt);"
+ }
+ }
+ Transition tr2: DestroyAndRestore -> LoadInArray {
+ triggers {
+ <hello: op>
+ }
+ action {
+ "System.out.println(\"received \"+txt);"
+ }
+ }
+ Transition tr3: LoadInArray -> ReceivedHello {
+ triggers {
+ <hello: opa>
+ }
+ action {
+ "System.out.println(\"received \"+txt);"
+ }
+ }
+ Transition tr4: ReceivedHello -> Done {
+ triggers {
+ <hello: opa>
+ }
+ action {
+ "System.out.println(\"received \"+txt);"
+ }
+ }
+ State Init {
+ entry {
+ "clean();"
+ "FilePersistor.createAndLoad(opt, getThread(), FIRST_OPT_OBJ, \"Optional1\");"
+ "op.step();"
+ "op.step();"
+ "op.sayHello();"
+ }
+ }
+ State DestroyAndCreate {
+ entry {
+ "FilePersistor.saveAndDestroy(opt, FIRST_OPT_OBJ);"
+ "FilePersistor.createAndLoad(opt, getThread(), SECOND_OPT_OBJ, \"Optional2\");"
+ "op.step();"
+ "op.step();"
+ "op.sayHello();"
+ }
+ }
+ State DestroyAndRestore {
+ entry {
+ "FilePersistor.saveAndDestroy(opt, SECOND_OPT_OBJ);"
+ "FilePersistor.createAndLoad(opt, getThread(), FIRST_OPT_OBJ, \"Optional1\");"
+ "op.sayHello();"
+ }
+ }
+ State Done {
+ entry {
+ "IRTObject object = getObject(\"/JavaGenTests/da7Test/main/cont/optarr/optarr:0/sub\");"
+ "EXPECT_TRUE(caseId, \"object 0 of optarr is an instance of actor class Sub1\", object instanceof Sub1);"
+ ""
+ "Sub1 inst = (Sub1) object;"
+ "EXPECT_EQUAL_INT32(caseId, \"state\", Sub1.STATE_Step3_StepA, inst.getState());"
+ "EXPECT_EQUAL_INT32(caseId, \"current value of ival\", 123, inst.getIval());"
+ "EXPECT_EQUAL_INT16(caseId, \"current value of sval\", (short)456, inst.getSval());"
+ "EXPECT_EQUAL_INT8(caseId, \"current value of bval\", (byte)3, inst.getBval());"
+ "EXPECT_TRUE(caseId, \"changed string\", \"changed\".equals(inst.getSome()[1].getStr()));"
+ "EXPECT_EQUAL_FLOAT32(caseId, \"current vaue of\", 3.14159f, inst.getDerived().getSome().getFval()[2], 0.001f);"
+ "EXPECT_EQUAL_UINT8(caseId, \"current value of cval\", 'x', inst.getCval());"
+ ""
+ "etUnit_testFinished(caseId);"
+ }
+ }
+ State LoadInArray {
+ entry {
+ "FilePersistor.createAndLoad(optarr, getThread(), FIRST_OPT_OBJ, \"Optional1\");"
+ "FilePersistor.createAndLoad(optarr, getThread(), SECOND_OPT_OBJ, \"Optional2\");"
+ "opa.sayHello();"
+ }
+ }
+ State ReceivedHello
+ }
+ }
+ }
+
+ abstract ActorClass Optional {
+ Interface {
+ Port fct: PStep
+ }
+ Structure { }
+ Behavior { }
+ }
+
+ ActorClass Optional1 extends Optional {
+ Structure {
+ ActorRef ^sub: Sub1
+ Binding fct and ^sub.fct
+ }
+ Behavior { }
+ }
+
+ ActorClass Optional2 extends Optional {
+ Structure {
+ ActorRef ^sub: Sub2
+ Binding fct and ^sub.fct
+ }
+ Behavior { }
+ }
+
+ ActorClass Sub1Base {
+ Structure {
+ Attribute cval: char
+ }
+ }
+
+ ActorClass Sub1 extends Sub1Base {
+ Interface {
+ Port fct: PStep
+ }
+ Structure {
+ external Port fct
+ conjugated Port dp: PStep
+
+ Attribute ival: int32
+ Attribute sval: int16
+ Attribute bval: int8
+ Attribute some[3]: SomeData
+ Attribute other: OtherData
+ Attribute derived: DerivedData
+
+ ActorRef deep: DeepSub1
+ Binding dp and deep.fct
+ }
+ Behavior {
+ StateMachine {
+ Transition init: initial -> Step1 { }
+ Transition tr0: Step1 -> Step2 {
+ triggers {
+ <step: fct>
+ }
+ action {
+ "dp.step();"
+ }
+ }
+ Transition tr1: Step2 -> Step3 {
+ triggers {
+ <step: fct>
+ }
+ action {
+ "dp.step();"
+ }
+ }
+ Transition tr2: my tp0 -> my tp0 {
+ triggers {
+ <sayHello: fct>
+ }
+ action {
+ "fct.hello(getClassName()+\", state=\"+stateStrings[getState()]+\", path= \"+getInstancePath());"
+ }
+ }
+ handler TransitionPoint tp0
+ State Step1 {
+ entry {
+ "ival = 1;"
+ "sval = 2;"
+ "bval = 3;"
+ "cval = 'x';"
+ }
+ }
+ State Step2 {
+ entry {
+ "ival = 123;"
+ "some[1].str = \"changed\";"
+ "derived.some.fval[2] = 3.14159f;"
+ }
+ }
+ State Step3 {
+ subgraph {
+ Transition init: initial -> StepA { }
+ Transition tr0: StepA -> StepB {
+ triggers {
+ <step: fct>
+ }
+ action {
+ "dp.step();"
+ }
+ }
+ Transition tr1: StepB -> StepC {
+ triggers {
+ <step: fct>
+ }
+ action {
+ "dp.step();"
+ }
+ }
+ State StepA {
+ entry {
+ "sval = 456;"
+ }
+ }
+ State StepB {
+ entry {
+ "bval = 13;"
+ }
+ }
+ State StepC
+ }
+ }
+ }
+ }
+ }
+
+ ActorClass DeepSub1 {
+ Interface {
+ Port fct: PStep
+ }
+ Structure {
+ external Port fct
+ }
+ Behavior {
+ StateMachine {
+ Transition init: initial -> Step1 { }
+ Transition tr0: Step1 -> Step2 {
+ triggers {
+ <step: fct>
+ }
+ }
+ Transition tr1: Step2 -> Step3 {
+ triggers {
+ <step: fct>
+ }
+ }
+ Transition tr2: Step3 -> Step5 {
+ triggers {
+ <step: fct>
+ }
+ }
+ Transition tr3: Step5 -> Step6 {
+ triggers {
+ <step: fct>
+ }
+ }
+ Transition tr4: Step6 -> Step7 {
+ triggers {
+ <step: fct>
+ }
+ }
+ State Step1
+ State Step2
+ State Step3
+ State Step5
+ State Step6
+ State Step7
+ }
+ }
+ }
+
+ ActorClass Sub2 {
+ Interface {
+ Port fct: PStep
+ }
+ Structure {
+ external Port fct
+ }
+ Behavior {
+ StateMachine {
+ Transition init: initial -> Ready { }
+ Transition tr0: Ready -> Ready {
+ triggers {
+ <step: fct>
+ }
+ }
+ Transition tr1: Ready -> Ready {
+ triggers {
+ <sayHello: fct>
+ }
+ action {
+ "fct.hello(getClassName()+\", state=\"+stateStrings[getState()]+\", path= \"+getInstancePath());"
+ }
+ }
+ State Ready
+ }
+ }
+ }
+
+ ProtocolClass PStep {
+ incoming {
+ Message step()
+ Message sayHello()
+ }
+ outgoing {
+ Message hello(txt: string)
+ }
+ }
+
+ DataClass SomeData {
+ Attribute fval[3]: float32 = "1.0"
+ Attribute dval: float64 = "123.4"
+ Attribute str: string = "\"Text\""
+ }
+
+ DataClass OtherData {
+ Attribute some: SomeData
+ Attribute bval: boolean = "false"
+ }
+
+ DataClass DerivedData extends OtherData {
+ Attribute cval[3]: char = "{'a', 'b', 'c'}"
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicConfigTest.config b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicConfigTest.config
new file mode 100644
index 000000000..13fd8a62b
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicConfigTest.config
@@ -0,0 +1,121 @@
+ConfigModel DynamicConfigTest {
+
+ import DynamicConfigTest.* from "DynamicConfigTest.room"
+
+
+ SubSystemConfig System_DynamicConfigTest / main {
+ dynamic configuration {
+ user import ""
+ user constructor "ConfigSourceTestInstance.getInstance()"
+ polling interval 200 ms
+ }
+ }
+
+ ActorClassConfig Testee_ac {
+ Attr aBool = false
+ Attr aInt8 = 0 {
+ min = -1 max = 59
+ }
+ Attr aInt16 = 0 {
+ min = -1 max = 59
+ }
+ Attr aInt32 = 0 {
+ min = -1 max = 59
+ }
+ Attr aInt64 = 0 {
+ min = -1 max = 59
+ }
+ Attr aFloat32 = 0.0 {
+ min = -1.0 max = 59.0
+ }
+ Attr aFloat64 = 0.0 {
+ min = -1.0 max = 59.0
+ }
+ Attr aChar = ''
+ Attr aString = ""
+ Attr aBool_array = false
+ Attr aInt8_array = 0 {
+ min = -1 max = 59
+ }
+ Attr aInt16_array = 0 {
+ min = -1 max = 59
+ }
+ Attr aInt32_array = 0 {
+ min = -1 max = 59
+ }
+ Attr aInt64_array = 0 {
+ min = -1 max = 59
+ }
+ Attr aFloat32_array = 0.0 {
+ min = -1.0 max = 59.0
+ }
+ Attr aFloat64_array = 0.0 {
+ min = -1.0 max = 59.0
+ }
+ Attr aChar_array
+ Attr dc {
+ Attr nested {
+ Attr aInt32 = 0 {
+ min = -1 max = 59
+ }
+ }
+ }
+ }
+
+ ActorInstanceConfig System_DynamicConfigTest / main / testee {
+ Attr aInt8 {
+ dynamic configuration read
+ }
+ Attr aInt16 {
+ dynamic configuration read
+ }
+ Attr aInt32 {
+ dynamic configuration read
+ }
+ Attr aInt64 {
+ dynamic configuration read
+ }
+ Attr aFloat32 {
+ dynamic configuration read
+ }
+ Attr aFloat64 {
+ dynamic configuration read
+ }
+ Attr aBool {
+ dynamic configuration read
+ }
+ Attr aChar {
+ dynamic configuration read
+ }
+ Attr aString {
+ dynamic configuration read
+ }
+ Attr aInt8_array {
+ dynamic configuration read
+ }
+ Attr aInt16_array {
+ dynamic configuration read
+ }
+ Attr aInt32_array {
+ dynamic configuration read
+ }
+ Attr aInt64_array {
+ dynamic configuration read
+ }
+ Attr aFloat32_array {
+ dynamic configuration read
+ }
+ Attr aFloat64_array {
+ dynamic configuration read
+ }
+ Attr aBool_array {
+ dynamic configuration read
+ }
+ Attr aChar_array {
+ dynamic configuration read
+ }
+ Attr dc {
+ dynamic configuration read
+ }
+ }
+}
diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicConfigTest.etmap b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicConfigTest.etmap
new file mode 100644
index 000000000..3ec15a8f2
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicConfigTest.etmap
@@ -0,0 +1,9 @@
+MappingModel DynamicConfigTest {
+
+ import DynamicConfigTest.* from "DynamicConfigTest.room"
+ import room.generic.physical.* from "GenericPhysical.etphys"
+
+ Mapping System_DynamicConfigTest -> GenericPhysicalSystem {
+ SubSystemMapping main -> node {}
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicConfigTest.room b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicConfigTest.room
new file mode 100644
index 000000000..f7ab9895d
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicConfigTest.room
@@ -0,0 +1,202 @@
+RoomModel DynamicConfigTest {
+
+ import room.basic.types.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Types.room"
+ import room.basic.service.timing.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/TimingService.room"
+
+ LogicalSystem System_DynamicConfigTest{
+ SubSystemRef main : SubSystem_DynamicConfigTest
+ }
+
+ SubSystemClass SubSystem_DynamicConfigTest {
+ ActorRef testee: Testee_ac
+ ActorRef timingService: ATimingService
+ LayerConnection ref testee satisfied_by timingService.timer
+ }
+
+ ActorClass Testee_ac {
+ Structure {
+ usercode1 {
+ "import java.util.HashMap;"
+ "import java.util.Map;"
+ "import org.eclipse.etrice.runtime.java.config.IConfigSource;"
+ }
+ SAP timer: PTimer
+ Attribute caseId: int32
+ Attribute testId: int32 = "1"
+
+ // no dynConfig
+ Attribute sString: string
+
+ // dynConfig
+ Attribute aInt8: int8
+ Attribute aInt16: int16
+ Attribute aInt32: int32
+ Attribute aInt64: int64
+ Attribute aBool: boolean
+ Attribute aFloat32: float32
+ Attribute aFloat64: float64
+ Attribute aChar: char
+ Attribute aString: string
+ Attribute aInt8_array [ 2 ]: int8
+ Attribute aInt16_array [ 2 ]: int16
+ Attribute aInt32_array [ 2 ]: int32
+ Attribute aInt64_array [ 2 ]: int64
+ Attribute aBool_array [ 2 ]: boolean
+ Attribute aFloat32_array [ 2 ]: float32
+ Attribute aFloat64_array [ 2 ]: float64
+ Attribute aChar_array [ 2 ]: char
+ Attribute dc: Data_dc
+ }
+ Behavior {
+ ctor {
+ "etUnit_open(\".\", \"DynamicConfigTest\");"
+ "etUnit_openTestSuite(\"org.eclipse.etrice.generator.common.tests.DynamicConfigTest\");"
+ "caseId = etUnit_openTestCase(\"DynamicConfigTest_case_Testee_ac\");"
+ }
+ dtor {
+ "etUnit_closeTestCase(caseId);"
+ "etUnit_closeTestSuite();"
+ "etUnit_close();"
+ }
+ StateMachine {
+ Transition t0: initial -> ChangeConfigValid { }
+ Transition t1: ChangeConfigValid -> Test {
+ triggers {
+ <timeout: timer>
+ }
+ action {
+ "testId++;"
+ }
+ }
+ Transition t2: Test -> ChangeConfigInvalid {
+ triggers {
+ <timeout: timer guard {
+ "testId==2"
+ }>
+ }
+ }
+ Transition t3: ChangeConfigInvalid -> Test {
+ triggers {
+ <timeout: timer>
+ }
+ action {
+ "testId++;"
+ }
+ }
+ Transition t4: Test -> Done {
+ triggers {
+ <timeout: timer guard {
+ "testId==4"
+ }>
+ }
+ }
+ Transition tr0: Test -> ChangeConfigValid {
+ triggers {
+ <timeout: timer guard {
+ "testId==3"
+ }>
+ }
+ }
+ State ChangeConfigValid {
+ entry {
+ "IConfigSource source = ConfigSourceTestInstance.getInstance();"
+ "String path = this.getInstancePath();"
+ "Map<String, Object> testValues = new HashMap<String, Object>();"
+ "testValues.put(path+\"/aInt8\", 50);"
+ "testValues.put(path+\"/aInt16\", 51);"
+ "testValues.put(path+\"/aInt32\", 52);"
+ "testValues.put(path+\"/aInt64\", 53);"
+ "testValues.put(path+\"/aFloat32\", 5.4f);"
+ "testValues.put(path+\"/aFloat64\", 5.5);"
+ "testValues.put(path+\"/aChar\", 'B');"
+ "testValues.put(path+\"/aString\", \"Do-NOT-UPDATE-me\");"
+ "testValues.put(path+\"/aBool\", true);"
+ "testValues.put(path+\"/dc/nested/aInt32\", 56);"
+ "testValues.put(path+\"/dc/aString\", \"Okay\");"
+ "testValues.put(path+\"/aInt8_array\", new Byte[]{50,40});"
+ "testValues.put(path+\"/aInt16_array\", new Short[]{51,41});"
+ "testValues.put(path+\"/aInt32_array\", new Integer[]{52,42});"
+ "testValues.put(path+\"/aInt64_array\", new Long[]{53L,43L});"
+ "testValues.put(path+\"/aFloat32_array\", new Float[]{5.4f, 4.4f});"
+ "testValues.put(path+\"/aFloat64_array\", new Double[]{5.5, 4.5});"
+ "testValues.put(path+\"/aChar_array\", \"BB\");"
+ "testValues.put(path+\"/aBool_array\", new Boolean[]{true, false});"
+ "source.writeValues(testValues);"
+ "timer.startTimer(400);"
+ }
+ }
+ State ChangeConfigInvalid {
+ entry {
+ // do not update aString
+ "getAStringLock().forbidUpdate();"
+
+ "IConfigSource source = ConfigSourceTestInstance.getInstance();"
+ "String path = this.getInstancePath();"
+ "Map<String, Object> testValues = new HashMap<String, Object>();"
+ "testValues.put(path+\"/aInt8\", 128);"
+ "testValues.put(path+\"/aInt16\", 61);"
+ "testValues.put(path+\"/aInt32\", -2);"
+ "testValues.put(path+\"/aInt64\", Long.MAX_VALUE);"
+ "testValues.put(path+\"/aFloat32\", -100f);"
+ "testValues.put(path+\"/aFloat64\", 100d);"
+ "testValues.put(path+\"/aChar\", \"string\");"
+ "testValues.put(path+\"/aString\", \"VALID-String\");"
+ "testValues.put(path+\"/aBool\", \"true\");"
+ "testValues.put(path+\"/dc/aString\", 0.89898);"
+ "testValues.put(path+\"/dc/nested/aInt32\", 62);"
+ "testValues.put(path+\"/aInt8_array\", 128);"
+ "testValues.put(path+\"/aInt16_array\", new Short[]{-1,-2});"
+ "testValues.put(path+\"/aInt32_array\", new Integer[]{60,59});"
+ "testValues.put(path+\"/aInt64_array\", new Long[]{60000L,60000L});"
+ "testValues.put(path+\"/aFloat32_array\", new Float[]{0f, -2f});"
+ "testValues.put(path+\"/aFloat64_array\", \"string\");"
+ "testValues.put(path+\"/aChar_array\", \"BBB\");"
+ "testValues.put(path+\"/aBool_array\", 500);"
+ "source.writeValues(testValues);"
+ "timer.startTimer(400);"
+ }
+ }
+ State Test {
+ entry {
+ "EXPECT_EQUAL_INT8(caseId, \"1:Testee_ac\", (byte)50, getAInt8());"
+ "EXPECT_EQUAL_INT16(caseId, \"2:Testee_ac\", (short)51, getAInt16());"
+ "EXPECT_EQUAL_INT32(caseId, \"3:Testee_ac\", 52, getAInt32());"
+ "EXPECT_TRUE(caseId, \"4:Testee_ac\", getAInt64() == 53L);"
+ "EXPECT_EQUAL_FLOAT32(caseId, \"5:Testee_ac\", 5.4f, getAFloat32(), 0.1f);"
+ "EXPECT_TRUE(caseId, \"6:Testee_ac\", getAFloat64() == 5.5);"
+ "EXPECT_TRUE(caseId, \"7:Testee_ac\", getAChar() == 'B');"
+ "EXPECT_TRUE(caseId, \"8:Testee_ac\", \"Do-NOT-UPDATE-me\".equals(getAString()));"
+ "EXPECT_TRUE(caseId, \"9:Testee_ac\", getABool() == true);"
+ "EXPECT_TRUE(caseId, \"10:Testee_ac\", getAInt8_array()[0] == 50 && getAInt8_array()[1] == 40);"
+ "EXPECT_TRUE(caseId, \"11:Testee_ac\", getAInt16_array()[0] == 51 && getAInt16_array()[1] == 41);"
+ "EXPECT_TRUE(caseId, \"12:Testee_ac\", getAInt32_array()[0] == 52 && getAInt32_array()[1] == 42);"
+ "EXPECT_TRUE(caseId, \"13:Testee_ac\", getAInt64_array()[0] == 53L && getAInt64_array()[1] == 43L);"
+ "EXPECT_EQUAL_FLOAT32(caseId, \"14.1:Testee_ac\", 5.4f, getAFloat32_array()[0], 0.1f);"
+ "EXPECT_EQUAL_FLOAT32(caseId, \"14.2:Testee_ac\", 4.4f, getAFloat32_array()[1], 0.1f);"
+ "EXPECT_TRUE(caseId, \"15:Testee_ac\", getAFloat64_array()[0] == 5.5 && getAFloat64_array()[1] == 4.5);"
+ "EXPECT_TRUE(caseId, \"16:Testee_ac\", String.valueOf(getAChar_array()).equals(\"BB\"));"
+ "EXPECT_TRUE(caseId, \"18:Testee_ac\", getABool_array()[0] == true && getABool_array()[1] == false);"
+ "EXPECT_TRUE(caseId, \"19:Testee_ac\", \"Okay\".equals(getDc().getAString()));"
+ "EXPECT_TRUE(caseId, \"20:Testee_ac\", getDc().getNested().getAInt32() == 56);"
+ "timer.startTimer(1);"
+ }
+ }
+ State Done {
+ entry {
+ "\tetUnit_testFinished(caseId);"
+ }
+ }
+ }
+ }
+ }
+
+ DataClass Data_dc {
+ Attribute aString:string
+ Attribute nested: Data_nested_dc
+ }
+
+ DataClass Data_nested_dc {
+ Attribute aInt32: int32
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/DynamicConfigTest.rt-config b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicConfigTest.rt-config
new file mode 100644
index 000000000..c27ad68cf
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.java.tests/models/DynamicConfigTest.rt-config
@@ -0,0 +1,20 @@
+/System_DynConfigTest/subSystem/testee/aBool=true
+/System_DynConfigTest/subSystem/testee/aBool_array={ true,false }
+/System_DynConfigTest/subSystem/testee/aChar="B"
+/System_DynConfigTest/subSystem/testee/aChar_array="BB"
+/System_DynConfigTest/subSystem/testee/aFloat32=5.4
+/System_DynConfigTest/subSystem/testee/aFloat32_array={ 5.4,4.4 }
+/System_DynConfigTest/subSystem/testee/aFloat64=5.5
+/System_DynConfigTest/subSystem/testee/aFloat64_array={ 5.5,4.5 }
+/System_DynConfigTest/subSystem/testee/aInt16=51
+/System_DynConfigTest/subSystem/testee/aInt16_array={ 51,41 }
+/System_DynConfigTest/subSystem/testee/aInt32=52
+/System_DynConfigTest/subSystem/testee/aInt32_array={ 52,42 }
+/System_DynConfigTest/subSystem/testee/aInt64=53
+/System_DynConfigTest/subSystem/testee/aInt64_array={ 53,43 }
+/System_DynConfigTest/subSystem/testee/aInt8=50
+/System_DynConfigTest/subSystem/testee/aInt8_array={ 50,40 }
+/System_DynConfigTest/subSystem/testee/aString="Do-NOT-UPDATE-me"
+/System_DynConfigTest/subSystem/testee/dc/aString="Okay"
+/System_DynConfigTest/subSystem/testee/dc/nested/aInt32=56
+polling_timer[ms]=200
diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/StoreRestoreTest.room b/tests/org.eclipse.etrice.generator.java.tests/models/StoreRestoreTest.room
new file mode 100644
index 000000000..bf9b8f9c5
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.java.tests/models/StoreRestoreTest.room
@@ -0,0 +1,217 @@
+RoomModel StoreRestoreTest {
+
+ import room.basic.test.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Tests.room"
+
+ ActorClass StoreRestore_Top {
+ @TestInstance
+ Structure {
+ ActorRef tester: Tester
+ ActorRef testee: Testee
+ Binding tester.prt and testee.prt
+ }
+ Behavior { }
+ }
+
+ ActorClass Testee {
+ Interface {
+ Port prt: PC
+ }
+ Structure {
+ usercode1 { "import StoreRestore.ObjectHolder;" }
+
+ external Port prt
+
+ Attribute ival: int16
+ Attribute iarr [ 3 ]: int32
+ Attribute sdval: SomeData
+ Attribute sdarr [ 5 ]: SomeData
+ Attribute cdval: ComplexData
+ }
+ Behavior {
+ Operation doStore() {
+ "System.out.println(\"doStore()\");"
+ "IActorClassDataObject dataObject = newDataObject();"
+ "store(dataObject);"
+ "ObjectHolder.setObject(dataObject);"
+ }
+ Operation doRestore() {
+ "System.out.println(\"doRestore()\");"
+ "IActorClassDataObject dataObject = ObjectHolder.getObject();"
+ "restore(dataObject);"
+ }
+ StateMachine {
+ Transition tr0: my tp0 -> Restore {
+ triggers {
+ <restore: prt>
+ }
+ }
+ Transition init: initial -> Begin { }
+ Transition tr1: Begin -> Store {
+ triggers {
+ <step: prt>
+ }
+ }
+ Transition tr2: Store -> state2 {
+ triggers {
+ <step: prt>
+ }
+ }
+ Transition tr3: state2 -> state3 {
+ triggers {
+ <step: prt>
+ }
+ }
+ TransitionPoint tp0
+ State Begin {
+ entry {
+ "ival = 3;"
+ }
+ }
+ State Store {
+ entry {
+ "System.out.println(\"<|MODEL_LOCATION|>\");"
+ "setFinalAction(new SingleFinalAction() {"
+ "\tpublic void run() {"
+ "\t\tdoStore();"
+ "\t}"
+ "});"
+ }
+ }
+ State state2 {
+ entry {
+ "prt.valueIs(ival);"
+ ""
+ "ival = 123;"
+ }
+ }
+ State Restore {
+ entry {
+ "System.out.println(\"<|MODEL_LOCATION|>\");"
+ "setFinalAction(new SingleFinalAction() {"
+ "\tpublic void run() {"
+ "\t\tdoRestore();"
+ "\t}"
+ "});"
+ }
+ }
+ State state3 {
+ entry {
+ "ival = 456;"
+ ""
+ "prt.answer();"
+ }
+ }
+ }
+ }
+ }
+
+ ActorClass Tester {
+ Interface {
+ conjugated Port prt: PC
+ }
+ Structure {
+ external Port prt
+
+ Attribute caseId: int32
+ Attribute counter: int32 = "0"
+ }
+ Behavior {
+ ctor {
+ "caseId = etUnit_openAll(\".\", \"StoreRestoreTest\", \"org.eclipse.etrice.generator.common.tests.StoreRestoreTest\", \"StoreRestoreTest_case\");"
+ }
+ dtor {
+ "etUnit_closeAll(caseId);"
+ }
+
+ StateMachine {
+ Transition init: initial -> Prepare { }
+ Transition tr1: Loop2 -> cp cp0 {
+ triggers {
+ <answer: prt>
+ }
+ }
+ Transition tr2: cp cp0 -> Done
+ Transition tr3: cp cp0 -> Loop {
+ cond {
+ "++counter<10"
+ }
+ }
+ Transition tr0: Prepare -> Prepare2 {
+ triggers {
+ <valueIs: prt>
+ }
+ action {
+ "EXPECT_EQUAL_INT16(caseId, \"check old value <|MODEL_LOCATION|>\", (short)3, val);"
+ }
+ }
+ Transition tr4: Prepare2 -> Loop {
+ triggers {
+ <answer: prt>
+ }
+ }
+ Transition tr5: Loop -> Loop2 {
+ triggers {
+ <valueIs: prt>
+ }
+ action {
+ "EXPECT_EQUAL_INT16(caseId, \"check old value <|MODEL_LOCATION|>\", (short)3, val);"
+ }
+ }
+ ChoicePoint cp0
+ State Prepare {
+ entry {
+ "prt.step();"
+ "prt.step();"
+ }
+ }
+ State Loop {
+ entry {
+ "prt.restore();"
+ ""
+ "prt.step();"
+ "prt.step();"
+ }
+ }
+ State Done {
+ entry {
+ "etUnit_testFinished(caseId);"
+ }
+ }
+ State Prepare2 {
+ entry {
+ "prt.step();"
+ }
+ }
+ State Loop2 {
+ entry {
+ "prt.step();"
+ }
+ }
+ }
+ }
+ }
+
+ ProtocolClass PC {
+ incoming {
+ Message step()
+ Message restore()
+ }
+ outgoing {
+ Message answer()
+ Message valueIs(val: int16)
+ }
+ }
+
+ DataClass SomeData {
+ Attribute ival: int16
+ Attribute iarr [ 3 ]: int32
+ }
+
+ DataClass ComplexData {
+ Attribute sdval: SomeData
+ Attribute sdarr [ 5 ]: SomeData
+ }
+
+ PrimitiveType int16: ptInteger -> 'short' (Short) default '0'
+ PrimitiveType int32: ptInteger -> 'int' (Integer) default '0'
+} \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/TCPTest.room b/tests/org.eclipse.etrice.generator.java.tests/models/TCPTest.room
new file mode 100644
index 000000000..6671d6d3d
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.java.tests/models/TCPTest.room
@@ -0,0 +1,160 @@
+RoomModel TCPTest {
+
+ import room.basic.test.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Tests.room"
+ import room.basic.types.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Types.room"
+ import room.basic.service.tcp.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/TcpService.room"
+
+ ActorClass TCPTestTop {
+ @TestInstance
+ 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 [*]: 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 {
+ ctor {
+ "caseId = etUnit_openAll(\".\", \"TCPTest\", \"org.eclipse.etrice.generator.common.tests.TCPTest\", \"TCPTest_case\");"
+ }
+ dtor {
+ "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

Back to the top