Search in sources :

Example 16 with DriverLocator

use of org.osgi.service.device.DriverLocator in project felix by apache.

the class DriverLoaderTest method loadDrivers_InstallFails.

@Test
public void loadDrivers_InstallFails() 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(string)).thenReturn(null);
        Mockito.when(m_context.installBundle(DriverLoader.DRIVER_LOCATION_PREFIX + string, null)).thenThrow(new BundleException("test exception"));
    }
    List<ServiceReference> refs = m_loader.loadDrivers(locators, driverIds);
    Assert.assertEquals("", 0, refs.size());
}
Also used : DriverLocator(org.osgi.service.device.DriverLocator) ArrayList(java.util.ArrayList) BundleException(org.osgi.framework.BundleException) ServiceReference(org.osgi.framework.ServiceReference) Test(org.junit.Test)

Aggregations

DriverLocator (org.osgi.service.device.DriverLocator)16 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)8 ServiceReference (org.osgi.framework.ServiceReference)6 CountDownLatch (java.util.concurrent.CountDownLatch)5 Device (org.osgi.service.device.Device)5 Properties (java.util.Properties)4 Driver (org.osgi.service.device.Driver)4 Dictionary (java.util.Dictionary)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 Answer (org.mockito.stubbing.Answer)3 BundleException (org.osgi.framework.BundleException)3 Bundle (org.osgi.framework.Bundle)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Ignore (org.junit.Ignore)1 DriverSelector (org.osgi.service.device.DriverSelector)1