Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2011-12-08 15:20:32 +0000
committerThomas Watson2011-12-08 15:20:32 +0000
commitaefd5bd422b0f347c291f061805e0468f975d8ff (patch)
tree85193835257ba097be6e3f46fd216f8afb91ce51
parent9876030b849fbf63a92767c15b92d0a946743e4c (diff)
downloadrt.equinox.framework-aefd5bd422b0f347c291f061805e0468f975d8ff.tar.gz
rt.equinox.framework-aefd5bd422b0f347c291f061805e0468f975d8ff.tar.xz
rt.equinox.framework-aefd5bd422b0f347c291f061805e0468f975d8ff.zip
Bug 365677 - WeavingHook causes failure due to missing packages
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/composites/CompositeShareTests.java50
1 files changed, 50 insertions, 0 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 0e68c0daa..875b3b3e6 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
@@ -15,6 +15,8 @@ import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.osgi.tests.OSGiTestsActivator;
import org.osgi.framework.*;
+import org.osgi.framework.hooks.weaving.WeavingHook;
+import org.osgi.framework.hooks.weaving.WovenClass;
import org.osgi.framework.launch.Framework;
import org.osgi.service.framework.*;
import org.osgi.service.packageadmin.PackageAdmin;
@@ -1005,6 +1007,54 @@ public class CompositeShareTests extends AbstractCompositeTests {
uninstallCompositeBundle(compositeBundle);
}
+ public void testBug365677() {
+ // create a composite bundle with one bundle that exports some api to child
+ // install one bundle into child that uses API from parent
+ // use a weavig hook in the child to add a dynamic import to the client bundle
+ 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.IMPORT_PACKAGE, "org.osgi.service.application, test.link.a; attr1=\"value1\", test.link.a.params; attr2=\"value2\""); //$NON-NLS-1$
+ CompositeBundle compositeBundle = createCompositeBundle(linkBundleFactory, getName(), null, linkManifest, false, false); //$NON-NLS-1$
+ installIntoCurrent("test.link.a"); //$NON-NLS-1$
+ final Bundle testClient = installIntoChild(compositeBundle.getCompositeFramework(), "test.link.a.client"); //$NON-NLS-1$
+
+ startCompositeBundle(compositeBundle, false);
+ // first confirm the testClient cannot load from the package that will be added dynamically
+ try {
+ testClient.loadClass("org.osgi.service.application.ApplicationDescriptor"); //$NON-NLS-1$
+ fail("Expected class load exception"); //$NON-NLS-1$
+ } catch (ClassNotFoundException e) {
+ // expected
+ }
+
+ // Add a weaving hook that will add the dyanmic import
+ compositeBundle.getCompositeFramework().getBundleContext().registerService(WeavingHook.class, new WeavingHook() {
+
+ public void weave(WovenClass wovenClass) {
+ Bundle b = wovenClass.getBundleWiring().getBundle();
+ if (testClient != b)
+ return;
+ wovenClass.getDynamicImports().add("org.osgi.service.application");
+ }
+ }, null);
+
+ // Start client to kick the weaving hook
+ try {
+ testClient.start();
+ } catch (BundleException e) {
+ fail("Unexpected exception", e); //$NON-NLS-1$
+ }
+
+ // Now a load of a class from the dynamically added package should work.
+ try {
+ testClient.loadClass("org.osgi.service.application.ApplicationDescriptor"); //$NON-NLS-1$
+ } catch (ClassNotFoundException e) {
+ fail("Unexpected class load exception", e); //$NON-NLS-1$
+ }
+ uninstallCompositeBundle(compositeBundle);
+ }
+
private void checkActive(Bundle b) {
try {
// just a hack to make sure we are restarted

Back to the top