Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schuetz2011-04-05 07:29:26 +0000
committerThomas Schuetz2011-04-05 07:29:26 +0000
commit8beec36b39f8f640b3bc0e6995c54f1932735b7f (patch)
tree5a37045e2fcae64fdef7a8cad0d74ee221ede4c0
parentf429e8a681404718ecf06be741749cb79d922552 (diff)
downloadorg.eclipse.etrice-8beec36b39f8f640b3bc0e6995c54f1932735b7f.tar.gz
org.eclipse.etrice-8beec36b39f8f640b3bc0e6995c54f1932735b7f.tar.xz
org.eclipse.etrice-8beec36b39f8f640b3bc0e6995c54f1932735b7f.zip
integration.tests and runtime: fixed integration tests to run several tests in one JUnit call -> removed SubSystemClassBase singleton and added destroy function to RTService (called in SubSystemClassBase.destroy)
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/RTServices.java16
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java21
-rw-r--r--tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.PingPongThreadTest.room6
-rw-r--r--tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.PingPongThreadTestReplPort.room5
-rw-r--r--tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.tests.room5
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/IntegrationTestFSMGenerator.java15
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/IntegrationTestPingPongThread.java15
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/base/IntegrationTestBase.java21
8 files changed, 62 insertions, 42 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/RTServices.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/RTServices.java
index 910aaf1e7..c462bc67a 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/RTServices.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/messaging/RTServices.java
@@ -12,6 +12,8 @@
package org.eclipse.etrice.runtime.java.messaging;
+import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
+
/**
* RTServices is the single point of access to all runtime services in one SubSystem
* e.g. MessageServices, DebuggingService, ...
@@ -32,11 +34,25 @@ public class RTServices {
return instance;
}
+ public void destroy(){
+ // TODO: also clean up all sub elements
+ subSystem = null;
+ messageServiceController = null;
+ instance = null;
+ }
+
public MessageServiceController getMsgSvcCtrl(){
assert(messageServiceController != null);
return messageServiceController;
}
+ public SubSystemClassBase getSubSystem() {
+ return subSystem;
+ }
+ public void setSubSystem(SubSystemClassBase subSystem) {
+ this.subSystem = subSystem;
+ }
private static RTServices instance = null;
private MessageServiceController messageServiceController = null;
+ private SubSystemClassBase subSystem = null;
}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java
index c9b64563d..88ee827cc 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/SubSystemClassBase.java
@@ -8,14 +8,14 @@
package org.eclipse.etrice.runtime.java.modelbase;
+import java.util.concurrent.Semaphore;
+
import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
-import org.eclipse.etrice.runtime.java.messaging.Address;
import org.eclipse.etrice.runtime.java.messaging.IRTObject;
import org.eclipse.etrice.runtime.java.messaging.MessageService;
import org.eclipse.etrice.runtime.java.messaging.RTObject;
import org.eclipse.etrice.runtime.java.messaging.RTServices;
-import org.eclipse.etrice.runtime.java.messaging.RTSystemServicesProtocol.*;
-import java.util.concurrent.Semaphore;
+import org.eclipse.etrice.runtime.java.messaging.RTSystemServicesProtocol.RTSystemServicesProtocolConjPortRepl;
/**
* The base class for all SubSystems.
@@ -26,28 +26,17 @@ import java.util.concurrent.Semaphore;
*/
public abstract class SubSystemClassBase extends RTObject implements IEventReceiver{
- private static SubSystemClassBase instance = null;
//--------------------- ports
protected RTSystemServicesProtocolConjPortRepl RTSystemPort = null;
//--------------------- interface item IDs
protected static final int IFITEM_RTSystemPort = 0;
- private boolean running = false;
protected ActorClassBase[] instances = null;
private Semaphore testSem=null;
private int testErrorCode;
- public static SubSystemClassBase getInstance() {
- return instance;
- }
-
public SubSystemClassBase(IRTObject parent, String name) {
super(parent, name);
- if (instance!=null)
- throw new RuntimeException("ComponentClassBase is a singleton!");
-
- instance = this;
-
DebuggingService.getInstance().getAsyncLogger()
.setMSC(name + "_Async", "");
DebuggingService.getInstance().getAsyncLogger().open();
@@ -55,6 +44,8 @@ public abstract class SubSystemClassBase extends RTObject implements IEventRecei
.setMSC(name + "_Sync", "");
DebuggingService.getInstance().getSyncLogger().open();
+ RTServices.getInstance().setSubSystem(this);
+
}
public void init() {
@@ -89,7 +80,6 @@ public abstract class SubSystemClassBase extends RTObject implements IEventRecei
// start all message services
RTServices.getInstance().getMsgSvcCtrl().start();
- running = true;
}
public void stop() {
@@ -111,6 +101,7 @@ public abstract class SubSystemClassBase extends RTObject implements IEventRecei
DebuggingService.getInstance().getAsyncLogger().close();
DebuggingService.getInstance().getSyncLogger().close();
+ RTServices.getInstance().destroy();
System.out.println("*** MainComponent "+getInstancePath()+"::destroy ***");
}
diff --git a/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.PingPongThreadTest.room b/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.PingPongThreadTest.room
index 93f86f5bb..c4c707bfe 100644
--- a/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.PingPongThreadTest.room
+++ b/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.PingPongThreadTest.room
@@ -37,6 +37,10 @@ RoomModel org.eclipse.etrice.integration.PingPongThreadTest {
conjugated Port PingPongPort3 : PingPongProtocol
}
Structure {
+ usercode1 {
+ "import org.eclipse.etrice.runtime.java.messaging.RTServices;"
+ }
+
external Port PingPongPort
external Port PingPongPort2
external Port PingPongPort3
@@ -75,7 +79,7 @@ RoomModel org.eclipse.etrice.integration.PingPongThreadTest {
Transition tr5: cp cp0 -> waitForTimer {
action {
"if (count++ > 1000) {"
- "SubSystemClassBase.getInstance().testFinished(0);"
+ "RTServices.getInstance().getSubSystem().testFinished(0);"
"} else {"
"System.out.println(count);"
"timer.Start(5);}"
diff --git a/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.PingPongThreadTestReplPort.room b/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.PingPongThreadTestReplPort.room
index d15263821..2166a9c06 100644
--- a/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.PingPongThreadTestReplPort.room
+++ b/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.PingPongThreadTestReplPort.room
@@ -35,6 +35,9 @@ RoomModel org.eclipse.etrice.integration.PingPongThreadTestReplPort {
conjugated Port PingPongPort [3] : PingPongProtocol
}
Structure {
+ usercode1 {
+ "import org.eclipse.etrice.runtime.java.messaging.RTServices;"
+ }
external Port PingPongPort
SAP timer: PTimeout
Attribute count : int32
@@ -70,7 +73,7 @@ RoomModel org.eclipse.etrice.integration.PingPongThreadTestReplPort {
Transition tr5: cp cp0 -> waitForTimer {
action {
"if (count++ > 1000) {"
- "SubSystemClassBase.getInstance().testFinished(0);"
+ "RTServices.getInstance().getSubSystem().testFinished(0);"
"} else {"
"System.out.println(count);"
"timer.Start(5);}"
diff --git a/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.tests.room b/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.tests.room
index 5cae5e257..6c9de770f 100644
--- a/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.tests.room
+++ b/tests/org.eclipse.etrice.integration.tests/model/org.eclipse.etrice.integration.tests.room
@@ -192,6 +192,9 @@ RoomModel org.eclipse.etrice.integration.tests {
conjugated Port testee : p_HFSM
}
Structure {
+ usercode1 {
+ "import org.eclipse.etrice.runtime.java.messaging.RTServices;"
+ }
external Port testee
}
Behavior {
@@ -244,7 +247,7 @@ RoomModel org.eclipse.etrice.integration.tests {
State State7 {}
State TestPass {
entry {
- "SubSystemClassBase.getInstance().testFinished(0);"
+ "RTServices.getInstance().getSubSystem().testFinished(0);"
}
}
}
diff --git a/tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/IntegrationTestFSMGenerator.java b/tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/IntegrationTestFSMGenerator.java
index 4dd418efc..4149f6598 100644
--- a/tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/IntegrationTestFSMGenerator.java
+++ b/tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/IntegrationTestFSMGenerator.java
@@ -18,6 +18,7 @@ import static org.junit.Assert.assertEquals;
import org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher;
import org.eclipse.etrice.integration.tests.SubSystemHFSMTest;
import org.eclipse.etrice.integration.tests.a_HFSM_Tester;
+import org.eclipse.etrice.integration.tests.base.IntegrationTestBase;
import org.eclipse.etrice.runtime.java.messaging.RTServices;
import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
import org.junit.After;
@@ -27,19 +28,9 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
-import java.util.concurrent.Semaphore;
-public class IntegrationTestFSMGenerator {
- private Semaphore testSem = new Semaphore(0);
-
- private synchronized void waitForTestcase(){
- try{
- this.testSem.acquire(1);
- }catch(InterruptedException e){
- System.out.println("Semaphore fault !");
- }
- }
+public class IntegrationTestFSMGenerator extends IntegrationTestBase {
@Before
public void setUp() throws Exception {
// we have to launch a JUnit Plugin test since for the build we need an Eclipse environment
@@ -57,7 +48,7 @@ public class IntegrationTestFSMGenerator {
SubSystemHFSMTest main_component = new SubSystemHFSMTest(null,"MainComponent");
// hand over the semaphore to the subsystem
- SubSystemClassBase.getInstance().setTestSemaphore(this.testSem);
+ main_component.setTestSemaphore(this.testSem);
main_component.init(); // lifecycle init
main_component.start(); // lifecycle start
diff --git a/tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/IntegrationTestPingPongThread.java b/tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/IntegrationTestPingPongThread.java
index d80928333..2f9cdf458 100644
--- a/tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/IntegrationTestPingPongThread.java
+++ b/tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/IntegrationTestPingPongThread.java
@@ -16,24 +16,15 @@ package org.eclipse.etrice.integration.tests;
import static org.junit.Assert.assertEquals;
import org.eclipse.etrice.integration.PingPongThreadTest.SubSystem_PingPong;
+import org.eclipse.etrice.integration.tests.base.IntegrationTestBase;
import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import java.util.concurrent.Semaphore;
-public class IntegrationTestPingPongThread {
- private Semaphore testSem = new Semaphore(0);
-
- private synchronized void waitForTestcase(){
- try{
- this.testSem.acquire(1);
- }catch(InterruptedException e){
- System.out.println("Semaphore fault !");
- }
- }
+public class IntegrationTestPingPongThread extends IntegrationTestBase {
@Before
public void setUp() throws Exception {
// we have to launch a JUnit Plugin test since for the build we need an Eclipse environment
@@ -51,7 +42,7 @@ public class IntegrationTestPingPongThread {
SubSystem_PingPong main_component = new SubSystem_PingPong(null,"MainComponent");
// hand over the semaphore to the subsystem
- SubSystemClassBase.getInstance().setTestSemaphore(this.testSem);
+ main_component.setTestSemaphore(this.testSem);
main_component.init(); // lifecycle init
main_component.start(); // lifecycle start
diff --git a/tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/base/IntegrationTestBase.java b/tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/base/IntegrationTestBase.java
new file mode 100644
index 000000000..0e201ec88
--- /dev/null
+++ b/tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/base/IntegrationTestBase.java
@@ -0,0 +1,21 @@
+package org.eclipse.etrice.integration.tests.base;
+
+import java.util.concurrent.Semaphore;
+
+public class IntegrationTestBase {
+
+ protected Semaphore testSem = new Semaphore(0);
+
+ public IntegrationTestBase() {
+ super();
+ }
+
+ protected synchronized void waitForTestcase() {
+ try{
+ this.testSem.acquire(1);
+ }catch(InterruptedException e){
+ System.out.println("Semaphore fault !");
+ }
+ }
+
+} \ No newline at end of file

Back to the top