Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schuetz2011-04-05 04:50:00 -0400
committerThomas Schuetz2011-04-05 04:50:00 -0400
commitb5395f60e3adb86eb8e9d4d10be0a88575f45a2c (patch)
tree8500f136c4c3308f1fff54b3bd2a227b55a0c64e /tests/org.eclipse.etrice.runtime.java.tests
parent8beec36b39f8f640b3bc0e6995c54f1932735b7f (diff)
downloadorg.eclipse.etrice-b5395f60e3adb86eb8e9d4d10be0a88575f45a2c.tar.gz
org.eclipse.etrice-b5395f60e3adb86eb8e9d4d10be0a88575f45a2c.tar.xz
org.eclipse.etrice-b5395f60e3adb86eb8e9d4d10be0a88575f45a2c.zip
runtime.java.tests: fixed runtime tests after implementation of multi threading and system port
Diffstat (limited to 'tests/org.eclipse.etrice.runtime.java.tests')
-rw-r--r--tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBaseTest.java59
-rw-r--r--tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/PortBaseTest.java122
2 files changed, 108 insertions, 73 deletions
diff --git a/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBaseTest.java b/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBaseTest.java
index 8253f20c0..88244e309 100644
--- a/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBaseTest.java
+++ b/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBaseTest.java
@@ -11,6 +11,8 @@ package org.eclipse.etrice.runtime.java.modelbase;
import org.eclipse.etrice.runtime.java.messaging.Address;
import org.eclipse.etrice.runtime.java.messaging.IRTObject;
import org.eclipse.etrice.runtime.java.messaging.Message;
+import org.eclipse.etrice.runtime.java.messaging.MessageService;
+import org.eclipse.etrice.runtime.java.messaging.RTServices;
import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
@@ -20,9 +22,25 @@ import junit.framework.TestCase;
public class ActorClassBaseTest extends TestCase {
- public class TestActor extends ActorClassBase {
- public TestActor(IRTObject parent, String name) {
- super(parent, name, null);
+
+
+ public class MockRTObject implements IRTObject {
+
+ @Override
+ public String getInstancePath() {
+ return "TOP_Path";
+ }
+
+ @Override
+ public String getInstancePathName() {
+ return "TOP_PathName";
+ }
+
+ }
+
+ public class MockActor extends ActorClassBase {
+ public MockActor(IRTObject parent, String name, Address system_port_addr,Address peer_system_port_addr) {
+ super(parent, name, system_port_addr, peer_system_port_addr);
}
public void receive(Message msg) {
@@ -41,23 +59,32 @@ public class ActorClassBaseTest extends TestCase {
public void stop() {}
@Override
public void destroy() {}
+ @Override
+ public void executeInitTransition() {
+ }
}
-
public void testActorClassBase() {
- ActorClassBase actor = new TestActor(null, "Actor1");
- assertEquals("/Actor1", actor.getInstancePath());
- }
+ MockRTObject topRTObject = new MockRTObject();
+ RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(
+ new MessageService(topRTObject, new Address(0, 0, 0),"MessageService_Main"));
- public void testToString() {
- ActorClassBase actor = new TestActor(null, "Actor1");
- actor.setClassName("ActorClassBase");
- assertEquals("ActorClass(className=ActorClassBase, instancePath=/Actor1)", actor.toString());
- }
+ Address peer_system_port_addr = new Address(0, 0, 0);
+ Address system_port_addr = new Address(0, 0, 1);
- public void testSetGetClassName() {
- ActorClassBase actor = new TestActor(null, "Actor1");
- actor.setClassName("ActorClassBase");
- assertEquals("ActorClassBase", actor.getClassName());
+ // PathNames
+ ActorClassBase actor = new MockActor(topRTObject, "MockActor1", system_port_addr, peer_system_port_addr);
+ assertEquals("TOP_Path/MockActor1", actor.getInstancePath());
+ assertEquals("TOP_PathName_MockActor1", actor.getInstancePathName());
+
+ // ClassName
+ actor.setClassName("MockActor");
+ assertEquals("MockActor", actor.getClassName());
+
+ actor.setClassName("MockActor");
+ assertEquals("ActorClass(className=MockActor, instancePath=TOP_Path/MockActor1)", actor.toString());
+
}
+
+
}
diff --git a/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/PortBaseTest.java b/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/PortBaseTest.java
index ff07673aa..c98374bf5 100644
--- a/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/PortBaseTest.java
+++ b/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/PortBaseTest.java
@@ -13,40 +13,55 @@ import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
import org.eclipse.etrice.runtime.java.messaging.IRTObject;
import org.eclipse.etrice.runtime.java.messaging.Message;
import org.eclipse.etrice.runtime.java.messaging.MessageService;
+import org.eclipse.etrice.runtime.java.messaging.RTServices;
import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
import org.eclipse.etrice.runtime.java.modelbase.IEventReceiver;
import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
import org.eclipse.etrice.runtime.java.modelbase.PortBase;
+import org.eclipse.etrice.runtime.java.modelbase.ActorClassBaseTest.MockRTObject;
import junit.framework.TestCase;
public class PortBaseTest extends TestCase {
+ // TODO: pull out all Mock Objects
+ public class MockEventReceiver implements IEventReceiver {
- public class TestActor extends ActorClassBase {
- public TestActor(IRTObject parent, String name) {
- super(parent, name, null);
- }
- public void receive(Message msg) {
-
- }
- public Address getAddress() {
- return null;
- }
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object... data) {
+ @Override
+ public String getInstancePath() {
+ return "TOP_Path";
}
+
@Override
- public void init() {}
+ public String getInstancePathName() {
+ return "TOP_PathName";
+ }
+
@Override
- public void start() {}
+ public void receiveEvent(InterfaceItemBase ifitem, int evt,
+ Object... data) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+ public class MockRTObject implements IRTObject {
+
@Override
- public void stop() {}
+ public String getInstancePath() {
+ return "TOP_Path";
+ }
+
@Override
- public void destroy() {}
+ public String getInstancePathName() {
+ return "TOP_PathName";
+ }
+
}
+
- class MyPortBase extends PortBase {
- public MyPortBase(IEventReceiver parent, String name, int localId, int idx, Address address,
- Address peerAddress, IMessageReceiver msgReceiver) {
+ class MockPort extends PortBase {
+ public MockPort(IEventReceiver parent, String name, int localId, int idx, Address address,
+ Address peerAddress) {
super(parent, name, localId, idx, address, peerAddress);
}
@@ -63,48 +78,41 @@ public class PortBaseTest extends TestCase {
}
public void testPortBase() {
- MessageService msgService = new MessageService(null, new Address(4, 5, 6), "MessageService1");
- Address portAddress = new Address(1, 2, 3);
- Address peerAddress = new Address(3, 2, 1);
- PortBase port = new MyPortBase(null, "Port1", 0, 0, portAddress, peerAddress, msgService);
- assertEquals(msgService, port.getMsgReceiver());
- assertEquals(portAddress, port.getAddress());
- assertEquals(peerAddress, port.getPeerAddress());
- }
+ MockRTObject topRTObject = new MockRTObject();
+ RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(
+ new MessageService(topRTObject, new Address(0, 0, 0),"MessageService_0"));
+ RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(
+ new MessageService(topRTObject, new Address(0, 1, 0),"MessageService_1"));
- public void testSetGetPeerAddress() {
- Address peerAddress = new Address(3, 2, 1);
- PortBase port = new MyPortBase(null, "", 0, 0, null, peerAddress, null);
- assertEquals(peerAddress, port.getPeerAddress());
- }
+ MockEventReceiver eventRcv = new MockEventReceiver();
+ Address portAddress = new Address(0, 0, 5);
+ Address peerAddress = new Address(0, 1, 10);
- public void testSetGetMsgService() {
- MessageService msgService = new MessageService(null, new Address(4, 5, 6), "MessageService1");
- Address portAddress = new Address(1, 2, 3);
- PortBase port = new MyPortBase(null, "", 0, 0, portAddress, null, msgService);
- assertEquals(msgService, port.getMsgReceiver());
- }
-
- public void testSetInstanceId() {
- PortBase port = new MyPortBase(null, "Port1", 0, 0, null, null, null);
- assertEquals("/Port1", port.getInstancePath());
- }
-
- public void testGetLocalId() {
- PortBase port = new MyPortBase(null, "Port1", 123, 0, null, null, null);
- assertEquals(123, port.getLocalId());
- }
-
- public void testGetIdx() {
- PortBase port = new MyPortBase(null, "Port1", 0, 456, null, null, null);
- assertEquals(456, port.getIdx());
- }
+ PortBase port0 = new MockPort(eventRcv, "Port0", 33, 0, portAddress, peerAddress);
+ PortBase port1 = new MockPort(eventRcv, "Port1", 44, 5, peerAddress, portAddress);
+ assertEquals(RTServices.getInstance().getMsgSvcCtrl().getMsgSvc(0), port0.getMsgReceiver());
+ assertEquals(RTServices.getInstance().getMsgSvcCtrl().getMsgSvc(1), port1.getMsgReceiver());
- public void testSetGetParentObject(){
- ActorClassBase actor = new TestActor(null, "Actor1");
- PortBase port = new MyPortBase(actor, "Port1", 0, 0, null, null, null);
- assertEquals("/Actor1/Port1", port.getInstancePath());
- assertEquals(actor, port.getActor());
+ assertEquals(portAddress, port0.getAddress());
+ assertEquals(peerAddress, port0.getPeerAddress());
+ assertEquals(peerAddress, port1.getAddress());
+ assertEquals(portAddress, port1.getPeerAddress());
+
+ assertEquals("TOP_Path/Port0", port0.getInstancePath());
+ assertEquals("TOP_PathName_Port0", port0.getInstancePathName());
+ assertEquals("TOP_Path/Port1", port1.getInstancePath());
+ assertEquals("TOP_PathName_Port1", port1.getInstancePathName());
+
+ assertEquals(33, port0.getLocalId());
+ assertEquals(44, port1.getLocalId());
+
+ assertEquals(0, port0.getIdx());
+ assertEquals(5, port1.getIdx());
+
+ assertEquals(eventRcv, port0.getActor());
+ assertEquals(eventRcv, port1.getActor());
}
+
+
}

Back to the top