Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2011-06-29 14:59:45 -0400
committerThomas Watson2011-06-29 14:59:45 -0400
commit4c4d9b4db4f9fde25f9f14aa62440eedae2ed077 (patch)
tree763439db463588071927f4d258c022ffca739779
parent8a106ac643666e9262e3d01186ef55bc090e928b (diff)
downloadrt.equinox.framework-4c4d9b4db4f9fde25f9f14aa62440eedae2ed077.tar.gz
rt.equinox.framework-4c4d9b4db4f9fde25f9f14aa62440eedae2ed077.tar.xz
rt.equinox.framework-4c4d9b4db4f9fde25f9f14aa62440eedae2ed077.zip
Bug 350739 - composite bundle which has substitutable exports does not work
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/composites/CompositeShareTests.java43
-rw-r--r--bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeHelper.java16
2 files changed, 53 insertions, 6 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/composites/CompositeShareTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/composites/CompositeShareTests.java
index 462d27dde..f44adf87a 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/composites/CompositeShareTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/composites/CompositeShareTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2011 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
@@ -254,6 +254,47 @@ public class CompositeShareTests extends AbstractCompositeTests {
}
}
+ public void testCompositeShare04c() {
+ // create a composite bundle with one bundle that exports some api to parent
+ // install one bundle into parent that uses API from child
+ // Setup the composite to have substitutable exports
+ Map linkManifest = new HashMap();
+ linkManifest.put(Constants.BUNDLE_SYMBOLICNAME, getName()); //$NON-NLS-1$
+ linkManifest.put(Constants.BUNDLE_VERSION, "1.0.0"); //$NON-NLS-1$
+ linkManifest.put(Constants.EXPORT_PACKAGE, "test.link.a; attr1=\"value1\"; uses:=\"org.osgi.framework, test.link.a.params\", test.link.a.params; attr2=\"value2\""); //$NON-NLS-1$
+ linkManifest.put(Constants.IMPORT_PACKAGE, "test.link.a, test.link.a.params"); //$NON-NLS-1$
+ CompositeBundle compositeBundle = createCompositeBundle(linkBundleFactory, getName(), null, linkManifest, false, false); //$NON-NLS-1$
+ installIntoChild(compositeBundle.getCompositeFramework(), "test.link.a"); //$NON-NLS-1$
+ Bundle testClient = installIntoCurrent("test.link.a.client"); //$NON-NLS-1$
+
+ SurrogateBundle surrogate = compositeBundle.getSurrogateBundle();
+ assertNotNull("Companion is null", surrogate); //$NON-NLS-1$
+ startCompositeBundle(compositeBundle, false);
+ try {
+ testClient.start();
+ } catch (BundleException e) {
+ fail("Unexpected exception", e); //$NON-NLS-1$
+ }
+
+ // put bad value for export
+ linkManifest.put(Constants.EXPORT_PACKAGE, "test.link.a; attr1=\"bad value\"; uses:=\"org.osgi.framework, test.link.a.params\", test.link.a.params; attr2=\"bad value\""); //$NON-NLS-1$
+ try {
+ compositeBundle.update(linkManifest);
+ } catch (BundleException e) {
+ fail("Unexpected composite update exception", e); //$NON-NLS-1$
+ }
+ installer.refreshPackages(new Bundle[] {compositeBundle});
+ startCompositeBundle(compositeBundle, true);
+ try {
+ testClient.start();
+ fail("Expected start failure"); //$NON-NLS-1$
+ } catch (BundleException e) {
+ assertEquals("Unexpected exception type", BundleException.RESOLVE_ERROR, e.getType()); //$NON-NLS-1$
+ }
+
+ uninstallCompositeBundle(compositeBundle);
+ }
+
public void testCompositeShare05() {
// create a composite bundle with one bundle that exports some api to child
// install one bundle into child that uses API from parent
diff --git a/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeHelper.java b/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeHelper.java
index d5ad91a8d..5ef32c766 100644
--- a/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeHelper.java
+++ b/bundles/org.eclipse.osgi/core/composite/org/eclipse/osgi/internal/composite/CompositeHelper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2011 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
@@ -62,7 +62,7 @@ public class CompositeHelper {
addImports(attributes, compositeDesc, matchingExports);
// convert the matchingExports from the composite into exports
- addExports(attributes, matchingExports);
+ addExports(attributes, compositeDesc, matchingExports);
}
// add the rest
@@ -158,16 +158,22 @@ public class CompositeHelper {
addMap(importStatement, export.getAttributes(), "="); //$NON-NLS-1$
}
- private static void addExports(Attributes attributes, ExportPackageDescription[] matchingExports) {
+ private static void addExports(Attributes attributes, BundleDescription compositeDesc, ExportPackageDescription[] matchingExports) {
if (matchingExports.length == 0)
return;
StringBuffer exportStatement = new StringBuffer();
for (int i = 0; i < matchingExports.length; i++) {
- if (i != 0)
+ if (matchingExports[i].getExporter() == compositeDesc) {
+ // the matching export from outside is the composite bundle itself
+ // this must be one of our own substitutable exports, it must be ignored (bug 345640)
+ continue;
+ }
+ if (exportStatement.length() > 0)
exportStatement.append(',');
getExportFrom(matchingExports[i], exportStatement);
}
- attributes.putValue(Constants.EXPORT_PACKAGE, exportStatement.toString());
+ if (exportStatement.length() > 0)
+ attributes.putValue(Constants.EXPORT_PACKAGE, exportStatement.toString());
}
private static void getExportFrom(ExportPackageDescription export, StringBuffer exportStatement) {

Back to the top