Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2013-08-02 08:57:14 +0000
committerHenrik Rentz-Reichert2013-08-02 08:57:14 +0000
commit5885c07309adbca8d4a43c70626112509f2c20c8 (patch)
tree322b5201ec1a7f00e0c32a7b00ed890f0946f8f4 /tests
parent03763864efe7e4fc495426733aa6eb7797067992 (diff)
downloadorg.eclipse.etrice-5885c07309adbca8d4a43c70626112509f2c20c8.tar.gz
org.eclipse.etrice-5885c07309adbca8d4a43c70626112509f2c20c8.tar.xz
org.eclipse.etrice-5885c07309adbca8d4a43c70626112509f2c20c8.zip
[generator.common.test, generator.java.tests] added more dynamic actor tests
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/DynamicActorTest3.room239
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/DynamicActorTest4.room101
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/DynamicActorTest5.room153
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.etmap9
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.room6
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/standard.etphys3
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/make.xml39
7 files changed, 550 insertions, 0 deletions
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/DynamicActorTest3.room b/tests/org.eclipse.etrice.generator.common.tests/models/DynamicActorTest3.room
new file mode 100644
index 000000000..3952d0d5e
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/DynamicActorTest3.room
@@ -0,0 +1,239 @@
+RoomModel DynamicActorTest3 {
+
+ import room.basic.types.* from "Types.room"
+
+ SubSystemClass SubSystem_DynamicActorTest3 {
+ ActorRef appl: Appl
+
+ LogicalThread dflt_thread
+ }
+
+ ActorClass Appl {
+ Structure {
+ ActorRef cont: Controller
+ }
+ Behavior { }
+ }
+
+ ActorClass Controller {
+ Structure {
+ conjugated Port worker: PWorker
+ conjugated Port opt: PC
+ Attribute caseId: int32
+ ActorRef worker: Worker
+ Binding worker and worker.fct
+ Binding opt and worker.opt
+ }
+ Behavior {
+ Operation Controller() {
+ "caseId = etUnit_openAll(\"tmp\", \"DynamicActorTest3\", \"org.eclipse.etrice.generator.common.tests.DynamicActorTest3\", \"DynamicActorTest3_case\");"
+ }
+ Operation ~Controller() {
+ "etUnit_closeAll(caseId);"
+ }
+ StateMachine {
+ Transition init: initial -> createOpt1 { }
+ Transition tr0: createOpt1 -> SendHello {
+ triggers {
+ <ok: worker>
+ }
+ }
+ Transition tr1: SendHello -> TryCreateInvalid {
+ triggers {
+ <hello: opt>
+ }
+ action {
+ "System.out.println(\"controller received \"+txt);"
+ }
+ }
+ Transition tr2: createOpt1 -> UnexpectedError {
+ triggers {
+ <error: worker>
+ }
+ }
+ Transition tr3: TryCreateInvalid -> ExpectedError {
+ triggers {
+ <error: worker>
+ }
+ }
+ State createOpt1 {
+ entry {
+ "worker.create(\"Optional1\");"
+ }
+ }
+ State SendHello {
+ entry {
+ "opt.sayHello();"
+ }
+ }
+ State TryCreateInvalid {
+ entry {
+ "worker.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 opt: Optional
+ Binding opt and opt.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 (opt.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.common.tests/models/DynamicActorTest4.room b/tests/org.eclipse.etrice.generator.common.tests/models/DynamicActorTest4.room
new file mode 100644
index 000000000..534882392
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/DynamicActorTest4.room
@@ -0,0 +1,101 @@
+RoomModel DynamicActorTest4 {
+
+ import room.basic.types.* from "Types.room"
+
+ SubSystemClass SubSystem_DynamicActorTest4 {
+ ActorRef appl: Appl
+
+ LogicalThread dflt_thread
+ }
+
+ 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 {
+ Operation Container() {
+ "caseId = etUnit_openAll(\"tmp\", \"DynamicActorTest4\", \"org.eclipse.etrice.generator.common.tests.DynamicActorTest4\", \"DynamicActorTest4_case\");"
+ }
+ Operation ~Container() {
+ "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.common.tests/models/DynamicActorTest5.room b/tests/org.eclipse.etrice.generator.common.tests/models/DynamicActorTest5.room
new file mode 100644
index 000000000..388ed54e2
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/DynamicActorTest5.room
@@ -0,0 +1,153 @@
+RoomModel DynamicActorTest5 {
+
+ import room.basic.types.* from "Types.room"
+
+ SubSystemClass SubSystem_DynamicActorTest5 {
+ ActorRef appl: Appl
+
+ LogicalThread dflt_thread
+ }
+
+ ActorClass Appl {
+ 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 {
+ Operation Container() {
+ "caseId = etUnit_openAll(\"tmp\", \"DynamicActorTest5\", \"org.eclipse.etrice.generator.common.tests.DynamicActorTest5\", \"DynamicActorTest5_case\");"
+ }
+ Operation ~Container() {
+ "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.common.tests/models/generator.java.tests.etmap b/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.etmap
index c968ab9b7..30e909187 100644
--- a/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.etmap
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.etmap
@@ -43,5 +43,14 @@ MappingModel JavaGenTest {
SubSystemMapping da2Test -> node11 {
ThreadMapping dflt_thread -> DfltThread
}
+ SubSystemMapping da3Test -> node12 {
+ ThreadMapping dflt_thread -> DfltThread
+ }
+ SubSystemMapping da4Test -> node13 {
+ ThreadMapping dflt_thread -> DfltThread
+ }
+ SubSystemMapping da5Test -> node14 {
+ ThreadMapping dflt_thread -> DfltThread
+ }
}
} \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.room b/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.room
index 75851cea4..415c41622 100644
--- a/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.room
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.room
@@ -11,6 +11,9 @@ RoomModel JavaGenTests {
import DataDrivenTest.* from "DataDrivenTest.room"
import DynamicActorTest1.* from "DynamicActorTest1.room"
import DynamicActorTest2.* from "DynamicActorTest2.room"
+ import DynamicActorTest3.* from "DynamicActorTest3.room"
+ import DynamicActorTest4.* from "DynamicActorTest4.room"
+ import DynamicActorTest5.* from "DynamicActorTest5.room"
LogicalSystem JavaGenTests {
SubSystemRef hdTest: SubSystem_HandlerTest
@@ -24,5 +27,8 @@ RoomModel JavaGenTests {
SubSystemRef ddTest: SubSystem_DataDriven
SubSystemRef da1Test: SubSystem_DynamicActorTest1
SubSystemRef da2Test: SubSystem_DynamicActorTest2
+ SubSystemRef da3Test: SubSystem_DynamicActorTest3
+ SubSystemRef da4Test: SubSystem_DynamicActorTest4
+ SubSystemRef da5Test: SubSystem_DynamicActorTest5
}
} \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/standard.etphys b/tests/org.eclipse.etrice.generator.common.tests/models/standard.etphys
index eb55b73f7..859d7540e 100644
--- a/tests/org.eclipse.etrice.generator.common.tests/models/standard.etphys
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/standard.etphys
@@ -13,6 +13,9 @@ PhysicalModel Standard {
NodeRef node10: PC
NodeRef node11: PC
NodeRef node12: PC
+ NodeRef node13: PC
+ NodeRef node14: PC
+ NodeRef node15: PC
}
NodeClass PC {
diff --git a/tests/org.eclipse.etrice.generator.java.tests/make.xml b/tests/org.eclipse.etrice.generator.java.tests/make.xml
index 4d505d7e3..03cc550e2 100644
--- a/tests/org.eclipse.etrice.generator.java.tests/make.xml
+++ b/tests/org.eclipse.etrice.generator.java.tests/make.xml
@@ -206,6 +206,24 @@
<classpath path="${bin.path};${runtime.path}/bin;${modellib.path}/bin"/>
</java>
<echo>end DynamicActorTest2</echo>
+ <echo>start DynamicActorTest3</echo>
+ <java output="${output}/runDynamicActorTest3.txt" classname="DynamicActorTest3.Node_node12_da3TestRunner" fork="true" failonerror="true">
+ <arg value="-headless"/>
+ <classpath path="${bin.path};${runtime.path}/bin;${modellib.path}/bin"/>
+ </java>
+ <echo>end DynamicActorTest3</echo>
+ <echo>start DynamicActorTest4</echo>
+ <java output="${output}/runDynamicActorTest4.txt" classname="DynamicActorTest4.Node_node13_da4TestRunner" fork="true" failonerror="true">
+ <arg value="-headless"/>
+ <classpath path="${bin.path};${runtime.path}/bin;${modellib.path}/bin"/>
+ </java>
+ <echo>end DynamicActorTest4</echo>
+ <echo>start DynamicActorTest5</echo>
+ <java output="${output}/runDynamicActorTest5.txt" classname="DynamicActorTest5.Node_node14_da5TestRunner" fork="true" failonerror="true">
+ <arg value="-headless"/>
+ <classpath path="${bin.path};${runtime.path}/bin;${modellib.path}/bin"/>
+ </java>
+ <echo>end DynamicActorTest5</echo>
</target>
<!--
@@ -298,6 +316,27 @@
<arg value="./tmp/DynamicActorTest2.etu"/>
<classpath refid="clspath"/>
</java>
+
+ <java output="${output}/convert.txt" append="true" classname="org.eclipse.etrice.etunit.converter.EtUnitReportConverter" fork="true" failonerror="true">
+ <arg value="-suite"/>
+ <arg value="org.eclipse.etrice.generator.java.tests.DynamicActorTest3"/>
+ <arg value="./tmp/DynamicActorTest3.etu"/>
+ <classpath refid="clspath"/>
+ </java>
+
+ <java output="${output}/convert.txt" append="true" classname="org.eclipse.etrice.etunit.converter.EtUnitReportConverter" fork="true" failonerror="true">
+ <arg value="-suite"/>
+ <arg value="org.eclipse.etrice.generator.java.tests.DynamicActorTest4"/>
+ <arg value="./tmp/DynamicActorTest4.etu"/>
+ <classpath refid="clspath"/>
+ </java>
+
+ <java output="${output}/convert.txt" append="true" classname="org.eclipse.etrice.etunit.converter.EtUnitReportConverter" fork="true" failonerror="true">
+ <arg value="-suite"/>
+ <arg value="org.eclipse.etrice.generator.java.tests.DynamicActorTest5"/>
+ <arg value="./tmp/DynamicActorTest5.etu"/>
+ <classpath refid="clspath"/>
+ </java>
</target>
<!--

Back to the top