Source:
<code>public void testBundleIDLock() { File config = OSGiTestsActivator.getContext().getDataFile(getName()); Map<String, Object> configuration = new HashMap<String, Object>(); configuration.put(EquinoxConfiguration.PROP_FILE_LIMIT, "10"); configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath()); final Equinox equinox = new Equinox(configuration); try { equinox.init(); } catch (BundleException e) { fail("Unexpected exception in init()", e); } assertEquals("Wrong state for SystemBundle", Bundle.STARTING, equinox.getState()); final BundleContext systemContext = equinox.getBundleContext(); assertNotNull("System context is null", systemContext); try { equinox.start(); } catch (BundleException e) { fail("Failed to start the framework", e); } assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, equinox.getState()); final int numBundles = 5000; final File[] testBundles; try { testBundles = createBundles(new File(config, "bundles"), numBundles); } catch (IOException e) { fail("Unexpected error creating budnles", e); throw new RuntimeException(); } ExecutorService executor = Executors.newFixedThreadPool(50); final List<Throwable> errors = new CopyOnWriteArrayList<Throwable>(); try { for <START> (File testBundleFile : <END> testBundles) { executor.execute(new Runnable() { @Override public void run() { try { systemContext.installBundle("file:/ } catch (BundleException e) { e.printStackTrace(); errors.add(e); } } }); } } finally { executor.shutdown(); try { executor.awaitTermination(600, TimeUnit.SECONDS); } catch (InterruptedException e) { fail("Interrupted.", e); } } Assert.assertEquals("Errors found.", Collections.emptyList(), errors); Assert.assertEquals("Wrong number of bundles.", numBundles + 1, systemContext.getBundles().length); try { equinox.stop(); } catch (BundleException e) { fail("Unexpected erorr stopping framework", e); } try { equinox.waitForStop(10000); } catch (InterruptedException e) { fail("Unexpected interrupted exception", e); } assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); }</code><technical_language>testBundleFile needs final</technical_language>

Target:
public void testBundleIDLock() { File config = OSGiTestsActivator.getContext().getDataFile(getName()); Map<String, Object> configuration = new HashMap<String, Object>(); configuration.put(EquinoxConfiguration.PROP_FILE_LIMIT, "10"); configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath()); final Equinox equinox = new Equinox(configuration); try { equinox.init(); } catch (BundleException e) { fail("Unexpected exception in init()", e); } assertEquals("Wrong state for SystemBundle", Bundle.STARTING, equinox.getState()); final BundleContext systemContext = equinox.getBundleContext(); assertNotNull("System context is null", systemContext); try { equinox.start(); } catch (BundleException e) { fail("Failed to start the framework", e); } assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, equinox.getState()); final int numBundles = 5000; final File[] testBundles; try { testBundles = createBundles(new File(config, "bundles"), numBundles); } catch (IOException e) { fail("Unexpected error creating budnles", e); throw new RuntimeException(); } ExecutorService executor = Executors.newFixedThreadPool(50); final List<Throwable> errors = new CopyOnWriteArrayList<Throwable>(); try { for (final File testBundleFile : testBundles) { executor.execute(new Runnable() { @Override public void run() { try { systemContext.installBundle("file:/ } catch (BundleException e) { e.printStackTrace(); errors.add(e); } } }); } } finally { executor.shutdown(); try { executor.awaitTermination(600, TimeUnit.SECONDS); } catch (InterruptedException e) { fail("Interrupted.", e); } } Assert.assertEquals("Errors found.", Collections.emptyList(), errors); Assert.assertEquals("Wrong number of bundles.", numBundles + 1, systemContext.getBundles().length); try { equinox.stop(); } catch (BundleException e) { fail("Unexpected erorr stopping framework", e); } try { equinox.waitForStop(10000); } catch (InterruptedException e) { fail("Unexpected interrupted exception", e); } assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); }