diff options
author | Thomas Watson | 2013-08-20 13:23:21 +0000 |
---|---|---|
committer | Thomas Watson | 2013-08-20 13:23:21 +0000 |
commit | 5bcdd0aa0076f0a6cefe121455813b33606f4bb5 (patch) | |
tree | 6a14c734f94e43495955755658ee1d1d1c279296 | |
parent | 37d3b9a293ebb51aaa483fb2009afbb2a4a8c27d (diff) | |
download | rt.equinox.framework-5bcdd0aa0076f0a6cefe121455813b33606f4bb5.tar.gz rt.equinox.framework-5bcdd0aa0076f0a6cefe121455813b33606f4bb5.tar.xz rt.equinox.framework-5bcdd0aa0076f0a6cefe121455813b33606f4bb5.zip |
Bug 415447 - Unable to obtain system.bundle by Platform.getBundle
2 files changed, 15 insertions, 1 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PackageAdminBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PackageAdminBundleTests.java index 70f3c0e83..33607e99f 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PackageAdminBundleTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/PackageAdminBundleTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -20,6 +20,7 @@ import junit.framework.TestSuite; import org.eclipse.osgi.tests.OSGiTestsActivator; import org.osgi.framework.*; import org.osgi.service.packageadmin.ExportedPackage; +import org.osgi.service.packageadmin.PackageAdmin; public class PackageAdminBundleTests extends AbstractBundleTests { public class TestListener implements SynchronousBundleListener { @@ -249,6 +250,14 @@ public class PackageAdminBundleTests extends AbstractBundleTests { } } + public void testBug415447() { + PackageAdmin pa = installer.getPackageAdmin(); + Bundle[] systemBundles = pa.getBundles(Constants.SYSTEM_BUNDLE_SYMBOLICNAME, null); + assertNotNull("No system bundles found.", systemBundles); + assertEquals("Srong number of system bundles.", 1, systemBundles.length); + assertEquals("Wrong system bundle found.", OSGiTestsActivator.getContext().getBundle(Constants.SYSTEM_BUNDLE_LOCATION), systemBundles[0]); + } + private String getMessage(Throwable[] results) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/legacy/PackageAdminImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/legacy/PackageAdminImpl.java index 7e4178c36..f98ab5b7b 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/legacy/PackageAdminImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/legacy/PackageAdminImpl.java @@ -17,6 +17,7 @@ import java.util.*; import org.eclipse.osgi.container.*; import org.eclipse.osgi.internal.container.Capabilities; import org.eclipse.osgi.internal.container.InternalUtils; +import org.eclipse.osgi.internal.framework.EquinoxContainer; import org.osgi.framework.*; import org.osgi.framework.namespace.*; import org.osgi.framework.wiring.*; @@ -149,6 +150,10 @@ public class PackageAdminImpl implements PackageAdmin { if (symbolicName == null) { throw new IllegalArgumentException(); } + if (Constants.SYSTEM_BUNDLE_SYMBOLICNAME.equals(symbolicName)) { + // need to alias system.bundle to the implementation BSN + symbolicName = EquinoxContainer.NAME; + } VersionRange range = versionRange == null ? null : new VersionRange(versionRange); String filter = (range != null ? "(&" : "") + "(" + IdentityNamespace.IDENTITY_NAMESPACE + "=" + symbolicName + ")" + (range != null ? range.toFilterString(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE) + ")" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ Requirement identityReq = container.createRequirement(IdentityNamespace.IDENTITY_NAMESPACE, Collections.<String, String> singletonMap(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter), Collections.<String, Object> emptyMap()); |