Search in sources :

Example 1 with ObjectTargetMsg

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);
        }
    }
}
Also used : ObjectTargetMsg(abs.backend.java.lib.net.msg.ObjectTargetMsg) COGMsg(abs.backend.java.lib.net.msg.COGMsg) ABSObject(abs.backend.java.lib.runtime.ABSObject) ObjectMsg(abs.backend.java.lib.net.msg.ObjectMsg)

Example 2 with ObjectTargetMsg

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);
}
Also used : ObjectTargetMsg(abs.backend.java.lib.net.msg.ObjectTargetMsg) Test(org.junit.Test)

Example 3 with ObjectTargetMsg

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);
}
Also used : ObjectTargetMsg(abs.backend.java.lib.net.msg.ObjectTargetMsg) Test(org.junit.Test)

Example 4 with ObjectTargetMsg

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);
}
Also used : ObjectTargetMsg(abs.backend.java.lib.net.msg.ObjectTargetMsg) Test(org.junit.Test)

Example 5 with ObjectTargetMsg

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);
}
Also used : ObjectTargetMsg(abs.backend.java.lib.net.msg.ObjectTargetMsg) Test(org.junit.Test)

Aggregations

ObjectTargetMsg (abs.backend.java.lib.net.msg.ObjectTargetMsg)7 Test (org.junit.Test)5 ObjectMsg (abs.backend.java.lib.net.msg.ObjectMsg)2 ABSObject (abs.backend.java.lib.runtime.ABSObject)2 COGMsg (abs.backend.java.lib.net.msg.COGMsg)1