use of abs.backend.java.lib.net.msg.ObjectTargetMsg in project abstools by abstools.
the class NodeImpl method processMsg.
@Override
public synchronized void processMsg(Msg m) {
if (m instanceof ObjectTargetMsg) {
ObjectTargetMsg otm = (ObjectTargetMsg) m;
if (objects.contains(otm.getTarget())) {
NetCOG cog = (NetCOG) otm.getTarget().getCOG();
cog.processMsg(m);
} else {
routeAway(m);
}
} else if (m instanceof COGMsg) {
COGMsg cm = (COGMsg) m;
NetCOG cog = cm.getCOG();
cog.setNode(this);
cogs.add(cog);
} else if (m instanceof ObjectMsg) {
ObjectMsg om = (ObjectMsg) m;
ABSObject object = om.getObject();
NetCOG cog = (NetCOG) object.getCOG();
if (cogs.contains(cog)) {
objects.add(object);
} else {
routeAway(m);
}
}
}
use of abs.backend.java.lib.net.msg.ObjectTargetMsg in project abstools by abstools.
the class DefaultRouterTest method nextNodeIsSelf.
@Test
public void nextNodeIsSelf() {
ObjectTargetMsg msg = createMock(ObjectTargetMsg.class);
currentRouter.register(obj1);
expect(msg.getTarget()).andReturn(obj1);
replay(msg);
assertEquals("next node must be node1", node1, currentRouter.getNextNode(msg));
verify(msg);
}
use of abs.backend.java.lib.net.msg.ObjectTargetMsg in project abstools by abstools.
the class DefaultRouterTest method nextNodeIsSelectedNeighbour.
@Test
public void nextNodeIsSelectedNeighbour() {
ObjectTargetMsg msg = createMock(ObjectTargetMsg.class);
currentRouter.replace(obj1, node2, 1);
expect(msg.getTarget()).andReturn(obj1);
replay(msg);
assertEquals("next node must be node2", node2, currentRouter.getNextNode(msg));
verify(msg);
}
use of abs.backend.java.lib.net.msg.ObjectTargetMsg in project abstools by abstools.
the class DefaultRouterTest method hasNoRoutEntryForTarget.
@Test
public void hasNoRoutEntryForTarget() {
ObjectTargetMsg msg = createMock(ObjectTargetMsg.class);
expect(msg.getTarget()).andReturn(obj1);
expect(node1.defaultRoute()).andReturn(node2);
replay(msg);
replay(node1);
assertEquals("next node must be node2", node2, currentRouter.getNextNode(msg));
verify(msg);
verify(node1);
}
use of abs.backend.java.lib.net.msg.ObjectTargetMsg in project abstools by abstools.
the class NodeImplTest method processObjectTargetMsgOnNode.
@Test
public void processObjectTargetMsgOnNode() {
ObjectTargetMsg msg = createMock(ObjectTargetMsg.class);
currentNode.registerObject(object);
expect(msg.getTarget()).andReturn(object);
expect(msg.getCOG()).andReturn(cog);
cog.processMsg(msg);
expectLastCall();
replay(msg);
replay(object);
replay(cog);
currentNode.processMsg(msg);
verify(msg);
verify(object);
verify(cog);
}
Aggregations