### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.junit Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.junit/META-INF/MANIFEST.MF,v retrieving revision 1.39 diff -u -r1.39 MANIFEST.MF --- META-INF/MANIFEST.MF 2 Sep 2009 14:40:30 -0000 1.39 +++ META-INF/MANIFEST.MF 2 Mar 2010 23:10:59 -0000 @@ -36,7 +36,7 @@ org.eclipse.ltk.core.refactoring;bundle-version="[3.5.0,4.0.0)", org.eclipse.core.variables;bundle-version="[3.2.200,4.0.0)", org.eclipse.ltk.ui.refactoring;bundle-version="[3.4.100,4.0.0)", - org.eclipse.equinox.simpleconfigurator.manipulator;bundle-version="[1.0.100,2.0.0)", - org.eclipse.equinox.frameworkadmin;bundle-version="[1.0.100,2.0.0)", + org.eclipse.equinox.simpleconfigurator.manipulator;bundle-version="[2.0.0,3.0.0)", + org.eclipse.equinox.frameworkadmin;bundle-version="[2.0.0,3.0.0)", org.eclipse.jdt.junit.core;bundle-version="[3.6.0,4.0.0)";visibility:=reexport Bundle-RequiredExecutionEnvironment: J2SE-1.4 #P org.eclipse.jdt.junit.core Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.junit.core/META-INF/MANIFEST.MF,v retrieving revision 1.40 diff -u -r1.40 MANIFEST.MF --- META-INF/MANIFEST.MF 4 Sep 2009 09:24:09 -0000 1.40 +++ META-INF/MANIFEST.MF 2 Mar 2010 23:10:59 -0000 @@ -24,6 +24,6 @@ org.eclipse.jdt.launching;bundle-version="[3.5.0,4.0.0)", org.eclipse.jdt.junit.runtime;bundle-version="[3.4.100,4.0.0)", org.eclipse.core.variables;bundle-version="[3.2.200,4.0.0)", - org.eclipse.equinox.simpleconfigurator.manipulator;bundle-version="[1.0.100,2.0.0)", - org.eclipse.equinox.frameworkadmin;bundle-version="[1.0.100,2.0.0)" + org.eclipse.equinox.simpleconfigurator.manipulator;bundle-version="[2.0.0,3.0.0)", + org.eclipse.equinox.frameworkadmin;bundle-version="[2.0.0,3.0.0)" Bundle-RequiredExecutionEnvironment: J2SE-1.4 Index: src/org/eclipse/jdt/internal/junit/buildpath/BuildPathSupport.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/buildpath/BuildPathSupport.java,v retrieving revision 1.25 diff -u -r1.25 BuildPathSupport.java --- src/org/eclipse/jdt/internal/junit/buildpath/BuildPathSupport.java 2 Mar 2010 21:03:00 -0000 1.25 +++ src/org/eclipse/jdt/internal/junit/buildpath/BuildPathSupport.java 2 Mar 2010 23:10:59 -0000 @@ -18,7 +18,7 @@ import org.osgi.framework.Version; -import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo; +import org.eclipse.equinox.frameworkadmin.BundleInfo; import org.eclipse.jdt.junit.JUnitCore; import org.eclipse.osgi.service.resolver.VersionRange; Index: src/org/eclipse/jdt/internal/junit/buildpath/P2Utils.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/buildpath/P2Utils.java,v retrieving revision 1.12 diff -u -r1.12 P2Utils.java --- src/org/eclipse/jdt/internal/junit/buildpath/P2Utils.java 8 Jan 2010 11:52:03 -0000 1.12 +++ src/org/eclipse/jdt/internal/junit/buildpath/P2Utils.java 2 Mar 2010 23:10:59 -0000 @@ -13,26 +13,20 @@ import java.io.File; import java.io.IOException; -import java.net.MalformedURLException; import java.net.URI; -import java.net.URL; import java.net.URLDecoder; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; +import org.osgi.framework.BundleContext; import org.osgi.framework.Version; -import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.provisional.simpleconfigurator.manipulator.SimpleConfiguratorManipulator; -import org.eclipse.osgi.service.datalocation.Location; +import org.eclipse.equinox.frameworkadmin.BundleInfo; +import org.eclipse.equinox.simpleconfigurator.manipulator.SimpleConfiguratorManipulator; import org.eclipse.osgi.service.resolver.VersionRange; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.URIUtil; import org.eclipse.jdt.internal.junit.JUnitCorePlugin; @@ -75,31 +69,6 @@ } /** - * Adds the directories (as java.io.File) for the given location and all of its parents to the given list. - * - * @param locations the list to add the URLs to - * @param location the location - * @param useParent true if location's parent directory should be used false otherwise - */ - private static void addLocationDirs(List locations, Location location, boolean useParent) { - while (location != null) { - URL url= location.getURL(); - if (url != null) { - try { - File dir = new File(FileLocator.toFileURL(url).getPath()); - if (useParent) - dir = dir.getParentFile(); - if (!locations.contains(dir)) - locations.add(dir); - } catch (IOException e) { - JUnitCorePlugin.log(e); - } - } - location= location.getParentLocation(); - } - } - - /** * Finds the bundle info for the given arguments. *

* The first match will be returned if more than one bundle matches the arguments. @@ -118,54 +87,41 @@ if (manipulator == null) return null; - List bundleLocations = new ArrayList(); - addLocationDirs(bundleLocations, Platform.getConfigurationLocation(), true); - addLocationDirs(bundleLocations, Platform.getInstallLocation(), false); - BundleInfo bestMatch= null; Version bestVersion= null; - for (Location configLocation= Platform.getConfigurationLocation(); configLocation != null; configLocation= configLocation.getParentLocation()) { - URL configUrl= configLocation.getURL(); - if (configUrl == null) - continue; - - try { - String bundleInfoPath= null; - if (isSourceBundle) - bundleInfoPath= SRC_INFO_PATH; - else - bundleInfoPath= BUNDLE_INFO_PATH; - - URL bundlesTxt = new URL(configUrl.getProtocol(), configUrl.getHost(), new File(configUrl.getPath(), bundleInfoPath).getAbsolutePath()); - - for (Iterator i= bundleLocations.iterator(); i.hasNext(); ) { - File home= (File) i.next(); - BundleInfo bundles[]= manipulator.loadConfiguration(bundlesTxt, home); - if (bundles != null) { - for (int j= 0; j < bundles.length; j++) { - BundleInfo bundleInfo= bundles[j]; - if (symbolicName.equals(bundleInfo.getSymbolicName())) { - Version version= new Version(bundleInfo.getVersion()); - if (versionRange.isIncluded(version)) { - IPath path= getBundleLocationPath(bundleInfo); - if (path.toFile().exists()) { - if (bestMatch == null || bestVersion.compareTo(version) < 0) { - bestMatch= bundleInfo; - bestVersion= version; - } - } - } + + String bundleInfoPath= null; + if (isSourceBundle) + bundleInfoPath= SRC_INFO_PATH; + else + bundleInfoPath= BUNDLE_INFO_PATH; + + BundleContext context= JUnitCorePlugin.getDefault().getBundle().getBundleContext(); + BundleInfo bundles[]= null; + try { + bundles= manipulator.loadConfiguration(context, bundleInfoPath); + } catch (IOException e) { + JUnitCorePlugin.log(e); + } + + if (bundles != null) { + for (int j= 0; j < bundles.length; j++) { + BundleInfo bundleInfo= bundles[j]; + if (symbolicName.equals(bundleInfo.getSymbolicName())) { + Version version= new Version(bundleInfo.getVersion()); + if (versionRange.isIncluded(version)) { + IPath path= getBundleLocationPath(bundleInfo); + if (path.toFile().exists()) { + if (bestMatch == null || bestVersion.compareTo(version) < 0) { + bestMatch= bundleInfo; + bestVersion= version; } } } } - } catch (MalformedURLException e) { - JUnitCorePlugin.log(e); - } catch (IOException e) { - JUnitCorePlugin.log(e); } } - + return bestMatch; }