Package net.floodlightcontroller.core

Examples of net.floodlightcontroller.core.IOFSwitchDriver


        }
        if (driver == null) {
            throw new NullPointerException("driver must not be null");
        }

        IOFSwitchDriver existingDriver = switchBindingMap.get(manufacturerDescPrefix);
        if (existingDriver != null ) {
            throw new IllegalStateException("Failed to add OFSwitch driver for "
                    + manufacturerDescPrefix + "already registered");
        }
        switchBindingMap.put(manufacturerDescPrefix, driver);
View Full Code Here


        // Find the appropriate driver
        for (String descPrefix: switchDescSorted) {
            if (description.getManufacturerDescription()
                    .startsWith(descPrefix)) {
                IOFSwitchDriver driver = switchBindingMap.get(descPrefix);
                IOFSwitch sw = driver.getOFSwitchImpl(description);
                if (sw != null) {
                    sw.setSwitchProperties(description);
                    return sw;
                }
            }
View Full Code Here

    /**
     * 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);
        IOFSwitch returnedSwitch = null;
        IOFSwitch mockSwitch = createMock(IOFSwitch.class);
        controller.addOFSwitchDriver("", driver3);
        controller.addOFSwitchDriver("test switch", driver1);
        controller.addOFSwitchDriver("test", driver2);

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

        OFDescriptionStatistics desc = createOFDescriptionStatistics();
        desc.setManufacturerDescription("test switch");
        desc.setHardwareDescription("version 0.9");
        reset(driver1);
        reset(driver2);
        reset(driver3);
        reset(mockSwitch);
        mockSwitch.setSwitchProperties(desc);
        expectLastCall().once();
        expect(driver1.getOFSwitchImpl(desc)).andReturn(mockSwitch).once();
        replay(driver1);
        replay(driver2);
        replay(driver3);
        replay(mockSwitch);
        returnedSwitch = controller.getOFSwitchInstance(desc);
        assertSame(mockSwitch, returnedSwitch);
        verify(driver1);
        verify(driver2);
        verify(driver3);
        verify(mockSwitch);

        desc = createOFDescriptionStatistics();
        desc.setManufacturerDescription("testFooBar");
        desc.setHardwareDescription("version 0.9");
        reset(driver1);
        reset(driver2);
        reset(driver3);
        reset(mockSwitch);
        mockSwitch.setSwitchProperties(desc);
        expectLastCall().once();
        expect(driver2.getOFSwitchImpl(desc)).andReturn(mockSwitch).once();
        replay(driver1);
        replay(driver2);
        replay(driver3);
        replay(mockSwitch);
        returnedSwitch = controller.getOFSwitchInstance(desc);
        assertSame(mockSwitch, returnedSwitch);
        verify(driver1);
        verify(driver2);
        verify(driver3);
        verify(mockSwitch);

        desc = createOFDescriptionStatistics();
        desc.setManufacturerDescription("FooBar");
        desc.setHardwareDescription("version 0.9");
        reset(driver1);
        reset(driver2);
        reset(driver3);
        reset(mockSwitch);
        mockSwitch.setSwitchProperties(desc);
        expectLastCall().once();
        expect(driver3.getOFSwitchImpl(desc)).andReturn(mockSwitch).once();
        replay(driver1);
        replay(driver2);
        replay(driver3);
        replay(mockSwitch);
        returnedSwitch = controller.getOFSwitchInstance(desc);
View Full Code Here

     * 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;
        IOFSwitch mockSwitch = createMock(IOFSwitch.class);
        controller.addOFSwitchDriver("test switch", driver);

        replay(driver);
        replay(mockSwitch);

        OFDescriptionStatistics desc = createOFDescriptionStatistics();
        desc.setManufacturerDescription("test switch");
        desc.setHardwareDescription("version 0.9");
        reset(driver);
        reset(mockSwitch);
        mockSwitch.setSwitchProperties(desc);
        expectLastCall().once();
        expect(driver.getOFSwitchImpl(desc)).andReturn(mockSwitch).once();
        replay(driver);
        replay(mockSwitch);
        returnedSwitch = controller.getOFSwitchInstance(desc);
        assertSame(mockSwitch, returnedSwitch);
        verify(driver);
View Full Code Here

    /**
     *
     */
    @Test
    public void testDriverRegistryExceptions() {
        IOFSwitchDriver driver = createMock(IOFSwitchDriver.class);
        IOFSwitchDriver driver2 = createMock(IOFSwitchDriver.class);
        replay(driver, driver2); // no calls expected on driver

        //---------------
        // Test exception handling when registering driver
        try {
View Full Code Here

TOP

Related Classes of net.floodlightcontroller.core.IOFSwitchDriver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.