Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2014-04-10 21:18:27 +0000
committerThomas Watson2014-04-10 21:18:27 +0000
commitd8ba008b28dc2778e2db9fffcdefbc272f4905aa (patch)
tree08de683ced44c24b4d3b948f4736cc5fb224329b
parent9a3dee0428c65629c5d35fe7f5d7b36d84fdbae6 (diff)
downloadrt.equinox.framework-d8ba008b28dc2778e2db9fffcdefbc272f4905aa.tar.gz
rt.equinox.framework-d8ba008b28dc2778e2db9fffcdefbc272f4905aa.tar.xz
rt.equinox.framework-d8ba008b28dc2778e2db9fffcdefbc272f4905aa.zip
Bug 432485 - EE changes not detected and so resolve state does not
change
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java91
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java6
2 files changed, 93 insertions, 4 deletions
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 ec62923e9..e37a06f32 100644
--- 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
@@ -22,6 +22,7 @@ import junit.framework.TestSuite;
import org.eclipse.osgi.launch.Equinox;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.tests.OSGiTestsActivator;
+import org.junit.Assert;
import org.osgi.framework.*;
import org.osgi.framework.hooks.resolver.ResolverHook;
import org.osgi.framework.hooks.resolver.ResolverHookFactory;
@@ -928,6 +929,82 @@ public class SystemBundleTests extends AbstractBundleTests {
assertEquals("Wrong stopEvent", FrameworkEvent.STOPPED, stopEvent.getType()); //$NON-NLS-1$
}
+ public void testChangeEE() throws IOException, BundleException {
+ URL javaSE7Profile = OSGiTestsActivator.getContext().getBundle(Constants.SYSTEM_BUNDLE_LOCATION).getEntry("JavaSE-1.7.profile");
+ URL javaSE8Profile = OSGiTestsActivator.getContext().getBundle(Constants.SYSTEM_BUNDLE_LOCATION).getEntry("JavaSE-1.8.profile");
+
+ // configure equinox for javaSE 8
+ File config = OSGiTestsActivator.getContext().getDataFile(getName()); //$NON-NLS-1$
+ Map<String, Object> configuration = new HashMap<String, Object>();
+ configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
+ configuration.put("osgi.java.profile", javaSE8Profile.toExternalForm()); //$NON-NLS-1$
+
+ Equinox equinox = new Equinox(configuration);
+ equinox.start();
+
+ // install a bundle that requires java 8
+ BundleContext systemContext = equinox.getBundleContext();
+ assertNotNull("System context is null", systemContext); //$NON-NLS-1$
+ Map<String, String> testHeaders = new HashMap<String, String>();
+ testHeaders.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+ testHeaders.put(Constants.BUNDLE_SYMBOLICNAME, getName());
+ testHeaders.put(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, "JavaSE-1.8");
+ File testBundle = createBundle(config, getName(), testHeaders);
+ Bundle b = systemContext.installBundle("reference:file:///" + testBundle.getAbsolutePath()); //$NON-NLS-1$
+ long bid = b.getBundleId();
+
+ // should resolve fine
+ Assert.assertTrue("Could not resolve bundle.", equinox.adapt(FrameworkWiring.class).resolveBundles(Collections.singleton(b)));
+
+ // put the framework back to the RESOLVED state
+ equinox.stop();
+ try {
+ equinox.waitForStop(10000);
+ } catch (InterruptedException e) {
+ fail("Unexpected interrupted exception", e); //$NON-NLS-1$
+ }
+
+ // configure equinox for java 7
+ configuration.put("osgi.java.profile", javaSE7Profile.toExternalForm());
+ equinox = new Equinox(configuration);
+ try {
+ equinox.start();
+ } catch (BundleException e) {
+ fail("Failed to start the framework", e); //$NON-NLS-1$
+ }
+ // bundle should fail to resolve
+ b = equinox.getBundleContext().getBundle(bid);
+ Assert.assertFalse("Could resolve bundle.", equinox.adapt(FrameworkWiring.class).resolveBundles(Collections.singleton(b)));
+
+ // put the framework back to the RESOLVED state
+ equinox.stop();
+ try {
+ equinox.waitForStop(10000);
+ } catch (InterruptedException e) {
+ fail("Unexpected interrupted exception", e); //$NON-NLS-1$
+ }
+
+ // move back to java 8
+ configuration.put("osgi.java.profile", javaSE8Profile.toExternalForm());
+ equinox = new Equinox(configuration);
+ try {
+ equinox.start();
+ } catch (BundleException e) {
+ fail("Failed to start the framework", e); //$NON-NLS-1$
+ }
+ // bundle should succeed to resolve again
+ b = equinox.getBundleContext().getBundle(bid);
+ Assert.assertTrue("Could not resolve bundle.", equinox.adapt(FrameworkWiring.class).resolveBundles(Collections.singleton(b)));
+
+ // put the framework back to the RESOLVED state
+ equinox.stop();
+ try {
+ equinox.waitForStop(10000);
+ } catch (InterruptedException e) {
+ fail("Unexpected interrupted exception", e); //$NON-NLS-1$
+ }
+ }
+
public void testMRUBundleFileList() {
doMRUBundleFileList(10);
}
@@ -2119,4 +2196,18 @@ public class SystemBundleTests extends AbstractBundleTests {
}
return manifest;
}
+
+ private static File createBundle(File outputDir, String bundleName, Map<String, String> headers) throws IOException {
+ Manifest m = new Manifest();
+ Attributes attributes = m.getMainAttributes();
+ attributes.putValue("Manifest-Version", "1.0");
+ for (Map.Entry<String, String> entry : headers.entrySet()) {
+ attributes.putValue(entry.getKey(), entry.getValue());
+ }
+ File file = new File(outputDir, "bundle" + bundleName + ".jar"); //$NON-NLS-1$ //$NON-NLS-2$
+ JarOutputStream jos = new JarOutputStream(new FileOutputStream(file), m);
+ jos.flush();
+ jos.close();
+ return file;
+ }
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
index 3795f5dd4..0c258a3fd 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java
@@ -324,10 +324,8 @@ public class Storage {
if (!currentRevision.getVersion().equals(newBuilder.getVersion())) {
return true;
}
- // only do this advanced check if in dev mode
- if (!equinoxContainer.getConfiguration().inDevelopmentMode()) {
- return false;
- }
+
+ // Always do the advanced check for bug 432485 to make sure we have a consistent system bundle
List<ModuleCapability> currentCapabilities = currentRevision.getModuleCapabilities(null);
List<GenericInfo> newCapabilities = newBuilder.getCapabilities();
if (currentCapabilities.size() != newCapabilities.size()) {

Back to the top