Search in sources :

Example 1 with DriverManager

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

the class MeterManagerTest method setup.

@Before
public void setup() {
    DeviceService deviceService = new TestDeviceService();
    DriverRegistryManager driverRegistry = new DriverRegistryManager();
    DriverManager driverService = new TestDriverManager(driverRegistry, deviceService, new NetworkConfigServiceAdapter());
    driverRegistry.addDriver(new DefaultDriver("foo", ImmutableList.of(), "", "", "", ImmutableMap.of(MeterProgrammable.class, TestMeterProgrammable.class, MeterQuery.class, TestMeterQuery.class), ImmutableMap.of()));
    meterStore = new DistributedMeterStore();
    TestUtils.setField(meterStore, "storageService", new TestStorageService());
    TestUtils.setField(meterStore, "driverService", driverService);
    KryoNamespace.Builder testKryoBuilder = TestUtils.getField(meterStore, "APP_KRYO_BUILDER");
    testKryoBuilder.register(TestApplicationId.class);
    Serializer testSerializer = Serializer.using(Lists.newArrayList(testKryoBuilder.build()));
    TestUtils.setField(meterStore, "serializer", testSerializer);
    meterStore.activate();
    manager = new MeterManager();
    TestUtils.setField(manager, "store", meterStore);
    injectEventDispatcher(manager, new TestEventDispatcher());
    manager.deviceService = deviceService;
    manager.mastershipService = new TestMastershipService();
    manager.cfgService = new ComponentConfigAdapter();
    manager.clusterService = new TestClusterService();
    registry = manager;
    manager.driverService = driverService;
    Dictionary<String, Object> cfgDict = new Hashtable<>();
    expect(componentContext.getProperties()).andReturn(cfgDict);
    replay(componentContext);
    manager.activate(componentContext);
    provider = new TestProvider(PID);
    providerService = registry.register(provider);
    assertTrue("provider should be registered", registry.getProviders().contains(provider.id()));
}
Also used : TestEventDispatcher(org.onosproject.common.event.impl.TestEventDispatcher) TestStorageService(org.onosproject.store.service.TestStorageService) Hashtable(java.util.Hashtable) DeviceService(org.onosproject.net.device.DeviceService) DistributedMeterStore(org.onosproject.store.meter.impl.DistributedMeterStore) ComponentConfigAdapter(org.onosproject.cfg.ComponentConfigAdapter) DefaultDriver(org.onosproject.net.driver.DefaultDriver) KryoNamespace(org.onlab.util.KryoNamespace) NetworkConfigServiceAdapter(org.onosproject.net.config.NetworkConfigServiceAdapter) DriverManager(org.onosproject.net.driver.impl.DriverManager) DriverRegistryManager(org.onosproject.net.driver.impl.DriverRegistryManager) Serializer(org.onosproject.store.service.Serializer) Before(org.junit.Before)

Aggregations

Hashtable (java.util.Hashtable)1 Before (org.junit.Before)1 KryoNamespace (org.onlab.util.KryoNamespace)1 ComponentConfigAdapter (org.onosproject.cfg.ComponentConfigAdapter)1 TestEventDispatcher (org.onosproject.common.event.impl.TestEventDispatcher)1 NetworkConfigServiceAdapter (org.onosproject.net.config.NetworkConfigServiceAdapter)1 DeviceService (org.onosproject.net.device.DeviceService)1 DefaultDriver (org.onosproject.net.driver.DefaultDriver)1 DriverManager (org.onosproject.net.driver.impl.DriverManager)1 DriverRegistryManager (org.onosproject.net.driver.impl.DriverRegistryManager)1 DistributedMeterStore (org.onosproject.store.meter.impl.DistributedMeterStore)1 Serializer (org.onosproject.store.service.Serializer)1 TestStorageService (org.onosproject.store.service.TestStorageService)1