Search in sources :

Example 1 with DefaultDriverProvider

use of org.onosproject.net.driver.DefaultDriverProvider in project onos by opennetworkinglab.

the class DriverRegistryManagerTest method basicQueries.

@Test
public void basicQueries() {
    DefaultDriverProvider mockProvider = new DefaultDriverProvider();
    DefaultDriver driver = new DefaultDriver("default", Lists.newArrayList(), MFR, HW, SW, ImmutableMap.of(TestBehaviour.class, TestBehaviourImpl.class), ImmutableMap.of("foo", "bar"));
    mockProvider.addDriver(driver);
    mgr.registerProvider(mockProvider);
    assertSame("driver is missing", driver, mgr.getDriver("default"));
    assertSame("driver is missing", driver, mgr.getDriver(MFR, HW, SW));
    assertArrayEquals("driver list is wrong", ImmutableList.of(driver).toArray(), mgr.getDrivers().toArray());
    assertArrayEquals("provider list is wrong", ImmutableList.of(mockProvider).toArray(), mgr.getProviders().toArray());
    assertEquals("wrong behaviour class", TestBehaviourImpl.class, mgr.getBehaviourClass("org.onosproject.net.driver.TestBehaviourImpl"));
}
Also used : TestBehaviourImpl(org.onosproject.net.driver.TestBehaviourImpl) DefaultDriver(org.onosproject.net.driver.DefaultDriver) TestBehaviour(org.onosproject.net.driver.TestBehaviour) DefaultDriverProvider(org.onosproject.net.driver.DefaultDriverProvider) Test(org.junit.Test) DefaultDriverTest(org.onosproject.net.driver.DefaultDriverTest)

Example 2 with DefaultDriverProvider

use of org.onosproject.net.driver.DefaultDriverProvider in project onos by opennetworkinglab.

the class DriverRegistryManagerTest method basicEvents.

@Test
public void basicEvents() {
    mgr.addListener(testListener);
    DefaultDriverProvider mockProvider = new DefaultDriverProvider();
    DefaultDriver driver = new DefaultDriver("foo", Lists.newArrayList(), MFR, HW, SW, ImmutableMap.of(TestBehaviour.class, TestBehaviourImpl.class), ImmutableMap.of("foo", "bar"));
    mockProvider.addDriver(driver);
    mgr.registerProvider(mockProvider);
    assertEquals("wrong driver event type", DRIVER_ENHANCED, testListener.event.type());
    assertSame("wrong driver event subject", driver, testListener.event.subject());
    mgr.unregisterProvider(mockProvider);
    assertEquals("wrong driver event type", DRIVER_REDUCED, testListener.event.type());
    assertSame("wrong driver event subject", driver, testListener.event.subject());
    mgr.removeListener(testListener);
}
Also used : TestBehaviourImpl(org.onosproject.net.driver.TestBehaviourImpl) DefaultDriver(org.onosproject.net.driver.DefaultDriver) TestBehaviour(org.onosproject.net.driver.TestBehaviour) DefaultDriverProvider(org.onosproject.net.driver.DefaultDriverProvider) Test(org.junit.Test) DefaultDriverTest(org.onosproject.net.driver.DefaultDriverTest)

Example 3 with DefaultDriverProvider

use of org.onosproject.net.driver.DefaultDriverProvider in project onos by opennetworkinglab.

the class DriverRegistryManagerTest method managerStart.

@Test
public void managerStart() {
    DefaultDriverProvider mockProvider = new DefaultDriverProvider();
    DefaultDriver driver = new DefaultDriver("default", Lists.newArrayList(), MFR, HW, SW, ImmutableMap.of(TestBehaviour.class, TestBehaviourImpl.class), ImmutableMap.of("foo", "bar"));
    mockProvider.addDriver(driver);
    mgr.registerProvider(mockProvider);
    assertTrue("should be activated", componentService.activated);
    mgr.unregisterProvider(mockProvider);
    assertFalse("should not be dactivated", componentService.activated);
}
Also used : TestBehaviourImpl(org.onosproject.net.driver.TestBehaviourImpl) DefaultDriver(org.onosproject.net.driver.DefaultDriver) TestBehaviour(org.onosproject.net.driver.TestBehaviour) DefaultDriverProvider(org.onosproject.net.driver.DefaultDriverProvider) Test(org.junit.Test) DefaultDriverTest(org.onosproject.net.driver.DefaultDriverTest)

Aggregations

Test (org.junit.Test)3 DefaultDriver (org.onosproject.net.driver.DefaultDriver)3 DefaultDriverProvider (org.onosproject.net.driver.DefaultDriverProvider)3 DefaultDriverTest (org.onosproject.net.driver.DefaultDriverTest)3 TestBehaviour (org.onosproject.net.driver.TestBehaviour)3 TestBehaviourImpl (org.onosproject.net.driver.TestBehaviourImpl)3