Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Jung2011-04-04 20:43:14 +0000
committerThomas Schuetz2011-04-04 20:43:14 +0000
commit6c9498396351f08fda26479dba36f732ff57a294 (patch)
tree62fb4bad2e5eb2ad7ea51878f1d2fc96d4961647 /tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice
parent9c99893df7e0526ad637d3281c68340c72b144cc (diff)
downloadorg.eclipse.etrice-6c9498396351f08fda26479dba36f732ff57a294.tar.gz
org.eclipse.etrice-6c9498396351f08fda26479dba36f732ff57a294.tar.xz
org.eclipse.etrice-6c9498396351f08fda26479dba36f732ff57a294.zip
applied patch for system port: https://bugs.eclipse.org/bugs/show_bug.cgi?id=339803
Diffstat (limited to 'tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice')
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/IntegrationTestFSMGenerator.java24
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/IntegrationTestPingPongThread.java73
2 files changed, 92 insertions, 5 deletions
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 6403e2c71..4dd418efc 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
@@ -19,6 +19,7 @@ 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.runtime.java.messaging.RTServices;
+import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -26,10 +27,19 @@ 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 !");
+ }
+ }
@Before
public void setUp() throws Exception {
// we have to launch a JUnit Plugin test since for the build we need an Eclipse environment
@@ -42,16 +52,20 @@ public class IntegrationTestFSMGenerator {
*/
}
- @Test(timeout=1000)
+ @Test (timeout=5000)
public void testHFSM(){
SubSystemHFSMTest main_component = new SubSystemHFSMTest(null,"MainComponent");
+
+ // hand over the semaphore to the subsystem
+ SubSystemClassBase.getInstance().setTestSemaphore(this.testSem);
+
main_component.init(); // lifecycle init
main_component.start(); // lifecycle start
- RTServices.getInstance().getMsgSvcCtrl().waitTerminate();
-
- assertEquals(a_HFSM_Tester.STATE_TestPass ,main_component.getInstance("/MainComponent/application/HFSM_Tests/Tester").getState());
+ waitForTestcase();
+ assertEquals(0,main_component.getTestErrorCode());
+
// end the lifecycle
main_component.stop(); // lifecycle stop
main_component.destroy(); // lifecycle destroy
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
new file mode 100644
index 000000000..d80928333
--- /dev/null
+++ b/tests/org.eclipse.etrice.integration.tests/src/org/eclipse/etrice/integration/tests/IntegrationTestPingPongThread.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2010 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.integration.tests;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.etrice.integration.PingPongThreadTest.SubSystem_PingPong;
+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 !");
+ }
+ }
+ @Before
+ public void setUp() throws Exception {
+ // we have to launch a JUnit Plugin test since for the build we need an Eclipse environment
+ // in this context the Mwe2Launcher suffers from https://bugs.eclipse.org/bugs/show_bug.cgi?id=318721
+ /*
+ Mwe2Launcher.main(new String[]{"/org.eclipse.etrice.integration.tests/src/de/protos/etrice/integration/test/IntegrationTestFSMGenerator.mwe2"});
+ final IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ final IProject project = workspace.getRoot().getProject("/org.eclipse.etrice.integration.tests");
+ project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, null);
+ */
+ }
+
+ @Test (timeout=25000)
+ public void testHFSM(){
+ SubSystem_PingPong main_component = new SubSystem_PingPong(null,"MainComponent");
+
+ // hand over the semaphore to the subsystem
+ SubSystemClassBase.getInstance().setTestSemaphore(this.testSem);
+
+ main_component.init(); // lifecycle init
+ main_component.start(); // lifecycle start
+
+ waitForTestcase();
+
+ assertEquals(0,main_component.getTestErrorCode());
+
+ // end the lifecycle
+ main_component.stop(); // lifecycle stop
+ main_component.destroy(); // lifecycle destroy
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+
+}

Back to the top