Search in sources :

Example 1 with OFDescStatsReplyAdapter

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

the class ControllerTest method switchItemNotFoundTest.

/**
 * Tests fetching a driver that throws an ItemNotFoundException.
 */
@Test
public void switchItemNotFoundTest() {
    controller.start(null, new MockDriverService(), null);
    OFDescStatsReply stats = new OFDescStatsReplyAdapter();
    OpenFlowSwitchDriver driver = controller.getOFSwitchInstance(MockDriverService.ITEM_NOT_FOUND_DRIVER_ID, stats, null);
    assertThat(driver, nullValue());
    controller.stop();
}
Also used : OFDescStatsReply(org.projectfloodlight.openflow.protocol.OFDescStatsReply) OpenFlowSwitchDriver(org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver) OFDescStatsReplyAdapter(org.onosproject.openflow.OFDescStatsReplyAdapter) Test(org.junit.Test)

Example 2 with OFDescStatsReplyAdapter

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

the class OFChannelHandlerTest method testDuplicateDpid.

// Normal workflow - duplicate Dpid
@Test
public void testDuplicateDpid() {
    // 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)), true));
    replay(controller);
    try {
        channelHandler.channelActive(channelHandlerContext);
        channelHandler.setState(WAIT_DESCRIPTION_STAT_REPLY);
        channelHandler.channelRead(channelHandlerContext, reply);
    } catch (Exception e) {
        channelHandler = null;
    }
    // exception should not be fired
    assertNotNull(channelHandler);
    assertThat(channelHandler.getStateForTesting(), is(WAIT_DESCRIPTION_STAT_REPLY));
    // Finally verify
    verify(controller);
}
Also used : OFDescStatsReply(org.projectfloodlight.openflow.protocol.OFDescStatsReply) OFDescStatsReplyAdapter(org.onosproject.openflow.OFDescStatsReplyAdapter) OpenflowSwitchDriverAdapter(org.onosproject.openflow.OpenflowSwitchDriverAdapter) Test(org.junit.Test)

Example 3 with OFDescStatsReplyAdapter

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

the class OFChannelHandlerTest method testActiveDpid.

// Normal workflow - connect
@Test
public void testActiveDpid() {
    // Expected behavior
    OFDescStatsReply reply = new OFDescStatsReplyAdapter();
    expect(controller.getOFSwitchInstance(0, reply, OF_13)).andReturn(new OpenflowSwitchDriverAdapter(ImmutableSet.of(), Dpid.dpid(Dpid.uri(0)), true));
    replay(controller);
    try {
        channelHandler.channelActive(channelHandlerContext);
        channelHandler.setState(WAIT_DESCRIPTION_STAT_REPLY);
        channelHandler.channelRead(channelHandlerContext, reply);
    } 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) OpenflowSwitchDriverAdapter(org.onosproject.openflow.OpenflowSwitchDriverAdapter) Test(org.junit.Test)

Example 4 with OFDescStatsReplyAdapter

use of org.onosproject.openflow.OFDescStatsReplyAdapter 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 5 with OFDescStatsReplyAdapter

use of org.onosproject.openflow.OFDescStatsReplyAdapter 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)

Aggregations

Test (org.junit.Test)6 OFDescStatsReplyAdapter (org.onosproject.openflow.OFDescStatsReplyAdapter)6 OFDescStatsReply (org.projectfloodlight.openflow.protocol.OFDescStatsReply)6 OpenflowSwitchDriverAdapter (org.onosproject.openflow.OpenflowSwitchDriverAdapter)4 MockOfPortStatus (org.onosproject.openflow.MockOfPortStatus)2 OpenFlowSwitchDriver (org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver)2