Search in sources :

Example 11 with Match

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

the class DriverMatcherTest method GetBestMatchWithMultipleDrivers.

@Test
public void GetBestMatchWithMultipleDrivers() throws Exception {
    add("org.apache.felix.driver.a-1.0", 1);
    add("org.apache.felix.driver.b-1.0", 1);
    add("org.apache.felix.driver.c-1.0", 10);
    Match match = m_matcherImpl.getBestMatch();
    Assert.assertNotNull(match);
    Assert.assertEquals("org.apache.felix.driver.c-1.0", tstDriverId(match));
}
Also used : Match(org.osgi.service.device.Match) Test(org.junit.Test)

Example 12 with Match

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

the class DriverMatcherTest method GetBestMatchWithInvalidRanking.

@Test
public void GetBestMatchWithInvalidRanking() throws Exception {
    add("org.apache.felix.driver.a-1.0", 1, 0);
    add("org.apache.felix.driver.b-1.0", 1, -1);
    Match match = m_matcherImpl.getBestMatch();
    Assert.assertNotNull(match);
    Assert.assertEquals("org.apache.felix.driver.a-1.0", tstDriverId(match));
}
Also used : Match(org.osgi.service.device.Match) Test(org.junit.Test)

Example 13 with Match

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

the class DriverMatcherTest method VerifyMatchToString.

@Test
public void VerifyMatchToString() throws Exception {
    DriverSelector selector = Mockito.mock(DriverSelector.class);
    ServiceReference deviceRef = Mockito.mock(ServiceReference.class);
    Mockito.when(selector.select(Mockito.eq(deviceRef), Mockito.isA(Match[].class))).thenReturn(0);
    add("org.apache.felix.driver-1.5", 2);
    Match match = m_matcherImpl.selectBestMatch(deviceRef, selector);
    Assert.assertNotNull(match);
    Assert.assertNotNull(match.toString());
}
Also used : DriverSelector(org.osgi.service.device.DriverSelector) ServiceReference(org.osgi.framework.ServiceReference) Match(org.osgi.service.device.Match) Test(org.junit.Test)

Aggregations

Match (org.osgi.service.device.Match)13 Test (org.junit.Test)11 ServiceReference (org.osgi.framework.ServiceReference)5 DriverSelector (org.osgi.service.device.DriverSelector)4 ArrayList (java.util.ArrayList)1 TreeMap (java.util.TreeMap)1 DriverAttributes (org.apache.felix.das.DriverAttributes)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1