Package org.osgi.service.device

Examples of org.osgi.service.device.Match


                    error( "match threw an exception", new Exception( t ) );
                }
            }

            // get the best match
            Match bestMatch = null;

            // local copy
            final DriverSelector selector = m_selector;
           
            if ( selector != null )
            {
                bestMatch = mi.selectBestMatch( m_ref, selector );
                if (bestMatch != null) {
                  debug(String.format("DriverSelector (%s) found best match: %s", selector.getClass().getName(), Util.showDriver(bestMatch.getDriver())));
                }
            }
           
            if (bestMatch == null)
            {
                bestMatch = mi.getBestMatch();
            }

            if ( bestMatch == null )
            {
                noDriverFound();
                // really return
                return null;
            }

            String driverId = String.class.cast( bestMatch.getDriver().getProperty( Constants.DRIVER_ID ) );

            debug( "best match: " + driverId );
            m_finalDriver = m_drivers.get( bestMatch.getDriver() );

            if ( m_finalDriver == null )
            {
                error( "we found a driverId, but not the corresponding driver: " + driverId, null );
                noDriverFound();
View Full Code Here


    @Test
    public void GetBestMatchWithNoDriver() throws Exception
    {

        Match match = m_matcherImpl.getBestMatch();
        Assert.assertNull( match );

    }
View Full Code Here

    public void GetBestMatchWithOneDriver() throws Exception
    {

        add( "org.apache.felix.driver-1.0", 1 );

        Match match = m_matcherImpl.getBestMatch();
        Assert.assertNotNull( match );
        Assert.assertEquals( "org.apache.felix.driver-1.0", tstDriverId( match ) );

    }
View Full Code Here

      DriverSelector selector = Mockito.mock(DriverSelector.class);

      Mockito.when(selector.select(Mockito.eq(deviceRef), Mockito.isA(Match[].class)))
        .thenThrow(new IllegalArgumentException("test"));
     
        Match match = m_matcherImpl.selectBestMatch(deviceRef, selector);
        Assert.assertNull( match );

    }
View Full Code Here

        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 ) );

    }
View Full Code Here

    {

        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 ) );

    }
View Full Code Here

    {

        add( "org.apache.felix.driver.a-1.0", 1 );
        add( "org.apache.felix.driver.b-1.0", 1 );

        Match match = m_matcherImpl.getBestMatch();
        Assert.assertNotNull( match );
        Assert.assertEquals( "org.apache.felix.driver.a-1.0", tstDriverId( match ) );
        Assert.assertEquals( 1, match.getMatchValue() );
    }
View Full Code Here

    {

        add( "org.apache.felix.driver.a-1.0", 1, 2 );
        add( "org.apache.felix.driver.b-1.0", 1 );

        Match match = m_matcherImpl.getBestMatch();

        Assert.assertNotNull( match );
        final String driverId = "org.apache.felix.driver.a-1.0";

        Assert.assertEquals( driverId, tstDriverId( match ) );
        Assert.assertEquals( 1, match.getMatchValue() );
    }
View Full Code Here

        add( "org.apache.felix.driver.a-1.0", 1 );
        add( "org.apache.felix.driver.b-1.0", 2 );
        add( "org.apache.felix.driver.c-1.0", 1 );

        Match match = m_matcherImpl.getBestMatch();
        Assert.assertNotNull( match );
        Assert.assertEquals( "org.apache.felix.driver.b-1.0", tstDriverId( match ) );

        Assert.assertEquals( 2, match.getMatchValue() );
    }
View Full Code Here

                return null;
            }
        } );


        Match match = m_matcherImpl.selectBestMatch( deviceRef, selector );

        Assert.assertNotNull( "no match returned", match );
        String driverId = tstDriverId( match );

        Assert.assertEquals( "org.apache.felix.driver-1.3", driverId );
View Full Code Here

TOP

Related Classes of org.osgi.service.device.Match

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.