Search in sources :

Example 1 with OpenflowSwitchDriverAdapter

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

the class OpenFlowControllerImplPacketsTest method setUp.

/**
 * Sets up switches to use as data, mocks and launches a controller instance.
 */
@Before
public void setUp() {
    try {
        switch1 = new OpenflowSwitchDriverAdapter();
        dpid1 = Dpid.dpid(new URI("of:0000000000000111"));
    } catch (URISyntaxException ex) {
        // Does not happen
        fail();
    }
    controller = new OpenFlowControllerImpl();
    agent = controller.agent;
    switchListener = new OpenFlowSwitchListenerAdapter();
    controller.addListener(switchListener);
    packetListener = new TestPacketListener();
    controller.addPacketListener(100, packetListener);
    statsExecutorService = new TestExecutorService();
    errorMsgExecutorService = new TestExecutorService();
    controller.executorMsgs = statsExecutorService;
    controller.executorErrorMsgs = errorMsgExecutorService;
}
Also used : OpenFlowSwitchListenerAdapter(org.onosproject.openflow.OpenFlowSwitchListenerAdapter) OpenflowSwitchDriverAdapter(org.onosproject.openflow.OpenflowSwitchDriverAdapter) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) Before(org.junit.Before)

Example 2 with OpenflowSwitchDriverAdapter

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

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

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

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

OpenflowSwitchDriverAdapter (org.onosproject.openflow.OpenflowSwitchDriverAdapter)6 Test (org.junit.Test)4 OFDescStatsReplyAdapter (org.onosproject.openflow.OFDescStatsReplyAdapter)4 OFDescStatsReply (org.projectfloodlight.openflow.protocol.OFDescStatsReply)4 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 Before (org.junit.Before)2 MockOfPortStatus (org.onosproject.openflow.MockOfPortStatus)2 Hashtable (java.util.Hashtable)1 EasyMock.anyObject (org.easymock.EasyMock.anyObject)1 ComponentConfigService (org.onosproject.cfg.ComponentConfigService)1 CoreService (org.onosproject.core.CoreService)1 NetworkConfigRegistry (org.onosproject.net.config.NetworkConfigRegistry)1 OpenFlowSwitchListenerAdapter (org.onosproject.openflow.OpenFlowSwitchListenerAdapter)1 OpenFlowService (org.onosproject.openflow.controller.OpenFlowService)1 ComponentContext (org.osgi.service.component.ComponentContext)1