Package org.osgi.service.device

Examples of org.osgi.service.device.DriverSelector


                        best = m;
                }
            }

            // Maybe use driver selector instead
            DriverSelector ds = selector;
            if (ds != null) {
                int ix = ds.select(dev, sel);
                if (ix == DriverSelector.SELECT_NONE) {
                    tellNotFound(dev);
                    return;
                }
                try {
View Full Code Here


        new String[] { driverId1, driverId2 },
        new int[] { 20, 20 } );

        Device device = tstCreateDevice( new String[]{ "org.apache.felix" } );

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

        SelectorMatcher matcher = new SelectorMatcher( driverId2 );

        Mockito.when( selector.select(
            Mockito.eq( m_osgi.getReference( device ) ),
            Mockito.isA(Match[].class) ) ).thenAnswer( matcher );

        final CountDownLatch attachLatch = tstExpectAttach( drivers.get( driverId2 ), device );
View Full Code Here

            // 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)
            {
View Full Code Here

    @Test
    public void GetSelectBestMatchThrowsException() throws Exception
    {
     
      ServiceReference deviceRef = Mockito.mock(ServiceReference.class);
      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

    @Test
    public void selectBestDriver() throws Exception
    {

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

        add( "org.apache.felix.driver-1.0", 1 );
        add( "org.apache.felix.driver-1.1", 1 );
        add( "org.apache.felix.driver-1.2", 1 );
        add( "org.apache.felix.driver-1.3", 1 );
        add( "org.apache.felix.driver-1.4", 1 );
        add( "org.apache.felix.driver-1.5", 1 );
       
       
       
        //this is the actual driverselector implementation
        Mockito.when( selector.select( Mockito.isA(ServiceReference.class), Mockito.isA(Match[].class) ) )
          .thenAnswer( new Answer<Integer>()
        {
         
          public Integer answer(InvocationOnMock invocation) throws Throwable
            {
View Full Code Here

    @Test
    public void selectFails() 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) ) )
            .thenThrow( new RuntimeException( "test exception" ) );

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

        Match match = m_matcherImpl.selectBestMatch( deviceRef, selector );
View Full Code Here

   
    @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 );
View Full Code Here

TOP

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

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.