This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git


The following commit(s) were added to refs/heads/master by this push:
     new f93d9bda45 Unmaintained code removal - deviceaccess
f93d9bda45 is described below

commit f93d9bda45ff891dba796eb34a857bf2db02a264
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Tue Aug 22 17:45:05 2023 +0200

    Unmaintained code removal - deviceaccess
---
 deviceaccess/pom.xml                               |  95 ---
 .../main/java/org/apache/felix/das/Activator.java  | 115 ---
 .../java/org/apache/felix/das/DeviceManager.java   | 728 ----------------
 .../org/apache/felix/das/DriverAttributes.java     | 114 ---
 .../src/main/java/org/apache/felix/das/Log.java    |  41 -
 .../org/apache/felix/das/NamedThreadFactory.java   |  47 --
 .../org/apache/felix/das/util/DeviceAnalyzer.java  |  99 ---
 .../org/apache/felix/das/util/DriverAnalyzer.java  |  60 --
 .../org/apache/felix/das/util/DriverLoader.java    | 194 -----
 .../org/apache/felix/das/util/DriverMatcher.java   | 209 -----
 .../main/java/org/apache/felix/das/util/Util.java  | 179 ----
 .../org/apache/felix/das/DeviceManagerTest.java    | 913 ---------------------
 .../org/apache/felix/das/DriverAttributesTest.java | 174 ----
 .../test/java/org/apache/felix/das/OSGiMock.java   | 168 ----
 .../src/test/java/org/apache/felix/das/Utils.java  |  78 --
 .../apache/felix/das/util/DriverAnalyzerTest.java  | 131 ---
 .../apache/felix/das/util/DriverLoaderTest.java    | 263 ------
 .../apache/felix/das/util/DriverMatcherTest.java   | 329 --------
 .../java/org/apache/felix/das/util/UtilTest.java   | 221 -----
 19 files changed, 4158 deletions(-)

diff --git a/deviceaccess/pom.xml b/deviceaccess/pom.xml
deleted file mode 100644
index be67f46a23..0000000000
--- a/deviceaccess/pom.xml
+++ /dev/null
@@ -1,95 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements.  See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership.  The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied.  See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
-
-  <modelVersion>4.0.0</modelVersion>
-
-  <parent>
-    <groupId>org.apache.felix</groupId>
-    <artifactId>felix-parent</artifactId>
-    <version>2</version>
-    <relativePath>../pom/pom.xml</relativePath>
-  </parent>
-
-  <artifactId>org.apache.felix.devicemanager</artifactId>
-  <version>0.9.0-SNAPSHOT</version>
-  <packaging>bundle</packaging>
-
-  <name>Apache Felix Device Manager</name>
-
-  <description>
-      Implementation of the OSGi Device Access Specification 1.1
-  </description>
-
-        <dependencies>
-          <dependency>
-              <groupId>org.osgi</groupId>
-              <artifactId>org.osgi.core</artifactId>
-                <version>4.2.0</version>
-              <scope>provided</scope>
-          </dependency>
-          <dependency>
-              <groupId>org.osgi</groupId>
-              <artifactId>org.osgi.compendium</artifactId>
-                <version>4.2.0</version>
-              <scope>provided</scope>
-          </dependency>
-          <dependency>
-            <groupId>${pom.groupId}</groupId>
-            <artifactId>org.apache.felix.framework</artifactId>
-            <version>1.6.0</version>
-            <scope>test</scope>
-          </dependency>
-          <dependency>
-            <groupId>${pom.groupId}</groupId>
-            <artifactId>org.apache.felix.dependencymanager</artifactId>
-            <version>3.0.0</version>
-            <scope>provided</scope>
-          </dependency>
-        </dependencies>
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-bundle-plugin</artifactId>
-        <version>1.4.0</version>
-        <extensions>true</extensions>
-        <configuration>
-          <instructions>
-            <Bundle-SymbolicName>org.apache.felix.das</Bundle-SymbolicName>
-            <Bundle-Name>Apache Felix Device Manager</Bundle-Name>
-            <Bundle-Description>A bundle that provides a run-time device 
manager.</Bundle-Description>
-            <Bundle-Vendor>Apache Software Foundation</Bundle-Vendor>
-            <Bundle-Activator>org.apache.felix.das.Activator</Bundle-Activator>
-            <Private-Package>org.apache.felix.das, 
org.apache.felix.das.util</Private-Package>
-          </instructions>
-        </configuration>
-      </plugin>
-      <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-compiler-plugin</artifactId>
-          <configuration>
-             <source>1.5</source>
-             <target>1.5</target>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-</project>
diff --git a/deviceaccess/src/main/java/org/apache/felix/das/Activator.java 
b/deviceaccess/src/main/java/org/apache/felix/das/Activator.java
deleted file mode 100644
index c7f918ab6a..0000000000
--- a/deviceaccess/src/main/java/org/apache/felix/das/Activator.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.das;
-
-
-import org.apache.felix.das.util.Util;
-import org.apache.felix.dm.Component;
-import org.apache.felix.dm.DependencyActivatorBase;
-import org.apache.felix.dm.DependencyManager;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.service.device.Device;
-import org.osgi.service.device.Driver;
-import org.osgi.service.device.DriverLocator;
-import org.osgi.service.device.DriverSelector;
-import org.osgi.service.log.LogService;
-
-
-/**
- * TODO: add javadoc
- * 
- * @author <a href="mailto:[email protected]";>Felix Project Team</a>
- */
-public class Activator extends DependencyActivatorBase
-{
-
-    /** the bundle context */
-    private volatile BundleContext m_context;
-
-    /** the dependency manager */
-    private volatile DependencyManager m_manager;
-
-    /** the device manager */
-    private DeviceManager m_deviceManager;
-
-
-    /**
-     * Here, we create and start the device manager, but we do not register it
-     * within the framework, since that is not specified by the specification.
-     * 
-     * @see 
org.apache.felix.dependencymanager.DependencyActivatorBase#init(org.osgi.framework.BundleContext,
-     *      org.apache.felix.dependencymanager.DependencyManager)
-     */
-    public void init( BundleContext context, DependencyManager manager ) 
throws Exception
-    {
-
-        m_context = context;
-        m_manager = manager;
-
-        m_deviceManager = new DeviceManager( m_context );
-
-        // the real device manager
-        startDeviceManager();
-
-    }
-
-
-    private void startDeviceManager() {
-
-        final String driverFilter = Util.createFilterString( "(%s=%s)", new 
String[]
-            { org.osgi.service.device.Constants.DRIVER_ID, "*" } );
-
-        final String deviceFilter = Util.createFilterString( 
"(|(%s=%s)(&(%s=%s)(%s=%s)))", new String[]
-            { 
-               Constants.OBJECTCLASS, Device.class.getName(), 
-               Constants.OBJECTCLASS, "*", 
-               org.osgi.service.device.Constants.DEVICE_CATEGORY, "*" 
-               } );
-
-        Component svc = createComponent();
-
-        svc.setImplementation( m_deviceManager );
-
-        svc.add( createServiceDependency().setService( LogService.class 
).setRequired( false ) );
-
-        svc.add( createServiceDependency().setService( DriverSelector.class 
).setRequired( false ).setAutoConfig( false )
-               .setCallbacks( "selectorAdded", "selectorRemoved" ) );
-
-        svc.add( createServiceDependency().setService( DriverLocator.class 
).setRequired( false ).setAutoConfig( false )
-            .setCallbacks( "locatorAdded", "locatorRemoved" ) );
-        
-        svc.add( createServiceDependency().setService( Driver.class, 
driverFilter ).setRequired( false )
-               .setCallbacks( "driverAdded", "driverModified", "driverRemoved" 
) );
-        
-        svc.add( createServiceDependency().setService( deviceFilter 
).setRequired( false )
-               .setCallbacks( "deviceAdded", "deviceModified", "deviceRemoved" 
) );
-        
-        m_manager.add( svc );
-
-    }
-
-
-    public void destroy( BundleContext context, DependencyManager manager ) 
throws Exception
-    {
-        // TODO Auto-generated method stub
-
-    }
-
-}
diff --git a/deviceaccess/src/main/java/org/apache/felix/das/DeviceManager.java 
b/deviceaccess/src/main/java/org/apache/felix/das/DeviceManager.java
deleted file mode 100644
index ed7159af54..0000000000
--- a/deviceaccess/src/main/java/org/apache/felix/das/DeviceManager.java
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.das;
-
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.felix.das.util.DriverLoader;
-import org.apache.felix.das.util.DriverMatcher;
-import org.apache.felix.das.util.Util;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.FrameworkListener;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.device.Constants;
-import org.osgi.service.device.Device;
-import org.osgi.service.device.Driver;
-import org.osgi.service.device.DriverLocator;
-import org.osgi.service.device.DriverSelector;
-import org.osgi.service.device.Match;
-import org.osgi.service.log.LogService;
-
-
-/**
- * This class represents the Apache Felix implementation of the device access 
specification.
- * It is based on version 1.1 of the spec.
- * 
- * 
- * @author <a href="mailto:[email protected]";>Felix Project Team</a>
- */
-public class DeviceManager implements Log
-{
-
-    private final long DEFAULT_TIMEOUT_SEC = 1;
-
-    // the logger
-    private volatile LogService m_log;
-
-    // the bundle context
-    private final BundleContext m_context;
-
-    // the driver selector
-    private volatile DriverSelector m_selector;
-
-    // the driver locators
-    private List<DriverLocator> m_locators;
-
-    // the devices
-    private Map<ServiceReference, Object> m_devices;
-
-    // the drivers
-    private Map<ServiceReference, DriverAttributes> m_drivers;
-
-    // performs all the background actions
-    private ExecutorService m_worker;
-
-    // used to add delayed actions
-    private ScheduledExecutorService m_delayed;
-
-    //the devices filter
-    private Filter m_deviceImplFilter;
-
-    //the drivers filter
-    private Filter m_driverImplFilter;
-
-
-    /**
-     * Public constructor. Used by the Activator in this <code>Bundle</code>
-     * to instantiate one instance.
-     * 
-     * @param context the <code>BundleContext</code>
-     */
-    public DeviceManager( BundleContext context )
-    {
-        m_context = context;
-    }
-
-
-    public void debug( String message )
-    {
-        m_log.log( LogService.LOG_DEBUG, message );
-    }
-
-
-    public void info( String message )
-    {
-        m_log.log( LogService.LOG_INFO, message );
-    }
-
-
-    public void warning( String message )
-    {
-        m_log.log( LogService.LOG_WARNING, message );
-    }
-
-
-    public void error( String message, Throwable e )
-    {
-        System.err.println( message );
-        if ( e != null )
-        {
-            e.printStackTrace();
-        }
-        m_log.log( LogService.LOG_ERROR, message, e );
-    }
-
-
-    // dependency manager methods
-    @SuppressWarnings("unused")
-    private void init() throws InvalidSyntaxException
-    {
-        m_locators = Collections.synchronizedList( new 
ArrayList<DriverLocator>() );
-        m_worker = Executors.newSingleThreadExecutor( new NamedThreadFactory( 
"Apache Felix Device Manager" ) );
-        m_delayed = Executors.newScheduledThreadPool( 1, new 
NamedThreadFactory(
-            "Apache Felix Device Manager - delayed" ) );
-        m_deviceImplFilter = Util.createFilter( "(%s=%s)", new Object[]
-            { org.osgi.framework.Constants.OBJECTCLASS, Device.class.getName() 
} );
-        m_driverImplFilter = Util.createFilter( "(%s=%s)", new Object[]
-            { org.osgi.framework.Constants.OBJECTCLASS, Driver.class.getName() 
} );
-    }
-
-
-    @SuppressWarnings("unused")
-    private void start()
-    {
-        m_drivers = new HashMap<ServiceReference, DriverAttributes>();
-        m_devices = new HashMap<ServiceReference, Object>();
-        submit( new WaitForStartFramework() );
-    }
-
-
-    public void stop()
-    {
-        // nothing to do ?
-    }
-
-
-    public void destroy()
-    {
-        m_worker.shutdownNow();
-        m_delayed.shutdownNow();
-    }
-
-
-    // callback methods
-
-    public void selectorAdded( DriverSelector selector )
-    {
-        m_selector = selector;
-        debug( "driver selector appeared" );
-    }
-
-
-    public void selectorRemoved( DriverSelector selector )
-    {
-        m_selector = null;
-        debug( "driver selector lost" );
-    }
-    
-    public void locatorAdded( DriverLocator locator )
-    {
-        m_locators.add( locator );
-        debug( "driver locator appeared" );
-    }
-
-
-    public void locatorRemoved( DriverLocator locator )
-    {
-        m_locators.remove( locator );
-        debug( "driver locator lost" );
-    }
-
-
-    public void driverAdded( ServiceReference ref, Object obj )
-    {
-        final Driver driver = Driver.class.cast( obj );
-        m_drivers.put( ref, new DriverAttributes( ref, driver ) );
-
-        debug( "driver appeared: " + Util.showDriver( ref ) );
-        
-        //immediately check for idle devices
-        submit( new CheckForIdleDevices() );
-    }
-
-    public void driverModified( ServiceReference ref, Object obj )
-    {
-        final Driver driver = Driver.class.cast( obj );
-        
-        debug( "driver modified: " + Util.showDriver( ref ) );
-        m_drivers.remove( ref );
-        m_drivers.put( ref , new DriverAttributes( ref, driver ) );
-
-        // check if devices have become idle
-        // after some time
-        schedule( new CheckForIdleDevices() );
-    }
-
-    public void driverRemoved( ServiceReference ref )
-    {
-        debug( "driver lost: " + Util.showDriver( ref ) );
-        m_drivers.remove( ref );
-
-        // check if devices have become idle
-        // after some time
-        schedule( new CheckForIdleDevices() );
-
-    }
-
-
-    public void deviceAdded( ServiceReference ref, Object device )
-    {
-        m_devices.put( ref, device );
-        debug( "device appeared: " + Util.showDevice( ref ) );
-        submit( new DriverAttachAlgorithm( ref, device ) );
-    }
-
-
-    public void deviceModified( ServiceReference ref, Object device )
-    {
-        debug( "device modified: " + Util.showDevice( ref ) );
-        // nothing further to do ?
-        // DeviceAttributes da = m_devices.get(ref);
-        // submit(new DriverAttachAlgorithm(da));
-    }
-
-
-    public void deviceRemoved( ServiceReference ref )
-    {
-        debug( "device removed: " + Util.showDevice( ref ) );
-        m_devices.remove( ref );
-        // nothing further to do ?
-        // the services that use this
-        // device should track it.
-    }
-
-
-    /**
-     * perform this task as soon as possible.
-     * 
-     * @param task
-     *            the task
-     */
-    private void submit( Callable<Object> task )
-    {
-        m_worker.submit( new LoggedCall( task ) );
-    }
-
-
-    /**
-     * perform this task after the default delay.
-     * 
-     * @param task
-     *            the task
-     */
-    private void schedule( Callable<Object> task )
-    {
-        m_delayed.schedule( new DelayedCall( task ), DEFAULT_TIMEOUT_SEC, 
TimeUnit.SECONDS );
-    }
-
-    // worker callables
-
-    /**
-     * Callable used to start the DeviceManager. It either waits (blocking the
-     * worker thread) for the framework to start, or if it has already started,
-     * returns immediately, freeing up the worker thread.
-     * 
-     * @author <a href="mailto:[email protected]";>Felix Project Team</a>
-     */
-    private class WaitForStartFramework implements Callable<Object>, 
FrameworkListener
-    {
-
-        private final CountDownLatch m_latch = new CountDownLatch( 1 );
-
-
-        public Object call() throws Exception
-        {
-            boolean addedAsListener = false;
-            if ( m_context.getBundle( 0 ).getState() == Bundle.ACTIVE )
-            {
-                m_latch.countDown();
-                debug( "Starting Device Manager immediately" );
-            }
-            else
-            {
-                m_context.addFrameworkListener( this );
-                addedAsListener = true;
-                debug( "Waiting for framework to start" );
-            }
-
-            m_latch.await();
-            for ( Map.Entry<ServiceReference, Object> entry : 
m_devices.entrySet() )
-            {
-                submit( new DriverAttachAlgorithm( entry.getKey(), 
entry.getValue() ) );
-            }
-            // cleanup
-            if ( addedAsListener )
-            {
-                m_context.removeFrameworkListener( this );
-            }
-            return null;
-        }
-
-
-        // FrameworkListener method
-        public void frameworkEvent( FrameworkEvent event )
-        {
-            switch ( event.getType() )
-            {
-                case FrameworkEvent.STARTED:
-                    debug( "Framework has started" );
-                    m_latch.countDown();
-                    break;
-            }
-        }
-
-
-        @Override
-        public String toString()
-        {
-            return getClass().getSimpleName();
-        }
-    }
-
-    private class LoggedCall implements Callable<Object>
-    {
-
-        private final Callable<Object> m_call;
-
-
-        public LoggedCall( Callable<Object> call )
-        {
-            m_call = call;
-        }
-
-
-        private String getName()
-        {
-            return m_call.getClass().getSimpleName();
-        }
-
-
-        public Object call() throws Exception
-        {
-
-            try
-            {
-                return m_call.call();
-            }
-            catch ( Exception e )
-            {
-                error( "call failed: " + getName(), e );
-                throw e;
-            }
-            catch ( Throwable e )
-            {
-                error( "call failed: " + getName(), e );
-                throw new RuntimeException( e );
-            }
-        }
-
-    }
-
-    private class DelayedCall implements Callable<Object>
-    {
-
-        private final Callable<Object> m_call;
-
-
-        public DelayedCall( Callable<Object> call )
-        {
-            m_call = call;
-        }
-
-
-        private String getName()
-        {
-            return m_call.getClass().getSimpleName();
-        }
-
-
-        public Object call() throws Exception
-        {
-            info( "Delayed call: " + getName() );
-            return m_worker.submit( m_call );
-        }
-    }
-
-    /**
-     * Checks for Idle devices, and attaches them
-     * 
-     * @author <a href="mailto:[email protected]";>Felix Project Team</a>
-     */
-    private class CheckForIdleDevices implements Callable<Object>
-    {
-
-        public Object call() throws Exception
-        {
-            debug( "START - check for idle devices" );
-            for ( ServiceReference ref : getIdleDevices() )
-            {
-                info( "IDLE: " + ref.getBundle().getSymbolicName() );
-                submit( new DriverAttachAlgorithm( ref, m_devices.get( ref ) ) 
);
-            }
-
-            submit( new IdleDriverUninstallAlgorithm() );
-            debug( "STOP - check for idle devices" );
-            return null;
-        }
-
-
-        /**
-         * get a list of all idle devices.
-         * 
-         * @return
-         */
-        private List<ServiceReference> getIdleDevices()
-        {
-            List<ServiceReference> list = new ArrayList<ServiceReference>();
-
-            for ( ServiceReference ref : m_devices.keySet() )
-            {
-                info( "checking if idle: " + ref.getBundle().getSymbolicName() 
);
-
-                final Bundle[] usingBundles = ref.getUsingBundles();
-                for ( Bundle bundle : usingBundles )
-                {
-                    if ( isDriverBundle( bundle ) )
-                    {
-                        info( "used by driver: " + bundle.getSymbolicName() );
-                        debug( "not idle: " + 
ref.getBundle().getSymbolicName() );
-                        break;
-                    }
-                    
-                    list.add( ref );
-
-                }
-            }
-            return list;
-        }
-    }
-
-
-    private boolean isDriverBundle( Bundle bundle )
-    {
-        ServiceReference[] refs = bundle.getRegisteredServices();
-        
-        if (refs == null) {
-            return false;
-        }
-        
-        for ( ServiceReference ref : refs )
-        {
-            if ( m_driverImplFilter.match( ref ) )
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * 
-     * Used to uninstall unused drivers
-     * 
-     * @author <a href="mailto:[email protected]";>Felix Project Team</a>
-     */
-    private class IdleDriverUninstallAlgorithm implements Callable<Object>
-    {
-
-        public Object call() throws Exception
-        {
-
-            info( "cleaning driver cache" );
-            for ( DriverAttributes da : m_drivers.values() )
-            {
-                // just call the tryUninstall; the da itself
-                // will know if it should really uninstall the driver.
-                try 
-                { 
-                       da.tryUninstall(); 
-                }
-                catch (Exception e) 
-                {
-                       debug(da.getDriverId() + " uninstall failed");
-                }
-            }
-
-            return null;
-        }
-    }
-
-    private class DriverAttachAlgorithm implements Callable<Object>
-    {
-
-        private final ServiceReference m_ref;
-
-        private final Device m_device;
-
-        private List<DriverAttributes> m_included;
-
-        private List<DriverAttributes> m_excluded;
-
-        private final DriverLoader m_driverLoader;
-
-        private DriverAttributes m_finalDriver;
-
-
-        public DriverAttachAlgorithm( ServiceReference ref, Object obj )
-        {
-            m_ref = ref;
-            if ( m_deviceImplFilter.match( ref ) )
-            {
-                m_device = Device.class.cast( obj );
-            }
-            else
-            {
-                m_device = null;
-            }
-
-            m_driverLoader = new DriverLoader( DeviceManager.this, m_context );
-        }
-
-
-        @SuppressWarnings("all")
-        private Dictionary createDictionary( ServiceReference ref )
-        {
-            final Properties p = new Properties();
-
-            for ( String key : ref.getPropertyKeys() )
-            {
-                p.put( key, ref.getProperty( key ) );
-            }
-            return p;
-        }
-
-
-        @SuppressWarnings("all")
-        public Object call() throws Exception
-        {
-            info( "finding suitable driver for: " + Util.showDevice( m_ref ) );
-
-            final Dictionary dict = createDictionary( m_ref );
-
-            // first create a copy of all the drivers that are already there.
-            // during the process, drivers will be added, but also excluded.
-            m_included = new ArrayList<DriverAttributes>( m_drivers.values() );
-            m_excluded = new ArrayList<DriverAttributes>();
-
-            // first find matching driver bundles
-            // if there are no driver locators
-            // we'll have to do with the drivers that were
-            // added 'manually'
-            Set<String> driverIds = m_driverLoader.findDrivers( m_locators, 
dict );
-
-            // remove the driverIds that are already available
-            for ( DriverAttributes da : m_drivers.values() )
-            {
-                driverIds.remove( da.getDriverId() );
-            }
-            driverIds.removeAll( m_drivers.keySet() );
-            try
-            {
-               debug("entering attach phase for " + Util.showDevice( m_ref ) );
-                return driverAttachment( dict, driverIds.toArray( new 
String[0] ) );
-            }
-            finally
-            {
-                // unload loaded drivers
-                // that were unnecessarily loaded
-                m_driverLoader.unload( m_finalDriver );
-            }
-        }
-
-
-        @SuppressWarnings("all")
-        private Object driverAttachment( Dictionary dict, String[] driverIds ) 
throws Exception
-        {
-            m_finalDriver = null;
-
-            // remove the excluded drivers
-            m_included.removeAll( m_excluded );
-
-            // now load the drivers
-            List<ServiceReference> driverRefs = m_driverLoader.loadDrivers( 
m_locators, driverIds );
-            // these are the possible driver references that have been added
-            // add them to the list of included drivers
-            for ( ServiceReference serviceReference : driverRefs )
-            {
-                DriverAttributes da = m_drivers.get( serviceReference );
-                if ( da != null )
-                {
-                    m_included.add( da );
-                }
-            }
-
-            // now start matching all drivers
-            final DriverMatcher mi = new DriverMatcher( DeviceManager.this );
-
-            for ( DriverAttributes driver : m_included )
-            {
-                try
-                {
-                    int match = driver.match( m_ref );
-                    if ( match <= Device.MATCH_NONE ) 
-                    {
-                        continue;
-                    }
-                    mi.add( match, driver );
-                }
-                catch ( Throwable t )
-                {
-                    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();
-                return null;
-            }
-
-            // here we get serious...
-            try
-            {
-                debug( "attaching to: " + driverId );
-                String newDriverId = m_finalDriver.attach( m_ref );
-                if ( newDriverId == null )
-                {
-                    // successful attach
-                    return null;
-                }
-                // its a referral
-                info( "attach led to a referral to: " + newDriverId );
-                m_excluded.add( m_finalDriver );
-                return driverAttachment( dict, new String[]{ newDriverId } );
-            }
-            catch ( Throwable t )
-            {
-                error( "attach failed due to an exception", t );
-            }
-            m_excluded.add( m_finalDriver );
-            return driverAttachment( dict, driverIds );
-        }
-
-
-        private void noDriverFound()
-        {
-            debug( "no suitable driver found for: " + Util.showDevice( m_ref ) 
);
-            if ( m_device != null )
-            {
-                m_device.noDriverFound();
-            }
-        }
-
-
-        @Override
-        public String toString()
-        {
-            return getClass().getSimpleName();// + ": " +
-            // Util.showDevice(m_ref);
-        }
-
-    }
-}
diff --git 
a/deviceaccess/src/main/java/org/apache/felix/das/DriverAttributes.java 
b/deviceaccess/src/main/java/org/apache/felix/das/DriverAttributes.java
deleted file mode 100644
index a60b543252..0000000000
--- a/deviceaccess/src/main/java/org/apache/felix/das/DriverAttributes.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.das;
-
-
-import org.apache.felix.das.util.DriverLoader;
-import org.apache.felix.das.util.Util;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.device.Constants;
-import org.osgi.service.device.Driver;
-
-
-/**
- * TODO: add javadoc
- * 
- * @author <a href="mailto:[email protected]";>Felix Project Team</a>
- */
-public class DriverAttributes
-{
-
-    private final Bundle m_bundle;
-
-    private final ServiceReference m_ref;
-
-    private final Driver m_driver;
-
-    private final boolean m_dynamic;
-
-    public DriverAttributes( ServiceReference ref, Driver driver )
-    {
-        m_ref = ref;
-        m_driver = driver;
-        m_bundle = ref.getBundle();
-        m_dynamic = m_bundle.getLocation().startsWith( 
DriverLoader.DRIVER_LOCATION_PREFIX );
-    }
-
-
-    public ServiceReference getReference()
-    {
-        return m_ref;
-    }
-
-
-    public String getDriverId()
-    {
-        return m_ref.getProperty( Constants.DRIVER_ID ).toString();
-    }
-
-
-    public int match( ServiceReference ref ) throws Exception
-    {
-        return m_driver.match( ref );
-    }
-
-
-    /**
-     * a driver bundle is idle if it isn't connected to a device bundle.
-     * 
-     * @return
-     */
-    private boolean isInUse()
-    {
-        ServiceReference[] used = m_bundle.getServicesInUse();
-        if ( used == null || used.length == 0 )
-        {
-            return false;
-        }
-
-        for ( ServiceReference ref : used )
-        {
-            if ( Util.isDevice( ref ) )
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-
-    public String attach( ServiceReference ref ) throws Exception
-    {
-        return m_driver.attach( ref );
-    }
-
-
-    public void tryUninstall() throws BundleException
-    {
-       
-        // only install if _we_ loaded the driver
-        if ( !isInUse() && m_dynamic )
-        {
-               m_bundle.uninstall();
-        }
-    }
-
-}
diff --git a/deviceaccess/src/main/java/org/apache/felix/das/Log.java 
b/deviceaccess/src/main/java/org/apache/felix/das/Log.java
deleted file mode 100644
index 698f4cf772..0000000000
--- a/deviceaccess/src/main/java/org/apache/felix/das/Log.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.das;
-
-
-/**
- * TODO: add javadoc
- * 
- * @author <a href="mailto:[email protected]";>Felix Project Team</a>
- */
-public interface Log
-{
-
-    public void debug( String message );
-
-
-    public void info( String message );
-
-
-    public void warning( String message );
-
-
-    public void error( String message, Throwable e );
-
-}
\ No newline at end of file
diff --git 
a/deviceaccess/src/main/java/org/apache/felix/das/NamedThreadFactory.java 
b/deviceaccess/src/main/java/org/apache/felix/das/NamedThreadFactory.java
deleted file mode 100644
index c4ad6b3f1f..0000000000
--- a/deviceaccess/src/main/java/org/apache/felix/das/NamedThreadFactory.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.das;
-
-
-import java.util.concurrent.ThreadFactory;
-
-
-/**
- * This class is able to create a named Thread.
- * 
- * @author <a href="mailto:[email protected]";>Felix Project Team</a>
- */
-public class NamedThreadFactory implements ThreadFactory
-{
-
-    private final String m_name;
-
-
-    public NamedThreadFactory( String name )
-    {
-        m_name = name;
-    }
-
-
-    public Thread newThread( Runnable r )
-    {
-        return new Thread( r, m_name );
-    }
-
-}
diff --git 
a/deviceaccess/src/main/java/org/apache/felix/das/util/DeviceAnalyzer.java 
b/deviceaccess/src/main/java/org/apache/felix/das/util/DeviceAnalyzer.java
deleted file mode 100644
index 0c29f7445c..0000000000
--- a/deviceaccess/src/main/java/org/apache/felix/das/util/DeviceAnalyzer.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.das.util;
-
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.device.Constants;
-import org.osgi.service.device.Device;
-import org.osgi.service.log.LogService;
-
-
-/**
- * TODO: add javadoc
- * 
- * @author <a href="mailto:[email protected]";>Felix Project Team</a>
- */
-public class DeviceAnalyzer
-{
-
-    private LogService m_log;
-
-    private Filter deviceImpl;
-
-    private Filter validCategory;
-
-    private final BundleContext m_context;
-
-
-    public DeviceAnalyzer( BundleContext context )
-    {
-        m_context = context;
-    }
-
-
-    @SuppressWarnings("unused")
-    private void start() throws InvalidSyntaxException
-    {
-        String deviceString = Util.createFilterString( "(%s=%s)", new Object[]
-            { org.osgi.framework.Constants.OBJECTCLASS, Device.class.getName() 
} );
-
-        deviceImpl = m_context.createFilter( deviceString );
-
-        String categoryString = Util.createFilterString( "(%s=%s)", new 
Object[]
-            { Constants.DEVICE_CATEGORY, "*" } );
-
-        validCategory = m_context.createFilter( categoryString );
-    }
-
-
-    /**
-     * used to analyze invalid devices
-     * 
-     * @param ref
-     */
-    public void deviceAdded( ServiceReference ref )
-    {
-
-        if ( deviceImpl.match( ref ) )
-        {
-            return;
-        }
-        if ( validCategory.match( ref ) )
-        {
-            Object cat = ref.getProperty( Constants.DEVICE_CATEGORY );
-            if ( !String[].class.isInstance( cat ) )
-            {
-                m_log.log( LogService.LOG_ERROR, "invalid device: invalid 
device category: " + Util.showDevice( ref ) );
-                return;
-            }
-            if ( String[].class.cast( cat ).length == 0 )
-            {
-                m_log.log( LogService.LOG_ERROR, "invalid device: empty device 
category: " + Util.showDevice( ref ) );
-            }
-        }
-        else
-        {
-            m_log.log( LogService.LOG_ERROR, "invalid device: no device 
category: " + Util.showDevice( ref ) );
-        }
-    }
-}
diff --git 
a/deviceaccess/src/main/java/org/apache/felix/das/util/DriverAnalyzer.java 
b/deviceaccess/src/main/java/org/apache/felix/das/util/DriverAnalyzer.java
deleted file mode 100644
index 0197f32464..0000000000
--- a/deviceaccess/src/main/java/org/apache/felix/das/util/DriverAnalyzer.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.das.util;
-
-
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.device.Constants;
-import org.osgi.service.log.LogService;
-
-
-/**
- * TODO: add javadoc
- * 
- * @author <a href="mailto:[email protected]";>Felix Project Team</a>
- */
-public class DriverAnalyzer
-{
-
-    private LogService m_log;
-
-
-    /**
-     * used to analyze invalid drivers
-     * 
-     * @param ref
-     */
-    public void driverAdded( ServiceReference ref )
-    {
-        Object driverId = ref.getProperty( Constants.DRIVER_ID );
-        if ( driverId == null || !String.class.isInstance( driverId ) )
-        {
-            m_log.log( LogService.LOG_ERROR, "invalid driver: no driver id: " 
+ Util.showDriver( ref ) );
-            return;
-        }
-        if ( String.class.isInstance( driverId ) )
-        {
-            String value = (String)( driverId );
-            if ( value.length() == 0 )
-            {
-                m_log.log( LogService.LOG_ERROR, "invalid driver: empty driver 
id: " + Util.showDriver( ref ) );
-            }
-        }
-    }
-}
diff --git 
a/deviceaccess/src/main/java/org/apache/felix/das/util/DriverLoader.java 
b/deviceaccess/src/main/java/org/apache/felix/das/util/DriverLoader.java
deleted file mode 100644
index 321b2adb6a..0000000000
--- a/deviceaccess/src/main/java/org/apache/felix/das/util/DriverLoader.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.das.util;
-
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Dictionary;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.felix.das.DriverAttributes;
-import org.apache.felix.das.Log;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.device.Constants;
-import org.osgi.service.device.DriverLocator;
-
-
-/**
- * TODO: add javadoc
- * 
- * @author <a href="mailto:[email protected]";>Felix Project Team</a>
- */
-public class DriverLoader
-{
-
-    private final BundleContext m_context;
-
-    private final Log m_log;
-
-    public final static String DRIVER_LOCATION_PREFIX = "_DD_";
-
-    /**
-     * to keep track of all loaded drivers
-     */
-    private final List<ServiceReference> m_loadedDrivers;
-
-
-    public DriverLoader( Log log, BundleContext context )
-    {
-        m_log = log;
-        m_context = context;
-        m_loadedDrivers = new ArrayList<ServiceReference>();
-    }
-
-
-    @SuppressWarnings("all")
-    public Set<String> findDrivers( Collection<DriverLocator> locators, 
Dictionary dict )
-    {
-        final Set<String> list = new HashSet<String>();
-        for ( DriverLocator locator : locators )
-        {
-            list.addAll( findDrivers( locator, dict ) );
-        }
-
-        return list;
-    }
-
-
-    @SuppressWarnings("all")
-    private List<String> findDrivers( DriverLocator locator, Dictionary dict )
-    {
-        final List<String> list = new ArrayList<String>();
-        try
-        {
-            String[] ids = locator.findDrivers( dict );
-            if ( ids != null )
-            {
-                list.addAll( Arrays.asList( ids ) );
-            }
-        }
-        catch ( Exception e )
-        {
-            // ignore, will also frequently happen (?)
-            // m_log.error("findDrivers failed for: " + locator, e);
-        }
-
-        return list;
-    }
-
-
-    /**
-     * load all drivers that belong to the given driver Ids
-     * 
-     * @param locator
-     * @param driverIds
-     */
-    public List<ServiceReference> loadDrivers( List<DriverLocator> locators, 
String[] driverIds )
-    {
-        List<ServiceReference> driverRefs = new ArrayList<ServiceReference>();
-
-        for ( String driverId : driverIds )
-        {
-            driverRefs.addAll( loadDriver( locators, driverId ) );
-        }
-
-        return driverRefs;
-    }
-
-
-    private List<ServiceReference> loadDriver( List<DriverLocator> locators, 
String driverId )
-    {
-        List<ServiceReference> driverRefs = new ArrayList<ServiceReference>();
-
-        for ( DriverLocator driverLocator : locators )
-        {
-            List<ServiceReference> drivers = loadDriver( driverLocator, 
driverId );
-            driverRefs.addAll( drivers );
-            if ( drivers.size() > 0 )
-            {
-                break;
-            }
-        }
-
-        return driverRefs;
-    }
-
-
-    private List<ServiceReference> loadDriver( DriverLocator locator, String 
driverId )
-    {
-        List<ServiceReference> driverRefs = new ArrayList<ServiceReference>();
-        try
-        {
-            InputStream in = locator.loadDriver( driverId );
-            // System.out.println(driverId + ", " + locator + " returned: " +
-            // in);
-            Bundle driverBundle = m_context.installBundle( 
DRIVER_LOCATION_PREFIX + driverId, in );
-
-            driverBundle.start();
-
-            ServiceReference[] refs = driverBundle.getRegisteredServices();
-
-            driverRefs.addAll( Arrays.asList( refs ) );
-            // keep track of them locally
-            m_loadedDrivers.addAll( Arrays.asList( refs ) );
-
-        }
-        catch ( Throwable t )
-        {
-            // ignore, this will happen frequently, if there are multiple
-            // locators
-        }
-        return driverRefs;
-    }
-
-
-    public void unload( DriverAttributes finalDriver )
-    {
-
-        ServiceReference finalRef = null;
-        if ( finalDriver != null )
-        {
-            finalRef = finalDriver.getReference();
-            m_log.debug( "unloading all except: " + finalRef.getProperty( 
Constants.DRIVER_ID ) );
-        }
-        for ( ServiceReference ref : m_loadedDrivers )
-        {
-            if ( !ref.equals( finalRef ) )
-            {
-                try
-                {
-                    m_log.debug( "uninstalling: " + ref.getProperty( 
Constants.DRIVER_ID ) );
-                    ref.getBundle().uninstall();
-                }
-                catch ( BundleException e )
-                {
-                    m_log.warning( "unable to uninstall: " + ref.getProperty( 
Constants.DRIVER_ID ) );
-                }
-            }
-        }
-    }
-}
diff --git 
a/deviceaccess/src/main/java/org/apache/felix/das/util/DriverMatcher.java 
b/deviceaccess/src/main/java/org/apache/felix/das/util/DriverMatcher.java
deleted file mode 100644
index f97c97492e..0000000000
--- a/deviceaccess/src/main/java/org/apache/felix/das/util/DriverMatcher.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.das.util;
-
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import org.apache.felix.das.DriverAttributes;
-import org.apache.felix.das.Log;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.device.Constants;
-import org.osgi.service.device.DriverSelector;
-import org.osgi.service.device.Match;
-
-
-/**
- * TODO: add javadoc
- * 
- * @author <a href="mailto:[email protected]";>Felix Project Team</a>
- */
-public class DriverMatcher
-{
-
-    private final Log m_log;
-
-    SortedMap<Integer, List<DriverAttributes>> m_map = new TreeMap<Integer, 
List<DriverAttributes>>();
-
-    List<Match> m_matches = new ArrayList<Match>();
-
-
-    public DriverMatcher( Log log )
-    {
-        m_log = log;
-    }
-
-
-    // we keep track of the driver attributes in two
-    // lists, one to aid us if there is no driver selector, one
-    // if there is...
-    public void add( Integer match, DriverAttributes value )
-    {
-        List<DriverAttributes> da = get( match );
-        da.add( value );
-        m_matches.add( new MatchImpl( value.getReference(), match ) );
-    }
-
-
-    private List<DriverAttributes> get( Integer key )
-    {
-        List<DriverAttributes> da = m_map.get( key );
-        if ( da == null )
-        {
-            m_map.put( ( Integer ) key, new ArrayList<DriverAttributes>() );
-        }
-        return m_map.get( key );
-    }
-
-
-    public Match getBestMatch()
-    {
-        if ( m_map.isEmpty() )
-        {
-            return null;
-        }
-
-        int matchValue = m_map.lastKey();
-
-        // these are the matches that
-        // got the highest match value
-        List<DriverAttributes> das = m_map.get( matchValue );
-        if ( das.size() == 1 )
-        {
-            // a shortcut: there's only one with the highest match
-            return new MatchImpl( das.get( 0 ).getReference(), matchValue );
-        }
-
-        // get the highest ranking driver
-        final SortedMap<ServiceReference, Match> matches = new 
TreeMap<ServiceReference, Match>( new ServicePriority() );
-
-        for ( DriverAttributes da : das )
-        {
-            matches.put( da.getReference(), new MatchImpl( da.getReference(), 
matchValue ) );
-        }
-
-        ServiceReference last = matches.lastKey();
-        return matches.get( last );
-    }
-
-
-    public Match selectBestMatch( ServiceReference deviceRef, DriverSelector 
selector )
-    {
-//        Match[] matches = m_matches.toArray( new Match[0] );
-        
-        //(re)check bundle status
-        List<Match> activeMatches = new ArrayList<Match>();
-        for (Match match : m_matches) {
-            if (match.getDriver().getBundle().getState() == Bundle.ACTIVE) {
-                activeMatches.add(match);
-            } else {
-                m_log.debug("skipping: " + match + ", it's bundle is: " + 
match.getDriver().getBundle().getState());
-            }
-        }
-        try
-        {
-          Match[] matches = activeMatches.toArray( new Match[0] );
-            int index = selector.select( deviceRef, matches );
-            if ( index != DriverSelector.SELECT_NONE && index >= 0 && index < 
matches.length )
-            {
-                return matches[index];
-            }
-        }
-        catch ( Exception e )
-        {
-            m_log.error( "exception thrown in DriverSelector.select()", e );
-        }
-        return null;
-    }
-
-    private class MatchImpl implements Match
-    {
-
-        private final ServiceReference ref;
-        private final int match;
-
-
-        public MatchImpl( ServiceReference ref, int match )
-        {
-            this.ref = ref;
-            this.match = match;
-        }
-
-
-        public ServiceReference getDriver()
-        {
-            return ref;
-        }
-
-
-        public int getMatchValue()
-        {
-            return match;
-        }
-
-
-        public String toString()
-        {
-            return "[MatchImpl: DRIVER_ID=" + ref.getProperty( 
Constants.DRIVER_ID ) + ", match=" + match + "]";
-        }
-
-    }
-
-    private class ServicePriority implements Comparator<ServiceReference>
-    {
-
-        private int getValue( ServiceReference ref, String key, int 
defaultValue )
-        {
-            Object obj = ref.getProperty( key );
-            if ( obj == null )
-            {
-                return defaultValue;
-            }
-            try
-            {
-                return Integer.class.cast( obj );
-            }
-            catch ( Exception e )
-            {
-                return defaultValue;
-            }
-        }
-
-
-        public int compare( ServiceReference o1, ServiceReference o2 )
-        {
-            int serviceRanking1 = getValue( o1, 
org.osgi.framework.Constants.SERVICE_RANKING, 0 );
-            int serviceRanking2 = getValue( o2, 
org.osgi.framework.Constants.SERVICE_RANKING, 0 );
-
-            if ( serviceRanking1 != serviceRanking2 )
-            {
-                return ( serviceRanking1 - serviceRanking2 );
-            }
-            int serviceId1 = getValue( o1, 
org.osgi.framework.Constants.SERVICE_ID, Integer.MAX_VALUE );
-            int serviceId2 = getValue( o2, 
org.osgi.framework.Constants.SERVICE_ID, Integer.MAX_VALUE );
-
-            return ( serviceId2 - serviceId1 );
-        }
-    }
-}
diff --git a/deviceaccess/src/main/java/org/apache/felix/das/util/Util.java 
b/deviceaccess/src/main/java/org/apache/felix/das/util/Util.java
deleted file mode 100644
index 09ed8c8160..0000000000
--- a/deviceaccess/src/main/java/org/apache/felix/das/util/Util.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.das.util;
-
-
-import org.osgi.framework.Constants;
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.device.Device;
-
-
-/**
- * TODO: add javadoc
- * 
- * @author <a href="mailto:[email protected]";>Felix Project Team</a>
- */
-public class Util
-{
-
-    private Util()
-    {
-    }
-
-
-    public static String showDriver( ServiceReference ref )
-    {
-        Object objectClass = ref.getProperty( Constants.OBJECTCLASS );
-        Object driverId = ref.getProperty( 
org.osgi.service.device.Constants.DRIVER_ID );
-        StringBuffer buffer = new StringBuffer();
-
-        buffer.append( "Driver: " );
-        buffer.append( Constants.OBJECTCLASS ).append( "=" );
-
-        if ( String[].class.isInstance( objectClass ) )
-        {
-            buffer.append( enumerateStringArray( String[].class.cast( 
objectClass ) ) );
-        }
-        else
-        {
-            buffer.append( objectClass );
-        }
-        buffer.append( " " );
-
-        buffer.append( org.osgi.service.device.Constants.DRIVER_ID ).append( 
"=" );
-        buffer.append( driverId );
-        return buffer.toString();
-    }
-
-    public static boolean isDevice( ServiceReference ref )
-    {
-        try
-        {
-            Filter device = createFilter( "(|(%s=%s)(%s=%s))", new Object[]
-                { 
-                       Constants.OBJECTCLASS, Device.class.getName(),
-                       org.osgi.service.device.Constants.DEVICE_CATEGORY, "*" 
-                       }
-            );
-            return device.match( ref );
-        }
-        catch ( Exception e )
-        {
-            e.printStackTrace();
-        }
-        return false;
-    }
-    
-    public static boolean isDeviceInstance( ServiceReference ref )
-    {
-        try
-        {
-            Filter device = createFilter( "(%s=%s)", new Object[]
-                { Constants.OBJECTCLASS, Device.class.getName() } );
-            return device.match( ref );
-        }
-        catch ( Exception e )
-        {
-            e.printStackTrace();
-        }
-        return false;
-    }
-
-
-    public static String createFilterString( String input, Object[] data )
-    {
-        return String.format( input, data );
-    }
-
-
-    public static Filter createFilter( String input, Object[] data ) throws 
InvalidSyntaxException
-    {
-        return FrameworkUtil.createFilter( String.format( input, data ) );
-    }
-
-
-    public static String showDevice( ServiceReference ref )
-    {
-        Object objectClass = ref.getProperty( Constants.OBJECTCLASS );
-        Object category = ref.getProperty( 
org.osgi.service.device.Constants.DEVICE_CATEGORY );
-        StringBuffer buffer = new StringBuffer();
-
-        buffer.append( "Device: " );
-        buffer.append( Constants.OBJECTCLASS ).append( "=" );
-
-        appendObject( buffer, objectClass );
-        buffer.append( " " );
-
-        buffer.append( org.osgi.service.device.Constants.DEVICE_CATEGORY 
).append( "=" );
-        appendObject( buffer, category );
-
-        buffer.append( "\n{ " );
-        String[] keys = ref.getPropertyKeys();
-        
-        for ( String key : keys )
-        {
-            if ( key.equals( Constants.OBJECTCLASS ) )
-            {
-                continue;
-            }
-            if ( key.equals( org.osgi.service.device.Constants.DEVICE_CATEGORY 
) )
-            {
-                continue;
-            }
-            buffer.append( key ).append( "=" );
-            appendObject( buffer, ref.getProperty( key ) );
-            buffer.append( " " );
-        }
-        buffer.append( "}\n" );
-
-        return buffer.toString();
-    }
-
-
-    private static void appendObject( StringBuffer buffer, Object obj )
-    {
-        if ( String[].class.isInstance( obj ) )
-        {
-            buffer.append( enumerateStringArray( String[].class.cast( obj ) ) 
);
-        }
-        else
-        {
-            buffer.append( obj );
-        }
-    }
-
-
-    private static String enumerateStringArray( String[] strings )
-    {
-        StringBuffer buffer = new StringBuffer();
-
-        buffer.append( "[" );
-        for ( String str : strings )
-        {
-            buffer.append( str );
-            buffer.append( " " );
-        }
-        buffer.deleteCharAt( buffer.length() - 1 );
-        buffer.append( "]" );
-        return buffer.toString();
-    }
-}
diff --git 
a/deviceaccess/src/test/java/org/apache/felix/das/DeviceManagerTest.java 
b/deviceaccess/src/test/java/org/apache/felix/das/DeviceManagerTest.java
deleted file mode 100644
index 35ee49618c..0000000000
--- a/deviceaccess/src/test/java/org/apache/felix/das/DeviceManagerTest.java
+++ /dev/null
@@ -1,913 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.das;
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import junit.framework.Assert;
-
-import org.apache.felix.das.util.DriverLoader;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.device.Constants;
-import org.osgi.service.device.Device;
-import org.osgi.service.device.Driver;
-import org.osgi.service.device.DriverLocator;
-import org.osgi.service.device.DriverSelector;
-import org.osgi.service.device.Match;
-import org.osgi.service.log.LogService;
-
-
-
-/**
- * Test the actual implementation.
- * 
- * @author <a href="mailto:[email protected]";>Felix Project Team</a>
- */
-public class DeviceManagerTest
-{
-
-       @Mock
-    private DeviceManager m_manager;
-
-       @Mock Bundle m_systemBundle;
-       
-       @Mock
-       private LogService m_log;
-       
-       
-       private BundleContext m_context;
-       
-       
-    private OSGiMock m_osgi;
-
-
-    @Before
-    public void setUp() throws Exception
-    {
-        m_osgi = new OSGiMock();
-
-       MockitoAnnotations.initMocks(this);
-       
-       m_context = m_osgi.getBundleContext();
-       
-        m_manager = new DeviceManager( m_context );
-        
-        Utils.invoke( m_manager, "init" );
-        
-        Utils.inject( m_manager, LogService.class, m_log );
-        
-        Mockito.when( m_context.getBundle( 0 ) ).thenReturn( m_systemBundle );
-
-        final CountDownLatch latch = new CountDownLatch( 1 );
-
-        Answer<Integer> answer = new Answer<Integer>()
-        {
-               public Integer answer(InvocationOnMock invocation) throws 
Throwable
-            {
-                latch.countDown();
-                return Bundle.ACTIVE;
-            }
-        };
-
-        Mockito.when( m_systemBundle.getState() ).thenAnswer( answer );
-
-        Utils.invoke( m_manager, "start" );
-        latch.await( 5, TimeUnit.SECONDS );
-
-        Mockito.when( m_context.installBundle(Mockito.isA( String.class ), ( 
InputStream ) Mockito.isNull() ) )
-               .thenThrow(new NullPointerException( "inputstream is null 
exception" ) );
-    }
-
-
-    @After
-    public void tearDown() throws Exception
-    {
-        Utils.invoke( m_manager, "stop" );
-        Utils.invoke( m_manager, "destroy" );
-    }
-
-    private Driver tstCreateDriver( String driverId, int match ) throws 
Exception
-    {
-        Properties p = new Properties();
-        p.put( Constants.DRIVER_ID, driverId );
-        p.put( "match", Integer.toString( match ) );
-
-        return tstCreateDriver( p );
-    }
-
-
-    private Driver tstCreateDriver( Properties p ) throws Exception
-    {
-        Driver driver = Mockito.mock( Driver.class );
-        
-        ServiceReference ref = m_osgi.registerService( 
-                       new String[]{ Driver.class.getName() }, driver, p );
-
-        MatchAnswer answer = new MatchAnswer( ref );
-
-        Mockito.when( driver.match( Mockito.isA( ServiceReference.class ) ) )
-               .thenAnswer( answer );
-        
-        Bundle bundle = m_osgi.getBundle( ref );
-        Mockito.when( bundle.getLocation() )
-               .thenReturn( 
-            DriverLoader.DRIVER_LOCATION_PREFIX  + p.getProperty( 
Constants.DRIVER_ID ));
-        
-        return driver;
-    }
-
-
-    private Device tstCreateDevice( String[] cat )
-    {
-        return tstCreateDevice( cat, true );
-    }
-
-
-    private Device tstCreateDevice( String[] cat, boolean isDevice )
-    {
-        Properties p = new Properties();
-        p.put( Constants.DEVICE_CATEGORY, cat );
-        if ( isDevice )
-        {
-            return ( Device ) tstCreateService( p, Device.class );
-        }
-        return tstCreateService( p, Object.class );
-    }
-
-
-    @SuppressWarnings("unchecked")
-    private <T> T tstCreateService( Properties p, Class<?> iface )
-    {
-        T svc = ( T ) Mockito.mock( iface, iface.getSimpleName() );
-        
-        m_osgi.registerService( new String[]
-            { iface.getName() }, svc, p );
-        return svc;
-    }
-
-
-    /**
-     * 
-     * prepared all expected behavior for the installation of a dynamic driver
-     * bundle based on an acquired InputStream.
-     * 
-     * 
-     * @param driverId
-     * @param match
-     * @param in
-     * @return
-     * @throws BundleException
-     * @throws Exception
-     */
-    private Driver tstExpectInstallDriverBundle( String driverId, int match, 
InputStream in ) throws BundleException,
-        Exception
-    {
-
-        Bundle bundle = Mockito.mock( Bundle.class, "driverBundle" );
-        Mockito.when( m_context.installBundle( 
-                       Mockito.eq( "_DD_" + driverId ), Mockito.eq( in ) ) )
-                       .thenReturn( bundle );
-
-        final Driver driver = tstCreateDriver( driverId, match );
-        final ServiceReference driverRef = m_osgi.getReference( driver );
-
-        Answer<Object> answer = new Answer<Object>()
-        {
-               
-               public Object answer(InvocationOnMock invocation) throws 
Throwable
-            {
-                m_manager.driverAdded( driverRef, driver );
-                return null;
-            }
-        };
-
-        //bundle start leads to the addition of the driver to
-        //the device manager.
-        Mockito.doAnswer(answer).when(bundle).start();
-
-        Mockito.when( bundle.getRegisteredServices() )
-               .thenReturn( new ServiceReference[]{ driverRef } );
-
-        return driver;
-    }
-
-
-    /**
-     * returns a CountDownLatch.
-     * This countdown latch will count down as soon as 
<code>Device.noDriverFound()</code>
-     * has been called.
-     * @param device the Device
-     * @return the countdown latch
-     */
-    private CountDownLatch tstExpectNoDriverFound( Device device )
-    {
-        final CountDownLatch latch = new CountDownLatch( 1 );
-
-        //countdown when noDriverFound is called
-        Answer<Object> answer = new Answer<Object>()
-        {
-               public Object answer(InvocationOnMock invocation) throws 
Throwable
-            {
-                latch.countDown();
-                return null;
-            }
-        };
-
-        Mockito.doAnswer( answer ).when(device).noDriverFound();
-
-        return latch;
-
-    }
-
-
-    private CountDownLatch tstExpectAttach( Driver driver, Object device ) 
throws Exception
-    {
-        final CountDownLatch latch = new CountDownLatch( 1 );
-        Answer<String> answer = new Answer<String>()
-        {
-            public String answer(InvocationOnMock invocation) throws Throwable
-            {
-                latch.countDown();
-                return null;
-            }
-        };
-
-        //successful attach
-        Mockito.when( driver.attach( m_osgi.getReference( device ) ) )
-               .thenAnswer( answer );
-
-        return latch;
-    }
-
-    private CountDownLatch tstExpectUnloadDriverBundle( Driver driver ) throws 
BundleException {
-       
-       
-       final CountDownLatch latch = new CountDownLatch( 1 );
-        Answer<String> answer = new Answer<String>()
-        {
-            public String answer(InvocationOnMock invocation) throws Throwable
-            {
-                latch.countDown();
-                return null;
-            }
-        };
-
-        Bundle bundle = m_osgi.getBundle( m_osgi.getReference( driver ) );
-        
-        Mockito.doAnswer(answer).when( bundle ).uninstall();
-
-        return latch;          
-    }
-
-    /**
-     * This method generates behavior on the provided DriverLocator.
-     * 
-     * The given driver Ids and their matches are expected as drivers found
-     * by this driver locator.
-     * Also, if a driver is found, we can also expect that loadDriver is 
called;
-     * resulting in an InputStream. That particular input stream should, when 
installed
-     * using a bundle context, lead to the registration of a driver with 
-     * the correcsponding driver id.
-     *  
-     * @param locator
-     * @param driverIds
-     * @param matches
-     * @return
-     * @throws Exception
-     */
-    private Map<String, Driver> tstExpectDriverLocatorFor( final DriverLocator 
locator, final String[] driverIds,
-        int[] matches ) throws Exception
-    {
-
-        Mockito.when( locator.findDrivers( Mockito.isA( Dictionary.class ) ) )
-               .thenReturn( driverIds );
-
-        Map<String, Driver> drivers = new HashMap<String, Driver>();
-
-        final Map<String, InputStream> streams = new HashMap<String, 
InputStream>();
-
-        for ( String driverId : driverIds )
-        {
-            InputStream in = Mockito.mock(InputStream.class, "[InputStream 
for: " + driverId + "]");
-            streams.put( driverId, in );
-        }
-
-        Answer<InputStream> answer = new Answer<InputStream>()
-        {
-               public InputStream answer(InvocationOnMock invocation) throws 
Throwable
-            {
-                final String id = invocation.getArguments()[0].toString();
-
-                for ( String driverId : driverIds )
-                {
-                    if ( id.equals( driverId ) )
-                    {
-                        return streams.get( id );
-                    }
-                }
-                throw new IOException( "no such driverId defined in this 
locator: " + locator );
-            }
-        };
-
-        
-        Mockito.when( locator.loadDriver( Mockito.isA( String.class ) ) )
-               .thenAnswer( answer );
-
-        int i = 0;
-        for ( String driverId : driverIds )
-        {
-            Driver driver = tstExpectInstallDriverBundle( driverId, 
matches[i], streams.get( driverId ) );
-            drivers.put( driverId, driver );
-            i++;
-        }
-
-        return drivers;
-
-    }
-
-
-    /**
-     * 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 );
-
-    }
-
-
-    /**
-     * 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 );
-
-    }
-
-
-    /**
-     * does not really test anything special, but ensures that the internal
-     * structure is able to parse the addition
-     * @throws Exception 
-     */
-    @Test
-    public void DriverAdded() throws Exception
-    {
-
-        Driver driver = tstCreateDriver( "org.apache.felix.driver-1.0", 1 );
-
-        m_manager.driverAdded( m_osgi.getReference( driver ), driver );
-
-    }
-
-
-    /**
-     * does not really test anything special, but ensures that the internal
-     * structure is able to parse the addition/ removal
-     * @throws Exception 
-     */
-    @Test
-    public void DriverRemoved() throws Exception
-    {
-
-        Driver driver = tstCreateDriver( "org.apache.felix.driver-1.0", 1 );
-
-        ServiceReference ref = m_osgi.getReference( driver );
-
-        m_manager.driverAdded( ref, driver );
-        m_manager.driverRemoved( ref );
-    }
-
-    /**
-     * does not really test anything special, but ensures that the internal
-     * structure is able to parse the addition/ removal
-     * @throws Exception 
-     */
-    @Test
-    public void DeviceRemoved() throws Exception
-    {
-
-       Properties p = new Properties();
-       p.put(Constants.DEVICE_CATEGORY, new String[]{"dummy"});
-       
-        ServiceReference ref = OSGiMock.createReference(p);
-        
-        Object device = new Object();
-
-        m_manager.deviceAdded( ref, device );
-        m_manager.deviceRemoved( ref );
-    }
-
-    /**
-     * does not really test anything special, but ensures that the internal
-     * structure is able to parse the addition/ removal
-     * @throws Exception 
-     */
-    @Test
-    public void DeviceModified() throws Exception
-    {
-
-       Properties p = new Properties();
-       p.put(Constants.DEVICE_CATEGORY, new String[]{"dummy"});
-       
-        ServiceReference ref = OSGiMock.createReference(p);
-        Object device = new Object();
-        
-        m_manager.deviceAdded( ref, new Object() );
-        m_manager.deviceModified(ref, device);
-    }
-    //intended flow, various configurations
-    /**
-     *         We add a device, but there are no driver locators, so
-     *  the noDriverFound method must be called
-     * @throws InterruptedException 
-     */
-    @Test
-    public void DeviceAddedNoDriverLocator() throws InterruptedException
-    {
-
-        //create a mocked device
-        Device device = tstCreateDevice( new String[]
-            { "org.apache.felix" } );
-
-        CountDownLatch latch = tstExpectNoDriverFound( device );
-
-        m_manager.deviceAdded( m_osgi.getReference( device ), device );
-
-        if ( !latch.await( 5, TimeUnit.SECONDS ) )
-        {
-            Assert.fail( "expected call noDriverFound" );
-        }
-        
-    }
-
-
-    /**
-     *         We add a device, but there are no driver locators, however, 
there is a driver
-     *  that matches. Thus an attach must follow.
-     * @throws Exception 
-     */
-    @Test
-    public void DeviceAddedNoDriverLocatorSuccessfulAttach() throws Exception
-    {
-
-        Device device = tstCreateDevice( new String[] { "org.apache.felix" } );
-        Driver driver = tstCreateDriver( "org.apache.felix.driver-1.0", 1 );
-
-        CountDownLatch attachLatch = tstExpectAttach( driver, device );
-
-        m_manager.driverAdded( m_osgi.getReference( driver ), driver );
-        m_manager.deviceAdded( m_osgi.getReference( device ), device );
-
-        if ( !attachLatch.await( 5, TimeUnit.SECONDS ) )
-        {
-            Assert.fail( "expected attach" );
-        }
-
-    }
-
-
-    /**
-     *         We add a device, but there are no driver locators, however, 
there is a driver
-     *  but it sadly doesn't match. Thus a <code>noDriverFound()</code> is 
called.
-     *  
-     * @throws Exception 
-     */
-    @Test
-    public void DeviceAddedNoDriverLocatorAttachFails() throws Exception
-    {
-
-        Device device = tstCreateDevice( new String[] { "org.apache.felix" } );
-        Driver driver = tstCreateDriver( "org.apache.felix.driver-1.0", 
Device.MATCH_NONE );
-
-        CountDownLatch attachLatch = tstExpectNoDriverFound( device );
-
-        m_manager.driverAdded( m_osgi.getReference( driver ), driver );
-        m_manager.deviceAdded( m_osgi.getReference( device ), device );
-
-        if ( !attachLatch.await( 5, TimeUnit.SECONDS ) )
-        {
-            Assert.fail( "expected attach" );
-        }
-
-    }
-
-
-    /**
-     * We add a device while there's one driverlocator that will successfully
-     * locate and load two driver bundles. We expect a 
<code>Driver.attach()</code> for 
-     * the best matching driver. There's already a driver loaded that should 
not match.
-     * 
-     * @throws Exception
-     */
-    @Test
-    public void DeviceAddedWithADriverLocator() throws Exception
-    {
-
-        final String driverId1 = "org.apache.felix.driver-1.0";
-        final String driverId2 = "org.apache.felix.driver-1.1";
-        final String notMatchingButLoadedDriverId = 
"dotorg.apache.felix.driver-1.0";
-
-
-        DriverLocator locator = Mockito.mock( DriverLocator.class );
-
-        Map<String, Driver> drivers = tstExpectDriverLocatorFor( locator, 
-               new String[] { driverId1, driverId2 }, 
-               new int[] { 30, 3 } );
-
-        Driver noMatcher = tstCreateDriver( notMatchingButLoadedDriverId, 100 
);
-
-        Device device = tstCreateDevice( new String[]{ "org.apache.felix" } );
-
-        final CountDownLatch attachLatch = tstExpectAttach( drivers.get( 
driverId1 ), device );
-
-        final CountDownLatch unloadDriverLatch = tstExpectUnloadDriverBundle( 
drivers.get ( driverId2 ) );
-
-        m_manager.locatorAdded( locator );
-
-        m_manager.driverAdded( m_osgi.getReference( noMatcher ), noMatcher );
-
-        m_manager.deviceAdded( m_osgi.getReference( device ), device );
-
-        if ( !attachLatch.await( 5, TimeUnit.SECONDS ) )
-        {
-            Assert.fail( "expected an attach" );
-        }
-        
-        //since driver1 is attached, we expect an uninstall()
-        //of all other (dynamically loaded) driver bundles
-        if ( !unloadDriverLatch.await( 5, TimeUnit.SECONDS ) )
-        {
-            Assert.fail( "expected an unload" );
-        }
-
-    }
-
-    @Test
-    public void DeviceAddedWithADriverLocatorUnloadFails() throws Exception
-    {
-
-        final String driverId1 = "org.apache.felix.driver-1.0";
-        final String driverId2 = "org.apache.felix.driver-1.1";
-        final String notMatchingButLoadedDriverId = 
"dotorg.apache.felix.driver-1.0";
-
-
-        DriverLocator locator = Mockito.mock( DriverLocator.class );
-
-        Map<String, Driver> drivers = tstExpectDriverLocatorFor( locator, 
-               new String[] { driverId1, driverId2 }, 
-               new int[] { 30, 3 } );
-
-        Driver noMatcher = tstCreateDriver( notMatchingButLoadedDriverId, 100 
);
-
-        Device device = tstCreateDevice( new String[]{ "org.apache.felix" } );
-
-        final CountDownLatch attachLatch = tstExpectAttach( drivers.get( 
driverId1 ), device );
-
-        final CountDownLatch unloadDriverLatch = new CountDownLatch( 1 );
-        
-        ServiceReference driver2Ref = m_osgi.getReference( drivers.get( 
driverId2 ) );
-        Bundle driver2Bundle = m_osgi.getBundle( driver2Ref );
-        
-        Answer<Object> answer = new Answer<Object>() {
-               
-               public Object answer(InvocationOnMock invocation) throws 
Throwable {
-                       try {
-                               throw new BundleException("test driverBundle 
uninstall failed");
-                       }
-                       finally {
-                               unloadDriverLatch.countDown();
-                       }
-               }
-        };
-        
-        Mockito.doAnswer(answer).when(driver2Bundle).uninstall();
-        
-        m_manager.locatorAdded( locator );
-
-        m_manager.driverAdded( m_osgi.getReference( noMatcher ), noMatcher );
-
-        m_manager.deviceAdded( m_osgi.getReference( device ), device );
-
-        if ( !attachLatch.await( 5, TimeUnit.SECONDS ) )
-        {
-            Assert.fail( "expected an attach" );
-        }
-        
-        if ( !unloadDriverLatch.await( 5, TimeUnit.SECONDS ) )
-        {
-            Assert.fail( "expected an unload" );
-        }
-
-        
-        //since driver1 is attached, we expect an uninstall()
-        //of all other (dynamically loaded) driver bundles
-        //Driver driver = drivers.get( driverId2 );
-        //tstVerifyBundleUninstall( driver );
-    }
-
-    /**
-     * Two drivers equally match the device. There is a driver selector
-     * that comes to the rescue that selects driver2. 
-     * 
-     * @throws Exception
-     */
-    @Test
-    public void EqualMatchWithDriverSelector() throws Exception
-    {
-
-        final String driverId1 = "org.apache.felix.driver-1.0";
-        final String driverId2 = "org.apache.felix.driver-1.1";
-
-        DriverLocator locator = Mockito.mock( DriverLocator.class );
-
-        Map<String, Driver> drivers = tstExpectDriverLocatorFor( locator, 
-               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 );
-
-
-        Utils.inject( m_manager, DriverSelector.class, selector );
-
-        m_manager.locatorAdded( locator );
-
-        m_manager.deviceAdded( m_osgi.getReference( device ), device );
-
-        if ( !attachLatch.await( 5, TimeUnit.SECONDS ) )
-        {
-            Assert.fail( "expected an attach" );
-        }
-        
-        
-        //driver2 is attached, so driver1 bundle should uninstall.
-        //Driver driver = drivers.get( driverId1 );
-        //tstVerifyBundleUninstall( driver );
-
-    }
-
-
-    //exceptional flow
-    @Test
-    public void DriverLocator_findDriverFails() throws Exception
-    {
-
-        final CountDownLatch latch = new CountDownLatch( 1 );
-
-        Answer<String[]> answer = new Answer<String[]>()
-        {
-
-            public String[] answer(InvocationOnMock invocation) throws 
Throwable
-            {
-                latch.countDown();
-                throw new RuntimeException( "test exception" );
-            }
-        };
-
-        DriverLocator locator = Mockito.mock( DriverLocator.class, "locator" );
-        Mockito.when( locator.findDrivers( Mockito.isA( Dictionary.class ) ) )
-               .thenAnswer( answer );
-
-        Device device = tstCreateDevice( new String[]
-            { "org.apache.felix" } );
-
-        final CountDownLatch latch2 = new CountDownLatch( 1 );
-
-        Answer<Object> answer2 = new Answer<Object>()
-        {
-            public Object answer(InvocationOnMock invocation) throws Throwable
-            {
-                latch2.countDown();
-                return null;
-            }
-        };
-        
-        Mockito.doAnswer(answer2).when(device).noDriverFound();
-        
-
-        m_manager.locatorAdded( locator );
-        m_manager.deviceAdded( m_osgi.getReference( device ), device );
-
-        if ( !latch.await( 5, TimeUnit.SECONDS ) )
-        {
-            Assert.fail( "expected a call to DriverLocator.findDrivers" );
-        }
-
-        if ( !latch2.await( 5, TimeUnit.SECONDS ) )
-        {
-            Assert.fail( "expected a call to Driver.noDriverFound" );
-        }
-
-    }
-
-
-    /**
-     * This test verified correct behavior when after a driver
-     * attach led to a referral, this referral leads to an exception.
-     * 
-     * 
-     * @throws Exception
-     */
-    @Ignore
-    public void DriverReferral_ReferralFails() throws Exception
-    {
-
-        final String referredDriver = "org.apache.felix.driver-2.0";
-
-        String[] driverIds = new String[]
-            { "org.apache.felix.driver-1.0", "org.apache.felix.driver-1.1" };
-        
-        int[] driverMatches = new int[]{ 1, Device.MATCH_NONE };
-        
-        DriverLocator locator = Mockito.mock( DriverLocator.class, "locator 
for v1.x" );
-        Map<String, Driver> drivers = tstExpectDriverLocatorFor( locator, 
driverIds, driverMatches );
-
-        
-        DriverLocator locatorv2 = Mockito.mock( DriverLocator.class, "locator 
for v2.x (fails always)" );
-        Mockito.when( locatorv2.findDrivers( Mockito.isA( Dictionary.class ) ) 
)
-               .thenReturn( null );
-
-        Mockito.when( locatorv2.loadDriver( Mockito.startsWith( 
"org.apache.felix.driver-1" ) ) )
-               .thenReturn( null );
-        
-        InputStream referredInputStream = Mockito.mock(InputStream.class);
-        Mockito.when( locatorv2.loadDriver( referredDriver ) ).thenReturn( 
referredInputStream );
-
-
-        //this is what initial driver referral eventually leads
-        //to: the loading of a driver bundle
-        //we fake it, so that it fails
-        Mockito.when( m_context.installBundle( 
-                       Mockito.anyString(), 
-                       Mockito.isA( InputStream.class ) ) )
-               .thenThrow(new BundleException( "test exception" ) );
-
-        Driver matched = drivers.get( "org.apache.felix.driver-1.0" );
-
-        final CountDownLatch latch = new CountDownLatch( 1 );
-
-        Answer<String> driver10_attach = new Answer<String>()
-        {
-            public String answer(InvocationOnMock invocation) throws Throwable
-            {
-               System.out.println("driver10_attach()");
-                latch.countDown();
-                return referredDriver;
-            }
-        };
-
-        Device device = tstCreateDevice( new String[]{ "org.apache.felix" } );
-        
-
-        Mockito.when( matched.match( m_osgi.getReference( device ) ) 
).thenReturn( 10 );
-
-        Mockito.when( matched.attach( Mockito.isA( ServiceReference.class ) ) )
-               .thenAnswer( driver10_attach );
-
-//        for ( String driverId : driverIds )
-//        {
-//            Driver driver = drivers.get( driverId );
-//            tstExpectBundleUninstall( driver );
-//        }
-
-
-        //the actual test
-        
-        m_manager.locatorAdded( locator );
-        m_manager.locatorAdded( locatorv2 );
-        
-        //depman induced callback
-        m_manager.deviceAdded( m_osgi.getReference( device ), device );
-
-        
-        if ( !latch.await( 5, TimeUnit.SECONDS ) )
-        {
-            Assert.fail( "expected an attach to: " + driverIds[0] );
-        }
-
-        
-        Mockito.verify(device).noDriverFound();
-    }
-
-    /**
-     * @author <a href="mailto:[email protected]";>Felix Project Team</a>
-     */
-    private class MatchAnswer implements Answer<Integer>
-    {
-
-        private final ServiceReference m_driverRef;
-
-        public MatchAnswer( ServiceReference driverRef )
-        {
-            m_driverRef = driverRef;
-        }
-
-
-        public Integer answer(InvocationOnMock invocation) throws Throwable
-        {
-            ServiceReference deviceRef = ( ServiceReference ) 
invocation.getArguments()[0];
-            String[] categories = String[].class.cast( deviceRef.getProperty( 
Constants.DEVICE_CATEGORY ) );
-            String driverId = String.class.cast( m_driverRef.getProperty( 
Constants.DRIVER_ID ) );
-
-            for ( String string : categories )
-            {
-                if ( driverId.startsWith( string ) )
-                {
-                    Object match = m_driverRef.getProperty( "match" );
-                    return Integer.valueOf( match.toString() );
-                }
-            }
-            return Device.MATCH_NONE;
-        }
-
-    }
-        
-
-    private class SelectorMatcher implements Answer<Integer>
-    {
-
-        private String m_driverId;
-
-
-        public SelectorMatcher( String driverId )
-        {
-            m_driverId = driverId;
-        }
-
-               public Integer answer(InvocationOnMock invocation) throws 
Throwable
-        {
-            int i = 0;
-            Match[] matches = (Match[])invocation.getArguments()[1];
-            
-            for ( Match match : matches )
-            {
-                if ( match.getDriver().getProperty( Constants.DRIVER_ID 
).equals( m_driverId ) )
-                {
-                    return i;
-                }
-                i++;
-            }
-            return DriverSelector.SELECT_NONE;
-        }
-
-
-    }
-    
-}
diff --git 
a/deviceaccess/src/test/java/org/apache/felix/das/DriverAttributesTest.java 
b/deviceaccess/src/test/java/org/apache/felix/das/DriverAttributesTest.java
deleted file mode 100644
index 56cef125d3..0000000000
--- a/deviceaccess/src/test/java/org/apache/felix/das/DriverAttributesTest.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.das;
-
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.device.Device;
-import org.osgi.service.device.Driver;
-
-/**
- * 
- * Some simple tests for the DriverAttributes class.
- * 
- * @author <a href="mailto:[email protected]";>Felix Project Team</a>
- *
- */
-public class DriverAttributesTest {
-
-       
-       private DriverAttributes m_attributes;
-       
-       @Mock
-       private ServiceReference m_ref;
-       
-       @Mock
-       private Driver m_driver;
-       
-       @Mock
-       private Bundle m_bundle;
-       
-       @Before
-       public void setUp() throws Exception {
-               
-               MockitoAnnotations.initMocks(this);
-               
-               Mockito.when(m_ref.getBundle()).thenReturn(m_bundle);
-               
-               
Mockito.when(m_bundle.getLocation()).thenReturn("_DD_test-driverbundle");
-               
-               m_attributes = new DriverAttributes(m_ref, m_driver);
-       }
-
-
-       @Test
-       public void VerifyDriverReferenceReturned() throws Exception {
-               
-               Assert.assertEquals(m_ref, m_attributes.getReference());
-       }
-
-       @Test
-       public void VerifyDriverInUseByDevice() throws Exception {
-               
-               ServiceReference ref = Mockito.mock(ServiceReference.class);
-               
-               Mockito.when(ref.getProperty(Constants.OBJECTCLASS))
-                       .thenReturn(new String[]{Object.class.getName()});
-               
-               Mockito.when(ref.getProperty(
-                       org.osgi.service.device.Constants.DEVICE_CATEGORY))
-                       .thenReturn(new String[]{"dummy"});
-               
-               Mockito.when(m_bundle.getServicesInUse()).thenReturn(new 
ServiceReference[]{ref});
-               
-               m_attributes.tryUninstall();
-               
-               Mockito.verify(m_bundle).getLocation();
-               Mockito.verify(m_bundle).getServicesInUse();
-               Mockito.verifyNoMoreInteractions(m_bundle);
-
-       }
-       
-       @Test
-       public void VerifyDriverInUseByDeviceInstance() throws Exception {
-               
-               ServiceReference ref = Mockito.mock(ServiceReference.class);
-               
-               
Mockito.when(ref.getProperty(Constants.OBJECTCLASS)).thenReturn(new 
String[]{Device.class.getName()});
-               Mockito.when(ref.getProperty(
-                               
org.osgi.service.device.Constants.DEVICE_CATEGORY))
-                               .thenReturn(new String[]{"dummy"});
-               
-               Mockito.when(m_bundle.getServicesInUse()).thenReturn(new 
ServiceReference[]{ref});
-               
-               m_attributes.tryUninstall();
-               
-               Mockito.verify(m_bundle).getLocation();
-               Mockito.verify(m_bundle).getServicesInUse();
-               Mockito.verifyNoMoreInteractions(m_bundle);
-
-       }
-       
-       
-       @Test
-       public void VerifyDriverInUseByNoDevice() throws Exception {
-               
-               ServiceReference ref = Mockito.mock(ServiceReference.class);
-               
-               
Mockito.when(ref.getProperty(Constants.OBJECTCLASS)).thenReturn(new 
String[]{Object.class.getName()});
-               Mockito.when(m_bundle.getServicesInUse()).thenReturn(new 
ServiceReference[]{ref});
-               
-               m_attributes.tryUninstall();
-               
-               Mockito.verify(m_bundle).getLocation();
-               Mockito.verify(m_bundle).getServicesInUse();
-               Mockito.verify(m_bundle).uninstall();
-
-       }
-       @Test
-       public void VerifyDriverNotInUseLeadsToUnInstall1() throws Exception {
-               
-               Mockito.when(m_bundle.getServicesInUse()).thenReturn(new 
ServiceReference[0]);
-               
-               m_attributes.tryUninstall();
-               
-               Mockito.verify(m_bundle).uninstall();
-               
-
-       }
-       
-       @Test
-       public void VerifyDriverNotInUseLeadsToUnInstall2() throws Exception {
-               
-               m_attributes.tryUninstall();
-               
-               Mockito.verify(m_bundle).uninstall();
-               
-       }       
-       
-       @Test
-       public void VerifyAttachCalledOnDriver() throws Exception {
-               
-               
-               ServiceReference ref = Mockito.mock(ServiceReference.class);
-               m_attributes.attach(ref);
-               
-               Mockito.verify(m_driver).attach(Mockito.eq(ref));
-               
-       }
-
-       @Test
-       public void VerifyMatchCalledOnDriver() throws Exception {
-               
-               
-               ServiceReference ref = Mockito.mock(ServiceReference.class);
-               m_attributes.match(ref);
-               
-               Mockito.verify(m_driver).match(Mockito.eq(ref));
-               
-       }
-}
diff --git a/deviceaccess/src/test/java/org/apache/felix/das/OSGiMock.java 
b/deviceaccess/src/test/java/org/apache/felix/das/OSGiMock.java
deleted file mode 100644
index aaaa591693..0000000000
--- a/deviceaccess/src/test/java/org/apache/felix/das/OSGiMock.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.das;
-
-
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-
-
-/**
- * 
- * a very simple mock of an osgi framework. enables the registration of 
services.
- * automatically generates mocked service references for them.
- *
- * @author <a href="mailto:[email protected]";>Felix Project Team</a>
- */
-public class OSGiMock
-{
-
-       @Mock
-    private BundleContext m_context;
-
-    private Map<Object, ServiceReference> m_references;
-
-    private Map<ServiceReference, Bundle> m_bundles;
-
-    private int m_serviceIndex = 1;
-
-    public OSGiMock()
-    {
-       MockitoAnnotations.initMocks(this);
-        m_references = new HashMap<Object, ServiceReference>();
-        m_bundles = new HashMap<ServiceReference, Bundle>();
-    }
-
-    public static ServiceReference createReference(final Properties p) 
-    {
-        ServiceReference ref = Mockito.mock( ServiceReference.class );
-
-        Mockito.when(ref.getProperty(Mockito.anyString())).thenAnswer(new 
Answer<Object>() {
-               public Object answer(InvocationOnMock invocation) throws 
Throwable {
-                       return p.get(invocation.getArguments()[0].toString());
-               }
-        });
-        
-        Mockito.when(ref.getPropertyKeys()).thenAnswer(new Answer<Object>() {
-               public Object answer(InvocationOnMock invocation) throws 
Throwable {
-                       return p.keySet().toArray(new String[0]);
-               }
-        });
-        
-        
-        return ref;
-    }
-
-
-
-    public BundleContext getBundleContext()
-    {
-        return m_context;
-    }
-
-
-    @SuppressWarnings("all")
-    public ServiceReference registerService( String[] ifaces, Object impl, 
Properties props )
-    {
-
-        ServiceReference ref = createReference( ifaces, props );
-
-        Mockito.when( m_context.registerService( ifaces, impl, props ) )
-               .thenReturn( null );
-
-        Mockito.when( m_context.getService( ref ) ).thenReturn( impl );
-
-        Mockito.when( ref.getUsingBundles() ).thenReturn( new Bundle[0] );
-        
-        m_references.put( impl, ref );
-
-        return ref;
-    }
-
-
-    public ServiceReference getReference( Object service )
-    {
-        return m_references.get( service );
-    }
-
-
-    public Bundle getBundle( ServiceReference ref )
-    {
-        return m_bundles.get( ref );
-    }
-
-
-
-    @SuppressWarnings("all")
-    public ServiceReference createReference( String[] ifaces, Properties props 
)
-    {
-
-        final ServiceReference ref = Mockito.mock( ServiceReference.class );
-
-        RefPropAnswer answer = new RefPropAnswer( props, ifaces );
-
-        Mockito.when( ref.getProperty( Mockito.anyString() ) )
-               .thenAnswer( answer );
-
-        Mockito.when( ref.getPropertyKeys() )
-               .thenReturn( props.keySet().toArray( new String[0] ) );
-
-        Bundle bundle = Mockito.mock( Bundle.class );
-        
-        Mockito.when( ref.getBundle() ).thenReturn( bundle );
-
-        m_bundles.put( ref, bundle );
-
-        return ref;
-    }
-
-    @SuppressWarnings({ "unchecked" })
-    private class RefPropAnswer implements Answer<Object>
-    {
-        private final Dictionary m_p;
-
-
-        public RefPropAnswer( Dictionary p, String[] iface )
-        {
-            m_p = p;
-            m_p.put( Constants.OBJECTCLASS, iface );
-            m_p.put( Constants.SERVICE_ID, m_serviceIndex++ );
-        }
-
-
-        public Object answer(InvocationOnMock invocation) throws Throwable
-        {
-               String key = (String)invocation.getArguments()[0];
-            return m_p.get( key );
-        }
-
-    }
-}
diff --git a/deviceaccess/src/test/java/org/apache/felix/das/Utils.java 
b/deviceaccess/src/test/java/org/apache/felix/das/Utils.java
deleted file mode 100644
index 6d2d9a3256..0000000000
--- a/deviceaccess/src/test/java/org/apache/felix/das/Utils.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.das;
-
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-
-/**
- * Utility class for injecting objects and invoking
- * methods that are normally invoked by the dependency manager.
- * 
- * @author <a href="mailto:[email protected]";>Felix Project Team</a>
- *
- */
-public class Utils
-{
-
-    public static void invoke( Object target, String method )
-    {
-        try
-        {
-            Method m = target.getClass().getDeclaredMethod( method, new 
Class[0] );
-            m.setAccessible( true );
-            m.invoke( target, new Object[0] );
-        }
-        catch ( Exception e )
-        {
-            e.printStackTrace();
-            junit.framework.Assert.fail( e.getMessage() );
-        }
-    }
-
-
-    public static void inject( Object target, Class clazz, Object injectable )
-    {
-
-        Field[] fields = target.getClass().getDeclaredFields();
-
-        for ( Field field : fields )
-        {
-            if ( clazz == field.getType() )
-            {
-                field.setAccessible( true );
-                try
-                {
-                    field.set( target, injectable );
-                }
-                catch ( IllegalArgumentException e )
-                {
-                    e.printStackTrace();
-                }
-                catch ( IllegalAccessException e )
-                {
-                    e.printStackTrace();
-                }
-            }
-        }
-    }
-
-}
diff --git 
a/deviceaccess/src/test/java/org/apache/felix/das/util/DriverAnalyzerTest.java 
b/deviceaccess/src/test/java/org/apache/felix/das/util/DriverAnalyzerTest.java
deleted file mode 100644
index 88423d9ce3..0000000000
--- 
a/deviceaccess/src/test/java/org/apache/felix/das/util/DriverAnalyzerTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.das.util;
-
-
-import java.util.Properties;
-
-import org.apache.felix.das.OSGiMock;
-import org.apache.felix.das.Utils;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.device.Constants;
-import org.osgi.service.device.Driver;
-import org.osgi.service.log.LogService;
-
-
-/**
- * 
- * Tests the Driver Analyzer.
- * 
- * Nothing fancy is being tested, but if something is changed this
- * validates that at least the most basic feedback can be expected. 
- * 
- * @author <a href="mailto:[email protected]";>Felix Project Team</a>
- *
- */
-public class DriverAnalyzerTest {
-
-       
-       
-       private DriverAnalyzer m_analyzer;
-       
-       
-       @Mock
-       private LogService m_log;
-       
-       private OSGiMock m_osgi;
-       
-       @Before
-       public void setUp() throws Exception {
-               
-               MockitoAnnotations.initMocks(this);
-               
-               m_osgi = new OSGiMock();
-               m_analyzer = new DriverAnalyzer();
-
-               Utils.inject(m_analyzer, LogService.class, m_log);
-       }
-       
-       
-       @Test
-       public void VerifyCorrectDriverIsIgnored() {
-               
-               
-               Properties p = new Properties();
-               p.put(Constants.DRIVER_ID, "a-driver-id");
-               
-               
-               ServiceReference ref = m_osgi.createReference(new 
String[]{Driver.class.getName()}, p); 
-               
-               m_analyzer.driverAdded(ref);
-               
-               Mockito.verifyZeroInteractions(m_log);
-               
-       }
-
-       @Test
-       public void VerifyIncorrectDriverNoDriverId() {
-               
-               
-               Properties p = new Properties();
-               
-               ServiceReference ref = m_osgi.createReference(new 
String[]{Driver.class.getName()}, p); 
-               
-               m_analyzer.driverAdded(ref);
-               
-               Mockito.verify(m_log).log(Mockito.eq(LogService.LOG_ERROR), 
Mockito.anyString());
-               Mockito.verifyNoMoreInteractions(m_log);
-               
-       }
-       
-       @Test
-       public void VerifyIncorrectDriverInvalidDriverId() {
-               
-               Properties p = new Properties();
-               p.put(Constants.DRIVER_ID, new Object());
-
-               ServiceReference ref = m_osgi.createReference(new 
String[]{Driver.class.getName()}, p); 
-               
-               m_analyzer.driverAdded(ref);
-               
-               Mockito.verify(m_log).log(Mockito.eq(LogService.LOG_ERROR), 
Mockito.anyString());
-               Mockito.verifyNoMoreInteractions(m_log);
-               
-       }
-
-       @Test
-       public void VerifyIncorrectDriverEmptyDriverId() {
-               
-               Properties p = new Properties();
-               p.put(Constants.DRIVER_ID, "");
-
-               ServiceReference ref = m_osgi.createReference(new 
String[]{Driver.class.getName()}, p); 
-               
-               m_analyzer.driverAdded(ref);
-               
-               Mockito.verify(m_log).log(Mockito.eq(LogService.LOG_ERROR), 
Mockito.anyString());
-               Mockito.verifyNoMoreInteractions(m_log);
-               
-       }
-}
diff --git 
a/deviceaccess/src/test/java/org/apache/felix/das/util/DriverLoaderTest.java 
b/deviceaccess/src/test/java/org/apache/felix/das/util/DriverLoaderTest.java
deleted file mode 100644
index d2dca9a014..0000000000
--- a/deviceaccess/src/test/java/org/apache/felix/das/util/DriverLoaderTest.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.das.util;
-
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-
-import org.apache.felix.das.DeviceManager;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.device.Constants;
-import org.osgi.service.device.DriverLocator;
-
-
-/**
- * The Device Manager delegates driver loading to the DriverLoader.
- * This JUnit test tests the behavior of that DriverMatcher.
- * 
- * Tests all kinds of driver loading flows.
- * all flows pertaining driver loading are grouped in the DriverLoader.
- * 
- * @author <a href="mailto:[email protected]";>Felix Project Team</a>
- *
- */
-public class DriverLoaderTest
-{
-
-
-    private DriverLoader m_loader;
-
-    @Mock
-    private BundleContext m_context;
-
-    @Mock
-    private DeviceManager m_log;
-    
-    @Before
-    public void setUp() throws Exception
-    {
-       
-       MockitoAnnotations.initMocks(this);
-        m_loader = new DriverLoader( m_log, m_context );
-    }
-
-
-    private DriverLocator tstExpectDriverIdsFor(String[] ids) {
-       
-        DriverLocator dl = Mockito.mock(DriverLocator.class );
-        Mockito.when( dl.findDrivers( Mockito.isA(Dictionary.class) ) 
).thenReturn( ids );
-        return dl;
-    }
-    
-    /**
-     * test whether the driver loader can handle a situation where
-     * there are no DriverLocators.
-     * 
-     */
-    @Test
-    public void findDriversNoDriverLocators()
-    {
-
-        List<DriverLocator> locators = new ArrayList<DriverLocator>();
-
-
-        Set<String> driverIds = m_loader.findDrivers( locators, new 
Properties() );
-        Assert.assertTrue( "should be an empty list", driverIds.size() == 0 );
-        
-    }
-
-
-    /**
-     * in this test there is a driver locator. the driver locator is 
instructed to 
-     * even return some driver ids.
-     * this test tests whether these driver ids are really returned. 
-     */
-    @Test
-    public void findDriversWithDriverLocator()
-    {
-
-        List<DriverLocator> locators = new ArrayList<DriverLocator>();
-
-        DriverLocator dl = tstExpectDriverIdsFor( 
-            new String[] { "org.apache.felix.driver-1.0", 
"org.apache.felix.driver-1.1" } );
-
-        locators.add( dl );
-
-        Properties dict = new Properties();
-        Set<String> driverIds = m_loader.findDrivers( locators, dict );
-
-        Assert.assertEquals( "should not be an empty list", 2, 
driverIds.size());
-
-    }
-
-
-    /**
-     * 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() );
-
-    }
-
-
-    @Test
-    public void findDriversWithDriverLocatorFails()
-    {
-
-        Properties dict = new Properties();
-        List<DriverLocator> locators = new ArrayList<DriverLocator>();
-
-        DriverLocator dl = Mockito.mock( DriverLocator.class, "dl" );
-        locators.add( dl );
-
-        Mockito.when( dl.findDrivers( Mockito.eq( dict ) ) ).thenThrow( new 
RuntimeException( "test exception" ) );
-
-        Set<String> driverIds = m_loader.findDrivers( locators, dict );
-
-        Assert.assertTrue( "should be an empty list", driverIds.size() == 0 );
-
-    }
-
-
-    @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" );
-            }
-        }
-
-    }
-
-
-    @Test
-    public void loadDrivers_LoadFails() 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 ) ).thenThrow( new 
IOException( "test exception" ) );
-        }
-
-        List<ServiceReference> refs = m_loader.loadDrivers( locators, 
driverIds );
-
-        Assert.assertEquals( "", 0, refs.size() );
-
-    }
-
-
-    @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() );
-    }
-
-}
diff --git 
a/deviceaccess/src/test/java/org/apache/felix/das/util/DriverMatcherTest.java 
b/deviceaccess/src/test/java/org/apache/felix/das/util/DriverMatcherTest.java
deleted file mode 100644
index c020d7eff3..0000000000
--- 
a/deviceaccess/src/test/java/org/apache/felix/das/util/DriverMatcherTest.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.das.util;
-
-
-
-import org.apache.felix.das.DriverAttributes;
-import org.apache.felix.das.DeviceManager;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.device.Driver;
-import org.osgi.service.device.DriverSelector;
-import org.osgi.service.device.Match;
-
-
-/**
- * The Device Manager delegates driver matching to the DriverMatcher.
- * This JUnit test tests the behavior of that DriverMatcher.
- * 
- * 
- * @author <a href="mailto:[email protected]";>Felix Project Team</a>
- */
-public class DriverMatcherTest
-{
-
-    private DriverMatcher m_matcherImpl;
-
-    private int m_serviceId;
-
-    @Mock
-    private DeviceManager m_log;
-
-    @Before
-    public void setUp() throws Exception
-    {
-
-        m_serviceId = 0;
-
-        MockitoAnnotations.initMocks(this);
-       
-        m_matcherImpl = new DriverMatcher( m_log );
-
-    }
-
-
-    private String tstDriverId( Match match )
-    {
-        return ( String ) match.getDriver().getProperty( 
org.osgi.service.device.Constants.DRIVER_ID );
-    }
-
-
-    private DriverAttributes tstCreateDriverAttributes( String id, int match, 
int ranking ) throws Exception
-    {
-
-        Bundle bundle = Mockito.mock( Bundle.class );
-        ServiceReference ref = Mockito.mock( ServiceReference.class );
-        
-        
-        Mockito.when(ref.getBundle()).thenReturn(bundle);
-        
Mockito.when(bundle.getLocation()).thenReturn(DriverLoader.DRIVER_LOCATION_PREFIX
 + "-" + id);
-        
-        Mockito.when(ref.getProperty(Constants.SERVICE_ID))
-               .thenReturn(m_serviceId++);
-        
-        
Mockito.when(ref.getProperty(org.osgi.service.device.Constants.DRIVER_ID))
-               .thenReturn(id);
-        
-        
-        
-        if ( ranking > 0 )
-        {
-               Mockito.when( ref.getProperty( Constants.SERVICE_RANKING ) 
).thenReturn( ranking );
-        }
-        else if ( ranking == 0 )
-        {
-               Mockito.when( ref.getProperty( Constants.SERVICE_RANKING ) 
).thenReturn( null );
-        }
-        else
-        {
-            //an invalid ranking object
-               Mockito.when( ref.getProperty( Constants.SERVICE_RANKING ) 
).thenReturn( new Object() );
-        }
-
-        Driver driver = Mockito.mock( Driver.class );
-        Mockito.when( driver.match( Mockito.isA( ServiceReference.class ) ) 
).thenReturn( match );
-
-        return new DriverAttributes( ref, driver );
-
-    }
-
-
-    private void add( String id, int match ) throws Exception
-    {
-        add( id, match, 0 );
-    }
-
-
-    private void add( String id, int match, int ranking ) throws Exception
-    {
-        m_matcherImpl.add( match, tstCreateDriverAttributes( id, match, 
ranking ) );
-    }
-
-
-    @Test
-    public void GetBestMatchWithNoDriver() throws Exception
-    {
-
-        Match match = m_matcherImpl.getBestMatch();
-        Assert.assertNull( match );
-
-    }
-
-
-    @Test
-    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 
) );
-
-    }
-
-    
-    @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 );
-
-    }
-
-    @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 ) );
-
-    }
-
-
-    @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 ) );
-
-    }
-
-
-    @Test
-    public void GetBestMatchWithSameRanking() throws Exception
-    {
-
-        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() );
-    }
-
-
-    @Test
-    public void GetBestMatchWithDifferentRanking() throws Exception
-    {
-
-        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() );
-    }
-
-
-    @Test
-    public void GetBestMatchWithDifferentMatchValue() throws Exception
-    {
-
-        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() );
-    }
-
-
-    @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
-            {
-                Match[] matches = ( Match[] ) invocation.getArguments()[1];
-                int index = 0;
-                for ( Match m : matches )
-                {
-                    if ( tstDriverId( m ).endsWith( "1.3" ) )
-                    {
-                        return index;
-                    }
-                    index++;
-                }
-                Assert.fail( "expected unreachable" );
-                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 );
-    }
-
-
-    @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 );
-
-        Assert.assertNull( match );
-
-    }
-    
-    
-    @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() );
-
-    }
-
-}
diff --git a/deviceaccess/src/test/java/org/apache/felix/das/util/UtilTest.java 
b/deviceaccess/src/test/java/org/apache/felix/das/util/UtilTest.java
deleted file mode 100644
index 918d32d6f7..0000000000
--- a/deviceaccess/src/test/java/org/apache/felix/das/util/UtilTest.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.das.util;
-
-
-import java.util.Properties;
-
-import junit.framework.Assert;
-
-import org.apache.felix.das.Utils;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.device.Constants;
-import org.osgi.service.device.Device;
-import org.osgi.service.log.LogService;
-
-
-/**
- * @author <a href="mailto:[email protected]";>Felix Project Team</a>
- *
- */
-public class UtilTest
-{
-
-    private DeviceAnalyzer m_devA;
-
-    @Mock
-    private LogService m_log;
-
-    @Mock
-    private BundleContext m_context;
-
-
-    @Before
-    public void before() throws Exception
-    {
-       System.setProperty("org.osgi.vendor.framework", 
"org.apache.felix.framework");
-       
-       MockitoAnnotations.initMocks(this);
-       
-        m_devA = new DeviceAnalyzer( m_context );
-        Utils.inject( m_devA, LogService.class, m_log );
-        
-        
-        String f1 = "(objectClass=org.osgi.service.device.Device)";
-        Filter deviceFilter = FrameworkUtil.createFilter(f1);
-        
Mockito.when(m_context.createFilter(Mockito.eq(f1))).thenReturn(deviceFilter);
-        
-        String f2 = "(DEVICE_CATEGORY=*)";
-        Filter driverFilter = FrameworkUtil.createFilter(f2);
-        Mockito.when(m_context.createFilter(f2)).thenReturn(driverFilter);
-        
-
-        Utils.invoke( m_devA, "start" );
-    }
-
-    
-    
-    private ServiceReference createReference(final Properties p) 
-    {
-        ServiceReference ref = Mockito.mock( ServiceReference.class );
-
-        Mockito.when(ref.getProperty(Mockito.anyString())).thenAnswer(new 
Answer<Object>() {
-               public Object answer(InvocationOnMock invocation) throws 
Throwable {
-                       return p.get(invocation.getArguments()[0].toString());
-               }
-        });
-        
-        Mockito.when(ref.getPropertyKeys()).thenAnswer(new Answer<Object>() {
-               public Object answer(InvocationOnMock invocation) throws 
Throwable {
-                       return p.keySet().toArray(new String[0]);
-               }
-        });
-        
-        
-        return ref;
-    }
-
-    @Test
-    public void ShowDeviceIfThereIsAnInvalidCategory() throws Exception
-    {
-
-        Properties p = new Properties();
-        p.put( org.osgi.framework.Constants.OBJECTCLASS, new 
String[]{Object.class.getName()} );
-        p.put(Constants.DEVICE_CATEGORY, "dummy");
-
-        ServiceReference ref = createReference(p);
-        
-        m_devA.deviceAdded( ref );
-        
-        Mockito.verify(m_log).log(Mockito.eq(LogService.LOG_ERROR), 
Mockito.anyString());
-
-    }
-
-
-    @Test
-    public void ShowDeviceIfThereIsNoCategory() throws Exception
-    {
-
-        Properties p = new Properties();
-        p.put( org.osgi.framework.Constants.OBJECTCLASS, new 
String[]{Object.class.getName()} );
-
-        ServiceReference ref = createReference(p);
-        
-        m_devA.deviceAdded( ref );
-        
-        Mockito.verify(m_log).log( Mockito.eq( LogService.LOG_ERROR ), 
Mockito.isA( String.class ) );
-    }
-
-    @Test 
-    public void VerifyValidIsDeviceInstanceValidationIfDevice() throws 
InvalidSyntaxException 
-    {
-
-        Properties p = new Properties();
-        p.put( org.osgi.framework.Constants.OBJECTCLASS, new 
String[]{Device.class.getName()} );
-        
-       ServiceReference ref = createReference(p);
-    
-       Assert.assertTrue( "Incorrectly determined as no device", 
Util.isDeviceInstance(ref) );
-    }
-
-    @Test 
-    public void VerifyValidIsDeviceInstanceValidationThrowsException() throws 
InvalidSyntaxException 
-    {
-
-        Properties p = new Properties();
-        p.put( org.osgi.framework.Constants.OBJECTCLASS, new 
String[]{Device.class.getName()} );
-        
-       ServiceReference ref = createReference(p);
-    
-       Assert.assertTrue( "Incorrectly determined as no device", 
Util.isDeviceInstance(ref) );
-    }
-
-    @Test 
-    public void VerifyValidFilterStringCreation() throws 
InvalidSyntaxException {
-       
-       Object[] data = new Object[]{"a","b","c","d"};
-       String str = Util.createFilterString("(|(%s=%s)(%s=%s))", data);
-       
-       Assert.assertEquals("filter string mismatch","(|(a=b)(c=d))", str);
-    }
-
-    @Test 
-    public void VerifyValidFilterCreation() throws InvalidSyntaxException {
-       
-       Object[] data = new Object[]{Constants.DEVICE_CATEGORY, "dummy"};
-       Filter filter = Util.createFilter("(%s=%s)", data);
-       
-       
-       Properties matching = new Properties();
-       matching.put(Constants.DEVICE_CATEGORY, new String[]{"dummy", 
"nonsense"});
-       Assert.assertTrue("matching filter does not match", 
filter.match(matching));
-       
-       Properties notmatching = new Properties();
-       notmatching.put(Constants.DEVICE_CATEGORY, new String[]{"lummy", 
"nonsense"});
-       Assert.assertFalse("notmatching filter does match", 
filter.match(notmatching));
-
-       
-    }
-    
- 
-    
-    
-    
-    @Test
-    public void ShowDeviceIfThereIsAnEmptyCategory() throws Exception
-    {
-
-        Properties p = new Properties();
-        p.put( org.osgi.framework.Constants.OBJECTCLASS, new 
String[]{Object.class.getName()} );
-        p.put( Constants.DEVICE_CATEGORY, new String[0] );
-
-        
-        ServiceReference ref = createReference(p);
-
-        m_devA.deviceAdded( ref );
-
-        Mockito.verify(m_log).log( Mockito.eq( LogService.LOG_ERROR ), 
Mockito.isA( String.class ) );
-
-    }
-
-
-    @Test
-    public void NoShowDeviceIfThereIsAValidCategory() throws Exception
-    {
-
-        Properties p = new Properties();
-        p.put( org.osgi.framework.Constants.OBJECTCLASS, new 
String[]{Device.class.getName()} );
-        p.put( Constants.DEVICE_CATEGORY, new String[]{"dummy"} );
-
-        ServiceReference ref = createReference(p);
-
-        m_devA.deviceAdded( ref );
-    }
-}

Reply via email to