use of org.osgi.service.device.DriverLocator in project felix by apache.
the class DeviceManagerTest method LocatorAdded.
/**
* does not really test anything special, but ensures that the internal
* structure is able to parse the addition
*/
@Test
public void LocatorAdded() {
DriverLocator locator = Mockito.mock(DriverLocator.class);
m_manager.locatorAdded(locator);
}
use of org.osgi.service.device.DriverLocator in project felix by apache.
the class DeviceManagerTest method LocatorRemoved.
/**
* does not really test anything special, but ensures that the internal
* structure is able to parse the addition/ removal
*/
@Test
public void LocatorRemoved() {
DriverLocator locator = Mockito.mock(DriverLocator.class);
m_manager.locatorAdded(locator);
m_manager.locatorRemoved(locator);
}
use of org.osgi.service.device.DriverLocator in project felix by apache.
the class DriverLoaderTest method tstExpectDriverIdsFor.
private DriverLocator tstExpectDriverIdsFor(String[] ids) {
DriverLocator dl = Mockito.mock(DriverLocator.class);
Mockito.when(dl.findDrivers(Mockito.isA(Dictionary.class))).thenReturn(ids);
return dl;
}
use of org.osgi.service.device.DriverLocator in project felix by apache.
the class DriverLoaderTest method loadDrivers.
@Test
public void loadDrivers() throws IOException, BundleException {
List<DriverLocator> locators = new ArrayList<DriverLocator>();
DriverLocator dl = Mockito.mock(DriverLocator.class, "dl");
locators.add(dl);
String[] driverIds = new String[] { "org.apache.felix.driver-1.0", "org.apache.felix.driver-1.1" };
for (String string : driverIds) {
Mockito.when(dl.loadDriver(Mockito.eq(string))).thenReturn(null);
Bundle bundle = Mockito.mock(Bundle.class);
Mockito.when(m_context.installBundle("_DD_" + string, null)).thenReturn(bundle);
bundle.start();
ServiceReference ref = Mockito.mock(ServiceReference.class);
Mockito.when(ref.getProperty(Constants.DRIVER_ID)).thenReturn(string);
Mockito.when(bundle.getRegisteredServices()).thenReturn(new ServiceReference[] { ref });
}
List<ServiceReference> refs = m_loader.loadDrivers(locators, driverIds);
Assert.assertEquals("", 2, refs.size());
for (ServiceReference serviceReference : refs) {
String driverId = "" + serviceReference.getProperty(Constants.DRIVER_ID);
if (!driverId.equals(driverIds[0]) && !driverId.equals(driverIds[1])) {
Assert.fail("unexpected driverId");
}
}
}
use of org.osgi.service.device.DriverLocator in project felix by apache.
the class DriverLoaderTest method findDriversWithDriverLocators.
/**
* in this test there are several driver locators, some of which return
* driver Ids, some don't. we expect an accurate number of driver ids being returned
* from the driverloader.
*/
@Test
public void findDriversWithDriverLocators() {
List<DriverLocator> locators = new ArrayList<DriverLocator>();
DriverLocator dl1 = tstExpectDriverIdsFor(new String[] { "org.apache.felix.driver-1.0", "org.apache.felix.driver-1.1" });
locators.add(dl1);
DriverLocator dl2 = tstExpectDriverIdsFor(new String[] { "org.apache.felix.driver-1.2", "org.apache.felix.driver-1.3" });
locators.add(dl2);
DriverLocator dl3 = tstExpectDriverIdsFor(null);
locators.add(dl3);
Properties dict = new Properties();
Set<String> driverIds = m_loader.findDrivers(locators, dict);
Assert.assertEquals("should not be an empty list", 4, driverIds.size());
}
Aggregations