Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-12-04 10:18:24 +0000
committerHenrik Rentz-Reichert2012-12-04 10:18:24 +0000
commit73b4a1693e646cffb9691ccd231801e961bb9257 (patch)
tree6ad1f13c02f3daaa9b0b9a4642243d5ce459f3ff /tests
parenta184bc763fdb00a1b129c4d6b564e1125d8a8f94 (diff)
downloadorg.eclipse.etrice-73b4a1693e646cffb9691ccd231801e961bb9257.tar.gz
org.eclipse.etrice-73b4a1693e646cffb9691ccd231801e961bb9257.tar.xz
org.eclipse.etrice-73b4a1693e646cffb9691ccd231801e961bb9257.zip
[core.room, core.room.tests] let ports with derived protocols connect
added validation for this case and test cases for the validation
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.etrice.core.room.tests/models/TestBindings.room104
-rw-r--r--tests/org.eclipse.etrice.core.room.tests/src/org/eclipse/etrice/core/TestBindings.java83
2 files changed, 187 insertions, 0 deletions
diff --git a/tests/org.eclipse.etrice.core.room.tests/models/TestBindings.room b/tests/org.eclipse.etrice.core.room.tests/models/TestBindings.room
new file mode 100644
index 000000000..47f081898
--- /dev/null
+++ b/tests/org.eclipse.etrice.core.room.tests/models/TestBindings.room
@@ -0,0 +1,104 @@
+RoomModel TestBindings {
+ LogicalSystem Sys {
+ SubSystemRef main: Application
+ }
+
+ SubSystemClass Application {
+ ActorRef ref1: AC1
+ ActorRef ref2: AC2
+
+ // no self connection allowed, ports are indentical
+ Binding ref1.reg and ref1.reg
+
+ // port with multiplicity 1 is already connected
+ Binding ref1.reg and ref2.conj
+ Binding ref1.reg and ref2.conj
+
+ // protocols don't match
+ Binding ref1.reg and ref2.other
+
+ // protocol extends incoming
+ Binding ref1.base and ref2.extin
+
+ // ok
+ Binding ref1.base2 and ref2.extout
+
+ // protocol extends outgoing
+ Binding ref1.base3 and ref2.extout2
+
+ // derived protocols not connectable (both directions extended)
+ Binding ref1.base4 and ref2.extinout
+
+ LogicalThread dflt_thread
+ }
+
+ ActorClass AC1 {
+ Interface {
+ Port reg: PC1
+ Port base: PCBase
+ Port base2: PCBase
+ conjugated Port base3: PCBase
+ conjugated Port base4: PCBase
+ }
+ Structure {
+ external Port reg
+ }
+ Behavior { }
+ }
+
+ ActorClass AC2 {
+ Interface {
+ conjugated Port conj: PC1
+ conjugated Port other: PC2
+ conjugated Port extout: PCExtendOut
+ conjugated Port extin: PCExtendIn
+ Port extout2: PCExtendOut
+ Port extinout: PCExtendInOut
+ }
+ Structure {
+ external Port conj
+ }
+ Behavior { }
+ }
+
+ ProtocolClass PC1 {
+ incoming {
+ Message in1()
+ }
+ }
+
+ ProtocolClass PC2 {
+ incoming {
+ Message in1()
+ }
+ }
+
+ ProtocolClass PCBase {
+ incoming {
+ Message in1()
+ }
+ }
+
+ ProtocolClass PCExtendIn extends PCBase {
+ incoming {
+ Message in2()
+ }
+ }
+
+ ProtocolClass PCExtendOut extends PCBase {
+ outgoing {
+ Message out1()
+ }
+ }
+
+ ProtocolClass PCExtendInOut extends PCBase {
+ incoming {
+ Message in2()
+ }
+ outgoing {
+ // a derived protocol should add either incoming or outgoing messages, not both
+ Message out1()
+ }
+ }
+
+} \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.core.room.tests/src/org/eclipse/etrice/core/TestBindings.java b/tests/org.eclipse.etrice.core.room.tests/src/org/eclipse/etrice/core/TestBindings.java
new file mode 100644
index 000000000..d370d16b5
--- /dev/null
+++ b/tests/org.eclipse.etrice.core.room.tests/src/org/eclipse/etrice/core/TestBindings.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.core;
+
+import static org.junit.Assert.*;
+
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.etrice.core.room.Binding;
+import org.eclipse.etrice.core.room.GeneralProtocolClass;
+import org.eclipse.etrice.core.room.RoomModel;
+import org.eclipse.etrice.core.room.SubSystemClass;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class TestBindings extends TestBase {
+ private Resource resource;
+
+ @Before
+ public void setUp() {
+ prepare();
+
+ resource = getResource("TestBindings.room");
+ }
+
+ @Test
+ public void testBindingValidation() {
+ RoomModel mdl = (RoomModel) resource.getContents().get(0);
+ SubSystemClass ssc = mdl.getSubSystemClasses().get(0);
+ Binding bind = ssc.getBindings().get(0);
+ Diagnostic diag = getDiag(bind).getChildren().get(0);
+ assertEquals("expect error message", "no self connection allowed, ports are indentical", diag.getMessage());
+
+ bind = ssc.getBindings().get(1);
+ diag = getDiag(bind).getChildren().get(0);
+ assertEquals("expect error message", "port with multiplicity 1 is already connected", diag.getMessage());
+
+ bind = ssc.getBindings().get(2);
+ diag = getDiag(bind).getChildren().get(0);
+ assertEquals("expect error message", "port with multiplicity 1 is already connected", diag.getMessage());
+
+ bind = ssc.getBindings().get(3);
+ diag = getDiag(bind).getChildren().get(0);
+ assertEquals("protocols don't match", diag.getMessage());
+
+ bind = ssc.getBindings().get(4);
+ diag = getDiag(bind).getChildren().get(0);
+ assertEquals("protocol extends incoming", diag.getMessage());
+
+ bind = ssc.getBindings().get(6);
+ diag = getDiag(bind).getChildren().get(0);
+ assertEquals("protocol extends outgoing", diag.getMessage());
+
+ bind = ssc.getBindings().get(7);
+ diag = getDiag(bind).getChildren().get(0);
+ assertEquals("derived protocols not connectable (both directions extended)", diag.getMessage());
+ }
+
+ @Test
+ public void testProtocolValidation() {
+ RoomModel mdl = (RoomModel) resource.getContents().get(0);
+ for (GeneralProtocolClass pc : mdl.getProtocolClasses()) {
+ if (pc.getName().equals("PCExtendInOut")) {
+ Diagnostic diag = getDiag(pc).getChildren().get(0);
+ assertEquals("a derived protocol should add either incoming or outgoing messages, not both", diag.getMessage());
+ }
+ }
+ }
+}

Back to the top