Search in sources :

Example 1 with MockOfPortStatus

use of org.onosproject.openflow.MockOfPortStatus in project onos by opennetworkinglab.

the class OFChannelHandlerTest method testActiveDpidSub.

// Through subhandshake
@Test
public void testActiveDpidSub() {
    // Expected behavior
    OFDescStatsReply reply = new OFDescStatsReplyAdapter();
    expect(controller.getOFSwitchInstance(0, reply, OF_13)).andReturn(new OpenflowSwitchDriverAdapter(ImmutableSet.of(), Dpid.dpid(Dpid.uri(0)), false));
    replay(controller);
    try {
        channelHandler.channelActive(channelHandlerContext);
        channelHandler.setState(WAIT_DESCRIPTION_STAT_REPLY);
        channelHandler.channelRead(channelHandlerContext, reply);
        channelHandler.channelRead(channelHandlerContext, new MockOfPortStatus());
    } catch (Exception e) {
        channelHandler = null;
    }
    // exception should not be fired
    assertNotNull(channelHandler);
    assertThat(channelHandler.getStateForTesting(), is(ACTIVE));
    // Finally verify
    verify(controller);
}
Also used : OFDescStatsReply(org.projectfloodlight.openflow.protocol.OFDescStatsReply) OFDescStatsReplyAdapter(org.onosproject.openflow.OFDescStatsReplyAdapter) MockOfPortStatus(org.onosproject.openflow.MockOfPortStatus) OpenflowSwitchDriverAdapter(org.onosproject.openflow.OpenflowSwitchDriverAdapter) Test(org.junit.Test)

Example 2 with MockOfPortStatus

use of org.onosproject.openflow.MockOfPortStatus in project onos by opennetworkinglab.

the class OFChannelHandlerTest method testDuplicateDpidSub.

// Through subhandshake - duplicate dpid
@Test
public void testDuplicateDpidSub() {
    // Expected behavior
    OFDescStatsReply reply = new OFDescStatsReplyAdapter();
    expect(controller.getOFSwitchInstance(0, reply, OF_13)).andReturn(new OpenflowSwitchDriverAdapter(ImmutableSet.of(Dpid.dpid(Dpid.uri(0))), Dpid.dpid(Dpid.uri(0)), false));
    replay(controller);
    try {
        channelHandler.channelActive(channelHandlerContext);
        channelHandler.setState(WAIT_DESCRIPTION_STAT_REPLY);
        channelHandler.channelRead(channelHandlerContext, reply);
        channelHandler.channelRead(channelHandlerContext, new MockOfPortStatus());
    } catch (Exception e) {
        channelHandler = null;
    }
    // exception should not be fired
    assertNotNull(channelHandler);
    assertThat(channelHandler.getStateForTesting(), is(WAIT_SWITCH_DRIVER_SUB_HANDSHAKE));
    // Finally verify
    verify(controller);
}
Also used : OFDescStatsReply(org.projectfloodlight.openflow.protocol.OFDescStatsReply) OFDescStatsReplyAdapter(org.onosproject.openflow.OFDescStatsReplyAdapter) MockOfPortStatus(org.onosproject.openflow.MockOfPortStatus) OpenflowSwitchDriverAdapter(org.onosproject.openflow.OpenflowSwitchDriverAdapter) Test(org.junit.Test)

Example 3 with MockOfPortStatus

use of org.onosproject.openflow.MockOfPortStatus in project onos by opennetworkinglab.

the class OpenFlowControllerImplPacketsTest method testPortStatus.

/**
 * Tests a port status operation.
 */
@Test
public void testPortStatus() {
    OFMessage portStatusPacket = new MockOfPortStatus();
    controller.processPacket(dpid1, portStatusPacket);
    assertThat(switchListener.portChangedDpids().size(), is(1));
    assertThat(switchListener.portChangedDpids().containsKey(dpid1), is(true));
    assertThat(switchListener.portChangedDpids().get(dpid1), equalTo(portStatusPacket));
}
Also used : MockOfPortStatus(org.onosproject.openflow.MockOfPortStatus) OFMessage(org.projectfloodlight.openflow.protocol.OFMessage) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 MockOfPortStatus (org.onosproject.openflow.MockOfPortStatus)3 OFDescStatsReplyAdapter (org.onosproject.openflow.OFDescStatsReplyAdapter)2 OpenflowSwitchDriverAdapter (org.onosproject.openflow.OpenflowSwitchDriverAdapter)2 OFDescStatsReply (org.projectfloodlight.openflow.protocol.OFDescStatsReply)2 OFMessage (org.projectfloodlight.openflow.protocol.OFMessage)1