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

项目: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);
}
项目:fast-failover-demo    文件:OFSwitchManagerTest.java   
/**
 * Test the driver registry: test the bind order
 */
@Test
public void testSwitchDriverRegistryBindOrder() {
    IOFSwitchDriver driver1 = createMock(IOFSwitchDriver.class);
    IOFSwitchDriver driver2 = createMock(IOFSwitchDriver.class);
    IOFSwitchDriver driver3 = createMock(IOFSwitchDriver.class);
    IOFSwitchBackend returnedSwitch = null;
    IOFSwitchBackend mockSwitch = createMock(IOFSwitchBackend.class);
    switchManager.addOFSwitchDriver("", driver3);
    switchManager.addOFSwitchDriver("test switch", driver1);
    switchManager.addOFSwitchDriver("test", driver2);

    replay(driver1);
    replay(driver2);
    replay(driver3);
    replay(mockSwitch);

    SwitchDescription description = new SwitchDescription(
            "test switch", "version 0.9", "", "", "");
    reset(driver1);
    reset(driver2);
    reset(driver3);
    reset(mockSwitch);
    mockSwitch.setSwitchProperties(description);
    expectLastCall().once();
    OFFactory factory = OFFactories.getFactory(OFVersion.OF_10);
    expect(driver1.getOFSwitchImpl(description, factory)).andReturn(mockSwitch).once();
    replay(driver1);
    replay(driver2);
    replay(driver3);
    replay(mockSwitch);
    returnedSwitch = switchManager.getOFSwitchInstance(new NullConnection(), description, factory, DatapathId.of(1));
    assertSame(mockSwitch, returnedSwitch);
    verify(driver1);
    verify(driver2);
    verify(driver3);
    verify(mockSwitch);

    description = new SwitchDescription(
            "testFooBar", "version 0.9", "", "", "");
    reset(driver1);
    reset(driver2);
    reset(driver3);
    reset(mockSwitch);
    mockSwitch.setSwitchProperties(description);
    expectLastCall().once();
    expect(driver2.getOFSwitchImpl(description, factory)).andReturn(mockSwitch).once();
    replay(driver1);
    replay(driver2);
    replay(driver3);
    replay(mockSwitch);
    returnedSwitch = switchManager.getOFSwitchInstance(new NullConnection(), description,
            OFFactories.getFactory(OFVersion.OF_10), DatapathId.of(1));
    assertSame(mockSwitch, returnedSwitch);
    verify(driver1);
    verify(driver2);
    verify(driver3);
    verify(mockSwitch);

    description = new SwitchDescription(
            "FooBar", "version 0.9", "", "", "");
    reset(driver1);
    reset(driver2);
    reset(driver3);
    reset(mockSwitch);
    mockSwitch.setSwitchProperties(description);
    expectLastCall().once();
    expect(driver3.getOFSwitchImpl(description, factory)).andReturn(mockSwitch).once();
    replay(driver1);
    replay(driver2);
    replay(driver3);
    replay(mockSwitch);
    returnedSwitch = switchManager.getOFSwitchInstance(new NullConnection(), description, factory, DatapathId.of(1));
    assertSame(mockSwitch, returnedSwitch);
    verify(driver1);
    verify(driver2);
    verify(driver3);
    verify(mockSwitch);
}
项目:floodlightLB    文件:OFSwitchManagerTest.java   
/**
 * Test the driver registry: test the bind order
 */
@Test
public void testSwitchDriverRegistryBindOrder() {
    IOFSwitchDriver driver1 = createMock(IOFSwitchDriver.class);
    IOFSwitchDriver driver2 = createMock(IOFSwitchDriver.class);
    IOFSwitchDriver driver3 = createMock(IOFSwitchDriver.class);
    IOFSwitchBackend returnedSwitch = null;
    IOFSwitchBackend mockSwitch = createMock(IOFSwitchBackend.class);
    switchManager.addOFSwitchDriver("", driver3);
    switchManager.addOFSwitchDriver("test switch", driver1);
    switchManager.addOFSwitchDriver("test", driver2);

    replay(driver1);
    replay(driver2);
    replay(driver3);
    replay(mockSwitch);

    SwitchDescription description = new SwitchDescription(
            "test switch", "version 0.9", "", "", "");
    reset(driver1);
    reset(driver2);
    reset(driver3);
    reset(mockSwitch);
    mockSwitch.setSwitchProperties(description);
    expectLastCall().once();
    OFFactory factory = OFFactories.getFactory(OFVersion.OF_10);
    expect(driver1.getOFSwitchImpl(description, factory)).andReturn(mockSwitch).once();
    replay(driver1);
    replay(driver2);
    replay(driver3);
    replay(mockSwitch);
    returnedSwitch = switchManager.getOFSwitchInstance(new NullConnection(), description, factory, DatapathId.of(1));
    assertSame(mockSwitch, returnedSwitch);
    verify(driver1);
    verify(driver2);
    verify(driver3);
    verify(mockSwitch);

    description = new SwitchDescription(
            "testFooBar", "version 0.9", "", "", "");
    reset(driver1);
    reset(driver2);
    reset(driver3);
    reset(mockSwitch);
    mockSwitch.setSwitchProperties(description);
    expectLastCall().once();
    expect(driver2.getOFSwitchImpl(description, factory)).andReturn(mockSwitch).once();
    replay(driver1);
    replay(driver2);
    replay(driver3);
    replay(mockSwitch);
    returnedSwitch = switchManager.getOFSwitchInstance(new NullConnection(), description,
            OFFactories.getFactory(OFVersion.OF_10), DatapathId.of(1));
    assertSame(mockSwitch, returnedSwitch);
    verify(driver1);
    verify(driver2);
    verify(driver3);
    verify(mockSwitch);

    description = new SwitchDescription(
            "FooBar", "version 0.9", "", "", "");
    reset(driver1);
    reset(driver2);
    reset(driver3);
    reset(mockSwitch);
    mockSwitch.setSwitchProperties(description);
    expectLastCall().once();
    expect(driver3.getOFSwitchImpl(description, factory)).andReturn(mockSwitch).once();
    replay(driver1);
    replay(driver2);
    replay(driver3);
    replay(mockSwitch);
    returnedSwitch = switchManager.getOFSwitchInstance(new NullConnection(), description, factory, DatapathId.of(1));
    assertSame(mockSwitch, returnedSwitch);
    verify(driver1);
    verify(driver2);
    verify(driver3);
    verify(mockSwitch);
}
项目:DSC    文件:OFSwitchManagerTest.java   
/**
 * Test the driver registry: test the bind order
 */
@Test
public void testSwitchDriverRegistryBindOrder() {
    IOFSwitchDriver driver1 = createMock(IOFSwitchDriver.class);
    IOFSwitchDriver driver2 = createMock(IOFSwitchDriver.class);
    IOFSwitchDriver driver3 = createMock(IOFSwitchDriver.class);
    IOFSwitchBackend returnedSwitch = null;
    IOFSwitchBackend mockSwitch = createMock(IOFSwitchBackend.class);
    switchManager.addOFSwitchDriver("", driver3);
    switchManager.addOFSwitchDriver("test switch", driver1);
    switchManager.addOFSwitchDriver("test", driver2);

    replay(driver1);
    replay(driver2);
    replay(driver3);
    replay(mockSwitch);

    SwitchDescription description = new SwitchDescription(
            "test switch", "version 0.9", "", "", "");
    reset(driver1);
    reset(driver2);
    reset(driver3);
    reset(mockSwitch);
    mockSwitch.setSwitchProperties(description);
    expectLastCall().once();
    OFFactory factory = OFFactories.getFactory(OFVersion.OF_10);
    expect(driver1.getOFSwitchImpl(description, factory)).andReturn(mockSwitch).once();
    replay(driver1);
    replay(driver2);
    replay(driver3);
    replay(mockSwitch);
    returnedSwitch = switchManager.getOFSwitchInstance(new NullConnection(), description, factory, DatapathId.of(1));
    assertSame(mockSwitch, returnedSwitch);
    verify(driver1);
    verify(driver2);
    verify(driver3);
    verify(mockSwitch);

    description = new SwitchDescription(
            "testFooBar", "version 0.9", "", "", "");
    reset(driver1);
    reset(driver2);
    reset(driver3);
    reset(mockSwitch);
    mockSwitch.setSwitchProperties(description);
    expectLastCall().once();
    expect(driver2.getOFSwitchImpl(description, factory)).andReturn(mockSwitch).once();
    replay(driver1);
    replay(driver2);
    replay(driver3);
    replay(mockSwitch);
    returnedSwitch = switchManager.getOFSwitchInstance(new NullConnection(), description,
            OFFactories.getFactory(OFVersion.OF_10), DatapathId.of(1));
    assertSame(mockSwitch, returnedSwitch);
    verify(driver1);
    verify(driver2);
    verify(driver3);
    verify(mockSwitch);

    description = new SwitchDescription(
            "FooBar", "version 0.9", "", "", "");
    reset(driver1);
    reset(driver2);
    reset(driver3);
    reset(mockSwitch);
    mockSwitch.setSwitchProperties(description);
    expectLastCall().once();
    expect(driver3.getOFSwitchImpl(description, factory)).andReturn(mockSwitch).once();
    replay(driver1);
    replay(driver2);
    replay(driver3);
    replay(mockSwitch);
    returnedSwitch = switchManager.getOFSwitchInstance(new NullConnection(), description, factory, DatapathId.of(1));
    assertSame(mockSwitch, returnedSwitch);
    verify(driver1);
    verify(driver2);
    verify(driver3);
    verify(mockSwitch);
}
项目:floodlight    文件:OFSwitchManagerTest.java   
/**
 * Test the driver registry: test the bind order
 */
@Test
public void testSwitchDriverRegistryBindOrder() {
    IOFSwitchDriver driver1 = createMock(IOFSwitchDriver.class);
    IOFSwitchDriver driver2 = createMock(IOFSwitchDriver.class);
    IOFSwitchDriver driver3 = createMock(IOFSwitchDriver.class);
    IOFSwitchBackend returnedSwitch = null;
    IOFSwitchBackend mockSwitch = createMock(IOFSwitchBackend.class);
    switchManager.addOFSwitchDriver("", driver3);
    switchManager.addOFSwitchDriver("test switch", driver1);
    switchManager.addOFSwitchDriver("test", driver2);

    replay(driver1);
    replay(driver2);
    replay(driver3);
    replay(mockSwitch);

    SwitchDescription description = new SwitchDescription(
            "test switch", "version 0.9", "", "", "");
    reset(driver1);
    reset(driver2);
    reset(driver3);
    reset(mockSwitch);
    mockSwitch.setSwitchProperties(description);
    expectLastCall().once();
    OFFactory factory = OFFactories.getFactory(OFVersion.OF_10);
    expect(driver1.getOFSwitchImpl(description, factory)).andReturn(mockSwitch).once();
    replay(driver1);
    replay(driver2);
    replay(driver3);
    replay(mockSwitch);
    returnedSwitch = switchManager.getOFSwitchInstance(new NullConnection(), description, factory, DatapathId.of(1));
    assertSame(mockSwitch, returnedSwitch);
    verify(driver1);
    verify(driver2);
    verify(driver3);
    verify(mockSwitch);

    description = new SwitchDescription(
            "testFooBar", "version 0.9", "", "", "");
    reset(driver1);
    reset(driver2);
    reset(driver3);
    reset(mockSwitch);
    mockSwitch.setSwitchProperties(description);
    expectLastCall().once();
    expect(driver2.getOFSwitchImpl(description, factory)).andReturn(mockSwitch).once();
    replay(driver1);
    replay(driver2);
    replay(driver3);
    replay(mockSwitch);
    returnedSwitch = switchManager.getOFSwitchInstance(new NullConnection(), description,
            OFFactories.getFactory(OFVersion.OF_10), DatapathId.of(1));
    assertSame(mockSwitch, returnedSwitch);
    verify(driver1);
    verify(driver2);
    verify(driver3);
    verify(mockSwitch);

    description = new SwitchDescription(
            "FooBar", "version 0.9", "", "", "");
    reset(driver1);
    reset(driver2);
    reset(driver3);
    reset(mockSwitch);
    mockSwitch.setSwitchProperties(description);
    expectLastCall().once();
    expect(driver3.getOFSwitchImpl(description, factory)).andReturn(mockSwitch).once();
    replay(driver1);
    replay(driver2);
    replay(driver3);
    replay(mockSwitch);
    returnedSwitch = switchManager.getOFSwitchInstance(new NullConnection(), description, factory, DatapathId.of(1));
    assertSame(mockSwitch, returnedSwitch);
    verify(driver1);
    verify(driver2);
    verify(driver3);
    verify(mockSwitch);
}