diff options
author | Thomas Watson | 2016-06-30 14:08:13 +0000 |
---|---|---|
committer | Thomas Watson | 2016-06-30 14:47:30 +0000 |
commit | adda20fca8b82495927ba45d158b53e22a5ca7f8 (patch) | |
tree | 6ef23090e37eed50e005631f1eb7bc30b43288a8 /bundles/org.eclipse.osgi.tests | |
parent | 1688d6ad5ef4ed976fc044c2d28c76d1e463ca81 (diff) | |
download | rt.equinox.framework-adda20fca8b82495927ba45d158b53e22a5ca7f8.tar.gz rt.equinox.framework-adda20fca8b82495927ba45d158b53e22a5ca7f8.tar.xz rt.equinox.framework-adda20fca8b82495927ba45d158b53e22a5ca7f8.zip |
Bug 497092 - Use INFO event from uninstalled/updated bundle revisionI20160705-1600
If trying to open a zip file and an IOException is thrown then check if
the bundle revision still exists in the list of revisions for the
bundle. If it does not then the revision was removed as part of an
uninstall or update operation. In this case just use an INFO event.
Change-Id: I975061a2e963be1c7b9752401aae6d70eddda003
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Diffstat (limited to 'bundles/org.eclipse.osgi.tests')
2 files changed, 50 insertions, 1 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java index 8f4d2b15b..434e7f983 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java @@ -21,6 +21,7 @@ import javax.xml.ws.Endpoint; import javax.xml.ws.Service; import junit.framework.Test; import junit.framework.TestSuite; +import org.eclipse.osgi.internal.loader.ModuleClassLoader; import org.eclipse.osgi.tests.OSGiTestsActivator; import org.osgi.framework.*; import org.osgi.framework.hooks.resolver.ResolverHook; @@ -2198,4 +2199,43 @@ public class ClassLoadingBundleTests extends AbstractBundleTests { getContext().removeBundleListener(delayB1); } } + + public void testLoaderUninstalledBundle() throws BundleException, IOException { + String testResourcePath = "testResource"; + File config = OSGiTestsActivator.getContext().getDataFile(getName()); //$NON-NLS-1$ + Map<String, String> testHeaders = new HashMap<String, String>(); + testHeaders.put(Constants.BUNDLE_MANIFESTVERSION, "2"); + testHeaders.put(Constants.BUNDLE_SYMBOLICNAME, getName()); + config.mkdirs(); + File testBundleFile = SystemBundleTests.createBundle(config, getName(), testHeaders, Collections.singletonMap(testResourcePath, "testValue")); + Bundle test = getContext().installBundle(getName(), new FileInputStream(testBundleFile)); + test.start(); + BundleWiring wiring = test.adapt(BundleWiring.class); + assertNotNull("No wiring found.", wiring); + ModuleClassLoader bundleClassLoader = (ModuleClassLoader) wiring.getClassLoader(); + URL testResource = bundleClassLoader.findLocalResource(testResourcePath); + assertNotNull("No test resource found.", testResource); + + test.update(new FileInputStream(testBundleFile)); + testResource = bundleClassLoader.findLocalResource(testResourcePath); + assertNull("Found resource.", testResource); + + Object[] expectedFrameworkEvents = new Object[] {new FrameworkEvent(FrameworkEvent.INFO, test, null)}; + Object[] actualFrameworkEvents = frameworkListenerResults.getResults(1); + compareResults(expectedFrameworkEvents, actualFrameworkEvents); + + wiring = test.adapt(BundleWiring.class); + assertNotNull("No wiring found.", wiring); + bundleClassLoader = (ModuleClassLoader) wiring.getClassLoader(); + testResource = bundleClassLoader.findLocalResource(testResourcePath); + assertNotNull("No test resource found.", testResource); + + test.uninstall(); + + testResource = bundleClassLoader.findLocalResource(testResourcePath); + assertNull("Found resource.", testResource); + + actualFrameworkEvents = frameworkListenerResults.getResults(1); + compareResults(expectedFrameworkEvents, actualFrameworkEvents); + } } diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java index c1127c9a7..8ea31cdb7 100755 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java @@ -2745,7 +2745,7 @@ public class SystemBundleTests extends AbstractBundleTests { return manifest; } - private static File createBundle(File outputDir, String bundleName, Map<String, String> headers) throws IOException { + static File createBundle(File outputDir, String bundleName, Map<String, String> headers, Map<String, String>... entries) throws IOException { Manifest m = new Manifest(); Attributes attributes = m.getMainAttributes(); attributes.putValue("Manifest-Version", "1.0"); @@ -2754,6 +2754,15 @@ public class SystemBundleTests extends AbstractBundleTests { } File file = new File(outputDir, "bundle" + bundleName + ".jar"); //$NON-NLS-1$ //$NON-NLS-2$ JarOutputStream jos = new JarOutputStream(new FileOutputStream(file), m); + if (entries != null) { + for (Map<String, String> entryMap : entries) { + for (Map.Entry<String, String> entry : entryMap.entrySet()) { + jos.putNextEntry(new JarEntry(entry.getKey())); + jos.write(entry.getValue().getBytes()); + jos.closeEntry(); + } + } + } jos.flush(); jos.close(); return file; |