use of org.onosproject.net.driver.DefaultDriver in project onos by opennetworkinglab.
the class CfmMepManagerTest method setup.
@Before
public void setup() throws CfmConfigException {
mepManager = new CfmMepManager();
mepStore = new DistributedMepStore();
storageService = new MockStorageService();
ma1 = DefaultMaintenanceAssociation.builder(MANAME1, MDNAME1.getNameLength()).build();
ma2 = DefaultMaintenanceAssociation.builder(MANAME2, MDNAME2.getNameLength()).build();
TestUtils.setField(mepStore, "storageService", storageService);
((DistributedMepStore) mepStore).activate();
TestUtils.setField(mepManager, "coreService", new TestCoreService());
TestUtils.setField(mepManager, "deviceService", deviceService);
TestUtils.setField(mepManager, "cfmMdService", mdService);
TestUtils.setField(mepManager, "mepStore", mepStore);
injectEventDispatcher(mepManager, new TestEventDispatcher());
mepService = mepManager;
mepManager.activate();
mep1 = DefaultMep.builder(MEPID1, DEVICE_ID1, PortNumber.P0, Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).build();
mepStore.createUpdateMep(new MepKeyId(MDNAME1, MANAME1, MEPID1), mep1);
mep11 = DefaultMep.builder(MEPID11, DEVICE_ID1, PortNumber.P0, Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).build();
mepStore.createUpdateMep(new MepKeyId(MDNAME1, MANAME1, MEPID11), mep11);
mep12 = DefaultMep.builder(MEPID12, DEVICE_ID1, PortNumber.P0, Mep.MepDirection.UP_MEP, MDNAME2, MANAME2).build();
mepStore.createUpdateMep(new MepKeyId(MDNAME2, MANAME2, MEPID12), mep12);
mep2 = DefaultMep.builder(MEPID2, DEVICE_ID2, PortNumber.portNumber(2), Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).build();
mepStore.createUpdateMep(new MepKeyId(MDNAME1, MANAME1, MEPID2), mep2);
mep21 = DefaultMep.builder(MEPID21, DEVICE_ID2, PortNumber.portNumber(2), Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).build();
mepStore.createUpdateMep(new MepKeyId(MDNAME1, MANAME1, MEPID21), mep21);
mep22 = DefaultMep.builder(MEPID22, DEVICE_ID2, PortNumber.portNumber(2), Mep.MepDirection.UP_MEP, MDNAME2, MANAME2).build();
mepStore.createUpdateMep(new MepKeyId(MDNAME2, MANAME2, MEPID22), mep22);
device1 = new DefaultDevice(ProviderId.NONE, DEVICE_ID1, Device.Type.SWITCH, TEST_MFR, TEST_HW_VERSION, TEST_SW_VERSION, TEST_SN, new ChassisId(1), DefaultAnnotations.builder().set(AnnotationKeys.DRIVER, TEST_DRIVER).build());
device2 = new DefaultDevice(ProviderId.NONE, DEVICE_ID2, Device.Type.SWITCH, TEST_MFR, TEST_HW_VERSION, TEST_SW_VERSION, TEST_SN, new ChassisId(2), DefaultAnnotations.builder().set(AnnotationKeys.DRIVER, TEST_DRIVER).build());
AbstractProjectableModel.setDriverService(null, driverService);
Map<Class<? extends Behaviour>, Class<? extends Behaviour>> behaviours = new HashMap<>();
behaviours.put(DeviceDescriptionDiscovery.class, TestDeviceDiscoveryBehavior.class);
behaviours.put(CfmMepProgrammable.class, TestCfmMepProgrammable.class);
behaviours.put(SoamDmProgrammable.class, TestSoamDmProgrammable.class);
testDriver = new DefaultDriver(TEST_DRIVER, new ArrayList<Driver>(), TEST_MFR, TEST_HW_VERSION, TEST_SW_VERSION, behaviours, new HashMap<>());
}
use of org.onosproject.net.driver.DefaultDriver 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);
}
use of org.onosproject.net.driver.DefaultDriver 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);
}
use of org.onosproject.net.driver.DefaultDriver in project onos by opennetworkinglab.
the class FlowRuleManagerTest method setUp.
@Before
public void setUp() {
mgr = new FlowRuleManager();
mgr.store = new SimpleFlowRuleStore();
injectEventDispatcher(mgr, new TestEventDispatcher());
mgr.deviceService = new TestDeviceService();
mgr.mastershipService = new TestMastershipService();
mgr.coreService = new TestCoreService();
mgr.operationsService = MoreExecutors.newDirectExecutorService();
mgr.deviceInstallers = MoreExecutors.newDirectExecutorService();
mgr.cfgService = new ComponentConfigAdapter();
ClusterService mockClusterService = createMock(ClusterService.class);
NodeId nodeId = new NodeId(NODE_ID);
MockControllerNode mockControllerNode = new MockControllerNode(nodeId);
expect(mockClusterService.getLocalNode()).andReturn(mockControllerNode).anyTimes();
replay(mockClusterService);
mgr.clusterService = mockClusterService;
service = mgr;
registry = mgr;
DriverRegistryManager driverRegistry = new DriverRegistryManager();
driverService = new TestDriverManager(driverRegistry);
driverRegistry.addDriver(new DefaultDriver("foo", ImmutableList.of(), "", "", "", ImmutableMap.of(FlowRuleProgrammable.class, TestFlowRuleProgrammable.class), ImmutableMap.of()));
mgr.activate(null);
mgr.addListener(listener);
provider = new TestProvider(PID);
providerService = this.registry.register(provider);
appId = new TestApplicationId(0, "FlowRuleManagerTest");
assertTrue("provider should be registered", this.registry.getProviders().contains(provider.id()));
}
use of org.onosproject.net.driver.DefaultDriver 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()));
}
Aggregations