diff options
author | Henrik Rentz-Reichert | 2013-07-30 11:30:40 +0000 |
---|---|---|
committer | Henrik Rentz-Reichert | 2013-07-30 11:30:40 +0000 |
commit | 2e36d8a1406d55de2c6807375681cc63cc0c7d22 (patch) | |
tree | e44d95216706e321ec91d4cb24c968ffa34d93aa | |
parent | 5cd772dedf523da438c66f5d80d7af04b030c829 (diff) | |
download | org.eclipse.etrice-2e36d8a1406d55de2c6807375681cc63cc0c7d22.tar.gz org.eclipse.etrice-2e36d8a1406d55de2c6807375681cc63cc0c7d22.tar.xz org.eclipse.etrice-2e36d8a1406d55de2c6807375681cc63cc0c7d22.zip |
[generator.java.tests, generator.common.tests] added DynamicActorTest2
for replicated optional actors
4 files changed, 261 insertions, 10 deletions
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/DynamicActorTest2.room b/tests/org.eclipse.etrice.generator.common.tests/models/DynamicActorTest2.room new file mode 100644 index 000000000..15966112b --- /dev/null +++ b/tests/org.eclipse.etrice.generator.common.tests/models/DynamicActorTest2.room @@ -0,0 +1,233 @@ +RoomModel DynamicActorTest2 { + + import room.basic.types.* from "Types.room" + + SubSystemClass SubSystem_DynamicActorTest2 { + 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 optarray[*]: Optional + + Binding p0 and optarray.p0 + } + Behavior { + Operation Container() { + "caseId = etUnit_openAll(\"tmp\", \"DynamicActorTest2\", \"org.eclipse.etrice.generator.common.tests.DynamicActorTest2\", \"DynamicActorTest2_case\");" + } + Operation ~Container() { + "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" + "// CAUTION: in the path the optarray appears twice because of the OptionalActorInterface." + "// On the other hand if the path of this object is computed the OptionalActorInterface is omitted" + "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.common.tests/models/generator.java.tests.etmap b/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.etmap index 7f1688f1e..c968ab9b7 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 @@ -40,5 +40,8 @@ MappingModel JavaGenTest { SubSystemMapping da1Test -> node10 { ThreadMapping dflt_thread -> DfltThread } + SubSystemMapping da2Test -> node11 { + 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 e695d919b..75851cea4 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 @@ -10,6 +10,7 @@ RoomModel JavaGenTests { import DynamicConfigTest.* from "DynamicConfigTest_Java.room" import DataDrivenTest.* from "DataDrivenTest.room" import DynamicActorTest1.* from "DynamicActorTest1.room" + import DynamicActorTest2.* from "DynamicActorTest2.room" LogicalSystem JavaGenTests { SubSystemRef hdTest: SubSystem_HandlerTest @@ -22,5 +23,6 @@ RoomModel JavaGenTests { SubSystemRef dcTest: SubSystem_DynamicConfigTest SubSystemRef ddTest: SubSystem_DataDriven SubSystemRef da1Test: SubSystem_DynamicActorTest1 + SubSystemRef da2Test: SubSystem_DynamicActorTest2 } }
\ No newline at end of file diff --git a/tests/org.eclipse.etrice.generator.java.tests/make.xml b/tests/org.eclipse.etrice.generator.java.tests/make.xml index 9bfa8452d..4d505d7e3 100644 --- a/tests/org.eclipse.etrice.generator.java.tests/make.xml +++ b/tests/org.eclipse.etrice.generator.java.tests/make.xml @@ -142,64 +142,70 @@ <mkdir dir="tmp/log"/> <echo>start HandlerTest</echo> <java output="${output}/runHandlerTest.txt" classname="HandlerTest.Node_node3_hdTestRunner" fork="true" failonerror="true"> - <arg value="-run_as_test"/> + <arg value="-headless"/> <classpath path="${bin.path};${runtime.path}/bin;${modellib.path}/bin"/> </java> <echo>end HandlerTest</echo> <echo>start ChoicePointTest</echo> <java output="${output}/runChoicePointTest.txt" classname="ChoicePointTest.Node_node1_cpTestRunner" fork="true" failonerror="true"> - <arg value="-run_as_test"/> + <arg value="-headless"/> <classpath path="${bin.path};${runtime.path}/bin;${modellib.path}/bin"/> </java> <echo>end ChoicePointTest</echo> <echo>start PingPongThreadTest</echo> <java output="${output}/runPingPongThreadTest.txt" classname="PingPongThreadTest.Node_node6_ppTestRunner" fork="true" failonerror="true"> - <arg value="-run_as_test"/> + <arg value="-headless"/> <classpath path="${bin.path};${runtime.path}/bin;${modellib.path}/bin"/> </java> <echo>end PingPongThreadTest</echo> <echo>start PingPongThreadTestReplPort</echo> <java output="${output}/runPingPongThreadReplPortTest.txt" classname="PingPongThreadTestReplPort.Node_node7_prTestRunner" fork="true" failonerror="true"> - <arg value="-run_as_test"/> + <arg value="-headless"/> <classpath path="${bin.path};${runtime.path}/bin;${modellib.path}/bin"/> </java> <echo>end PingPongThreadTestReplPort</echo> <echo>start SendingDataTestJava</echo> <java output="${output}/runSendingDataTestJava.txt" classname="SendingDataTestJava.Node_node4_sdTestRunner" fork="true" failonerror="true"> - <arg value="-run_as_test"/> + <arg value="-headless"/> <classpath path="${bin.path};${runtime.path}/bin;${modellib.path}/bin"/> </java> <echo>end SendingDataTestJava</echo> <echo>start TCPTest</echo> <java output="${output}/runTCPTest.txt" classname="TCPTest.Node_node8_tcTestRunner" fork="true" failonerror="true"> - <arg value="-run_as_test"/> + <arg value="-headless"/> <classpath path="${bin.path};${runtime.path}/bin;${modellib.path}/bin"/> </java> <echo>end TCPTest</echo> <echo>start StaticConfigTest</echo> <java output="${output}/runStaticConfigTest.txt" classname="StaticConfigTest.Node_node5_scTestRunner" fork="true" failonerror="true"> - <arg value="-run_as_test"/> + <arg value="-headless"/> <classpath path="${bin.path};${runtime.path}/bin;${modellib.path}/bin"/> </java> <echo>end StaticConfigTest</echo> <echo>start DynamicConfigTest</echo> <java output="${output}/runDynamicConfigTest.txt" classname="DynamicConfigTest.Node_node9_dcTestRunner" fork="true" failonerror="true"> - <arg value="-run_as_test"/> + <arg value="-headless"/> <classpath path="${bin.path};${runtime.path}/bin;${modellib.path}/bin"/> </java> <echo>end DynamicConfigTest</echo> <echo>start DataDrivenTest</echo> <java output="${output}/runDataDrivenTest.txt" classname="DataDrivenTest.Node_node2_ddTestRunner" fork="true" failonerror="true"> - <arg value="-run_as_test"/> + <arg value="-headless"/> <classpath path="${bin.path};${runtime.path}/bin;${modellib.path}/bin"/> </java> <echo>end DataDrivenTest</echo> <echo>start DynamicActorTest1</echo> <java output="${output}/runDynamicActorTest1.txt" classname="DynamicActorTest1.Node_node10_da1TestRunner" fork="true" failonerror="true"> - <arg value="-run_as_test"/> + <arg value="-headless"/> <classpath path="${bin.path};${runtime.path}/bin;${modellib.path}/bin"/> </java> <echo>end DynamicActorTest1</echo> + <echo>start DynamicActorTest2</echo> + <java output="${output}/runDynamicActorTest2.txt" classname="DynamicActorTest2.Node_node11_da2TestRunner" fork="true" failonerror="true"> + <arg value="-headless"/> + <classpath path="${bin.path};${runtime.path}/bin;${modellib.path}/bin"/> + </java> + <echo>end DynamicActorTest2</echo> </target> <!-- @@ -285,6 +291,13 @@ <arg value="./tmp/DynamicActorTest1.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.DynamicActorTest2"/> + <arg value="./tmp/DynamicActorTest2.etu"/> + <classpath refid="clspath"/> + </java> </target> <!-- |