Java 类net.floodlightcontroller.core.OFSwitch 实例源码

项目:fast-failover-demo    文件:OFSwitchManagerTest.java   
/**
 * Test SwitchDriverRegistry
 * Test fallback to default if no switch driver is registered for a
 * particular prefix
 */
@Test
public void testSwitchDriverRegistryNoDriver() {
    IOFSwitchDriver driver = createMock(IOFSwitchDriver.class);
    IOFSwitch returnedSwitch = null;
    IOFSwitchBackend mockSwitch = createMock(IOFSwitchBackend.class);
    switchManager.addOFSwitchDriver("test switch", driver);

    replay(driver);
    replay(mockSwitch);

    SwitchDescription desc = new SwitchDescription("test switch", "version 0.9", "", "", "");
    reset(driver);
    reset(mockSwitch);
    mockSwitch.setSwitchProperties(desc);
    expectLastCall().once();
    expect(driver.getOFSwitchImpl(desc, factory)).andReturn(mockSwitch).once();
    replay(driver);
    replay(mockSwitch);
    returnedSwitch = switchManager.getOFSwitchInstance(new NullConnection(), desc, factory, DatapathId.of(1));
    assertSame(mockSwitch, returnedSwitch);
    verify(driver);
    verify(mockSwitch);

    desc = new SwitchDescription("Foo Bar test switch", "version 0.9", "", "", "");
    reset(driver);
    reset(mockSwitch);
    replay(driver);
    replay(mockSwitch);
    returnedSwitch = switchManager.getOFSwitchInstance(new NullConnection(), desc,
            OFFactories.getFactory(OFVersion.OF_10), DatapathId.of(1));
    assertNotNull(returnedSwitch);
    assertTrue("Returned switch should be OFSwitch",
               returnedSwitch instanceof OFSwitch);
    assertEquals(desc, returnedSwitch.getSwitchDescription());
    verify(driver);
    verify(mockSwitch);
}
项目:floodlightLB    文件:OFSwitchManagerTest.java   
/**
 * Test SwitchDriverRegistry
 * Test fallback to default if no switch driver is registered for a
 * particular prefix
 */
@Test
public void testSwitchDriverRegistryNoDriver() {
    IOFSwitchDriver driver = createMock(IOFSwitchDriver.class);
    IOFSwitch returnedSwitch = null;
    IOFSwitchBackend mockSwitch = createMock(IOFSwitchBackend.class);
    switchManager.addOFSwitchDriver("test switch", driver);

    replay(driver);
    replay(mockSwitch);

    SwitchDescription desc = new SwitchDescription("test switch", "version 0.9", "", "", "");
    reset(driver);
    reset(mockSwitch);
    mockSwitch.setSwitchProperties(desc);
    expectLastCall().once();
    expect(driver.getOFSwitchImpl(desc, factory)).andReturn(mockSwitch).once();
    replay(driver);
    replay(mockSwitch);
    returnedSwitch = switchManager.getOFSwitchInstance(new NullConnection(), desc, factory, DatapathId.of(1));
    assertSame(mockSwitch, returnedSwitch);
    verify(driver);
    verify(mockSwitch);

    desc = new SwitchDescription("Foo Bar test switch", "version 0.9", "", "", "");
    reset(driver);
    reset(mockSwitch);
    replay(driver);
    replay(mockSwitch);
    returnedSwitch = switchManager.getOFSwitchInstance(new NullConnection(), desc,
            OFFactories.getFactory(OFVersion.OF_10), DatapathId.of(1));
    assertNotNull(returnedSwitch);
    assertTrue("Returned switch should be OFSwitch",
               returnedSwitch instanceof OFSwitch);
    assertEquals(desc, returnedSwitch.getSwitchDescription());
    verify(driver);
    verify(mockSwitch);
}
项目:DSC    文件:OFSwitchManagerTest.java   
/**
 * Test SwitchDriverRegistry
 * Test fallback to default if no switch driver is registered for a
 * particular prefix
 */
@Test
public void testSwitchDriverRegistryNoDriver() {
    IOFSwitchDriver driver = createMock(IOFSwitchDriver.class);
    IOFSwitch returnedSwitch = null;
    IOFSwitchBackend mockSwitch = createMock(IOFSwitchBackend.class);
    switchManager.addOFSwitchDriver("test switch", driver);

    replay(driver);
    replay(mockSwitch);

    SwitchDescription desc = new SwitchDescription("test switch", "version 0.9", "", "", "");
    reset(driver);
    reset(mockSwitch);
    mockSwitch.setSwitchProperties(desc);
    expectLastCall().once();
    expect(driver.getOFSwitchImpl(desc, factory)).andReturn(mockSwitch).once();
    replay(driver);
    replay(mockSwitch);
    returnedSwitch = switchManager.getOFSwitchInstance(new NullConnection(), desc, factory, DatapathId.of(1));
    assertSame(mockSwitch, returnedSwitch);
    verify(driver);
    verify(mockSwitch);

    desc = new SwitchDescription("Foo Bar test switch", "version 0.9", "", "", "");
    reset(driver);
    reset(mockSwitch);
    replay(driver);
    replay(mockSwitch);
    returnedSwitch = switchManager.getOFSwitchInstance(new NullConnection(), desc,
            OFFactories.getFactory(OFVersion.OF_10), DatapathId.of(1));
    assertNotNull(returnedSwitch);
    assertTrue("Returned switch should be OFSwitch",
               returnedSwitch instanceof OFSwitch);
    assertEquals(desc, returnedSwitch.getSwitchDescription());
    verify(driver);
    verify(mockSwitch);
}
项目:floodlight    文件:OFSwitchManagerTest.java   
/**
 * Test SwitchDriverRegistry
 * Test fallback to default if no switch driver is registered for a
 * particular prefix
 */
@Test
public void testSwitchDriverRegistryNoDriver() {
    IOFSwitchDriver driver = createMock(IOFSwitchDriver.class);
    IOFSwitch returnedSwitch = null;
    IOFSwitchBackend mockSwitch = createMock(IOFSwitchBackend.class);
    switchManager.addOFSwitchDriver("test switch", driver);

    replay(driver);
    replay(mockSwitch);

    SwitchDescription desc = new SwitchDescription("test switch", "version 0.9", "", "", "");
    reset(driver);
    reset(mockSwitch);
    mockSwitch.setSwitchProperties(desc);
    expectLastCall().once();
    expect(driver.getOFSwitchImpl(desc, factory)).andReturn(mockSwitch).once();
    replay(driver);
    replay(mockSwitch);
    returnedSwitch = switchManager.getOFSwitchInstance(new NullConnection(), desc, factory, DatapathId.of(1));
    assertSame(mockSwitch, returnedSwitch);
    verify(driver);
    verify(mockSwitch);

    desc = new SwitchDescription("Foo Bar test switch", "version 0.9", "", "", "");
    reset(driver);
    reset(mockSwitch);
    replay(driver);
    replay(mockSwitch);
    returnedSwitch = switchManager.getOFSwitchInstance(new NullConnection(), desc,
            OFFactories.getFactory(OFVersion.OF_10), DatapathId.of(1));
    assertNotNull(returnedSwitch);
    assertTrue("Returned switch should be OFSwitch",
               returnedSwitch instanceof OFSwitch);
    assertEquals(desc, returnedSwitch.getSwitchDescription());
    verify(driver);
    verify(mockSwitch);
}
项目:iTAP-controller    文件:OFSwitchTest.java   
@Before
public void setUp() throws Exception {
    MockOFConnection mockConnection = new MockOFConnection(DatapathId.of(1), OFAuxId.MAIN);
    sw = new OFSwitch(mockConnection, OFFactories.getFactory(OFVersion.OF_10),
            EasyMock.createMock(IOFSwitchManager.class), DatapathId.of(1));
}
项目:fast-failover-demo    文件:OFSwitchTest.java   
@Before
public void setUp() throws Exception {
    MockOFConnection mockConnection = new MockOFConnection(DatapathId.of(1), OFAuxId.MAIN);
    sw = new OFSwitch(mockConnection, OFFactories.getFactory(OFVersion.OF_10),
            EasyMock.createMock(IOFSwitchManager.class), DatapathId.of(1));
}
项目:floodlightLB    文件:OFSwitchTest.java   
@Before
public void setUp() throws Exception {
    MockOFConnection mockConnection = new MockOFConnection(DatapathId.of(1), OFAuxId.MAIN);
    sw = new OFSwitch(mockConnection, OFFactories.getFactory(OFVersion.OF_10),
            EasyMock.createMock(IOFSwitchManager.class), DatapathId.of(1));
}
项目:DSC    文件:OFSwitchTest.java   
@Before
public void setUp() throws Exception {
    MockOFConnection mockConnection = new MockOFConnection(DatapathId.of(1), OFAuxId.MAIN);
    sw = new OFSwitch(mockConnection, OFFactories.getFactory(OFVersion.OF_10),
            EasyMock.createMock(IOFSwitchManager.class), DatapathId.of(1));
}
项目:floodlight    文件:OFSwitchTest.java   
@Before
public void setUp() throws Exception {
    MockOFConnection mockConnection = new MockOFConnection(DatapathId.of(1), OFAuxId.MAIN);
    sw = new OFSwitch(mockConnection, OFFactories.getFactory(OFVersion.OF_10),
            EasyMock.createMock(IOFSwitchManager.class), DatapathId.of(1));
}